@kedem/okdb 3.1.6 → 3.1.8
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,93 @@ 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.8] - 2026-11-05
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **Compaction no longer blocks the event loop or parks writers for the length of the copy.** 3.0–3.1.7 compacted an env inside one
|
|
12
|
+
call on the owner thread with every writer of the env (in every process) parked until the copy finished: a multi-GB env held a
|
|
13
|
+
process's loop for minutes (store-oasis: its loop watchdog killed the worker 60 s into each auto-compaction, the next worker
|
|
14
|
+
started over, and every attempt left a partial copy on disk for an hour). Compaction is now a job the owner loop steps:
|
|
15
|
+
- the env is copied from a pinned snapshot into a fresh file on a worker thread while writers keep writing (a logical, sorted bulk
|
|
16
|
+
copy: as compact as `mdb_env_copy2` or more, and it goes through the env's cipher, so encrypted envs compact the same way);
|
|
17
|
+
- catch-up rounds on a worker thread re-sync, key by key, only the sub-DBs whose root changed since the last snapshot;
|
|
18
|
+
- writers are parked only for the final round (bounded by `OKDB_COMPACT_MAX_PARK_MS`, default 10 s; past it the round is
|
|
19
|
+
abandoned, the writers resume and it retries) and the swap, whose close grace now ends as soon as no peer holds the env.
|
|
20
|
+
`env.compact()` / `repair()` in JS await the job; `Env::compact` (Rust) runs it to completion. Also:
|
|
21
|
+
- the compaction lease is renewed every step (its 60 s TTL used to lapse mid-copy, letting a second process compact the same env);
|
|
22
|
+
- a synchronous write that meets a drain parks at most `OKDB_SYNC_WRITE_PARK_MS` (default 15 s; 250 ms inside a processor
|
|
23
|
+
quantum) and then fails with the retryable `ENV_DRAINING` (it parked up to 120 s); a write of the compacting process itself
|
|
24
|
+
drives its own compaction to the end instead of waiting on it; the pump skips an env's processors and views while a drain is
|
|
25
|
+
live;
|
|
26
|
+
- automatic compaction records each attempt in `~system` (`~compact_attempts`): one that died with its process, or failed, backs
|
|
27
|
+
the next automatic one off (cooldown x 2^failures, at most 24 h) instead of restarting it at every boot;
|
|
28
|
+
- leftovers are reaped at open and before each compaction: a temp dir whose owner process is gone at once (temp dirs carry an
|
|
29
|
+
owner file), an ownerless one after 10 quiet minutes (was 1 h), a stale `data.mdb.pre-compact`; logical-rebuild temp dirs now
|
|
30
|
+
live beside the env (no cross-filesystem copy inside the drain); the free-space check needs 1.2 x the live data, not 1.1 x the
|
|
31
|
+
file;
|
|
32
|
+
- `open()` no longer waits out another process's copy-phase drain (only a swap); its "blocked" warning names compaction.
|
|
33
|
+
Automatic compaction leaves the FTS storage pass to an explicit `compact()`, which still runs it inside the swap: peers'
|
|
34
|
+
reads of the env wait for that pass. `OKDB_COMPACT_TRACE=1` logs each phase transition of a compaction to stderr.
|
|
35
|
+
- **A live-map `$ref` change re-files the view doc everywhere.** When the doc a `map: { f: { $ref: [...], live: true } }` reads
|
|
36
|
+
changed, the view moved only its global scalar reducers and wrote grouped rows under a `_` bucket: per-bucket scalar, grouped,
|
|
37
|
+
items and `$min` / `$max` state kept the old mapped value (flat views: items and sorted state), and a bucketed view grew a
|
|
38
|
+
phantom `_` bucket. It now runs the same effects as a write of the doc itself. **Storage version 9**: views with a live map ref
|
|
39
|
+
rebuild once on open (non-blocking, resumable); every other view is restamped.
|
|
40
|
+
- **A parent entering / leaving a `$ref` view no longer scans every child.** The enter cascade read the whole ref type to find
|
|
41
|
+
the parent's children; leave and bucket moves scanned the whole ref tracking DB. Enter now reads the ref type's index on the
|
|
42
|
+
ref key when it is registered and ready (in the writing transaction); leave and bucket moves read a parent -> children inverse
|
|
43
|
+
of the tracking DB that every build since this release populates (views built before it keep the scan until their next
|
|
44
|
+
rebuild; the processing node fills theirs in the background on open). 300 000 line items: ~177 ms -> ~1 ms per order
|
|
45
|
+
cancelled / re-opened. **Upgrade every process to 3.1.8**: an older process writes `$ref` tracking without the inverse; the
|
|
46
|
+
cascades cross-check tracking and the next open refills an inverse that disagrees with it, but only 3.1.8 keeps it current.
|
|
47
|
+
- **Live-map refs are exact under concurrency and during builds.** A live-map update read the doc's current primary value and the
|
|
48
|
+
other live fields' current values, not what the view had applied: two live fields mapped from one doc and changed in one write
|
|
49
|
+
(bucket on one of them), or an async view's undrained primary write, filed rows the view never had. A build registered the
|
|
50
|
+
live-map handlers only at its end, so a mapped-from doc changed mid-build was never applied. Updates now start from the doc as
|
|
51
|
+
applied (prevDb / the build's bprev / the stored live values), and a build replays live-map ref changes since its start.
|
|
52
|
+
|
|
53
|
+
## [3.1.7] - 2026-11-05
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
|
|
57
|
+
- **A view bootstrap no longer holds the event loop for its whole duration.** 3.0 ran a view's build (`views.create()`, `rebuild()`,
|
|
58
|
+
`start()`, `resetView()` and the background rebuild of a view found unfinished at `open()` or on a views poke) inside one
|
|
59
|
+
native call: the 2.x worker thread and its awaits between batches were folded into one blocking scan. A `$ref` view over
|
|
60
|
+
~10^5 parents pinned the process for minutes (store-oasis: a worker's loop watchdog killed it every time, and the rebuild
|
|
61
|
+
started over on the next boot). The build is now a step machine the env pump advances in ~20 ms slices
|
|
62
|
+
(`OKDB_VIEWS_BUILD_STEP_MS`). `views.create()` & co. still resolve once the view is ready, and `db._viewRebuildChain` (2.x)
|
|
63
|
+
settles when the background rebuilds are done. A background rebuild heartbeats its `view-rebuild:` lease every step and stops
|
|
64
|
+
if the lease was lost, instead of letting a peer take over and wipe the view under it after the 600 s TTL. Rust callers of
|
|
65
|
+
`Views::create` / `rebuild` keep the blocking form; `create_begin` / `rebuild_begin` queue the build.
|
|
66
|
+
- **A parent that leaves a `$ref` view, is deleted or changes bucket moves its children's grouped and sorted state too.**
|
|
67
|
+
The cascade that follows a parent's membership / bucket change moved only the children's scalar and item state: `$countBy` /
|
|
68
|
+
`$group` (per bucket and in total) and `$min` / `$max` ref state kept them where they were (store-oasis: a cancelled order's line
|
|
69
|
+
items kept counting in `byProduct` until a rebuild). A deleted parent of a sync bucketed view lost its children's bucket rows
|
|
70
|
+
while their totals stayed. The cascades now run the same per-child code as a child write. During a build they used to do
|
|
71
|
+
nothing (gated on `ready`) and the `$ref` section read parents as they are rather than as the view had applied them; both
|
|
72
|
+
are fixed, so parents moving mid-build are exact too. **Storage version 8**: views whose `$ref` has a grouped or `$min` /
|
|
73
|
+
`$max` reducer rebuild once on open (non-blocking, resumable); every other view is restamped.
|
|
74
|
+
- **An interrupted view build resumes instead of starting over.** Each build step commits a checkpoint (section and last applied
|
|
75
|
+
key) in the same transaction as the rows it covers, and the build pins the changelog at its start clock in `~proc:state`
|
|
76
|
+
(`view:<name>:build`) so GC keeps what the resumed replay reads. The next lease holder (the next `open()`, or a peer)
|
|
77
|
+
continues where the dead builder stopped; a builder generation fences a stale one that is still running. A build without a
|
|
78
|
+
checkpoint (a 2.x view, or no pin) still rebuilds from scratch, and a fresh build now wipes every derived sub-DB (prevDb,
|
|
79
|
+
`$ref` tracking and items included) instead of leaving them from the failed attempt.
|
|
80
|
+
- **A view no longer stays `partially-ready` forever after a crash in its tail replay or finalize.** Every section read ready, so
|
|
81
|
+
open treated it as built, while its live handlers were never registered and it skipped every write. Such a view (its
|
|
82
|
+
`bootstrapStartClock` still set) is now treated as an unfinished build. A peer no longer rewrites the meta of a view another
|
|
83
|
+
process is building (it used to flip it to `creating` before taking the lease).
|
|
84
|
+
- **A `$ref` child no longer rewrites a whole-map row per grouped reducer.** Every child doc decoded, rewrote and re-encoded a
|
|
85
|
+
map of all groups for each `$countBy` / `$group` ref reducer: a row nothing reads (grouped state lives in per-group rows), but
|
|
86
|
+
it made a `$ref` build O(children x groups). store-oasis `commerce` view, 6 000 line items: 48.8 s -> 0.7 s at 2 000
|
|
87
|
+
products, now independent of the product count. Output unchanged.
|
|
88
|
+
- **Writes during a `$ref` view bootstrap are counted exactly once.** The tail replay applied an update of an already-scanned
|
|
89
|
+
child with no old value (counted twice) and never updated the ref's per-group rows (`$countBy` / `$group` previews stayed
|
|
90
|
+
wrong until the next rebuild). The replay now runs the live ref handler with the value the build applied for that child, kept
|
|
91
|
+
in a per-section `bprev` sub-DB while the view builds. The same covers the primary section of sync views (an update of an
|
|
92
|
+
already-scanned doc was counted twice). Async primaries already had this through `prevDb`.
|
|
93
|
+
|
|
7
94
|
## [3.1.6] - 2026-11-03
|
|
8
95
|
|
|
9
96
|
### Fixed
|
|
Binary file
|