Skip to content

Commit

Permalink
metric: add metric for pessimistic lock keys (#20383) (#20513)
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>
  • Loading branch information
ti-srebot authored Oct 21, 2020
1 parent 0b0fbf1 commit 9c6c698
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions metrics/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,5 @@ const (
LblAddress = "address"
LblBatchGet = "batch_get"
LblGet = "get"
LblLockKeys = "lock_keys"
)
2 changes: 2 additions & 0 deletions store/tikv/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
tikvTxnCmdHistogramWithRollback = metrics.TiKVTxnCmdHistogram.WithLabelValues(metrics.LblRollback)
tikvTxnCmdHistogramWithBatchGet = metrics.TiKVTxnCmdHistogram.WithLabelValues(metrics.LblBatchGet)
tikvTxnCmdHistogramWithGet = metrics.TiKVTxnCmdHistogram.WithLabelValues(metrics.LblGet)
tikvTxnCmdHistogramWithLockKeys = metrics.TiKVTxnCmdHistogram.WithLabelValues(metrics.LblLockKeys)
)

// SchemaAmender is used by pessimistic transactions to amend commit mutations for schema change during 2pc.
Expand Down Expand Up @@ -369,6 +370,7 @@ func (txn *tikvTxn) LockKeys(ctx context.Context, lockCtx *kv.LockCtx, keysInput
keys := make([][]byte, 0, len(keysInput))
startTime := time.Now()
defer func() {
tikvTxnCmdHistogramWithLockKeys.Observe(time.Since(startTime).Seconds())
if err == nil {
if lockCtx.PessimisticLockWaited != nil {
if atomic.LoadInt32(lockCtx.PessimisticLockWaited) > 0 {
Expand Down

0 comments on commit 9c6c698

Please sign in to comment.