Skip to content

Commit

Permalink
checking the snapshot ts before doing resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
cfzjywxk committed Nov 7, 2023
1 parent ef19971 commit 6110f80
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/store/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,17 @@ func (h *Helper) GetMvccByEncodedKeyWithTS(encodedKey kv.Key, startTS uint64) (*

// Try to resolve the lock and retry mvcc get again if the input startTS is a valid value.
if startTS > 0 && mvccResp.Info.GetLock() != nil {
latestTS, err := h.Store.GetOracle().GetLowResolutionTimestamp(context.Background(), &oracle.Option{TxnScope: oracle.GlobalTxnScope})
if err != nil {
logutil.BgLogger().Warn("Failed to get latest ts", zap.Error(err))
return nil, err
}
if startTS > latestTS {
errMsg := fmt.Sprintf("Snapshot ts=%v is larger than latest allocated ts=%v, lock could not be resolved",
startTS, latestTS)
logutil.BgLogger().Warn(errMsg)
return nil, errors.New(errMsg)
}
lockInfo := mvccResp.Info.GetLock()
lock := &txnlock.Lock{
Key: []byte(encodedKey),
Expand Down

0 comments on commit 6110f80

Please sign in to comment.