@kedem/okdb 3.1.9 → 3.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,64 @@ All notable changes to `@kedem/okdb` are documented here. Format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.0.0/); versions follow [SemVer](https://semver.org/).
5
5
  Dates are release dates.
6
6
 
7
+ ## [3.1.11] - 2026-11-06
8
+
9
+ ### Fixed
10
+
11
+ - **Upgrading a large 2.x store no longer takes hours.** The one-time 3.1 storage migration `per-env-blobs` counted each
12
+ stored file's references with a full scan of the env's file records (the field has no index) and committed per file: time
13
+ grew with the square of the file count. A store with 109,570 files was projected at ~7 h, during which the app could not
14
+ start. It now scans each env's file records once and writes the counts in batches: 20,000 files in ~6 s (3.1.10: 608 s).
15
+ - **An interrupted migration no longer blocks every retry in a restarted container.** The migration lock recorded only the
16
+ migrator's pid, and a waiter took over only if that pid was not running; in a new container the dead migrator's low pid
17
+ is routinely a live process of the new one, so each open waited out `MIGRATION_LOCK_TIMEOUT` (2 min) and failed. The lock
18
+ is now a `flock` on `<root>/.okdb-migration.lock`, which the kernel releases when its holder dies (any pid namespace;
19
+ containers sharing a volume on one host). A lock row left by 3.1.10 is taken over if its pid is not running, belongs to
20
+ a process that started after the row was written, or the row is older than a day.
21
+
22
+ ## [3.1.10] - 2026-11-06
23
+
24
+ ### Fixed
25
+
26
+ - **Idle processes sharing an env no longer write ~45 fsynced commits a second per env.** A process that did not hold a
27
+ processor's lease (another process was draining it) kept its own cursor where it last stopped, so every comparison with the
28
+ env head looked like backlog: it retried the lease every hold window (~200 ms) and wrote a want marker, an fsynced commit,
29
+ on every refusal, forever. store-oasis on 3.1.8, two workers, three idle stores: ~45 commits/s on every store regardless of
30
+ its size, ~280 GB/day of disk writes (reproduced: 196 MB/min). A refused lease now first catches the cursor up to the
31
+ holder's durable one; the want marker is written only under real backlog, at most once per half want window, and with no
32
+ backlog the retry takes the slow cadence. Same setup: 11 MB/min, the machine's background.
33
+ - **A process's lease heartbeats are one commit.** Every processor lease renewed itself in its own fsynced commit (an env with 6
34
+ processors: 0.6 commits/s per process); when one is due, all of the lock's leases are renewed in one transaction.
35
+ - **An idle store makes no disk commits at all.** Lease heartbeats and process-registry keepalives move to shared memory: a
36
+ lease row records ownership only (written on acquire / release / takeover) and its heartbeat is an atomic store in a new
37
+ per-env segment (`<env segment>_lease`); a registry row is written at start / stop / real state change and kept alive in a
38
+ per-root segment (`<root segment>_live`). Two idle processes with an async view and an FTS index: 0 commits and 0 flushes in
39
+ 60 s (3.1.9: one heartbeat commit per env per ~10 s per process, plus a registry row per keepalive). The cross-process
40
+ contract is unchanged: a dead holder is replaced at once, a stopped one after its TTL (the holder notices the loss when it
41
+ resumes); `lock.list()` / `inspect()` and the admin views show `updatedAt` / `heartbeatAt` advancing and the real `ttlMs`.
42
+ A shm-heartbeat row carries `live:"shm"`, `shmId`, `bootId` and its real TTL as `leaseTtlMs`; its `ttlMs` is 24 h so a 3.1.9
43
+ reader never sees it stale (it still steals at once from a dead pid). While any live peer is okdb 3.1.9 or does not share
44
+ `/dev/shm` with this process (containers), every process goes back to 3.1.9's disk heartbeats and returns when that peer is
45
+ gone (per store root, OR-ed: a process with one mixed store beats all its stores on disk). A row written before a reboot is
46
+ dead at once; a registry row whose pid was reused (no live slot carries that pid and start time) is dead too. A lease keeps
47
+ beating through a compaction drain (the shm beat is an atomic store; nothing is read or written). `OKDB_SHM_LIVENESS=off`
48
+ keeps the disk heartbeats. A wait for a lease held through shared memory is a slot stamp, not a `~lock:want` row (a holder
49
+ still reads both). `okdb shm-gc` sweeps leftover `_lease` / `_live` segments of crashed stores.
50
+ - **A process that lost an FTS index's lease no longer rewinds its cursor.** The FTS drain stages its output and persists the
51
+ cursor when it commits; a process that lost the lease kept its stage and committed it later (`fts.flush()`, a search, close),
52
+ persisting its old cursor over the one the new holder had advanced. The durable cursor then stayed behind the head: the other
53
+ process saw a backlog that never drained and re-contended for the lease on every wait-retry, forever (and the next holder
54
+ re-indexed the range). A stage that a peer has drained past is now dropped whole: its ops are not written either (they could
55
+ overwrite the postings the peer wrote from newer values of the same docs).
56
+ - **An encrypted env no longer serves stale pages from its decrypted-page cache.** LMDB keeps decrypted 16-page chunks per
57
+ process and trusted a cached page while any transaction still referenced its chunk. With overlapping transactions (a stepped
58
+ compaction's pinned snapshots, or any chain of overlapping readers), a page that was freed and rewritten by a later commit,
59
+ in this process or another, was returned to newer transactions as its old content. Readers saw an inconsistent tree (a
60
+ compaction aborted on `IS_LEAF(mp)` in `mdb_cursor_next`, a doc read back as missing, `MDB_NOTFOUND`), and a write
61
+ transaction could build on stale pages. An upstream lmdb-js bug in the vendored LMDB; `tests/multiprocess/rekey-interop` hit it in ~15% of
62
+ runs. A cached page is now reused only while its page number and txnid still match the file's, and a page this process
63
+ writes drops its cached copy. Unencrypted envs were not affected.
64
+
7
65
  ## [3.1.9] - 2026-11-06
8
66
 
9
67
  ### Fixed