-
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
sql: only create a LeafTxn for local flows if Streamer is enabled #76641
Conversation
6fe264d
to
0fe540b
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 (waiting on @rharding6373 and @yuzefovich)
pkg/sql/distsql_running.go, line 459 at r1 (raw file):
// Even if planCtx.isLocal is false (which is the case when we think it's // worth distributing the query), we need to go through the processors to // figure out whether any of them have concurrency.
nit: a comment here about why this is only relevant if we may be using the streamer would be helpful here.
Previously, during the flow setup stage we would always choose to create a LeafTxn for local flows if there is a processor that might use a Streamer API. This was the case even when the Streamer is disabled by a cluster setting. Such behavior is a regression (since leaf txns don't have a transparent span refresh mechanism and read spans have to be collected with the metadata at the end of the execution), so this commit fixes things by only using a LeafTxn if the Streamer is actually enabled. Now, the users of the Streamer API are expected to check that they do have a LeafTxn and only use the Streamer if so. Additionally, this commit correctly populates `HasConcurrency` field for the local flows even when the query might be distributed. The fix is needed since the physical planning decision to distribute the query or not is finalized after we decide which txn to use for the flow, which is too late. Thus, whenever the Streamer is enabled and we find an index join in the plan, we will make sure to use the LeafTxn (this was already the case if the plan ended up being distributed). Release note: None
0fe540b
to
7b0ef97
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.
Extended the comment.
TFTR!
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rharding6373)
Build failed (retrying...): |
Build succeeded: |
Previously, during the flow setup stage we would always choose to create
a LeafTxn for local flows if there is a processor that might use
a Streamer API. This was the case even when the Streamer is disabled by
a cluster setting. Such behavior is a regression (since leaf txns don't
have a transparent span refresh mechanism and read spans have to be
collected with the metadata at the end of the execution), so this commit
fixes things by only using a LeafTxn if the Streamer is actually
enabled. Now, the users of the Streamer API are expected to check that
they do have a LeafTxn and only use the Streamer if so.
Additionally, this commit correctly populates
HasConcurrency
field forthe local flows even when the query might be distributed. The fix is
needed since the physical planning decision to distribute the query or
not is finalized after we decide which txn to use for the flow, which is
too late. Thus, whenever the Streamer is enabled and we find an index
join in the plan, we will make sure to use the LeafTxn (this was already
the case if the plan ended up being distributed).
Release note: None