Skip to content

Commit

Permalink
kvcoord: remove GCed DistSender circuit breakers from tripped metrics
Browse files Browse the repository at this point in the history
Otherwise, these will register as tripped forever.

Epic: none
Release note: None
  • Loading branch information
erikgrinaker committed Mar 24, 2024
1 parent 99b725f commit 3ae54c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/kv/kvclient/kvcoord/dist_sender_circuit_breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,6 @@ func (d *DistSenderCircuitBreakers) gcLoop(ctx context.Context) {
// replace. We don't expect this, since only this loop removes them.
if v, ok := d.replicas.LoadAndDelete(key); ok {
cb = v.(*ReplicaCircuitBreaker)
// TODO(erikgrinaker): this needs to remove tripped circuit breakers
// from the metrics, otherwise they'll appear as tripped forever.
// However, there are race conditions with concurrent probes that can
// lead to metrics gauge leaks (both positive and negative), so we'll
// have to make sure we reap the probes here first.
d.metrics.CircuitBreaker.Replicas.Dec(1)
gced++

Expand All @@ -281,6 +276,11 @@ func (d *DistSenderCircuitBreakers) gcLoop(ctx context.Context) {
// probes run longer than the GC threshold. The map removal above will
// prevent new probes being launched (checked by launchProbe).
cb.reapProbe()

// Remove the GCed breaker from tripped metrics.
if cb.isTripped() {
d.metrics.CircuitBreaker.ReplicasTripped.Dec(1)
}
}
}
return true
Expand Down

0 comments on commit 3ae54c8

Please sign in to comment.