Quellcode durchsuchen

docs: prod on swap costs no measurable latency, and no data was lost

vmstat si=0/so=0 after recovery, so the 866 MB in swap is the cold boot
transient rather than thrashed working set. A pure DB read answers in
3-10 ms, which is the control that rules out a hidden paging cost; the one
8.17 s vector search was the cold provider, proven by the same query_text
repeating in 0.24 s.

Data continuity proven by sequence arithmetic rather than doc counts:
337213 + 69616 = 406829, so the WAL replay began exactly where the last
good snapshot ended across the whole 69-hour drought. Counts match under
several wrong outcomes; the sequence identity does not.
fszontagh vor 1 Monat
Ursprung
Commit
73ec7ab5cb
1 geänderte Dateien mit 2 neuen und 0 gelöschten Zeilen
  1. 2 0
      CLAUDE.md

+ 2 - 0
CLAUDE.md

@@ -242,6 +242,8 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   **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.
   **WHY NOBODY SAW IT, AND THIS IS THE GENERALISABLE PART: A CRASH THAT RESTARTS CLEANLY IS A SILENT CRASH.** systemd brought it back each hour, so the observable was a ~40 s outage once an hour inside consumers' retry budgets - and the database logs it only as `status=9/KILL`, with no line saying a snapshot FAILED. Worse, the run log lives in the database, so during each kill it goes QUIET rather than recording failures: the absence-is-not-information trap this file already records, now in its most expensive form. A consumer reported it only on the day it became permanent. **So "the service is up" and "the service has not been failing" are different claims, and `NRestarts` is the cheap way to tell them apart** - 183 here, which was visible all along and which nobody read. Check it when closing any window, next to `apt-mark showhold`; it is the same class of signal as the `ii`/`hi` column this file has now been read past twice.
+  **RUNNING PROD ON SWAP COSTS NOTHING MEASURABLE HERE, AND THAT IS A MEASUREMENT RATHER THAN A HOPE - BECAUSE THE SWAPPED PAGES ARE THE BOOT TRANSIENT AND ARE COLD.** The obvious worry after the fix is that a database holding 866 MB in swap now serves every read through paging. Measured after recovery: `vmstat` shows **si=0, so=0** - no page-in or page-out activity at all, so the swapped pages are the init-time peak sitting cold, not working set being thrashed. A pure DB read through our API (`/documents?limit=5`, no embedding in the path) answers in **3-10 ms**. The one slow number, an 8.17 s vector search, was NOT swap: the same `query_text` repeated answered in **0.267 s and 0.242 s**, which is the provider caching identical text exactly as recorded above, so the 8 s was the cold provider round trip in its known bad tail. **The pure DB read is the control that makes this conclusive** - it removes the provider from the path entirely, and at 3 ms it cannot be hiding a paging cost. Without it, a fast repeat would have been equally consistent with "swap is fine" and "the provider cached it while swap is still slow".
+  **No data was lost, and the arithmetic is the proof rather than the doc counts.** The last good snapshot ended at sequence 337213; recovery logged "Replayed 69616 WAL entries from sequence 337213" and "Persistence manager started, WAL sequence: 406829", and 337213 + 69616 = 406829 exactly - the WAL began precisely where the snapshot ended, with no gap and no overlap, across the whole ~69-hour snapshot drought. "Recovery complete (TrivialSuccess): 65030 docs in 73 collections", and a document body read back intact from all four live tenants. A COUNT would not have shown this: counts match under several wrong outcomes, whereas the sequence identity can only hold if every write in the gap was replayed.
   **GREPPING AN OOM LINE FOR A SERVICE NAME MISREADS IT, AND THE MISREADING IS THE FLATTERING ONE FOR WHOEVER IS GREPPING. `cpuset=` NAMES THE CGROUP THAT TRIGGERED THE ALLOCATION; `task=` AND `task_memcg=` NAME THE VICTIM.** Five kernel lines on 2026-10-19 read `cpuset=smartbotic-vectorapi.service ... task_memcg=/system.slice/smartbotic-database.service, task=smartbotic-data`, so a grep for our own service name matched them and they look exactly like vectorapi being OOM-killed. It never was: ours asked for memory, that request tripped the GLOBAL OOM killer, and the kernel chose the database as the victim because it was the largest. `NRestarts=0` on all three of our units is the control, against 183 on the database from the same command. Under global memory pressure the process that triggers a kill and the process that dies are routinely different, which also means **a service can be a repeated CAUSE of another service's death while its own logs stay perfectly clean** - worth knowing before taking "my service shows nothing wrong" as exculpatory. Read `task=`.
   **vectorapi itself came through untouched**, up since 2026-10-15 15:56 (the supervised restart after the client library moved) and the runner since 2026-10-13, and it answered **1664 requests with 503** during the permanent phase - correctly classified, naming the real condition, which is the error-slug work doing its job under the one condition nobody arranges deliberately.
   **The pre-flight rule that follows: a headroom measurement needs a RE-MEASUREMENT TRIGGER, not just a date.** "The snapshot survives hourly" was true, dated, and silently became false through ordinary growth - no deploy, no config change, nothing to review. Tie it to a quantity that moves: snapshot file size against free memory, or doc count against the figure the headroom was measured at. A dated measurement with no trigger is a claim that will be believed long after it stops being true, which is precisely the failure this file's maintenance rule exists to prevent - and here the stale claim was MINE, in this file, and it read as reassuring right up to the outage.