@harperfast/rocksdb-js 2.11.0 → 2.12.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 +25 -16
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +12 -2
- package/dist/index.mjs.map +1 -1
- package/docs/backups.md +27 -0
- package/docs/stats.md +7 -4
- package/docs/transaction-log.md +22 -3
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -2199,20 +2199,21 @@ const names = db.listLogs();
|
|
|
2199
2199
|
|
|
2200
2200
|
### `db.purgeLogs({ includeEntryCounts: true, ...options }): { path: string; entries: number }[]`
|
|
2201
2201
|
|
|
2202
|
-
Deletes transaction log files older than the `transactionLogRetention` (defaults to 3 days).
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
`
|
|
2211
|
-
|
|
2202
|
+
Deletes transaction log files older than the `transactionLogRetention` (defaults to 3 days). A file
|
|
2203
|
+
is deleted only when it lies entirely at or before the flushed position recorded in `txn.state`, so
|
|
2204
|
+
every entry in it is already in RocksDB; that includes the file `txn.state` names and the file
|
|
2205
|
+
currently being written, so an idle, fully flushed store is left with no log files. Retention removes
|
|
2206
|
+
a contiguous prefix: the first file that is too new or holds an unflushed entry stops the run. When
|
|
2207
|
+
the flush position lags — `txn.state` stuck at an old sequence because RocksDB flushing is behind —
|
|
2208
|
+
every file after it is retained regardless of age; `purge.retainedUnflushedFiles` reports that case.
|
|
2209
|
+
While a backup with `transactionLogs` is copying a store's files, purges of that store are skipped
|
|
2210
|
+
(`purge.retentionPins` reports it). On a filesystem that rejects a directory fsync, the store's last
|
|
2211
|
+
file is kept, since `txn.state` could not be made durable before deleting it.
|
|
2212
|
+
Use `destroy: true` only to remove the store itself.
|
|
2212
2213
|
|
|
2213
2214
|
- `options: object`
|
|
2214
2215
|
- `before?: number` Remove transaction log files older than the specified timestamp, subject to
|
|
2215
|
-
the
|
|
2216
|
+
the flushed-position and contiguous-prefix rules above.
|
|
2216
2217
|
- `destroy?: boolean` When `true`, deletes transaction log stores including all log sequence files
|
|
2217
2218
|
on disk.
|
|
2218
2219
|
- `includeEntryCounts?: boolean` When `true`, counts the entries in each deleted log file and
|
|
@@ -2386,9 +2387,8 @@ stats.totals.transactionsWritten; // lifetime count of transactions written
|
|
|
2386
2387
|
|
|
2387
2388
|
The `purge.retainedUnflushedFiles` gauge is useful for diagnosing why logs are not being cleaned
|
|
2388
2389
|
up: a file can be older than the retention period but still retained because its transactions have
|
|
2389
|
-
not yet been flushed to RocksDB (purging it would be unsafe for crash recovery).
|
|
2390
|
-
|
|
2391
|
-
position — is not counted as purgeable even when it is old and fully flushed.
|
|
2390
|
+
not yet been flushed to RocksDB (purging it would be unsafe for crash recovery). An old, fully
|
|
2391
|
+
flushed current file counts as purgeable.
|
|
2392
2392
|
|
|
2393
2393
|
### Transaction Log Initialization
|
|
2394
2394
|
|
|
@@ -2789,7 +2789,7 @@ backup references them, so this is not equivalent to deleting files manually.
|
|
|
2789
2789
|
|
|
2790
2790
|
Deletes all but the newest `keepCount` backups.
|
|
2791
2791
|
|
|
2792
|
-
### `backups.verify(backupDir: string, backupId: number, options?: { verifyWithChecksum?: boolean; verifyTransactionLogs?: boolean }): Promise<void>`
|
|
2792
|
+
### `backups.verify(backupDir: string, backupId: number, options?: { verifyWithChecksum?: boolean; verifyTables?: boolean; verifyTransactionLogs?: boolean }): Promise<void>`
|
|
2793
2793
|
|
|
2794
2794
|
Verifies a backup's file sizes, and optionally their checksums (which requires reading all
|
|
2795
2795
|
backed-up data). Resolves if the backup is intact and rejects otherwise.
|
|
@@ -2800,8 +2800,17 @@ When the backup was created with `transactionLogs: true`, the backup's transacti
|
|
|
2800
2800
|
log file's header and entry framing must be intact (snapshots are copied on committed entry
|
|
2801
2801
|
boundaries, so even a torn tail fails verification). Set `verifyTransactionLogs: false` to skip.
|
|
2802
2802
|
|
|
2803
|
+
Set `verifyTables: true` (default `false`) to also prove this build can read the backup's table
|
|
2804
|
+
files before you restore it. Each SST is opened in turn, one at a time, so file-descriptor use does
|
|
2805
|
+
not grow with the number of tables. Verification rejects, naming the file, when this build cannot
|
|
2806
|
+
decode a table's footer (for example a `format_version` written by a newer RocksDB) or its
|
|
2807
|
+
properties, or when the table records a compression algorithm this build does not support (see
|
|
2808
|
+
[`supportedCompression`](#supportedcompression)). Checksums cannot catch either case: the file is
|
|
2809
|
+
intact, just unreadable here, and RocksDB would otherwise fail on the first read after a restore.
|
|
2810
|
+
Blob files are not checked.
|
|
2811
|
+
|
|
2803
2812
|
```typescript
|
|
2804
|
-
await backups.verify('/path/to/backups', 1, { verifyWithChecksum: true });
|
|
2813
|
+
await backups.verify('/path/to/backups', 1, { verifyWithChecksum: true, verifyTables: true });
|
|
2805
2814
|
```
|
|
2806
2815
|
|
|
2807
2816
|
## Custom Store
|
package/dist/index.cjs
CHANGED
|
@@ -550,6 +550,14 @@ const backups = {
|
|
|
550
550
|
* Verifies a backup's file sizes, and optionally their checksums (which
|
|
551
551
|
* requires reading all backed-up data).
|
|
552
552
|
*
|
|
553
|
+
* Set `verifyTables: true` to also prove this build can read the backup
|
|
554
|
+
* before restoring it: every table file is opened, one at a time, and its
|
|
555
|
+
* footer (including `format_version`) and properties must be readable, and
|
|
556
|
+
* every compression algorithm it records must be supported by this build.
|
|
557
|
+
* A checksum-valid table written by a newer or differently built RocksDB
|
|
558
|
+
* otherwise passes and fails on the first read after a restore. Blob files
|
|
559
|
+
* are not checked.
|
|
560
|
+
*
|
|
553
561
|
* When the backup was created with `transactionLogs: true`, the backup's
|
|
554
562
|
* transaction log snapshot (`<backupDir>/transaction_logs/<backupId>/`) is
|
|
555
563
|
* also validated — every log file's header and entry framing must be intact
|
|
@@ -557,7 +565,9 @@ const backups = {
|
|
|
557
565
|
* is a verification failure). Set `verifyTransactionLogs: false` to skip.
|
|
558
566
|
*/
|
|
559
567
|
async verify(backupDir, backupId, options) {
|
|
560
|
-
|
|
568
|
+
const verifyTables = options?.verifyTables;
|
|
569
|
+
if (verifyTables !== void 0 && typeof verifyTables !== "boolean") throw new TypeError(`verifyTables must be a boolean, received ${verifyTables === null ? "null" : typeof verifyTables}`);
|
|
570
|
+
await new Promise((resolve, reject) => nativeBackupVerify(resolve, reject, backupDir, backupId, options?.verifyWithChecksum ?? false, verifyTables === true));
|
|
561
571
|
if (options?.verifyTransactionLogs === false) return;
|
|
562
572
|
const logsDir = (0, node_path.join)(backupDir, TRANSACTION_LOGS_DIRNAME, String(backupId));
|
|
563
573
|
if (!await exists(logsDir)) return;
|
|
@@ -3975,7 +3985,7 @@ function loadLastPosition(transactionLog, readUncommitted) {
|
|
|
3975
3985
|
//#region src/index.ts
|
|
3976
3986
|
const versions = {
|
|
3977
3987
|
rocksdb: version,
|
|
3978
|
-
"rocksdb-js": "2.
|
|
3988
|
+
"rocksdb-js": "2.12.0"
|
|
3979
3989
|
};
|
|
3980
3990
|
|
|
3981
3991
|
//#endregion
|