1
2
3
4
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# handoff 2026-08-06 — consumer-flap OOM: root cause fixed and verified
for the operator, re: the canary OOMKill at 14:20:16Z (ops-changelog
2026-08-06). the working theory in that entry was right. reproduced
locally, fixed on main, verified empirically.
## root cause (two compounding defects, serving side)
1. **uncapped replay materialization.** a consumer connect to
`subscribeRepos` with a cursor triggered `Broadcaster.replayTo` →
`DiskPersist.playback`, which read the **entire retained backlog from
cursor to head into memory in one shot** — every log file, no bound.
with 72h retention that is an O(gigabytes) allocation per connect.
2. **replay continued for dead consumers.** `Consumer.enqueue` never
checked `alive`, and an abrupt disconnect (RST) is only noticed when a
write fails. so a consumer that connected and died kept its replay
running, buffering up to 65,536 duplicated frames to a corpse.
a flapping consumer at a ~3.2s period stacks those replays faster than
they finish — that is the ~500 MiB/cycle compounding you measured, and
why every slow-consumer/queue protection saw nothing: the allocation is
upstream of the depth-bounded broadcast queue, on the connect path.
## reproduction (local, real binary, real disk replay)
branch `repro/consumer-flap-oom` carries the harness: a `seed` build
target that writes a synthetic event-log backlog through the real
`DiskPersist`, plus a flapper that does a raw websocket handshake with
`cursor=1` and RST-kills the socket every ~0.5s.
against a 622 MiB backlog (400k frames), before the fix:
- 1 flapper: RSS 43 MiB → ~1.3 GiB
- 4 flappers, 100 connects total: RSS → 5 GiB in 15s (~250–300 MiB/s,
the canary's burst rate), climbing to **13.8 GiB after all clients had
disconnected** — queued replays serving dead sockets finished the job.
65 zombie consumers were still registered minutes later.
## the fix (on main)
`fix: bound disk replay per chunk and abort for dead consumers`
- `playback()` takes `PlaybackLimits`; `replayTo` streams the backlog in
chunks of ≤4096 entries / ≤16 MiB, resuming by cursor between chunks.
peak transient allocation per connect is now ~16 MiB regardless of how
old the cursor is.
- `Consumer.enqueue` refuses frames once `alive` is false, so a dead
consumer's replay aborts at the next chunk instead of running to
completion against a corpse.
- regression tests: playback limit/resume semantics, and enqueue-refuses-
dead-consumer. full suite passes.
verified with the same harness: the identical 100-connect flap storm now
peaks at **174 MiB** RSS (baseline 43 MiB) and returns to baseline; a
healthy consumer still receives the complete 399,999-frame replay
(cursor is exclusive), RSS flat throughout.
## for deploy
- normal flow: `just zlay publish-remote ReleaseSafe <ref> zio` with a
ref at or past the fix commit on main.
- expected signals: `replay aborted after N frames (consumer dead or
buffer full)` warnings are the fix working; RSS should stay in the
certified 1.35–1.47 GiB band through consumer flap events.
- to stress it in anger, the repro branch's flapper can be pointed at the
canary from any box (it is a few hundred MB of localhost-style traffic
per full replay — do not run the seed/flap loop from a residential
connection against prod with a very old cursor).
## still open (engineer side, not blocking)
- connect/disconnect logs still carry no remote address or requested
cursor — the observability gap from your entry. worth fixing so the
next flapper is identifiable.
- one caveat: your log line for the flapper showed no cursor param
captured either way; a cursor-bearing request is the only path that
reaches disk replay. the repro matches the burst rate and self-recovery
shape exactly, but if a cursor-less flapper reproduces a burst on the
canary again, reopen — that would be a second mechanism.