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

Fix double read of shared atomic in reactor instrumentation #1788

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

bantonsson
Copy link
Contributor

Occasional NPEs when things race.

@bantonsson bantonsson requested a review from a team as a code owner August 20, 2020 09:30
@bantonsson bantonsson self-assigned this Aug 20, 2020
@@ -42,7 +42,7 @@ public TracingSubscriber(final AgentSpan upstreamSpan, final CoreSubscriber<T> d
if (downstreamScope != null) {
downstreamScope.setAsyncPropagation(true);
// create a hard reference to the trace that we don't want reported until we are done
continuation.set(activeScope().capture());
continuation.set(downstreamScope.capture());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is just cleanup, of using the thing we actually read 4 lines above.

Copy link
Member

@richardstartin richardstartin left a comment

Choose a reason for hiding this comment

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

Makes sense to me. How complicated would it be to add a deterministic test case which demonstrates this was a problem?

@bantonsson
Copy link
Contributor Author

Makes my head hurt just trying to think about a test case. Completely up to the Reactor runtime to schedule things, and I don't know how I could coordinate things without getting to know more than I want about it 😉

@richardstartin
Copy link
Member

Do you think we need a nondeterministic property based test which fires lots of requests at a reactor based application and verifies that the number of traces produced is the same as the number of requests? Would that have a better chance of verifying the issue exists?

@bantonsson
Copy link
Contributor Author

I think it would be good adding some property based tests for these types of asynchronous flows.

@bantonsson bantonsson merged commit a99a90f into master Aug 20, 2020
@bantonsson bantonsson deleted the ban/fix-small-reactor-race branch August 20, 2020 13:32
@github-actions github-actions bot added this to the 0.61.0 milestone Aug 20, 2020
@dougqh
Copy link
Contributor

dougqh commented Aug 20, 2020

Yes, that's a nice catch.

I'm wondering if we could do some static analysis. This is the equivalent of calling Reference.get() testing non-null and then calling Reference.get() again.

I suspect there's probably a case where someone wants to do something like that, but I think more often it would be an oversight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants