Procházet zdrojové kódy

docs: the prod OOM was TWO failures, discriminated by whether boot reached READY

Phase 1 (Oct 17-18): 48 kills, 48 READYs, each cycle serving exactly
3600 s then dying on the snapshot timer - so the outage was ~13-15 s per
hour, not the ~40 s read off the restart spacing.

Phase 2 (Oct 19 10:52+): 120 kills, ZERO READYs - recovery itself did not
fit, dying before the listener and therefore before the snapshot thread
allocates. That refutes blaming the loop on the WAL-triggered
post-recovery snapshot, which demonstrably runs 5 s AFTER READY.

Records that the snapshots directory mtime cannot discriminate between
'no snapshot attempted' and 'buffers built then killed before the write',
and that preventing a state is not the same guarantee as surviving it.
fszontagh před 1 měsícem
rodič
revize
48b96a1a01
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6 1
      CLAUDE.md

+ 6 - 1
CLAUDE.md

@@ -232,7 +232,12 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   1. **The hourly seal snapshot's anonymous peak outgrew the box.** The serialised snapshot is ~370-399 MB now, and the path is working set + one serialised copy + a compressed copy + a verify read-back, so the peak tracks STORE SIZE. Doc count went 33,321 (early October) to 56,590 (Oct 16) to 65,021 (Oct 19).
   2. **Every hourly snapshot was therefore killed.** systemd `oom-kill` results run hourly from 2026-10-17 00:37, 48 of them across Oct 17-18 - exactly 24 a day, at :37/:38.
   3. **A snapshot that never completes never truncates the WAL**, so it grew to 139 MB (a rotated 105 MB file plus a 34 MB current).
-  4. **Recovery cost scales with the WAL, so each boot was dearer than the last.** On 2026-10-19 it crossed the point where BOOT did not fit: the restart counter went 69 at 08:51, 70 at 09:51, 71 at 10:51 - hourly - and then 72 and 73 inside 10:52, continuous. Boot died ~3 s after "Re-mirrored 12045 document(s) to LMDB after WAL replay", at `anon-rss:1513544kB`.
+  4. **Recovery cost scales with the WAL, so each boot was dearer than the last.** On 2026-10-19 it crossed the point where RECOVERY did not fit: the restart counter went 69 at 08:51, 70 at 09:51, 71 at 10:51 - hourly - and then 72 and 73 inside 10:52, continuous. Boot died ~3 s after "Re-mirrored 12045 document(s) to LMDB after WAL replay", at `anon-rss:1513544kB`.
+  **IT WAS TWO DISTINCT FAILURES WITH DIFFERENT CAUSES, AND COLLAPSING THEM POINTS THE FIX AT THE WRONG PLACE. THE DISCRIMINATOR IS WHETHER THE BOOT REACHED `Notified systemd: READY`.**
+  - **Phase 1, Oct 17 00:37 to Oct 19 ~10:51 - the SNAPSHOT did not fit.** 48 kills and **48 READYs** across Oct 17-18: each cycle came up, served for exactly 3600 s, and died on the snapshot timer. READY at 00:37:48, killed at 01:37:48, READY again 13 s later. So the user-visible cost was **~13-15 s of downtime per hour**, not the ~40 s first estimated from the restart spacing - the spacing is the interval, the outage is only the recovery inside it.
+  - **Phase 2, from 10:52 on 2026-10-19 - RECOVERY did not fit.** 120 kills and **ZERO READYs**. Every cycle died in the init window after the WAL replay and re-mirror and before "Database service initialized successfully", so it was dead before the listener opened and therefore before the snapshot thread allocates anything.
+  **That ordering refutes the natural reading that the loop was the post-recovery snapshot failing** - which is a real mechanism, just not this one. `shouldSnapshot()` does fire immediately when the WAL is over `max_wal_size_mb` (100), and it fired on the recovery boot: service READY 11:39:16, "Created snapshot at sequence 406829" at 11:39:21, five seconds later and at the sequence recovery ended on, so no writes had intervened. But it runs AFTER READY, and phase 2 never got there. **Note the snapshots directory does NOT discriminate here and must not be used to:** its mtime sat at Oct 16 14:35 through all 120 cycles, which is equally consistent with "no snapshot attempted" and with "the writer builds its buffers in memory and died before writing". Execution progress discriminates; on-disk absence does not.
+  **The consequence for a fix: streaming the snapshot writer prevents phase 1 and therefore prevents the WAL ever reaching the size that causes phase 2 - but it does not make phase 2 survivable.** An operator who meets a 139 MB WAL after some unrelated crash is back in the unsurvivable case. Prevention and survivability are different guarantees and it is worth saying which one is on offer.
   Last snapshot before the gap: Oct 16 14:35, sequence 337213. Next: Oct 19 11:39, sequence 406829, after the fix. **~69 hours with none.**
   **FIXED BY ADDING SWAP, which is a floor under the symptom and not a cure.** 4 GB `/swapfile` plus an `/etc/fstab` line so it survives a reboot (`/etc/fstab` is owned by no package - `dpkg -S` first, per the conffile trap above; backed up to `/etc/fstab.bak-20261019`). Boot then peaked at ~1514 MB RSS **and 818 MB of swap**, settling at 847 MB in use, so the anonymous demand is well ABOVE the 1973 MB box rather than marginally over it. The snapshot peak still scales with the store, and swapping a 400 MB serialise is slow; the structural fix is the database's.
   **THE KILL POINT IS A LOWER BOUND ON THE REQUIREMENT, NEVER THE REQUIREMENT.** Without swap the process died at 1.51 GB anon, and it is tempting to size against that. The kernel STOPPED it there - it never revealed its own peak. Only once swap gave it room did the real figure appear, and it was ~2.3 GB of anonymous demand. Sizing against an OOM kill point under-provisions by however much the process still had left to allocate, which is unknowable from the kill.