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) #15085

Closed

Conversation

sre-bot
Copy link
Contributor

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

cherry-pick #14921 to release-3.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.

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented Mar 3, 2020

/run-all-tests

@tiancaiamao
Copy link
Contributor

Duplicated by #15114

@tiancaiamao tiancaiamao closed this Mar 5, 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.

2 participants