Ver Fonte

docs: the 2.17.x migration OOM-kills at 900 MiB, and the ABI holds

Three measurements taken before tonight's window, on the artifact prod
installs rather than an upstream image.

The migration peaks near 1.1 GB on a copy of TODAY's prod data and is
OOM-killed under a 900 MiB cap. The same run on 2.17.1 dies identically, so
it is the dataset and not the version: Friday's copy held 24733 rows and
peaked at 364 MiB anonymous, today's holds 33321 and peaks at 1092 MiB.
Prod is 1973 MB with no swap. I would have carried Friday's comfortable
number into the window had I not re-measured for the version I am deploying.
An OOM is recoverable - the migration re-runs at the next boot and skips
completed work - so the failure mode is a longer outage, not lost
credentials.

The second restart is unnecessary on 2.17.2, measured: our bootstraps do
perform the online upgrade, with 0 rows and 0 history versions rewritten
because the collections are already ciphertext via the alias merge, and
verify then reports sealed yes, CLEAN, exit 0. Two steps and one compaction,
with verify as the branch rather than a third step taken on faith.

And the ABI holds. Every 2.x client shares one soname, so apt puts a 2.17.2
library under a binary compiled against 2.14.0 headers, whose documented
failure mode is installing fine and segfaulting later. A Debian 13 container
with the real 0.12.0 deb and the 2.17.2 client answered 21 of 21 calls,
including the unique-index path that exercises CreateIndexResult - the
by-value struct whose size would be the thing to break - and a 409 duplicate
refusal proving duplicateExamples crossed intact.

Also recorded: prod binds localhost, and the upstream "plaintext removed at
the next restart" line fires even when nothing was rewritten.
fszontagh há 1 mês atrás
pai
commit
9d4fb75d4a
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      CLAUDE.md

+ 6 - 0
CLAUDE.md

@@ -160,6 +160,12 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **DB v2.3.1: `dropProject` does not physically purge collection data.** A recycled project name is otherwise blocked by stale collections/registry → the project-delete handler drops the registry + collections first, and collection-create drops invisible orphans (after the registry "exists" check).
 - **WE strip `id` from a document body, not the database client.** This note used to say the client did it, and that is measured as false on client 2.12.1: inserting `{"id":"body-id-value"}` with an explicit document id stores the body field verbatim and it reads back alongside the real `_id` metadata. The stripping is ours, in `documentBody()` (`documents_util.hpp`), which erases `id` and then calls `stripDbMetadata()` to drop the six reserved keys. Keep doing it: the database stores a reserved key as an ordinary user field while every read overwrites it with the real metadata, so a body carrying `_version` would put an invisible shadow copy on disk that no read ever shows and no filter can reach. Our layer is what keeps stored documents clean (the database is fixing this server-side in 2.13.0, for every other client). API keys store their stable id as `key_id` in the body (exposed as `id` externally) - that predates this and the stored rows are not worth migrating, but it was never forced by the client.
 - **Debian 13 (trixie) gRPC cmake config is broken** unless `protobuf-compiler-grpc` + `libgrpc++-dev` + `libprotobuf-dev` are installed - `find_package(gRPC CONFIG)` (used transitively by `smartbotic-db-clientConfig.cmake`) fails on a `gRPCTargets.cmake` referencing missing plugin files. The Docker base installs them.
+- **THE 2.17.x MIGRATION'S MEMORY PEAK SCALES WITH THE DATASET, AND IT OOM-KILLS. Measure it against the box you are deploying to, on the data you are deploying over.** Measured on 2.17.2 with the PUBLISHED debs in a Debian 13 container (not an upstream image - prod installs the deb), prod's own config, over a copy of prod's data directory: **204 s, cgroup `memory.peak` 1092 MiB, process `VmHWM` 1212 MiB**, ending `CLEAN` / `sealed: yes`. Under a **900 MiB cap it was OOM-KILLED** during compaction. Prod is **1973 MB with NO SWAP**, and the running database holds ~757 MB RSS which is freed when it restarts, so the margin is real but not generous.
+  **The same run on 2.17.1 OOM-kills identically, so this is NOT a version regression - it is the DATA.** Friday's copy held 24733 rows and peaked at 364 MiB anonymous; today's held 33321 rows, 35% more, and peaks near 1.1 GB. **A migration memory figure is therefore a measurement of one corpus on one day, exactly like a search baseline**, and the earlier comfortable number would have been carried straight into a window had the second run not been made. An OOM is RECOVERABLE - the migration re-runs at the next boot and skips completed work - so the failure mode is a longer outage rather than lost credentials, which is worth telling consumers when asking for the window.
+- **A SECOND RESTART IS NOT NEEDED ON 2.17.2, measured rather than reasoned.** Our `KeyStore`/`SettingsStore` bootstraps DO perform the online upgrade after the migration, and the log says so - but with **0 rows and 0 history versions rewritten**, because the collections are already ciphertext through the bare-alias merge. `encryption-verify` then reports `sealed: yes`, `CLEAN`, exit 0. So the window is TWO steps and ONE compaction (upgrade, then start vectorapi), with verify as the branch: plain `CLEAN` means done, `CLEAN (UNSEALED: ...)` means take the reseal inside the window. On 2.17.1 that same flag move requested a reseal that compacted every project, which is where the obsolete three-step plan came from.
+  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.
 - **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.
 - **`--rebuild-base` is required when `DB_CLIENT_VERSION` moves.** The client version is baked into the Docker BASE image, so bumping the variable alone leaves the release build compiling against the old headers - it fails on the new entry points, or worse, silently links the old ones. Note `devstack/run-tests.sh` installs the client debs explicitly, so the TEST path can be on a newer client than the RELEASE path: a green suite is not evidence about the packages.
 - **`systemctl start` on an already-running unit is a no-op.** A package postinst starts the service, so any config written AFTER apt needs a `restart`, not a `start` - otherwise the process keeps the config that existed at install time and the file on disk disagrees with the running state. Compare the file mtime against `systemctl show -p ActiveEnterTimestamp` when a setting appears not to apply.