Skip to content

Commit

Permalink
store/tikv: use latest PD TS plus one as min commit ts (#24579)
Browse files Browse the repository at this point in the history
  • Loading branch information
sticnarf authored May 13, 2021
1 parent 1c4fbfc commit aa3e64d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions store/tikv/2pc.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,17 +996,18 @@ func (c *twoPhaseCommitter) execute(ctx context.Context) (err error) {
// If we want to use async commit or 1PC and also want linearizability across
// all nodes, we have to make sure the commit TS of this transaction is greater
// than the snapshot TS of all existent readers. So we get a new timestamp
// from PD as our MinCommitTS.
// from PD and plus one as our MinCommitTS.
if commitTSMayBeCalculated && c.needLinearizability() {
failpoint.Inject("getMinCommitTSFromTSO", nil)
minCommitTS, err := c.store.oracle.GetTimestamp(ctx, &oracle.Option{TxnScope: oracle.GlobalTxnScope})
latestTS, err := c.store.oracle.GetTimestamp(ctx, &oracle.Option{TxnScope: oracle.GlobalTxnScope})
// If we fail to get a timestamp from PD, we just propagate the failure
// instead of falling back to the normal 2PC because a normal 2PC will
// also be likely to fail due to the same timestamp issue.
if err != nil {
return errors.Trace(err)
}
c.minCommitTS = minCommitTS
// Plus 1 to avoid producing the same commit TS with previously committed transactions
c.minCommitTS = latestTS + 1
}
// Calculate maxCommitTS if necessary
if commitTSMayBeCalculated {
Expand Down

0 comments on commit aa3e64d

Please sign in to comment.