From b9148c7ae5bd425973eac647d1b3fdbd7aa5ccba Mon Sep 17 00:00:00 2001 From: Erik Grinaker Date: Sun, 28 May 2023 08:10:28 +0000 Subject: [PATCH] kvserver: log system range lease acquisition This patch logs acquisition of meta/liveness range leases to the health log. These leases are critical to cluster health, and during debugging it's useful to know their location over time. Epic: none Release note: None --- pkg/kv/kvserver/replica_proposal.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/kv/kvserver/replica_proposal.go b/pkg/kv/kvserver/replica_proposal.go index 547df418854c..ea03b019b5d7 100644 --- a/pkg/kv/kvserver/replica_proposal.go +++ b/pkg/kv/kvserver/replica_proposal.go @@ -366,6 +366,17 @@ func (r *Replica) leasePostApplyLocked( r.gossipFirstRangeLocked(ctx) } + // Log acquisition of meta and liveness range leases. These are critical to + // cluster health, so it's useful to know their location over time. + if leaseChangingHands && iAmTheLeaseHolder && + r.descRLocked().StartKey.Less(roachpb.RKey(keys.NodeLivenessKeyMax)) { + if r.ownsValidLeaseRLocked(ctx, now) { + log.Health.Infof(ctx, "acquired system range lease: %s", newLease) + } else { + log.Health.Warningf(ctx, "applied system range lease after it expired: %s", newLease) + } + } + st := r.leaseStatusAtRLocked(ctx, now) if leaseChangingHands && newLease.Type() == roachpb.LeaseExpiration && r.ownsValidLeaseRLocked(ctx, now) && !r.shouldUseExpirationLeaseRLocked() {