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

txnkv: read through locks #380

Merged
merged 4 commits into from
Dec 1, 2021

Conversation

youjiali1995
Copy link
Contributor

Signed-off-by: youjiali1995 zlwgx1023@gmail.com

TiKV supports read-through-lock tikv/tikv#11238. This PR makes use of it:

  1. I removed the forWrite parameter of resolveLocks because it's useless(Abort optimistic transaction when prewrite encounters a lock with larger TS #367) and add the forRead. If forRead is true, resolving secondary locks is asynchronous and committedLocks or resolvedLocks is returned to the user.
  2. ClientHelper passes the resolvedLocks to Context to make use of read-through-lock.

Should be merged after pingcap/tidb#29898

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
}

func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock, forWrite bool, lite bool) (int64, []uint64 /*pushed*/, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Without forWrite flag, it seems the mechanism for conflict of optimistic transactions is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's handled here #367.

go.mod Outdated Show resolved Hide resolved
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
var locks []*txnlock.Lock

// commitTS < readStartTS
startTS, _ := s.lockKey([]byte("k1"), []byte("v1"), []byte("k11"), []byte("v11"), true, false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a test for resolving a committed async-commit lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Copy link
Collaborator

@sticnarf sticnarf left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@you06 you06 left a comment

Choose a reason for hiding this comment

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

LGTM

@youjiali1995 youjiali1995 merged commit 3a76757 into tikv:master Dec 1, 2021
MyonKeminta pushed a commit to MyonKeminta/client-go that referenced this pull request Dec 13, 2021
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
Signed-off-by: MyonKeminta <MyonKeminta@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants