@kedem/okdb 3.1.9 → 3.1.10

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,49 @@ 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.10] - 2026-11-06
8
+
9
+ ### Fixed
10
+
11
+ - **Idle processes sharing an env no longer write ~45 fsynced commits a second per env.** A process that did not hold a
12
+ processor's lease (another process was draining it) kept its own cursor where it last stopped, so every comparison with the
13
+ env head looked like backlog: it retried the lease every hold window (~200 ms) and wrote a want marker, an fsynced commit,
14
+ on every refusal, forever. store-oasis on 3.1.8, two workers, three idle stores: ~45 commits/s on every store regardless of
15
+ its size, ~280 GB/day of disk writes (reproduced: 196 MB/min). A refused lease now first catches the cursor up to the
16
+ holder's durable one; the want marker is written only under real backlog, at most once per half want window, and with no
17
+ backlog the retry takes the slow cadence. Same setup: 11 MB/min, the machine's background.
18
+ - **A process's lease heartbeats are one commit.** Every processor lease renewed itself in its own fsynced commit (an env with 6
19
+ processors: 0.6 commits/s per process); when one is due, all of the lock's leases are renewed in one transaction.
20
+ - **An idle store makes no disk commits at all.** Lease heartbeats and process-registry keepalives move to shared memory: a
21
+ lease row records ownership only (written on acquire / release / takeover) and its heartbeat is an atomic store in a new
22
+ per-env segment (`<env segment>_lease`); a registry row is written at start / stop / real state change and kept alive in a
23
+ per-root segment (`<root segment>_live`). Two idle processes with an async view and an FTS index: 0 commits and 0 flushes in
24
+ 60 s (3.1.9: one heartbeat commit per env per ~10 s per process, plus a registry row per keepalive). The cross-process
25
+ contract is unchanged: a dead holder is replaced at once, a stopped one after its TTL (the holder notices the loss when it
26
+ resumes); `lock.list()` / `inspect()` and the admin views show `updatedAt` / `heartbeatAt` advancing and the real `ttlMs`.
27
+ 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
28
+ 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
29
+ `/dev/shm` with this process (containers), every process goes back to 3.1.9's disk heartbeats and returns when that peer is
30
+ 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
31
+ 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
32
+ beating through a compaction drain (the shm beat is an atomic store; nothing is read or written). `OKDB_SHM_LIVENESS=off`
33
+ keeps the disk heartbeats. A wait for a lease held through shared memory is a slot stamp, not a `~lock:want` row (a holder
34
+ still reads both). `okdb shm-gc` sweeps leftover `_lease` / `_live` segments of crashed stores.
35
+ - **A process that lost an FTS index's lease no longer rewinds its cursor.** The FTS drain stages its output and persists the
36
+ cursor when it commits; a process that lost the lease kept its stage and committed it later (`fts.flush()`, a search, close),
37
+ persisting its old cursor over the one the new holder had advanced. The durable cursor then stayed behind the head: the other
38
+ process saw a backlog that never drained and re-contended for the lease on every wait-retry, forever (and the next holder
39
+ re-indexed the range). A stage that a peer has drained past is now dropped whole: its ops are not written either (they could
40
+ overwrite the postings the peer wrote from newer values of the same docs).
41
+ - **An encrypted env no longer serves stale pages from its decrypted-page cache.** LMDB keeps decrypted 16-page chunks per
42
+ process and trusted a cached page while any transaction still referenced its chunk. With overlapping transactions (a stepped
43
+ compaction's pinned snapshots, or any chain of overlapping readers), a page that was freed and rewritten by a later commit,
44
+ in this process or another, was returned to newer transactions as its old content. Readers saw an inconsistent tree (a
45
+ compaction aborted on `IS_LEAF(mp)` in `mdb_cursor_next`, a doc read back as missing, `MDB_NOTFOUND`), and a write
46
+ transaction could build on stale pages. An upstream lmdb-js bug in the vendored LMDB; `tests/multiprocess/rekey-interop` hit it in ~15% of
47
+ runs. A cached page is now reused only while its page number and txnid still match the file's, and a page this process
48
+ writes drops its cached copy. Unencrypted envs were not affected.
49
+
7
50
  ## [3.1.9] - 2026-11-06
8
51
 
9
52
  ### Fixed