Skip to content

Commit 2aa4cec

Browse files
alexluongclaude
andauthored
fix: increase consumer error tolerance for transient infra outages (#900)
Previously the consumer gave up after 5 consecutive receive errors with a 5s backoff cap (~3s total tolerance), permanently killing the worker with no recovery path. A brief broker hiccup (e.g. GCP OAuth/DNS blip, managed broker restart) was enough to take down logmq/deliverymq workers across deployments until containers were manually restarted. Mirrors the same fix applied to the retrymq scheduler in #881. Increase to 10 errors with 15s backoff cap (~1 min tolerance window). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 121bd95 commit 2aa4cec

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

internal/consumer/consumer.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,30 @@ import (
1212
"go.uber.org/zap"
1313
)
1414

15+
// Error retry schedule (with 200ms initial backoff):
16+
//
17+
// Error Backoff Cumulative
18+
// 1 200ms 0.2s
19+
// 2 400ms 0.6s
20+
// 3 800ms 1.4s ← 3 retries within ~1.5s
21+
// 4 1.6s 3.0s
22+
// 5 3.2s 6.2s
23+
// 6 6.4s 12.6s
24+
// 7 12.8s 25.4s
25+
// 8 15s (cap) 40.4s
26+
// 9 15s (cap) 55.4s
27+
// 10 15s (cap) 70.4s ← worker dies (~1 min total)
28+
//
29+
// Backoff formula: initialBackoff * 2^(attempt-1), capped at maxBackoff.
30+
// After maxConsecutiveErrors the worker dies permanently (supervisor does
31+
// not restart it), so these values must tolerate transient infra outages
32+
// (e.g. brief MQ broker restarts, GCP OAuth/DNS blips) without killing the
33+
// worker. ~1 min is sufficient for managed broker recovery from routine
34+
// restarts or short network blips.
1535
const (
16-
defaultMaxConsecutiveErrors = 5
36+
defaultMaxConsecutiveErrors = 10
1737
defaultInitialBackoff = 200 * time.Millisecond
18-
defaultMaxBackoff = 5 * time.Second
38+
defaultMaxBackoff = 15 * time.Second
1939
)
2040

2141
type Consumer interface {

0 commit comments

Comments
 (0)