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

executor: fix auto retry when transaction has select for update #11714

Merged
merged 2 commits into from
Aug 12, 2019

Conversation

coocood
Copy link
Member

@coocood coocood commented Aug 12, 2019

What problem does this PR solve?

When @@tidb_disable_txn_auto_retry is set to 0, transactions will retry automatically when there are write conflicts, but when there are select for update statements, auto-retry should be prevented. A previous PR #10972 makes point get plan supports select for update, but didn't set TransactionContext.ForUpdate to true, so the transaction will retry even it has select for update statements.

What is changed and how it works?

extract a function doLockKeys that used by both SelectLock executor and PointGet executor. In this function, set TransactionContext.ForUpdate to true.

Check List

Tests

  • Unit test

Code changes

  • Has exported variable/fields change

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

@coocood coocood requested review from jackysp, lysu and zz-jason August 12, 2019 05:55
@coocood coocood added needs-cherry-pick-3.0 type/bugfix This PR fixes a bug. priority/release-blocker This issue blocks a release. Please solve it ASAP. labels Aug 12, 2019
@codecov
Copy link

codecov bot commented Aug 12, 2019

Codecov Report

Merging #11714 into master will decrease coverage by 0.1295%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master    #11714        +/-   ##
===============================================
- Coverage   81.4415%   81.312%   -0.1296%     
===============================================
  Files           429       429                
  Lines         92621     92621                
===============================================
- Hits          75432     75312       -120     
- Misses        11798     11936       +138     
+ Partials       5391      5373        -18

@codecov
Copy link

codecov bot commented Aug 12, 2019

Codecov Report

Merging #11714 into master will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##            master    #11714   +/-   ##
=========================================
  Coverage   81.493%   81.493%           
=========================================
  Files          429       429           
  Lines        92830     92830           
=========================================
  Hits         75650     75650           
  Misses       11795     11795           
  Partials      5385      5385

@coocood
Copy link
Member Author

coocood commented Aug 12, 2019

/run-all-tests

@coocood coocood requested a review from tiancaiamao August 12, 2019 07:15
@coocood
Copy link
Member Author

coocood commented Aug 12, 2019

/run-unit-test

@coocood
Copy link
Member Author

coocood commented Aug 12, 2019

/run-unit-test

@tiancaiamao
Copy link
Contributor

LGTM

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 12, 2019
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.

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 12, 2019
@zz-jason zz-jason merged commit 140718d into pingcap:master Aug 12, 2019
@coocood coocood deleted the fix-for-update-retry branch August 12, 2019 08:33
@sre-bot
Copy link
Contributor

sre-bot commented Aug 12, 2019

cherry pick to release-3.0 in PR #11718

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/release-blocker This issue blocks a release. Please solve it ASAP. 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.

4 participants