@harperfast/rocksdb-js 2.4.1 → 2.6.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/README.md +224 -15
- package/bin/rocksdb-js.mjs +67 -3
- package/dist/index.cjs +293 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1382 -1125
- package/dist/index.d.mts +1382 -1125
- package/dist/index.mjs +294 -41
- package/dist/index.mjs.map +1 -1
- package/docs/backups.md +15 -0
- package/docs/stats.md +2 -0
- package/docs/transaction-log.md +10 -0
- package/package.json +17 -17
package/docs/backups.md
CHANGED
|
@@ -73,6 +73,13 @@ await backups.delete('/path/to/backups', id); // remove one backup
|
|
|
73
73
|
await backups.purge('/path/to/backups', 3); // keep the newest 3
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
`backups.verify` also validates the backup's transaction log snapshot when one was captured
|
|
77
|
+
(`transactionLogs: true`): every log file's header and entry framing must be intact, in strict mode
|
|
78
|
+
(snapshots are copied on committed entry boundaries, so even a recoverable torn tail fails
|
|
79
|
+
verification). Pass `verifyTransactionLogs: false` to check only the RocksDB files. Standalone
|
|
80
|
+
stores (e.g. the `transaction_logs` directory of a closed database) can be validated directly with
|
|
81
|
+
`validateTransactionLogStore()`.
|
|
82
|
+
|
|
76
83
|
### Restoring
|
|
77
84
|
|
|
78
85
|
```typescript
|
|
@@ -96,6 +103,14 @@ Restore modes:
|
|
|
96
103
|
- **`verifyChecksum`**: reuse existing destination files whose checksums match the backup, replacing
|
|
97
104
|
only mismatched/corrupt files.
|
|
98
105
|
|
|
106
|
+
Restore reads the backup directory and holds its lock in shared mode, so multiple restores run
|
|
107
|
+
concurrently but a writer (`db.backup()` / `delete` / `purge`) and a restore exclude each other.
|
|
108
|
+
Because the restore only reads, the source may be a **read-only backup directory** — an
|
|
109
|
+
immutable/WORM store or a read-only-mounted volume — even though writers require a writable one. The
|
|
110
|
+
lock is taken read-only on the existing lock file; if the media is read-only for every process it
|
|
111
|
+
degrades to a no-op (no writer can be racing), but a plain permission denial fails loudly rather than
|
|
112
|
+
skip coordination, since a more-privileged writer could still be active.
|
|
113
|
+
|
|
99
114
|
### Caveats
|
|
100
115
|
|
|
101
116
|
- **The data is duplicated onto local disk.** A backup is a real, separate copy in the backup
|
package/docs/stats.md
CHANGED
|
@@ -34,6 +34,8 @@ By default, `db.getStats()` returns properties only.
|
|
|
34
34
|
|
|
35
35
|
| Name | Description | Type |
|
|
36
36
|
| ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
|
|
37
|
+
| `commitPipeline.commitQueueDepth` | Number of async commits queued on the database's commit lane but not yet started (in the default single-lane mode this covers the whole commit: log write + RocksDB commit). | gauge |
|
|
38
|
+
| `commitPipeline.logQueueDepth` | Number of async commits queued on the database's transaction-log lane but not yet started (always `0` in the default single-lane mode; see `ROCKSDB_JS_COMMIT_THREAD=2`). | gauge |
|
|
37
39
|
| `rocksdb.block-cache-capacity` | Capacity in bytes of the block cache. | gauge |
|
|
38
40
|
| `rocksdb.block-cache-pinned-usage` | Bytes occupied by pinned block cache entries. | gauge |
|
|
39
41
|
| `rocksdb.block-cache-usage` | Bytes currently used by block cache entries. | gauge |
|
package/docs/transaction-log.md
CHANGED
|
@@ -206,6 +206,16 @@ await db.transaction((txn) => {
|
|
|
206
206
|
- Commit with unknown transaction ID throws an error
|
|
207
207
|
- Invalid data is detected during read operations
|
|
208
208
|
|
|
209
|
+
### Validation
|
|
210
|
+
|
|
211
|
+
A store directory can be validated offline with `validateTransactionLogStore(path, options?)`: it
|
|
212
|
+
checks every log file's header (token, version) and entry framing using the same scan as open-time
|
|
213
|
+
crash recovery, plus file-name/sequence continuity and the `txn.state` side file. A torn tail,
|
|
214
|
+
sequence gap, or implausible `txn.state` position is a warning by default (a torn tail is
|
|
215
|
+
recoverable — open-time recovery truncates it losslessly) and an error with `{ strict: true }`,
|
|
216
|
+
which `backups.verify()` uses for backup snapshots since an intact snapshot can have none of them.
|
|
217
|
+
The CLI exposes the same check as `verify-logs [name]`.
|
|
218
|
+
|
|
209
219
|
## Reading The Transaction Log
|
|
210
220
|
|
|
211
221
|
Log entries are not guaranteed to be in order, but are guaranteed to have a monotonic timestamp.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harperfast/rocksdb-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "RocksDB binding for Node.js",
|
|
5
5
|
"homepage": "https://github.com/HarperFast/rocksdb-js",
|
|
6
6
|
"bugs": [
|
|
@@ -38,33 +38,33 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@rollup/plugin-replace": "6.0.3",
|
|
41
|
-
"@types/node": "26.1.
|
|
41
|
+
"@types/node": "26.1.2",
|
|
42
42
|
"@vitest/coverage-v8": "4.1.10",
|
|
43
43
|
"cross-env": "10.1.0",
|
|
44
44
|
"dotenv": "17.4.2",
|
|
45
|
-
"lefthook": "2.1.
|
|
45
|
+
"lefthook": "2.1.10",
|
|
46
46
|
"lmdb": "3.5.6",
|
|
47
47
|
"node-gyp": "13.0.1",
|
|
48
|
-
"oxfmt": "0.
|
|
49
|
-
"oxlint": "1.
|
|
48
|
+
"oxfmt": "0.60.0",
|
|
49
|
+
"oxlint": "1.75.0",
|
|
50
50
|
"prebuildify": "6.0.1",
|
|
51
51
|
"semver": "7.8.5",
|
|
52
|
-
"tar": "7.5.
|
|
53
|
-
"tsdown": "0.22.
|
|
52
|
+
"tar": "7.5.22",
|
|
53
|
+
"tsdown": "0.22.14",
|
|
54
54
|
"tslib": "2.8.1",
|
|
55
|
-
"tsx": "4.23.
|
|
56
|
-
"typescript": "
|
|
55
|
+
"tsx": "4.23.1",
|
|
56
|
+
"typescript": "7.0.2",
|
|
57
57
|
"vitest": "4.1.10"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"@harperfast/rocksdb-js-darwin-arm64": "2.
|
|
61
|
-
"@harperfast/rocksdb-js-darwin-x64": "2.
|
|
62
|
-
"@harperfast/rocksdb-js-linux-arm64-glibc": "2.
|
|
63
|
-
"@harperfast/rocksdb-js-linux-arm64-musl": "2.
|
|
64
|
-
"@harperfast/rocksdb-js-linux-x64-glibc": "2.
|
|
65
|
-
"@harperfast/rocksdb-js-linux-x64-musl": "2.
|
|
66
|
-
"@harperfast/rocksdb-js-win32-arm64": "2.
|
|
67
|
-
"@harperfast/rocksdb-js-win32-x64": "2.
|
|
60
|
+
"@harperfast/rocksdb-js-darwin-arm64": "2.6.0",
|
|
61
|
+
"@harperfast/rocksdb-js-darwin-x64": "2.6.0",
|
|
62
|
+
"@harperfast/rocksdb-js-linux-arm64-glibc": "2.6.0",
|
|
63
|
+
"@harperfast/rocksdb-js-linux-arm64-musl": "2.6.0",
|
|
64
|
+
"@harperfast/rocksdb-js-linux-x64-glibc": "2.6.0",
|
|
65
|
+
"@harperfast/rocksdb-js-linux-x64-musl": "2.6.0",
|
|
66
|
+
"@harperfast/rocksdb-js-win32-arm64": "2.6.0",
|
|
67
|
+
"@harperfast/rocksdb-js-win32-x64": "2.6.0"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": "^22.18.0 || >=24.0.0"
|