Commit d55d1dd
fix(redis-worker): jittered reconnect backoff for mollifier buffer client
The buffer client's ioredis retryStrategy used a fixed Math.min(times*50, 1000) schedule with no jitter, so a fleet of webapp instances reconnecting after the same Redis blip retried in lockstep and stampeded Redis on recovery (thundering herd) — the same lockstep-load pattern the mutate-fallback wait loop was changed to avoid.
Extract mollifierReconnectDelayMs(times, random) and apply equal jitter: a uniform pick in [base/2, base]. Bounded by the original 1s cap, so it is never slower than before, just decorrelated. Pure unit tests pin the band, the cap, and that draws spread.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8bfa741 commit d55d1dd
3 files changed
Lines changed: 66 additions & 4 deletions
File tree
- .changeset
- packages/redis-worker/src/mollifier
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
6 | 51 | | |
7 | 52 | | |
8 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
21 | 39 | | |
22 | 40 | | |
23 | 41 | | |
| |||
95 | 113 | | |
96 | 114 | | |
97 | 115 | | |
98 | | - | |
99 | | - | |
| 116 | + | |
100 | 117 | | |
101 | 118 | | |
102 | 119 | | |
| |||
0 commit comments