@harperfast/rocksdb-js 2.11.0 → 2.13.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 +158 -27
- package/dist/index.cjs +322 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -39
- package/dist/index.d.mts +178 -39
- package/dist/index.mjs +320 -67
- package/dist/index.mjs.map +1 -1
- package/docs/backups.md +27 -0
- package/docs/performance/mutex-contention.md +4 -3
- package/docs/stats.md +11 -4
- package/docs/steady-clock-design.md +1 -1
- package/docs/transaction-log.md +27 -7
- package/package.json +19 -18
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ExtendedIterable } from "@harperfast/extended-iterable";
|
|
2
|
-
//#region src/backup.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Options for creating a backup via `db.backup()`.
|
|
5
4
|
*
|
|
@@ -178,6 +177,14 @@ export declare const backups: {
|
|
|
178
177
|
* Verifies a backup's file sizes, and optionally their checksums (which
|
|
179
178
|
* requires reading all backed-up data).
|
|
180
179
|
*
|
|
180
|
+
* Set `verifyTables: true` to also prove this build can read the backup
|
|
181
|
+
* before restoring it: every table file is opened, one at a time, and its
|
|
182
|
+
* footer (including `format_version`) and properties must be readable, and
|
|
183
|
+
* every compression algorithm it records must be supported by this build.
|
|
184
|
+
* A checksum-valid table written by a newer or differently built RocksDB
|
|
185
|
+
* otherwise passes and fails on the first read after a restore. Blob files
|
|
186
|
+
* are not checked.
|
|
187
|
+
*
|
|
181
188
|
* When the backup was created with `transactionLogs: true`, the backup's
|
|
182
189
|
* transaction log snapshot (`<backupDir>/transaction_logs/<backupId>/`) is
|
|
183
190
|
* also validated — every log file's header and entry framing must be intact
|
|
@@ -186,12 +193,11 @@ export declare const backups: {
|
|
|
186
193
|
*/
|
|
187
194
|
verify(backupDir: string, backupId: number, options?: {
|
|
188
195
|
verifyWithChecksum?: boolean;
|
|
196
|
+
verifyTables?: boolean;
|
|
189
197
|
verifyTransactionLogs?: boolean;
|
|
190
198
|
}): Promise<void>;
|
|
191
199
|
};
|
|
192
|
-
|
|
193
|
-
//#region src/encoding.d.ts
|
|
194
|
-
type Key = Key[] | string | symbol | number | boolean | Uint8Array | Buffer | null;
|
|
200
|
+
type Key = Key[] | string | symbol | number | bigint | boolean | Uint8Array | Buffer | null;
|
|
195
201
|
interface BufferWithDataView extends Buffer {
|
|
196
202
|
dataView: DataView;
|
|
197
203
|
start: number;
|
|
@@ -219,8 +225,6 @@ type Encoding = "binary" | "ordered-binary" | "msgpack" | false;
|
|
|
219
225
|
type KeyEncoding = "binary" | "ordered-binary" | "uint32";
|
|
220
226
|
type ReadKeyFunction<T> = (source: BufferWithDataView, start: number, end?: number) => T;
|
|
221
227
|
type WriteKeyFunction = (key: Key, target: BufferWithDataView, start: number) => number;
|
|
222
|
-
//#endregion
|
|
223
|
-
//#region src/dbi-iterator.d.ts
|
|
224
228
|
interface DBIteratorValue<T> {
|
|
225
229
|
key: Key;
|
|
226
230
|
value: T;
|
|
@@ -238,14 +242,12 @@ export declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
|
|
|
238
242
|
#private;
|
|
239
243
|
iterator: InstanceType<typeof NativeIteratorCls>;
|
|
240
244
|
store: Store;
|
|
241
|
-
constructor(iterator: InstanceType<typeof NativeIteratorCls>, store: Store, includeValues: boolean, limit?: number);
|
|
245
|
+
constructor(iterator: InstanceType<typeof NativeIteratorCls>, store: Store, includeValues: boolean, limit?: number, transaction?: NativeTransaction);
|
|
242
246
|
[Symbol.iterator](): Iterator<DBIteratorValue<T>>;
|
|
243
247
|
next(): IteratorResult<DBIteratorValue<T>>;
|
|
244
248
|
return(value?: any): IteratorResult<DBIteratorValue<T>, any>;
|
|
245
249
|
throw(err: unknown): IteratorResult<DBIteratorValue<T>, any>;
|
|
246
250
|
}
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region src/store.d.ts
|
|
249
251
|
type StoreContext = NativeDatabase | NativeTransaction;
|
|
250
252
|
type StoreGetOptions = GetOptions & DBITransactional;
|
|
251
253
|
type StoreIteratorOptions = IteratorOptions & DBITransactional;
|
|
@@ -676,6 +678,10 @@ export declare class Store {
|
|
|
676
678
|
* sealed and flushed.
|
|
677
679
|
*/
|
|
678
680
|
writeBufferSize?: number;
|
|
681
|
+
/**
|
|
682
|
+
* The memtable arena block size in bytes; `0` or unset is automatic.
|
|
683
|
+
*/
|
|
684
|
+
arenaBlockSize?: number;
|
|
679
685
|
/**
|
|
680
686
|
* The function used to encode keys using the shared `keyBuffer`.
|
|
681
687
|
*/
|
|
@@ -912,8 +918,6 @@ interface PutOptions {
|
|
|
912
918
|
noDupData?: boolean;
|
|
913
919
|
noOverwrite?: boolean;
|
|
914
920
|
}
|
|
915
|
-
//#endregion
|
|
916
|
-
//#region src/transaction.d.ts
|
|
917
921
|
/**
|
|
918
922
|
* Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
|
|
919
923
|
* transaction encountered an IsBusy conflict. The native layer parks on VT
|
|
@@ -921,6 +925,35 @@ interface PutOptions {
|
|
|
921
925
|
* intent, so callers should retry immediately without any backoff delay.
|
|
922
926
|
*/
|
|
923
927
|
declare const RETRY_NOW: number;
|
|
928
|
+
/**
|
|
929
|
+
* `abort()` of a transaction whose transaction-log batch could not be marked aborted
|
|
930
|
+
* (`transactionLogAbortMarkers`). The batch stays unresolved, so committed readers do not pass it and
|
|
931
|
+
* the log store refuses appends, until a retry on the next append, database flush or store close
|
|
932
|
+
* marks it.
|
|
933
|
+
*/
|
|
934
|
+
export declare class TransactionAbortUnresolvedError extends Error {
|
|
935
|
+
readonly code = "ERR_TRANSACTION_ABORT_UNRESOLVED";
|
|
936
|
+
readonly txn: Transaction;
|
|
937
|
+
constructor(error: Error, txn: Transaction);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Why a transaction's most recent attempt was refused or retried, from {@link Transaction.lastConflictKind}.
|
|
941
|
+
*/
|
|
942
|
+
export declare const ConflictKind: {
|
|
943
|
+
readonly none: 0;
|
|
944
|
+
/** Refused on an older transaction's write intent before writing its log batch. */
|
|
945
|
+
readonly intentBeforeLog: 1;
|
|
946
|
+
/** Refused on an older transaction's write intent after its log batch was written. */
|
|
947
|
+
readonly intentAfterLog: 2;
|
|
948
|
+
/** RocksDB found a conflict at commit. */
|
|
949
|
+
readonly atCommit: 3;
|
|
950
|
+
/**
|
|
951
|
+
* RocksDB's conflict check, run before the log write, found a write that already committed, or,
|
|
952
|
+
* as at commit, could not validate because the memtable history it needs was flushed (needs a
|
|
953
|
+
* RocksDB build that exports the check).
|
|
954
|
+
*/
|
|
955
|
+
readonly checkBeforeLog: 4;
|
|
956
|
+
};
|
|
924
957
|
/**
|
|
925
958
|
* Provides transaction level operations to a transaction callback.
|
|
926
959
|
*/
|
|
@@ -966,6 +999,22 @@ export declare class Transaction extends DBI {
|
|
|
966
999
|
* @returns The transaction timestamp in milliseconds.
|
|
967
1000
|
*/
|
|
968
1001
|
getTimestamp(): number;
|
|
1002
|
+
/**
|
|
1003
|
+
* Whether this transaction's batch is in the transaction log. A commit conflict after the batch
|
|
1004
|
+
* was written keeps it for the retry, which must not stage it again; an attempt refused before
|
|
1005
|
+
* writing it (`refusedBeforeLog`) leaves nothing.
|
|
1006
|
+
*/
|
|
1007
|
+
logWritten(): boolean;
|
|
1008
|
+
/**
|
|
1009
|
+
* Why the most recent attempt was refused or retried; one of {@link ConflictKind}.
|
|
1010
|
+
*/
|
|
1011
|
+
lastConflictKind(): number;
|
|
1012
|
+
/**
|
|
1013
|
+
* Bounds coordinated-retry parks: past `deadline` (epoch milliseconds) a parked commit resolves
|
|
1014
|
+
* `RETRY_NOW` at once, so a caller enforcing its own deadline can abort instead of waiting out
|
|
1015
|
+
* the default park bound. 0 clears it.
|
|
1016
|
+
*/
|
|
1017
|
+
setParkDeadline(deadline: number): void;
|
|
969
1018
|
/**
|
|
970
1019
|
* Get the transaction id.
|
|
971
1020
|
*/
|
|
@@ -982,11 +1031,7 @@ export declare class Transaction extends DBI {
|
|
|
982
1031
|
*/
|
|
983
1032
|
setTimestamp(timestamp?: number): void;
|
|
984
1033
|
}
|
|
985
|
-
//#endregion
|
|
986
|
-
//#region src/util.d.ts
|
|
987
1034
|
type MaybePromise<T> = T | Promise<T>;
|
|
988
|
-
//#endregion
|
|
989
|
-
//#region src/dbi.d.ts
|
|
990
1035
|
interface RocksDBOptions {
|
|
991
1036
|
/**
|
|
992
1037
|
* When `true`, RocksDB will do some enhancements for prefetching the data.
|
|
@@ -1324,8 +1369,6 @@ export declare class DBI<T extends DBITransactional | unknown = unknown> {
|
|
|
1324
1369
|
*/
|
|
1325
1370
|
useLog(name: string | number): TransactionLog;
|
|
1326
1371
|
}
|
|
1327
|
-
//#endregion
|
|
1328
|
-
//#region src/stats.d.ts
|
|
1329
1372
|
/**
|
|
1330
1373
|
* Database-level RocksDB statistics types for `db.getStats()` / `db.getStat()`.
|
|
1331
1374
|
*
|
|
@@ -1666,6 +1709,10 @@ type StatsAllExtras = {
|
|
|
1666
1709
|
"rocksdb.checkpoint.read.bytes": number;
|
|
1667
1710
|
"rocksdb.checkpoint.write.bytes": number;
|
|
1668
1711
|
"rocksdb.file.submit.async.read.fallback": number;
|
|
1712
|
+
"rocksdb.blobdb.lazy.read.count": number;
|
|
1713
|
+
"rocksdb.blobdb.lazy.read.bytes": number;
|
|
1714
|
+
"rocksdb.blobdb.lazy.partial.read.count": number;
|
|
1715
|
+
"rocksdb.blobdb.lazy.partial.bytes.saved": number;
|
|
1669
1716
|
"rocksdb.compaction.times.cpu_micros": StatsHistogramData;
|
|
1670
1717
|
"rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
|
|
1671
1718
|
"rocksdb.table.sync.micros": StatsHistogramData;
|
|
@@ -1748,8 +1795,6 @@ interface GetStatsMethod {
|
|
|
1748
1795
|
getStats(all?: false): StatsDefault;
|
|
1749
1796
|
getStats(all: true): StatsAll;
|
|
1750
1797
|
}
|
|
1751
|
-
//#endregion
|
|
1752
|
-
//#region src/validate-transaction-log.d.ts
|
|
1753
1798
|
/**
|
|
1754
1799
|
* The validation result for a single transaction log file within a store, as
|
|
1755
1800
|
* returned by {@link validateTransactionLogStore}.
|
|
@@ -1856,8 +1901,6 @@ interface ValidateTransactionLogStoreOptions {
|
|
|
1856
1901
|
* ```
|
|
1857
1902
|
*/
|
|
1858
1903
|
export declare function validateTransactionLogStore(path: string, options?: ValidateTransactionLogStoreOptions): Promise<TransactionLogStoreValidation>;
|
|
1859
|
-
//#endregion
|
|
1860
|
-
//#region src/load-binding.d.ts
|
|
1861
1904
|
/**
|
|
1862
1905
|
* The `Error` subclass passed to `'error'` event listeners and returned by
|
|
1863
1906
|
* `db.getLastError()` when RocksDB reports a background error (e.g. a write
|
|
@@ -1951,9 +1994,13 @@ type NativeTransaction = {
|
|
|
1951
1994
|
getCount(options?: RangeOptions): number;
|
|
1952
1995
|
getSync(keyLengthOrKeyBuffer: number | Buffer): Buffer | number | undefined;
|
|
1953
1996
|
getTimestamp(): number;
|
|
1997
|
+
lastConflictKind(): number;
|
|
1998
|
+
logWritten(): boolean;
|
|
1954
1999
|
putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
|
|
1955
2000
|
removeSync(key: Key): void;
|
|
2001
|
+
setParkDeadline(deadline: number): void;
|
|
1956
2002
|
setTimestamp(timestamp?: number): void;
|
|
2003
|
+
trimIterators(): void;
|
|
1957
2004
|
useLog(name: string | number, jsDatabase: NativeDatabase): TransactionLog;
|
|
1958
2005
|
};
|
|
1959
2006
|
type LogBuffer = Buffer & {
|
|
@@ -2016,6 +2063,7 @@ type TransactionLogStats = {
|
|
|
2016
2063
|
oldestFileAgeMs: number;
|
|
2017
2064
|
purgeableFiles: number;
|
|
2018
2065
|
retainedUnflushedFiles: number;
|
|
2066
|
+
retentionPins: number;
|
|
2019
2067
|
lastPurgeMs: number;
|
|
2020
2068
|
};
|
|
2021
2069
|
totals: {
|
|
@@ -2028,6 +2076,16 @@ type TransactionLogStats = {
|
|
|
2028
2076
|
purgeRuns: number;
|
|
2029
2077
|
databaseFlushes: number;
|
|
2030
2078
|
writeFailures: number;
|
|
2079
|
+
/** Batches marked aborted (`transactionLogAbortMarkers`). */
|
|
2080
|
+
abortsMarked: number;
|
|
2081
|
+
/** Abort marker writes or syncs that failed; each leaves its batch unresolved until a retry. */
|
|
2082
|
+
abortMarkFailures: number;
|
|
2083
|
+
/**
|
|
2084
|
+
* Microseconds logged batches held the committed-read watermark back after their first commit
|
|
2085
|
+
* conflict, until they committed or ended; `pinnedTransactions` counts those batches.
|
|
2086
|
+
*/
|
|
2087
|
+
watermarkPinnedUs: number;
|
|
2088
|
+
pinnedTransactions: number;
|
|
2031
2089
|
};
|
|
2032
2090
|
config: {
|
|
2033
2091
|
maxFileSize: number;
|
|
@@ -2045,11 +2103,13 @@ export type TransactionLog = {
|
|
|
2045
2103
|
query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
|
|
2046
2104
|
_currentLogBuffer: WeakRef<LogBuffer> | undefined;
|
|
2047
2105
|
_findPosition(timestamp: number): number;
|
|
2106
|
+
_findExactStart(timestamp: number, span: Float64Array): number;
|
|
2048
2107
|
_getLastCommittedPosition(): Buffer;
|
|
2049
2108
|
_getLastFlushed(): number;
|
|
2050
2109
|
_getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
|
|
2051
2110
|
_lastCommittedPosition: Float64Array;
|
|
2052
2111
|
_nextLogId(sequenceId: number): number;
|
|
2112
|
+
_segmentRemovals(): number;
|
|
2053
2113
|
_logBuffers: Map<number, WeakRef<LogBuffer>>;
|
|
2054
2114
|
};
|
|
2055
2115
|
/**
|
|
@@ -2079,11 +2139,22 @@ type NativeIteratorResult = number | {
|
|
|
2079
2139
|
declare class NativeIteratorCls {
|
|
2080
2140
|
constructor(context: StoreContext, flags: number, startKeyEnd: number, endKeyStart: number, endKeyEnd: number, options?: NativeIteratorAdvancedOptions, transactionId?: number);
|
|
2081
2141
|
next(): NativeIteratorResult;
|
|
2082
|
-
|
|
2083
|
-
|
|
2142
|
+
/** Returns whether the native iterator went back to its transaction's pool. */
|
|
2143
|
+
return(): boolean;
|
|
2144
|
+
throw(err?: unknown): boolean;
|
|
2084
2145
|
}
|
|
2085
2146
|
type NativeDatabaseMode = "optimistic" | "pessimistic";
|
|
2086
2147
|
type NativeDatabaseOptions = {
|
|
2148
|
+
/**
|
|
2149
|
+
* Memtable arena block size in bytes. Every column family that has been
|
|
2150
|
+
* written holds at least one block charged to the WriteBufferManager, so
|
|
2151
|
+
* with many column families this sets a floor on the manager's usage.
|
|
2152
|
+
* `0` (the default) is automatic: with a WriteBufferManager attached,
|
|
2153
|
+
* `writeBufferManagerSize / 2048` clamped to between 64 KiB and
|
|
2154
|
+
* `min(1 MiB, writeBufferSize / 8)`; without one, RocksDB's own
|
|
2155
|
+
* `min(1 MiB, writeBufferSize / 8)`.
|
|
2156
|
+
*/
|
|
2157
|
+
arenaBlockSize?: number;
|
|
2087
2158
|
/**
|
|
2088
2159
|
* The friendly name of a compression algorithm compiled into this RocksDB
|
|
2089
2160
|
* build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
|
|
@@ -2257,6 +2328,7 @@ type NativeDatabase = {
|
|
|
2257
2328
|
dropSync(): void;
|
|
2258
2329
|
flush(resolve: ResolveCallback<void>, reject: RejectCallback, options?: FlushOptions): void;
|
|
2259
2330
|
flushSync(options?: FlushOptions): void;
|
|
2331
|
+
syncWal(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
2260
2332
|
notify(event: string | BufferWithDataView, args?: any[]): boolean;
|
|
2261
2333
|
get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
|
|
2262
2334
|
estimateCount(startKey?: Buffer, endKey?: Buffer): {
|
|
@@ -2346,6 +2418,24 @@ type RocksDatabaseConfig = {
|
|
|
2346
2418
|
* concurrent `commitSync()` calls always have. Open databases keep their limit.
|
|
2347
2419
|
*/
|
|
2348
2420
|
commitThreads?: number;
|
|
2421
|
+
/**
|
|
2422
|
+
* Marks a transaction-log batch aborted in place (`TRANSACTION_LOG_ENTRY_ABORTED_FLAG` on its
|
|
2423
|
+
* first entry) when its transaction ends without committing after the batch was written, so
|
|
2424
|
+
* readers skip it. Off by default: with it off, behavior is unchanged. Turn it on only once every
|
|
2425
|
+
* reader of these logs (replicas, restores, repair tools) skips aborted batches; an older reader
|
|
2426
|
+
* shows an aborted batch as live. Read when a transaction starts and when it is reset for a
|
|
2427
|
+
* retry, so it can change at runtime.
|
|
2428
|
+
*/
|
|
2429
|
+
transactionLogAbortMarkers?: boolean;
|
|
2430
|
+
/**
|
|
2431
|
+
* With `transactionLogAbortMarkers` on, refuses a conflicting attempt before it writes its
|
|
2432
|
+
* transaction-log batch when an older transaction holds a write intent on one of its keys, and
|
|
2433
|
+
* (with `coordinatedRetry`) parks it until that holder ends. This bounds how long the losers of
|
|
2434
|
+
* heavily overlapping transactions wait, at the cost of more retries and less throughput when
|
|
2435
|
+
* transactions are large or contention is low. Off by default; no effect with abort markers off
|
|
2436
|
+
* or the verification table disabled. Read with `transactionLogAbortMarkers`.
|
|
2437
|
+
*/
|
|
2438
|
+
transactionLogWriteIntents?: boolean;
|
|
2349
2439
|
/**
|
|
2350
2440
|
* Number of slots in the process-global verification table. Each slot is
|
|
2351
2441
|
* 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
|
|
@@ -2394,7 +2484,27 @@ type RocksDatabaseConfig = {
|
|
|
2394
2484
|
* @default false
|
|
2395
2485
|
*/
|
|
2396
2486
|
writeBufferManagerAllowStall?: boolean;
|
|
2487
|
+
/**
|
|
2488
|
+
* Which memtable the WriteBufferManager flushes when it is over budget:
|
|
2489
|
+
*
|
|
2490
|
+
* - `'oldest'`: the oldest memtable of the database being written.
|
|
2491
|
+
* - `'largest'`: the largest memtable of the database being written. Because
|
|
2492
|
+
* this library opens databases with atomic flush, this currently behaves
|
|
2493
|
+
* like `'oldest'`.
|
|
2494
|
+
* - `'largestAcrossDBs'`: a background thread flushes whichever database
|
|
2495
|
+
* holds the most memtable memory, whether or not it is being written.
|
|
2496
|
+
*
|
|
2497
|
+
* When unset, `'largestAcrossDBs'` while `writeBufferManagerAllowStall` is
|
|
2498
|
+
* on (and following later changes to it), otherwise `'oldest'`. With stalls
|
|
2499
|
+
* allowed, `'oldest'` can stall writes permanently: a writer to one database
|
|
2500
|
+
* waits for memory held by other databases that nothing is writing to, so
|
|
2501
|
+
* nothing flushes them. Without stalls, `'largestAcrossDBs'` has measured
|
|
2502
|
+
* slower. Can be changed while databases are open; an explicit value stays
|
|
2503
|
+
* in effect for the life of the process.
|
|
2504
|
+
*/
|
|
2505
|
+
writeBufferManagerFlushPolicy?: WriteBufferManagerFlushPolicy;
|
|
2397
2506
|
};
|
|
2507
|
+
type WriteBufferManagerFlushPolicy = "oldest" | "largest" | "largestAcrossDBs";
|
|
2398
2508
|
type RegistryStatusTransaction = {
|
|
2399
2509
|
/** The transaction id assigned by the database descriptor. */
|
|
2400
2510
|
id: number;
|
|
@@ -2455,6 +2565,11 @@ type WriteBufferManagerStats = {
|
|
|
2455
2565
|
mutableMemoryUsage: number;
|
|
2456
2566
|
allowStall: boolean;
|
|
2457
2567
|
costToCache: boolean;
|
|
2568
|
+
/**
|
|
2569
|
+
* The flush policy in effect: the live manager's, or the one a manager would
|
|
2570
|
+
* be created with (see `writeBufferManagerFlushPolicy`).
|
|
2571
|
+
*/
|
|
2572
|
+
flushPolicy: WriteBufferManagerFlushPolicy;
|
|
2458
2573
|
stallActive: boolean;
|
|
2459
2574
|
/**
|
|
2460
2575
|
* How long the current stall has been active, in milliseconds; 0 when not
|
|
@@ -2537,6 +2652,10 @@ export declare const constants: {
|
|
|
2537
2652
|
RETRY_NOW_VALUE: number;
|
|
2538
2653
|
TRANSACTION_LOG_TOKEN: number;
|
|
2539
2654
|
TRANSACTION_LOG_ENTRY_HEADER_SIZE: number;
|
|
2655
|
+
TRANSACTION_LOG_ENTRY_LAST_FLAG: number;
|
|
2656
|
+
TRANSACTION_LOG_ENTRY_ABORTED_FLAG: number;
|
|
2657
|
+
/** 1 when the linked RocksDB exports the conflict check run before the log write. */
|
|
2658
|
+
PRELOG_CONFLICT_CHECK: number;
|
|
2540
2659
|
TRANSACTION_LOG_FILE_HEADER_SIZE: number;
|
|
2541
2660
|
ITERATOR_REVERSE_FLAG: number;
|
|
2542
2661
|
ITERATOR_INCLUSIVE_END_FLAG: number;
|
|
@@ -2547,6 +2666,7 @@ export declare const constants: {
|
|
|
2547
2666
|
ITERATOR_HAS_TRANSACTION_ID_FLAG: number;
|
|
2548
2667
|
ITERATOR_RESULT_DONE: number;
|
|
2549
2668
|
ITERATOR_RESULT_FAST: number;
|
|
2669
|
+
ITERATOR_RESULT_RELEASED: number;
|
|
2550
2670
|
};
|
|
2551
2671
|
/**
|
|
2552
2672
|
* The friendly names of every compression algorithm compiled into the loaded
|
|
@@ -2602,7 +2722,7 @@ export declare const currentThreadId: () => number;
|
|
|
2602
2722
|
* Reads the process-wide steady clock: `std::chrono::steady_clock` as
|
|
2603
2723
|
* fractional milliseconds from an unspecified origin that is fixed for the life
|
|
2604
2724
|
* of the process. Every sample in the process — main thread and every
|
|
2605
|
-
* `worker_threads` worker, whenever started or restarted, on Node
|
|
2725
|
+
* `worker_threads` worker, whenever started or restarted, on Node and Bun
|
|
2606
2726
|
* — is in one domain, and the difference between two samples is real elapsed
|
|
2607
2727
|
* time unaffected by wall-clock steps. Non-decreasing but not unique (two
|
|
2608
2728
|
* samples may be equal; treat `==` as "not later"). Windows QPC samples from
|
|
@@ -2658,8 +2778,6 @@ export declare const stats: {
|
|
|
2658
2778
|
All: number;
|
|
2659
2779
|
};
|
|
2660
2780
|
};
|
|
2661
|
-
//#endregion
|
|
2662
|
-
//#region src/backup-stream.d.ts
|
|
2663
2781
|
/**
|
|
2664
2782
|
* Options for streaming a backup via `db.backup(stream)`.
|
|
2665
2783
|
*/
|
|
@@ -2689,8 +2807,6 @@ interface BackupStreamOptions {
|
|
|
2689
2807
|
*/
|
|
2690
2808
|
transactionLogs?: boolean;
|
|
2691
2809
|
}
|
|
2692
|
-
//#endregion
|
|
2693
|
-
//#region src/count-estimator.d.ts
|
|
2694
2810
|
interface CountEstimatorOptions extends CountEstimateOptions {}
|
|
2695
2811
|
/**
|
|
2696
2812
|
* Progressively refines a range key-count estimate as an iterator traverses
|
|
@@ -2740,8 +2856,6 @@ export declare class CountEstimator {
|
|
|
2740
2856
|
*/
|
|
2741
2857
|
estimate(): CountEstimate;
|
|
2742
2858
|
}
|
|
2743
|
-
//#endregion
|
|
2744
|
-
//#region src/database.d.ts
|
|
2745
2859
|
type TransactionCallback<T> = (txn: Transaction, attempt: number) => T | PromiseLike<T>;
|
|
2746
2860
|
interface RocksDatabaseOptions extends StoreOptions {
|
|
2747
2861
|
/**
|
|
@@ -2761,7 +2875,8 @@ interface TransactionOptions extends NativeTransactionOptions {
|
|
|
2761
2875
|
/**
|
|
2762
2876
|
* Whether to retry the transaction if it fails with `IsBusy`.
|
|
2763
2877
|
*
|
|
2764
|
-
* @default `true` when the transaction
|
|
2878
|
+
* @default `true` when the transaction wrote a transaction-log batch or was refused before
|
|
2879
|
+
* writing one (`refusedBeforeLog`), otherwise `false`
|
|
2765
2880
|
*/
|
|
2766
2881
|
retryOnBusy?: boolean;
|
|
2767
2882
|
}
|
|
@@ -3094,6 +3209,17 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
3094
3209
|
* @return {void} Does not return a value.
|
|
3095
3210
|
*/
|
|
3096
3211
|
flushSync(options?: FlushOptions): void;
|
|
3212
|
+
/**
|
|
3213
|
+
* Syncs the write-ahead log to stable storage (`DB::SyncWAL`), so every WAL-backed write
|
|
3214
|
+
* committed before the call survives a power loss afterwards. Unlike {@link flush} it writes
|
|
3215
|
+
* no SST file and never stalls writers. Not covered: writes that skipped the WAL
|
|
3216
|
+
* (`disableWAL`), and transaction-log files, which keep their own durability. Runs on the
|
|
3217
|
+
* libuv threadpool; RocksDB serializes concurrent syncs of one WAL, so keep one in flight
|
|
3218
|
+
* per database rather than parking pool workers on a queue of them.
|
|
3219
|
+
*
|
|
3220
|
+
* On a read-only database the returned promise resolves without syncing.
|
|
3221
|
+
*/
|
|
3222
|
+
syncWal(): Promise<void>;
|
|
3097
3223
|
/**
|
|
3098
3224
|
* Returns the most recent {@link BackgroundError} observed on this database, or
|
|
3099
3225
|
* `null` when none has occurred. The `'error'` event is the push counterpart;
|
|
@@ -3564,8 +3690,6 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
3564
3690
|
*/
|
|
3565
3691
|
withLock(key: Key, callback: () => void | Promise<void>): Promise<void> | undefined;
|
|
3566
3692
|
}
|
|
3567
|
-
//#endregion
|
|
3568
|
-
//#region src/parse-transaction-log.d.ts
|
|
3569
3693
|
interface LogEntry {
|
|
3570
3694
|
anomalies?: string[];
|
|
3571
3695
|
data?: Buffer;
|
|
@@ -3589,8 +3713,6 @@ interface TransactionLog$1 {
|
|
|
3589
3713
|
export declare function parseTransactionLog(path: string, options?: {
|
|
3590
3714
|
skipData?: boolean;
|
|
3591
3715
|
}): TransactionLog$1;
|
|
3592
|
-
//#endregion
|
|
3593
|
-
//#region src/transaction-log-reader.d.ts
|
|
3594
3716
|
/**
|
|
3595
3717
|
* Thrown when an entry's framing is broken. `resyncPosition` is the offset where valid framing
|
|
3596
3718
|
* resumes, when one was found: the frames after a mid-log break are intact and reachable, and
|
|
@@ -3611,12 +3733,29 @@ export declare class CorruptFrameError extends RangeError {
|
|
|
3611
3733
|
unreadableBytes: number;
|
|
3612
3734
|
constructor(message: string, logId: number, position: number, resyncPosition: number | undefined);
|
|
3613
3735
|
}
|
|
3614
|
-
|
|
3615
|
-
|
|
3736
|
+
/**
|
|
3737
|
+
* Thrown when an iterator advances past segments it never read and that can no longer be read —
|
|
3738
|
+
* typically ones retention purged while the reader lagged. The entries they held cannot be
|
|
3739
|
+
* recovered from this log, so a consumer replicating it must not treat the stream as contiguous.
|
|
3740
|
+
* Missing sequence numbers prove only that continuity is unknown, not that each held entries.
|
|
3741
|
+
*
|
|
3742
|
+
* The iterator is left positioned at the start of `resumeLogId`, so a caller that accepts the
|
|
3743
|
+
* discontinuity calls `next()` again to continue from there.
|
|
3744
|
+
*
|
|
3745
|
+
* Not a `RangeError`: this is not broken framing, and consumers classify those by class.
|
|
3746
|
+
*/
|
|
3747
|
+
export declare class TransactionLogGapError extends Error {
|
|
3748
|
+
/** Sequence number of the last segment this iterator read up to. */
|
|
3749
|
+
logId: number;
|
|
3750
|
+
/** Sequence number of the segment iteration resumes in. */
|
|
3751
|
+
resumeLogId: number;
|
|
3752
|
+
/** Segments between `logId` and `resumeLogId` that could not be read. Empty segments are not counted. */
|
|
3753
|
+
unavailableLogCount: number;
|
|
3754
|
+
constructor(logId: number, resumeLogId: number, unavailableLogCount: number);
|
|
3755
|
+
}
|
|
3616
3756
|
export declare const versions: {
|
|
3617
3757
|
rocksdb: string;
|
|
3618
3758
|
"rocksdb-js": string;
|
|
3619
3759
|
};
|
|
3620
|
-
|
|
3621
|
-
export type { BackgroundErrorOptions, BackupInfo, BackupOptions, BackupStreamOptions, CompressionAlgorithm, CompressionInfo, CompressionOption, CountEstimate, CountEstimateOptions, CountEstimatorOptions, FlushOptions, GetStatsMethod, IteratorOptions, Key, LogOptions, RestoreMode, RestoreOptions, RocksDBStat, RocksDBStats, RocksDatabaseOptions, StatsAll, StatsAllExtras, StatsBasics, StatsCurated, StatsCuratedExtras, StatsDefault, StatsHistogramData, StatsValue, StoreContext, StoreGetOptions, StoreIteratorOptions, StorePutOptions, StoreRangeOptions, StoreRemoveOptions, TransactionEntry, TransactionLogFileValidation, TransactionLogPosition, TransactionLogStats, TransactionLogStoreValidation, ValidateTransactionLogStoreOptions, WriteBufferManagerStats };
|
|
3760
|
+
export type { BackgroundErrorOptions, BackupInfo, BackupOptions, BackupStreamOptions, CompressionAlgorithm, CompressionInfo, CompressionOption, CountEstimate, CountEstimateOptions, CountEstimatorOptions, FlushOptions, GetStatsMethod, IteratorOptions, Key, LogOptions, RestoreMode, RestoreOptions, RocksDBStat, RocksDBStats, RocksDatabaseOptions, StatsAll, StatsAllExtras, StatsBasics, StatsCurated, StatsCuratedExtras, StatsDefault, StatsHistogramData, StatsValue, StoreContext, StoreGetOptions, StoreIteratorOptions, StorePutOptions, StoreRangeOptions, StoreRemoveOptions, TransactionEntry, TransactionLogFileValidation, TransactionLogPosition, TransactionLogStats, TransactionLogStoreValidation, ValidateTransactionLogStoreOptions, WriteBufferManagerFlushPolicy, WriteBufferManagerStats };
|
|
3622
3761
|
//# sourceMappingURL=index.d.cts.map
|