Parcourir la source

docs: the at-rest migration's real cost, the reseal restart, the prune's global lock

Measured by both consumers on 2.17.0/2.17.1: the duration tracks the largest
LMDB env's compaction (history is rewritten only where a value changes), the
memory to plan with is anonymous memory (RSS includes the reclaimable LMDB
map), the restart after an online encryption upgrade compacts every project
again, and the maxVersions prune holds the global collection lock. ROADMAP:
prune outside the global lock; compact only what a reseal touched.
fszontagh il y a 1 mois
Parent
commit
10313b555f
2 fichiers modifiés avec 30 ajouts et 5 suppressions
  1. 10 0
      docs/ROADMAP.md
  2. 20 5
      docs/integration-guide.md

+ 10 - 0
docs/ROADMAP.md

@@ -372,6 +372,16 @@ joins; see 5c), which does not fit in 10 s. Run the container with
   encrypted). See CLAUDE.md v2.17.0. What a database cannot fix: copies made
   before the upgrade (backups, `pre-upgrade-*`, nightly backup archives)
   still hold the plaintext.
+- **Prune under the global lock (2.17.1):** `createCollection(existing, lower
+  maxVersions)` prunes history while holding MemoryStore's global collection
+  lock and the history append lock, so every collection waits for it. Move the
+  file rewrite outside the global lock (the prune needs only the append lock,
+  and a streamed rewrite like `HistoryStore::rewrite`'s rather than per-doc
+  buckets of the whole file).
+- **Reseal compaction cost:** a boot after an online encryption upgrade
+  compacts EVERY project, including ones the upgrade never touched (a 262 MB
+  test env took 2.5 minutes and reclaimed nothing). Compact only the projects
+  whose collections were rewritten, or skip an env whose free pages are few.
 - Collection schemas cannot be declared in a migration file yet (the
   existing-row check lives in the SetCollectionSchema handler).
 - ~~**Bogus index declarations on a production instance (found 2026-10-09, predates 2.14.0):**~~ removed

+ 20 - 5
docs/integration-guide.md

@@ -1012,8 +1012,18 @@ backups or copies taken before the upgrade.
 - **No double encryption:** a value already carrying `$ENC$`/`$ENCJ$` is never
   encrypted again, so the pass is idempotent.
 - **Boot time:** it is logged (`v2.17 at-rest`) and extends the systemd start
-  timeout as it goes. On a copy of a production dataset (22,298 rows, 626 MB) it
-  took about 6.5 minutes; the compaction shrank that file to 35 MB.
+  timeout as it goes. What it costs: a scan of every row and every history file
+  (history is REWRITTEN only where a value must change), then compacting every
+  project's LMDB env, which costs about the time to copy the LARGEST
+  `data.mdb`. Measured: 22,298 rows / 626 MB env / a 230 MB history file that
+  needed rewriting took about 6.5 minutes; 24,733 rows / a 339 MB env / 192 MB
+  of history that needed no rewriting took 190 s, of which 167 s was compacting
+  that one env (measured by a consumer, under a 900 MB memory cap).
+- **Memory:** plan with the ANONYMOUS memory (364 MiB in the second run). RSS /
+  VmHWM also count the file-backed LMDB map (1.1 GB in that run, above its cap)
+  which the kernel reclaims under pressure rather than killing anything, so an
+  RSS above 1 GB on a 2 GB host is not by itself a reason to stop it. Since
+  2.17.1 history is rewritten one record at a time.
 - **What it cannot reach:** copies made BEFORE that boot - backups, pre-upgrade
   copies, replicas, released disk blocks. Rotate any credential that was stored
   in plaintext.
@@ -1022,7 +1032,10 @@ backups or copies taken before the upgrade.
 ..., encrypted=true)` on an existing collection now switches it on (never off),
 and `sensitive_fields` given that way are added. Its rows and history are
 encrypted immediately. The old plaintext copies are removed at the next
-restart: `encryption-verify` reports `sealed: NO` until then.
+restart: `encryption-verify` reports `sealed: NO` until then. **That next
+restart compacts every project again** (the same cost as the migration's seal:
+about the time to copy the largest `data.mdb`), so plan it as a window, not as
+an ordinary 15-second restart. Later restarts are ordinary.
 
 **Check the flag rather than assume it.** A bootstrap that calls
 `createCollection(..., encrypted=true)` only when the collection does not exist
@@ -1273,8 +1286,10 @@ Semantics:
 **Trimming history that already exists (2.17.1+).** `createCollection(name, ...,
 maxVersions=N)` on an EXISTING collection with a cap lower than before (or any
 cap over unlimited) rewrites its history file keeping the newest N versions per
-document. It runs inside the call, so a large file takes seconds; do it at a
-quiet moment. Before 2.17.1 the call changed the setting and trimmed nothing,
+document. ⚠ It runs inside the call while holding the store's global collection
+lock and the global history lock, so EVERY collection's operations wait until
+it finishes (seconds or more for a large file): run it at a quiet moment, one
+collection at a time, never in a loop under live traffic. Before 2.17.1 the call changed the setting and trimmed nothing,
 and no supported call could cut back history kept with `maxVersions = 0`.
 
 #### Relation enforcement on/off (2.11.0+)