A Redis outage logged one line per refresh and per failed write. The
loop now logs at most one store error per 30 seconds, the interval the
limiter already uses.
During a Redis outage the queued failure deltas kept a replaced
gateway's loop alive for ever. A queued failure older than the fail
window cannot change the fleet count, so the breaker now drops it.
A request that outlived the idle window ended after the loop had
stopped. Its finish delta then stayed queued with no loop to send it.
The end function now touches the loop.
A flush whose reply timed out may have landed in Redis. The flusher
kept the batch and resent it every tick, which counted it many times.
A batch that never reached the wire is still kept. A batch that may
have landed is resent once and then dropped.
A flush whose INCR Redis applied but whose reply failed was resent.
The resend never crossed the threshold, so the fleet never tripped.
The flush now trips when the count is at or above the threshold and the
last refresh shows the breaker closed. A short reply is now an error.
The open count only grew, so each trip after a recovery waited longer
than the last. The breaker now reads the open count on every refresh.
A success sets the count to zero when the last refresh showed it above
zero. The next trip then opens for the base duration.
The request breaker now also reads and writes the fleet breaker when redis.sharedState is on. A pod that sees enough failures opens the breaker for every pod after one refresh. A success on any pod closes it again. With the switch off, the tracker runs its local code only and makes no store call.
begin and end now add to a local accumulator. The refresh loop sends
all deltas in one incrMulti before each read, so a request starts no
goroutine and makes no store call. A failed flush keeps the deltas.
Deltas for epochs outside the read window are discarded.
Breaker failures use the same path. The instance whose flush takes a
count from below the threshold to at or above it opens the breaker.
The loop does not idle-stop with pending deltas and flushes on Close.
Add sharedStateLoop, sharedBreaker and sharedInflight. One loop per
gateway refreshes every primitive from the store once per second, so
request paths read local copies only. A store error keeps the last
values, and three failed refreshes make shared values absent.
Add the redis.sharedState switch. It defaults off, and it needs
redis.address. With it off, no shared keys are read or written.