fix(shared-state): count discovery failures per instance

With redis.sharedState on, every route instance added each failed
discovery refresh to one fleet count. One failed round across the
fleet could then open the discovery breaker.

Each instance now counts its own consecutive failures. Only the
instance whose own count reaches breaker.failureThreshold shares a
trip, and the fleet breaker opens on the first trip.
This commit is contained in:
2026-11-26 06:21:10 +00:00
parent 00bb36d29d
commit ebe38e7527
5 changed files with 36 additions and 7 deletions
+2 -3
View File
@@ -20,10 +20,9 @@ func (g *Gateway) wireSharedState(cfg *Config) {
if err != nil {
brk = breakerConfig{failureThreshold: defaultBreakerFailureThreshold, openBase: defaultBreakerOpenDuration, openMax: defaultBreakerMaxOpenDuration}
}
// With a shared breaker, brk.failureThreshold counts failed refreshes across all route instances and replicas
// inside 2*openMax, not consecutive failures on one instance.
// Each instance counts its own consecutive failures and shares only its trip, so the fleet opens on the first one.
g.registry.shareBreaker(newSharedBreaker(g.sharedState, sharedKindDiscovery, ids,
brk.failureThreshold, brk.openBase, brk.openMax, 2*brk.openMax))
sharedDiscoveryFleetThreshold, brk.openBase, brk.openMax, 2*brk.openMax))
}
g.shareDecisionBreakers(ids)
if g.tokenCalib != nil && g.limiter != nil {