From 37bdc34d86dccae298b9cb4fca6d8697e2877c4f Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Tue, 31 Dec 2019 16:42:38 +0800 Subject: [PATCH] metrics,store: add a metric for ttlManager to record the lifetime reach events --- metrics/metrics.go | 1 + metrics/tikvclient.go | 8 ++++++++ store/tikv/2pc.go | 1 + 3 files changed, 10 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index e25c6aa6c0872..57401d1c0b879 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -156,4 +156,5 @@ func RegisterMetrics() { prometheus.MustRegister(TiKVTxnHeartBeatHistogram) prometheus.MustRegister(TiKVPessimisticLockKeysDuration) prometheus.MustRegister(GRPCConnTransientFailureCounter) + prometheus.MustRegister(TiKVTTLLifeTimeReachCounter) } diff --git a/metrics/tikvclient.go b/metrics/tikvclient.go index 8c12c4fa384e3..c00d4027acd40 100644 --- a/metrics/tikvclient.go +++ b/metrics/tikvclient.go @@ -240,4 +240,12 @@ var ( Buckets: prometheus.ExponentialBuckets(0.001, 2, 24), // 1ms ~ 16777s Help: "tidb txn pessimistic lock keys duration", }) + + TiKVTTLLifeTimeReachCounter = prometheus.NewCounter( + prometheus.CounterOpts{ + Namespace: "tidb", + Subsystem: "tikvclient", + Name: "ttl_lifetime_reach_total", + Help: "Counter of ttlManager live too long.", + }) ) diff --git a/store/tikv/2pc.go b/store/tikv/2pc.go index de6af63718f10..bcced34acb3a6 100644 --- a/store/tikv/2pc.go +++ b/store/tikv/2pc.go @@ -703,6 +703,7 @@ func (tm *ttlManager) keepAlive(c *twoPhaseCommitter) { // the key will not be locked forever. logutil.Logger(context.Background()).Info("ttlManager live up to its lifetime", zap.Uint64("txnStartTS", c.startTS)) + metrics.TiKVTTLLifeTimeReachCounter.Inc() return }