Skip to content

Commit c87174e

Browse files
author
sujuntao
committed
Add txn write conflict metrics
Signed-off-by: sujuntao <[email protected]>
1 parent ec9ad0f commit c87174e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

txnkv/transaction/pipelined_flush.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/tikv/client-go/v2/internal/locate"
3535
"github.com/tikv/client-go/v2/internal/logutil"
3636
"github.com/tikv/client-go/v2/kv"
37+
"github.com/tikv/client-go/v2/metrics"
3738
"github.com/tikv/client-go/v2/tikvrpc"
3839
"github.com/tikv/client-go/v2/txnkv/rangetask"
3940
"github.com/tikv/client-go/v2/txnkv/txnlock"
@@ -244,6 +245,7 @@ func (action actionPipelinedFlush) handleSingleBatch(
244245
// TiKV will return a PessimisticLockNotFound error directly if it encounters a different lock. Otherwise,
245246
// TiKV returns lock.TTL = 0, and we still need to resolve the lock.
246247
if lock.TxnID > c.startTS && !c.isPessimistic {
248+
metrics.LockResolverCountWithWriteConflict.Inc()
247249
return tikverr.NewErrWriteConflictWithArgs(
248250
c.startTS,
249251
lock.TxnID,

txnkv/transaction/prewrite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ func (handler *prewrite1BatchReqHandler) extractKeyErrs(keyErrs []*kvrpcpb.KeyEr
487487
// TiKV returns lock.TTL = 0, and we still need to resolve the lock.
488488
if (lock.TxnID > handler.committer.startTS && !handler.committer.isPessimistic) ||
489489
handler.committer.txn.prewriteEncounterLockPolicy == NoResolvePolicy {
490+
metrics.LockResolverCountWithWriteConflict.Inc()
490491
return nil, tikverr.NewErrWriteConflictWithArgs(
491492
handler.committer.startTS,
492493
lock.TxnID,

0 commit comments

Comments
 (0)