Commit b264229
committed
feat(redis): add reconnectOnError for READONLY / LOADING reply errors
Empirical proof from the redis-failover-harness (TRI-8878) shows
ElastiCache vertical scale-up events surface as Redis-level reply
errors (READONLY when the role swap happens under an open connection,
LOADING when a node is still initializing) rather than connection-level
errors. Without intervention these errors propagate directly to caller
code at the rate of tens of thousands per minute over a multi-minute
window.
Returning 2 from reconnectOnError tells ioredis to tear down the
connection, reconnect, and re-issue the failed command. After
reconnect, DNS / SG state routes the new socket to a writable node and
the workload resumes.
Harness measurements:
- Without this option: ~437,000 caller-surfaced errors over 4 min of
zero-write throughput per task during cache.t4g.medium -> m7g.large.
- With this option (same workload, m7g.large -> m7g.xlarge): 2 total
caller-surfaced errors across both tasks; throughput uninterrupted.
Reduction: ~218,000x.
Scope: only the shared createRedisClient helper in @internal/redis.
Direct 'new Redis()' callsites in apps/webapp/ still need migration;
defaultReconnectOnError is exported so they can opt in inline as a
follow-up.
Refs TRI-8868 TRI-8878.1 parent 6cdd881 commit b264229
2 files changed
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
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 | + | |
6 | 25 | | |
7 | 26 | | |
8 | 27 | | |
9 | 28 | | |
10 | 29 | | |
11 | 30 | | |
| 31 | + | |
12 | 32 | | |
13 | 33 | | |
14 | 34 | | |
| |||
0 commit comments