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

*: lock unchanged rows for pessimistic transaction #14045

Merged
merged 4 commits into from
Dec 13, 2019

Conversation

coocood
Copy link
Member

@coocood coocood commented Dec 12, 2019

What problem does this PR solve?

The pessimistic lock is not acquired if a row is unchanged.

What is changed and how it works?

Add the unchanged row key to TxnCtx, later collect them before calling LockKeys.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Fix the issue that unchanged rows are not locked for a pessimistic transaction.

@codecov
Copy link

codecov bot commented Dec 12, 2019

Codecov Report

Merging #14045 into master will decrease coverage by 0.2649%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master     #14045       +/-   ##
===============================================
- Coverage   80.4293%   80.1644%   -0.265%     
===============================================
  Files           482        482               
  Lines        122367     120904     -1463     
===============================================
- Hits          98419      96922     -1497     
- Misses        16219      16246       +27     
- Partials       7729       7736        +7

tk.MustExec("update unchanged set c = 1 where id < 2")

tk2.MustExec("begin pessimistic")
err := tk2.ExecToErr("select * from unchanged where id = 1 for update nowait")
Copy link
Contributor

Choose a reason for hiding this comment

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

How long does the lock time out, would it block the CI ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it returns an error instantly.

@tiancaiamao
Copy link
Contributor

Mostly LGTM
It's a good time to re-evaluate the real cost of the optimization that we previously made.
Do not write unchanged key-values adds too much complexity and brings many corner cases. @crazycs520 also met some problems before.

@cfzjywxk
Copy link
Contributor

LGTM

@coocood coocood added the status/LGT2 Indicates that a PR has LGTM 2. label Dec 13, 2019
@coocood
Copy link
Member Author

coocood commented Dec 13, 2019

@jackysp PTAL

Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp jackysp added the status/can-merge Indicates a PR has been approved by a committer. label Dec 13, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Dec 13, 2019

/run-all-tests

@sre-bot
Copy link
Contributor

sre-bot commented Dec 13, 2019

cherry pick to release-3.0 in PR #14049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/transaction SIG:Transaction status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants