Skip to content

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

Merged
zz-jason merged 2 commits into
pingcap:masterfrom
coocood:fix-for-update-retry
Aug 12, 2019
Merged

executor: fix auto retry when transaction has select for update#11714
zz-jason merged 2 commits into
pingcap:masterfrom
coocood:fix-for-update-retry

Conversation

@coocood
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Member Author

coocood commented Aug 12, 2019

/run-unit-test

@coocood
Copy link
Copy Markdown
Member Author

coocood commented Aug 12, 2019

/run-unit-test

@tiancaiamao
Copy link
Copy Markdown
Contributor

LGTM

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