diff --git a/txnkv/transaction/pipelined_flush.go b/txnkv/transaction/pipelined_flush.go index d2fe35cf9e..41c412d839 100644 --- a/txnkv/transaction/pipelined_flush.go +++ b/txnkv/transaction/pipelined_flush.go @@ -34,6 +34,7 @@ import ( "github.com/tikv/client-go/v2/internal/locate" "github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/kv" + "github.com/tikv/client-go/v2/metrics" "github.com/tikv/client-go/v2/tikvrpc" "github.com/tikv/client-go/v2/txnkv/rangetask" "github.com/tikv/client-go/v2/txnkv/txnlock" @@ -244,6 +245,7 @@ func (action actionPipelinedFlush) handleSingleBatch( // TiKV will return a PessimisticLockNotFound error directly if it encounters a different lock. Otherwise, // TiKV returns lock.TTL = 0, and we still need to resolve the lock. if lock.TxnID > c.startTS && !c.isPessimistic { + metrics.LockResolverCountWithWriteConflict.Inc() return tikverr.NewErrWriteConflictWithArgs( c.startTS, lock.TxnID, diff --git a/txnkv/transaction/prewrite.go b/txnkv/transaction/prewrite.go index b01e1bba61..1d50213e64 100644 --- a/txnkv/transaction/prewrite.go +++ b/txnkv/transaction/prewrite.go @@ -487,6 +487,7 @@ func (handler *prewrite1BatchReqHandler) extractKeyErrs(keyErrs []*kvrpcpb.KeyEr // TiKV returns lock.TTL = 0, and we still need to resolve the lock. if (lock.TxnID > handler.committer.startTS && !handler.committer.isPessimistic) || handler.committer.txn.prewriteEncounterLockPolicy == NoResolvePolicy { + metrics.LockResolverCountWithWriteConflict.Inc() return nil, tikverr.NewErrWriteConflictWithArgs( handler.committer.startTS, lock.TxnID,