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

Closed
wants to merge 3 commits into from

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot 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.

@sre-bot
Copy link
Contributor Author

sre-bot commented Dec 13, 2019

/run-all-tests

@@ -116,6 +117,11 @@ func updateRecord(ctx sessionctx.Context, h int64, oldData, newData []types.Datu
if ctx.GetSessionVars().ClientCapability&mysql.ClientFoundRows > 0 {
sc.AddAffectedRows(1)
}
unchangedRowKey := tablecodec.EncodeRowKeyWithHandle(t.Meta().ID, h)
txnCtx := sctx.GetSessionVars().TxnCtx
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
txnCtx := sctx.GetSessionVars().TxnCtx
txnCtx := ctx.GetSessionVars().TxnCtx

@coocood coocood closed this Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants