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

flowinfra: replace ConcurrentExecution with ConcurrentTxnUse #52621

Merged
merged 1 commit into from
Aug 13, 2020
Merged

flowinfra: replace ConcurrentExecution with ConcurrentTxnUse #52621

merged 1 commit into from
Aug 13, 2020

Conversation

asubiotto
Copy link
Contributor

Previously, the DistSQLPlanner would reject any local flows with any
concurrency due to possible concurrent use of a RootTxn. This policy was overly
prohibitive as it would reject stats flows that contain processors that cannot
be fused even though there would be no concurrent txn usage.

This commit makes this policy a bit more lenient, introducing a way for
processors to indicate that they and their input will not be using a txn. This
is exposed through the new ConcurrentTxnUse method in the flow interface, which
returns whether more than one processor will be using a txn.

This commit also removes ConcurrentExecution since all usages have been
replaced with ConcurrentTxnUse.

Release note: None (internal refactor to fix an error message received only in
a multitenant environment)

Fixes #50049

@asubiotto asubiotto added the A-multitenancy Related to multi-tenancy label Aug 11, 2020
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@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.

Are there any other processors that cannot be fused but also don't use a txn?

Reviewed 13 of 13 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @asubiotto)


pkg/sql/execinfra/processorsbase.go, line 45 at r1 (raw file):

// local flow from running in parallel if this is unknown since concurrent use
// of the RootTxn is forbidden (in a distributed flow these are leaf txns, so
// it doesn't matter.)

nit: period before parenthesis.

Previously, the DistSQLPlanner would reject any local flows with any
concurrency due to possible concurrent use of a RootTxn. This policy was overly
prohibitive as it would reject stats flows that contain processors that cannot
be fused even though there would be no concurrent txn usage.

This commit makes this policy a bit more lenient, introducing a way for
processors to indicate that they and their input will not be using a txn. This
is exposed through the new ConcurrentTxnUse method in the flow interface, which
returns whether more than one processor will be using a txn.

This commit also removes ConcurrentExecution since all usages have been
replaced with ConcurrentTxnUse.

Release note: None (internal refactor to fix an error message received only in
a multitenant environment)
Copy link
Contributor Author

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

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

Probably, but it's not the goal of this PR to implement DoesNotUseTxn for all processors, only for the stats ones to fix the immediate problem of not being able to run CREATE STATS in a multitenant environment. If we encounter a problem related to other processors, the fix should be as easy as implementing DoesNotUseTxn.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @yuzefovich)

Copy link
Member

@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.

:lgtm:

Reviewed 2 of 2 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

Copy link
Contributor

@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.

that cannot be fused even though there would be no concurrent txn usage

Is there a good reason why whatever prompted this cannot be fused?

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andreimatei)

@asubiotto
Copy link
Contributor Author

It's another solution I mentioned in (#50049 (comment)), but it's code I'm not familiar with (stats collection processors) and will probably be non-trivial based on my experience refactoring so want to leave it on the optimizer team's plate. Created an issue: #52700

Copy link
Contributor

@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.

Let's see what @rytaft says. If we can just fuse whatever, I'd rather do that than introduce this interface since I don't trust an interface like this to stay accurate.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained

@RaduBerinde
Copy link
Member

@rytaft is OOO this week. I don't see any reason we can't fuse them, but we are all pretty swamped right now.

@asubiotto
Copy link
Contributor Author

To be clear: the inability to fuse in the commit message is in reference to the current state of the DistSQLPlanner not being able to do so because the processors do not implement RowSource, not that these processors cannot implement RowSource, which would make them fusable.

I'm going to go ahead and merge this to unblock stats creation in a multitenant environment. This is an opt-in interface, and I think it's very unlikely for any processors that need to implement this interface to change their behavior to suddenly use a txn since it's such an intrinsic part of the processor. Also, the number of processors that don't implement RowSource is probably pretty low. Once #52700 is dealt with, I'm happy to remove this interface.

bors r=yuzefovich

@craig
Copy link
Contributor

craig bot commented Aug 13, 2020

Build succeeded:

@craig craig bot merged commit f4a935e into cockroachdb:master Aug 13, 2020
@asubiotto asubiotto deleted the mtfc branch August 17, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-multitenancy Related to multi-tenancy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql/multitenancy: unexpected concurrency for flow error when creating stats
5 participants