@kedem/okdb 3.2.0 → 3.3.0
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 +57 -0
- package/native/linux-x64-gnu/okdb-node.linux-x64-gnu.node +0 -0
- package/okdb-native.js +1 -1
- package/package.json +1 -1
- package/public/core/db/parts/db-overview.ok.js +1 -1
- package/public/core/system/modals/data-ops-modal.ok.js +1 -1
- package/types/environment.d.ts +5 -3
- package/types/options.d.ts +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,63 @@ 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.3.0] - 2026-11-26
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- **Compaction is online and in place.** `compact()` and automatic compaction no longer copy the env into a new file and swap
|
|
12
|
+
it in. Data moves from the end of `data.mdb` into free space near the front, in short steps between ordinary writes, and the
|
|
13
|
+
free end of the file is cut off. No freeze, no drain, no `ENV_DRAINING`, no peer reopening the file, and **no extra disk
|
|
14
|
+
space** (the copy needed about 1.2× the live data free). The full-text index files and the embeddings vector envs
|
|
15
|
+
(`~<env>:emb:<type>`) are reclaimed the same way; a loaded `graph` search view lets go of its snapshot during a reclaim.
|
|
16
|
+
Ordinary writes keep LMDB's normal page allocation; only while a reclaim runs do they prefer free pages near the front
|
|
17
|
+
(from the free list already in memory, at no extra cost).
|
|
18
|
+
A reclaim ends when nothing more can be moved or cut right now (space still held by a long-running reader, for example):
|
|
19
|
+
a later run cuts the rest.
|
|
20
|
+
Automatic steps move up to `autoCompact.reclaimBudget` pages (default 500) every `autoCompact.reclaimIntervalMs` (default
|
|
21
|
+
100 ms); an explicit `compact()` runs back to back. One process reclaims an env at a time (the compaction lease).
|
|
22
|
+
On NVMe, 200k documents with 70% deleted: 419 → 172 MB, about 5 ms per automatic step.
|
|
23
|
+
- **Automatic compaction starts earlier:** at 20% free space (`autoCompact.wastedRatioThreshold`, was 50%) and from 10 MB
|
|
24
|
+
(`autoCompact.minFileBytes`, was 100 MB), since a reclaim costs little. It shrinks the file to the live data plus 10%,
|
|
25
|
+
room for ordinary writes without growing the file again. The Storage card's "reclaimable" warning uses the same threshold.
|
|
26
|
+
- **The copy is still there:** `compact({ rebuild: true })` (a fully re-sorted file, including the full-text index's own
|
|
27
|
+
copy), or `autoCompact.mode: 'copy'` for the old automatic behaviour. `repair()` is unchanged.
|
|
28
|
+
- **`compact()` results** carry `reason: 'reclaim'` for an online reclaim. A `compact()` during an automatic reclaim takes it
|
|
29
|
+
over instead of failing with `REBUILD_IN_PROGRESS`; one while another process reclaims returns `skipped`.
|
|
30
|
+
- **Admin:** the env Storage card shows "reclaiming online" while any process of the store reclaims the env, the newest
|
|
31
|
+
outcome ("reclaimed online · 130 MB → 45.9 MB"), and a **Compact now** button; it refreshes itself while a reclaim runs.
|
|
32
|
+
System → Data Ops → Compact offers _Compact (online)_, _Rebuild (copy)_ and _Logical rebuild (repair)_.
|
|
33
|
+
`GET /api/system/storage` adds `reclaiming`, `compactMode` and `lastReclaim` per env; `POST /api/env/:env/compact` accepts
|
|
34
|
+
`rebuild: true`.
|
|
35
|
+
- **Windows:** a mapped file cannot shrink, so there the last process to close an env cuts the file (data has already moved
|
|
36
|
+
to the front). Other platforms cut while running.
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- **"Reclaimable" counted space a compaction cannot give back.** The live size walked each sub-DB's tree pages and missed the
|
|
41
|
+
sub-trees of indexes with many values per key, so "file − live" overstated free space (a real brain store showed 27%
|
|
42
|
+
reclaimable with 9% free) and the automatic compaction could fire again and again for nothing. Live is now the pages in
|
|
43
|
+
use minus the free list: `liveBytes` / `reclaimablePct` (Storage card, `storageStats`) and the automatic trigger agree with
|
|
44
|
+
what a reclaim frees.
|
|
45
|
+
- **`autoCompact: false` did not turn automatic compaction off** (since the 3.0 native core): only `{ enabled: false }` was read.
|
|
46
|
+
Both forms work now; the types accept `false`. Found by the mixed-version test, where an automatic reclaim held the
|
|
47
|
+
compaction lease.
|
|
48
|
+
|
|
49
|
+
## [3.2.1] - 2026-11-25
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- **Encrypted envs could crash (SIGSEGV) with write transactions on more than one thread.** LMDB released the writer lock
|
|
54
|
+
before releasing the ending write transaction's page list, which the next write transaction reuses. A writer on another
|
|
55
|
+
thread could start in that window, and pages still in use were unmapped: the next read faulted (in `mdb_rpage_encsum` /
|
|
56
|
+
`chacha8`). Only encrypted envs (they run LMDB's chunked page cache). The lock is now released after the list. Regression
|
|
57
|
+
test: `crates/lmdb-js-sys/tests/enc_writer_race.rs` (stock LMDB API only).
|
|
58
|
+
- **A hot backup of an encrypted store never worked.** `db.migrate.backup()` failed with "Bad address": LMDB's page-for-page
|
|
59
|
+
copy wrote straight from the memory map, which for an encrypted env is mapped in chunks, not as one view of the file. The
|
|
60
|
+
copy now reads the pages from the file (they stay encrypted). The backup also left out each env's `keyring` file (the
|
|
61
|
+
env's data key, wrapped by your key), so even a copy could not be opened; it is copied now. Test:
|
|
62
|
+
`parity_gaps::encrypted_store_hot_backup` (backs up, checks the copy is encrypted, opens it, reads every document).
|
|
63
|
+
|
|
7
64
|
## [3.2.0] - 2026-11-17
|
|
8
65
|
|
|
9
66
|
Nothing to change in code; what the first start does is under **Migration** below.
|
|
Binary file
|