-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
tracing: fix corruption of structured recording buffer #75099
tracing: fix corruption of structured recording buffer #75099
Conversation
4dc5b50
to
fb7f04e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why #73876 made it worse/was bisected to?
pkg/util/tracing/crdbspan.go
Outdated
for _, c := range children { | ||
for _, e := range c.StructuredRecords { | ||
s.recordInternalLocked(&e, &s.mu.recording.structured) | ||
for c := range children { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[mega nit] c
looks like it'd be of type tracingpb.RecordedSpan but it's an index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed to ci
Not really. The symptoms that the failed tests report (trying to read the first element of an empty buffer) are caused by the fact that the computed size of the buffer is not kept in sync with reality, which is a problem when a span overflows its byte limit for the structured recordings. So one thing that would trigger it is a change that makes some span accumulate more structured recordings than before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif)
This patch fixes a bug leading to corruption of one of the Span's recording buffers. We had broken code like the following: ``` for _, e := range c.StructuredRecords { s.recordInternalLocked(&e, &s.mu.recording.structured) } ``` `recordInternalLocked(ptr)` takes ownership of ptr, so the `&e` is broken because `e` keep being reassigned. The bug was causing buffer elements to essentially be overwritten. In turn, this was leading to inconsistencies in the accounting of the size of the buffer's elements - we were maintaining a size sum that was diverging from the overwritten reality. Fixes cockroachdb#74994 Fixes cockroachdb#75045 Release note: None
fb7f04e
to
5a1adf7
Compare
Canceled. |
bors r+ |
Build failed (retrying...): |
Build failed (retrying...): |
Build succeeded: |
This patch fixes a bug leading to corruption of one of the Span's
recording buffers.
We had broken code like the following:
recordInternalLocked(ptr)
takes ownership of ptr, so the&e
isbroken because
e
keep being reassigned.The bug was causing buffer elements to essentially be overwritten. In
turn, this was leading to inconsistencies in the accounting of the size
of the buffer's elements - we were maintaining a size sum that was
diverging from the overwritten reality.
Fixes #74994
Fixes #75045
Release note: None