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

sql: fix and simplify session tracing span mgmt #72122

Merged

Conversation

andreimatei
Copy link
Contributor

Before this patch, session tracing was broken in two ways:

  • it leaked a span, corresponding to the transaction that was ongoing
    when session tracing is initiated. Session tracing was replacing that
    span in the connection's tracking, and so nobody was ever Finish()ing
    it.
  • it exposed a span to use-after-finish. This is the span that replaced
    the span discussed above. When session tracing is initiated in a
    transaction, it overwrote the txn's span. When session tracing was
    finished, it finished that span. But, in case tracing is finished
    in the same txn as the one it started in, then that span is still
    referenced by the connection.

This patch fixes these issues and also simplifies how session tracing
works. We do away with the special handling of the transaction during
which tracing starts. Instead, we just give this transaction a span
inheriting from the same recording span that future transactions will
inherit from. The SessionTracing struct gets out of the business of
owning any spans.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@andreimatei andreimatei force-pushed the tracing.use-after-finish-session-tracing branch 4 times, most recently from 4840d61 to ffaef58 Compare October 28, 2021 22:05
Before this patch, session tracing was broken in two ways:
- it leaked a span, corresponding to the transaction that was ongoing
  when session tracing is initiated. Session tracing was replacing that
  span in the connection's tracking, and so nobody was ever Finish()ing
  it.
- it exposed a span to use-after-finish. This is the span that replaced
  the span discussed above. When session tracing is initiated in a
  transaction, it overwrote the txn's span. When session tracing was
  finished, it finished that span. But, in case tracing is finished
  in the same txn as the one it started in, then that span is still
  referenced by the connection.

This patch fixes these issues and also simplifies how session tracing
works. We do away with the special handling of the transaction during
which tracing starts. Instead, we just give this transaction a span
inheriting from the same recording span that future transactions will
inherit from. The SessionTracing struct gets out of the business of
owning any spans.

Release note: None
@andreimatei andreimatei force-pushed the tracing.use-after-finish-session-tracing branch from ffaef58 to a6558fd Compare November 4, 2021 18:37
Copy link
Contributor Author

@andreimatei andreimatei left a 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: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @abarganier)

@craig
Copy link
Contributor

craig bot commented Nov 4, 2021

Build succeeded:

@craig craig bot merged commit 7833610 into cockroachdb:master Nov 4, 2021
@andreimatei andreimatei deleted the tracing.use-after-finish-session-tracing branch January 26, 2022 17:27
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.

3 participants