Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trace] Fix race between CreateAsyncChild and span.Send #39

Merged
merged 1 commit into from
Nov 28, 2018

Conversation

tredman
Copy link
Contributor

@tredman tredman commented Nov 23, 2018

CreateChild adds a new span to the current span's list of children. CreateAsyncChild calls CreateChild, then sets the isAsync bool on the span. This can lead to a race caused by simultaneous read of the child span's isAsync bool by Send as it's being written by CreateAsyncChild. To fix this, I refactored the code a bit to allow us to set isAsync before the span is added to the list of child spans.

This doesn't seem to be the same race reported in #38 but it should be fixed either way.

`CreateChild` adds a new span to the current span's list of children. `CreateAsyncChild` calls `CreateChild`, then sets the isAsync bool on the span. This can lead to a race caused by simultaneous read of the child span's `isAsync` bool by `Send` as it's being written by `CreateAsyncChild`. To fix this, I refactored  the code a bit to allow us to set `isAsync` before the span is added to the list of child spans.

This doesn't seem to be the same race reported in #38 but it should be fixed either way.
Copy link
Member

@martin308 martin308 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tredman tredman merged commit 4d5b2a2 into master Nov 28, 2018
@tredman tredman deleted the tredman.async_span_race branch November 28, 2018 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants