rangecache: fix a span use-after-Finish#73478
Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom Dec 6, 2021
Merged
Conversation
Member
aayushshah15
reviewed
Dec 6, 2021
Contributor
aayushshah15
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15 and @andreimatei)
pkg/kv/kvclient/rangecache/range_cache.go, line 649 at r1 (raw file):
} requestKey := makeLookupRequestKey(key, prevDesc, useReverseScan) reqCtx, reqSpan := tracing.EnsureChildSpan(ctx, rc.tracer, "range lookup")
Could you say why we don't just fork synchronously inside the DoChan callback?
Lookups of range descriptors use a form of pretty unusual unstructured concurrency: a request spawns a goroutine that might outlive it (in case the request is canceled), but at the same time the goroutine wants to be part of the same trace as the request. Before this patch, the goroutine was responsible for forking the request's span asynchronously. This was pretty broken because the request's span might be finished by the time it's forked. This is a use-after-Finish, and I'm trying to stop tolerating such uses. This patch fixes it by forking the span synchronously. Release note: None
fff5ca0 to
b9a4a72
Compare
andreimatei
commented
Dec 6, 2021
Contributor
Author
andreimatei
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @aayushshah15)
pkg/kv/kvclient/rangecache/range_cache.go, line 649 at r1 (raw file):
Previously, aayushshah15 (Aayush Shah) wrote…
Could you say why we don't just fork synchronously inside the
DoChancallback?
Like this?
aayushshah15
reviewed
Dec 6, 2021
Contributor
aayushshah15
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @aayushshah15)
andreimatei
commented
Dec 6, 2021
Contributor
|
Build failed (retrying...): |
Contributor
|
Build succeeded: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lookups of range descriptors use a form of pretty unusual unstructured
concurrency: a request spawns a goroutine that might outlive it (in case
the request is canceled), but at the same time the goroutine wants to be
part of the same trace as the request. Before this patch, the goroutine
was responsible for forking the request's span asynchronously. This was
pretty broken because the request's span might be finished by the time
it's forked. This is a use-after-Finish, and I'm trying to stop
tolerating such uses. This patch fixes it by forking the span
synchronously.
Release note: None