Skip to content

txnkv: read through locks#380

Merged
youjiali1995 merged 4 commits into
tikv:masterfrom
youjiali1995:improve-resolve-for-read
Dec 1, 2021
Merged

txnkv: read through locks#380
youjiali1995 merged 4 commits into
tikv:masterfrom
youjiali1995:improve-resolve-for-read

Conversation

@youjiali1995
Copy link
Copy Markdown
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>
Comment thread txnkv/txnlock/lock_resolver.go Outdated
Comment thread txnkv/txnlock/lock_resolver.go Outdated
return lr.resolveLocks(bo, callerStartTS, locks, true, lite)
}

func (lr *LockResolver) resolveLocks(bo *retry.Backoffer, callerStartTS uint64, locks []*Lock, forWrite bool, lite bool) (int64, []uint64 /*pushed*/, error) {
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread go.mod Outdated
Comment thread integration_tests/snapshot_fail_test.go Outdated
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
@youjiali1995 youjiali1995 force-pushed the improve-resolve-for-read branch from c5dba6b to a2936f9 Compare November 30, 2021 07:51
Comment thread integration_tests/lock_test.go Outdated
var locks []*txnlock.Lock

// commitTS < readStartTS
startTS, _ := s.lockKey([]byte("k1"), []byte("v1"), []byte("k11"), []byte("v11"), true, false)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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