Explorar el Código

docs: policy-rc.d does not hold the database package, so a promised hold point did not exist

Measured the hard way during the 2.17.2 prod window. A policy-rc.d returning
101 was in place, the pinned install ran, and the service restarted anyway -
the first-boot migration completed before the install command returned.
policy-rc.d blocks invoke-rc.d, and that postinst calls systemctl directly.

That cost two separate things, not one. One consumer lost the chance to say
"wait, a call is live" that they had explicitly been offered. And because the
install itself triggered the migration, the outage happened at 18:21 rather
than in the 18:30 slot all three consumers had approved - nine minutes early,
outside the approved window, which is a governance failure distinct from the
missing check. A consumer put that second point in the record; my own account
had blurred it into the first.

The error was verifying the mechanism's PURPOSE instead of its EFFECT.
policy-rc.d is genuinely the standard way to stop a maintainer script
starting a service; it is simply not effective against a script that bypasses
invoke-rc.d. One ActiveEnterTimestamp read before the install, or one grep
for systemctl over the postinst, would have shown it. A control nobody has
seen fire is not a control - so rehearse the pause, not just the migration.
The confirmed procedure is systemctl mask, which refuses the start and is
absorbed by the postinst's || true.

Also recorded, from the consumer who went looking for the damage: a database
outage erases its own evidence from the function run log, because the run log
lives in the database. Zero runs recorded inside the window rather than
failures, so the gap had to be inferred from surrounding cron ticks. Absence
of failures there is not evidence that nothing failed.
fszontagh hace 1 mes
padre
commit
b35bfcc87f
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      CLAUDE.md

+ 4 - 0
CLAUDE.md

@@ -178,6 +178,10 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
   Note the upstream log line still says "old plaintext copies are removed at the next restart" even when it rewrote NOTHING, which contradicts verify's `sealed: yes` and would have an operator restart for no reason. Trust verify.
 - **MOVING THE CLIENT PACKAGE UNDER AN EXISTING BINARY IS AN ABI QUESTION, AND IT IS CHEAP TO TEST.** Every 2.x client shares one SONAME, so apt will happily put a 2.17.2 `libsmartbotic-db-client.so.2` under a server binary compiled against 2.14.0 headers - and the documented failure mode is that it installs fine and segfaults later. Verified before deploying rather than hoped: a Debian 13 container holding the real `smartbotic-vectorapi 0.12.0-1` deb plus `libsmartbotic-db-client 2.17.2-1`, against a 2.17.2 server, answered **21 of 21 calls** correctly - including `POST /indexes` with `unique`, which exercises `CreateIndexResult`, the by-value struct whose SIZE is the thing that would break, and a 409 duplicate refusal, which proves `duplicateExamples` crossed the boundary intact. `/api/v1/version` reported `db_client: 2.17.2` so the new library really was loaded. Repeat this whenever `DB_CLIENT_VERSION` and the deployed client diverge; it takes minutes and the alternative is a restart days later.
 - **Prod's database binds `localhost`, not `0.0.0.0`** (`storage.bind_address`), which is why it is only reachable from vectorapi on the same box - correct, and worth knowing before wondering why a port-mapped copy refuses connections.
+- **`policy-rc.d` DOES NOT HOLD THE DATABASE PACKAGE. It blocks `invoke-rc.d`, and that postinst calls `systemctl` DIRECTLY.** Measured the hard way on 2026-10-12: a `policy-rc.d` returning 101 was in place, the pinned install ran at 18:21:12, and the service restarted anyway - the 2.17.2 first-boot migration ran to completion before the install command had even returned. **A hold point three consumers had been promised simply did not exist**, and that cost TWO separate things, not one. One consumer lost the chance to say "wait, a call is live" that they had explicitly been offered. **And because the install itself triggered the migration, the outage happened at 18:21 rather than in the 18:30 slot all three had approved** - it ran NINE MINUTES EARLY, outside the approved window, which is a governance failure distinct from the missing check. A consumer put that second point in the record; my own account had blurred it into the first, which understated it.
+  **The error was verifying the mechanism's PURPOSE instead of its EFFECT.** `policy-rc.d` genuinely is the standard Debian way to prevent a maintainer script starting a service; it is just not effective against a script that bypasses `invoke-rc.d`. Checking that it is the right tool is not the same as checking that it works here, and one `systemctl show -p ActiveEnterTimestamp` before the install - or one `grep systemctl` over the postinst - would have shown it. **A control nobody has seen fire is not a control.** If a window needs a pause, REHEARSE THE PAUSE, not just the migration: install on a scratch box and confirm the service did NOT start. The consumer's framing is the one to keep - they asked for a pause and then treated it as load-bearing without either of us testing that it pauses.
+  **To actually hold a start for this package: `systemctl mask` the unit for the duration**, confirmed upstream - a masked unit REFUSES the start and the postinst's `|| true` absorbs the failure, so the install completes with nothing running. Then unmask and start deliberately. Upstream is also moving the postinst to `deb-systemd-invoke` so `policy-rc.d` will work too, but that is ROADMAP, not shipped. Whichever route, PROVE it by reading `ActiveEnterTimestamp` before and after the install rather than assuming the hold took.
+- **A DATABASE OUTAGE ERASES ITS OWN EVIDENCE FROM THE FUNCTION RUN LOG, because the run log lives in the database.** Observed by a consumer diagnosing the 50-second window: ZERO recorded function runs inside it, not failures. They had to infer the gap from the surrounding minute-cron ticks (16:21:05, then 16:22:46) rather than read it. So when diagnosing a past outage, the run log goes QUIET rather than showing errors, and absence of failures there is not evidence that nothing failed - the same absence-is-not-information trap as a missing `scan_capped`, one layer out.
 - **THE DATABASE PACKAGES ARE ON APT HOLD, so an upgrade needs `--allow-change-held-packages` or it FAILS.** `apt-mark showhold` lists `smartbotic-database` and `libsmartbotic-db-client`; our three app packages are not held, which is why an ordinary vectorapi release needs nothing special. A pinned install without the flag dies with `E: Held packages were changed and -y was used without --allow-change-held-packages` - caught here by a `--dry-run` a few hours before a window, which is the only reason it was not discovered mid-outage. **Prefer the FLAG over `apt-mark unhold` plus a re-hold:** the hold is per PACKAGE rather than per version, so it survives the upgrade and keeps protecting the new version automatically, whereas the unhold route leaves the database freely upgradable if the re-hold is ever forgotten - a protection silently switched off is worse than an install that refuses.
   **The signal was in plain sight and I walked past it.** `dpkg -l` prints `hi` rather than `ii` for a held package, and that appeared in the very first prod inventory of the day; I read the versions out of that output and ignored the status column. Always `--dry-run` a pinned install before a window and read what it says it will do: this one also confirmed 2 upgraded, 1 newly installed (`smartbotic-db-cli`, which is how `encryption-verify` arrives on prod), 0 removed and nothing held back.
 - **Abseil ABI:** `smartbotic-database`/client debs must be built against the system's current Abseil; a stale build crash-loops on `libabsl_*.so.<old>`. Rebuild the DB if it won't start.