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

*: fix a bug that the pessimistic lock doesn't work on a partition (#14921) #15086

Closed

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Mar 3, 2020

cherry-pick #14921 to release-4.0


What problem does this PR solve?

'select ... for update' doesn't work right on a partitioned table.

txn1: begin
txn1:  select * from t where a = xx for update

txn2:  update t set b = yy where a = xx

In pessimistic txn mode, txn2 should be blocked.

What is changed and how it works?

The bug is that we use table ID to construct the lock key.
On a partitioned table, partition ID should be used.

Changes:

  • During column pruning, do not prune the partition columns for LogicalLock
  • In SelectLockExec, use table ID and partition columns to locate the partition, then use the partition ID to construct the lock key.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Write release note for bug-fix or new feature.

…ingcap#14921)

physicalID should be used if 'select for update' works on a
partitioned table.
@sre-bot sre-bot requested a review from a team as a code owner March 3, 2020 07:08
@sre-bot
Copy link
Contributor Author

sre-bot commented Mar 3, 2020

/run-all-tests

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

@tiancaiamao Please confirm that whether we should cherry pick PRs one by one from master to release-4.0. I remembered that we are going to fast forward the code from master branch to release-4.0.

@tiancaiamao
Copy link
Contributor

OK... maybe I see someone cherry-pick and following him
The type/4.0 cherry-pick is misleading...

@tiancaiamao tiancaiamao closed this Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants