pingcap / pingcap/tidb

Avoid unnecessary statement retry in Fair Locking mode

Open
#42,772 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement

Ref: https://github.com/tikv/tikv/issues/13298

In Fair Locking mode introduced recently, when a statement in a pessimistic transaction tries to lock a single key and there's write conflict on the key, it will try to force the key be locked before retrying the statement. It can be seen that if the pessimistic-lock operation is **the first read/write operation of the statement**, force-locking the key doesn't break the consistency of the snapshot we are currently reading. If we update forUpdateTS and continue execution of the statement, we can still guarantee that the current statement is reading a consistent snapshot. Thus we can expect to reduce part of the latency of this kinds of statements that's introduced by retrying statement.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.