-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
release-24.1: execbuilder: only apply implicit for-update locking to mutation input #121391
Conversation
c8c2a7c
to
21b3b94
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
Also, please add a brief release justification to the body of your PR to justify this |
60c0c51
to
5a909aa
Compare
The failure is an unrelated flake. I believe this is RFAL. |
Gentle ping 🙂 |
Friendly ping @mgartner @yuzefovich |
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 3 of 5 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @mgartner and @michae2)
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 3 of 5 files at r1, 2 of 2 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @michae2)
Sorry for the delay! |
No worries! |
5a909aa
to
4355650
Compare
In `shouldApplyImplicitLockingToMutationInput` we match only certain plan shapes of UPDATE and UPSERT, to make certain that implicit for-update locking will not be a pessimization. Then in `buildMutationInput` we were enabling implicit for-update locking for _all_ operations underneath the input of the mutation. This was causing subqueries in projections to also have implicit for-update locking, for example in queries like: ```sql UPDATE ab SET b = (SELECT sum(c) FROM c) WHERE a = 1; ``` In order to restrict implicit for-update locking to the mutation target table, this commit changes `shouldApplyImplicitLockingToMutationInput` to return the TableID of the input scan. We now only apply implicit for-update locking to these tables. Fixes: #121322 Release note (bug fix): Fix a bug where UPDATE and UPSERT queries with a subquery were sometimes inappropriately using implicit FOR-UPDATE locking within the subquery. This bug has existing since implicit FOR-UPDATE locking was introduced in 20.1.0.
4355650
to
34e94c1
Compare
Backport 1/1 commits from #121333 on behalf of @michae2.
/cc @cockroachdb/release
In
shouldApplyImplicitLockingToMutationInput
we match only certain plan shapes of UPDATE and UPSERT, to make certain that implicit for-update locking will not be a pessimization. Then inbuildMutationInput
we were enabling implicit for-update locking for all operations underneath the input of the mutation.This was causing subqueries in projections to also have implicit for-update locking, for example in queries like:
In order to restrict implicit for-update locking to the mutation target table, this commit changes
shouldApplyImplicitLockingToMutationInput
to return the TableID of the input scan. We now only apply implicit for-update locking to these tables.Fixes: #121322
Release note (bug fix): Fix a bug where UPDATE and UPSERT queries with a subquery were sometimes inappropriately using implicit FOR-UPDATE locking within the subquery. This bug has existing since implicit FOR-UPDATE locking was introduced in 20.1.0.
Release justification: fix for a serious contention issue discovered on the DRT cluster.