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

Merged
merged 3 commits into from
Dec 16, 2019

Conversation

coocood
Copy link
Member

@coocood coocood commented Dec 13, 2019

cherry-pick #14045 to release-3.0


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.

@coocood
Copy link
Member Author

coocood commented Dec 13, 2019

@tiancaiamao @jackysp @cfzjywxk PTAL

@tiancaiamao
Copy link
Contributor

CI failed @coocood


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

Choose a reason for hiding this comment

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

So this time it slows our CI for sure? @coocood
The nowait grammar is not introduced in 3.0? @cfzjywxk

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, the LockWaitTimeout is set to 1ms, it runs fast.
nowait is not picked to 3.0

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be picked.

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't need to pick it for now.

@tiancaiamao
Copy link
Contributor

LGTM

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

jackysp commented Dec 16, 2019

/merge

1 similar comment
@coocood
Copy link
Member Author

coocood commented Dec 16, 2019

/merge

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

sre-bot commented Dec 16, 2019

/run-all-tests

@sre-bot sre-bot merged commit 13b945d into pingcap:release-3.0 Dec 16, 2019
@coocood coocood deleted the unchanged-rows-3.0 branch March 9, 2020 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants