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: only create a LeafTxn for local flows if Streamer is enabled #76641

Merged
merged 1 commit into from
Feb 18, 2022

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Feb 16, 2022

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

@yuzefovich yuzefovich requested review from rharding6373 and a team February 16, 2022 03:50
@yuzefovich yuzefovich requested a review from a team as a code owner February 16, 2022 03:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich force-pushed the streamer-cleanup branch 2 times, most recently from 6fe264d to 0fe540b Compare February 16, 2022 20:30
Copy link
Collaborator

@rharding6373 rharding6373 left a comment

Choose a reason for hiding this comment

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

Good work! :lgtm:

Reviewable status: :shipit: 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
Copy link
Member Author

@yuzefovich yuzefovich left a 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: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rharding6373)

@craig
Copy link
Contributor

craig bot commented Feb 17, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Feb 18, 2022

Build succeeded:

@craig craig bot merged commit 44d2361 into cockroachdb:master Feb 18, 2022
@yuzefovich yuzefovich deleted the streamer-cleanup branch February 18, 2022 01:49
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