@harperfast/rocksdb-js 2.12.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 +133 -11
- package/dist/index.cjs +311 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +168 -39
- package/dist/index.d.mts +168 -39
- package/dist/index.mjs +309 -66
- package/dist/index.mjs.map +1 -1
- package/docs/performance/mutex-contention.md +4 -3
- package/docs/stats.md +4 -0
- package/docs/steady-clock-design.md +1 -1
- package/docs/transaction-log.md +5 -4
- package/package.json +16 -16
package/dist/index.d.mts
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
|
*
|
|
@@ -198,9 +197,7 @@ export declare const backups: {
|
|
|
198
197
|
verifyTransactionLogs?: boolean;
|
|
199
198
|
}): Promise<void>;
|
|
200
199
|
};
|
|
201
|
-
|
|
202
|
-
//#region src/encoding.d.ts
|
|
203
|
-
type Key = Key[] | string | symbol | number | boolean | Uint8Array | Buffer | null;
|
|
200
|
+
type Key = Key[] | string | symbol | number | bigint | boolean | Uint8Array | Buffer | null;
|
|
204
201
|
interface BufferWithDataView extends Buffer {
|
|
205
202
|
dataView: DataView;
|
|
206
203
|
start: number;
|
|
@@ -228,8 +225,6 @@ type Encoding = "binary" | "ordered-binary" | "msgpack" | false;
|
|
|
228
225
|
type KeyEncoding = "binary" | "ordered-binary" | "uint32";
|
|
229
226
|
type ReadKeyFunction<T> = (source: BufferWithDataView, start: number, end?: number) => T;
|
|
230
227
|
type WriteKeyFunction = (key: Key, target: BufferWithDataView, start: number) => number;
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/dbi-iterator.d.ts
|
|
233
228
|
interface DBIteratorValue<T> {
|
|
234
229
|
key: Key;
|
|
235
230
|
value: T;
|
|
@@ -247,14 +242,12 @@ export declare class DBIterator<T> implements Iterator<DBIteratorValue<T>> {
|
|
|
247
242
|
#private;
|
|
248
243
|
iterator: InstanceType<typeof NativeIteratorCls>;
|
|
249
244
|
store: Store;
|
|
250
|
-
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);
|
|
251
246
|
[Symbol.iterator](): Iterator<DBIteratorValue<T>>;
|
|
252
247
|
next(): IteratorResult<DBIteratorValue<T>>;
|
|
253
248
|
return(value?: any): IteratorResult<DBIteratorValue<T>, any>;
|
|
254
249
|
throw(err: unknown): IteratorResult<DBIteratorValue<T>, any>;
|
|
255
250
|
}
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/store.d.ts
|
|
258
251
|
type StoreContext = NativeDatabase | NativeTransaction;
|
|
259
252
|
type StoreGetOptions = GetOptions & DBITransactional;
|
|
260
253
|
type StoreIteratorOptions = IteratorOptions & DBITransactional;
|
|
@@ -685,6 +678,10 @@ export declare class Store {
|
|
|
685
678
|
* sealed and flushed.
|
|
686
679
|
*/
|
|
687
680
|
writeBufferSize?: number;
|
|
681
|
+
/**
|
|
682
|
+
* The memtable arena block size in bytes; `0` or unset is automatic.
|
|
683
|
+
*/
|
|
684
|
+
arenaBlockSize?: number;
|
|
688
685
|
/**
|
|
689
686
|
* The function used to encode keys using the shared `keyBuffer`.
|
|
690
687
|
*/
|
|
@@ -921,8 +918,6 @@ interface PutOptions {
|
|
|
921
918
|
noDupData?: boolean;
|
|
922
919
|
noOverwrite?: boolean;
|
|
923
920
|
}
|
|
924
|
-
//#endregion
|
|
925
|
-
//#region src/transaction.d.ts
|
|
926
921
|
/**
|
|
927
922
|
* Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
|
|
928
923
|
* transaction encountered an IsBusy conflict. The native layer parks on VT
|
|
@@ -930,6 +925,35 @@ interface PutOptions {
|
|
|
930
925
|
* intent, so callers should retry immediately without any backoff delay.
|
|
931
926
|
*/
|
|
932
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
|
+
};
|
|
933
957
|
/**
|
|
934
958
|
* Provides transaction level operations to a transaction callback.
|
|
935
959
|
*/
|
|
@@ -975,6 +999,22 @@ export declare class Transaction extends DBI {
|
|
|
975
999
|
* @returns The transaction timestamp in milliseconds.
|
|
976
1000
|
*/
|
|
977
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;
|
|
978
1018
|
/**
|
|
979
1019
|
* Get the transaction id.
|
|
980
1020
|
*/
|
|
@@ -991,11 +1031,7 @@ export declare class Transaction extends DBI {
|
|
|
991
1031
|
*/
|
|
992
1032
|
setTimestamp(timestamp?: number): void;
|
|
993
1033
|
}
|
|
994
|
-
//#endregion
|
|
995
|
-
//#region src/util.d.ts
|
|
996
1034
|
type MaybePromise<T> = T | Promise<T>;
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region src/dbi.d.ts
|
|
999
1035
|
interface RocksDBOptions {
|
|
1000
1036
|
/**
|
|
1001
1037
|
* When `true`, RocksDB will do some enhancements for prefetching the data.
|
|
@@ -1333,8 +1369,6 @@ export declare class DBI<T extends DBITransactional | unknown = unknown> {
|
|
|
1333
1369
|
*/
|
|
1334
1370
|
useLog(name: string | number): TransactionLog;
|
|
1335
1371
|
}
|
|
1336
|
-
//#endregion
|
|
1337
|
-
//#region src/stats.d.ts
|
|
1338
1372
|
/**
|
|
1339
1373
|
* Database-level RocksDB statistics types for `db.getStats()` / `db.getStat()`.
|
|
1340
1374
|
*
|
|
@@ -1675,6 +1709,10 @@ type StatsAllExtras = {
|
|
|
1675
1709
|
"rocksdb.checkpoint.read.bytes": number;
|
|
1676
1710
|
"rocksdb.checkpoint.write.bytes": number;
|
|
1677
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;
|
|
1678
1716
|
"rocksdb.compaction.times.cpu_micros": StatsHistogramData;
|
|
1679
1717
|
"rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
|
|
1680
1718
|
"rocksdb.table.sync.micros": StatsHistogramData;
|
|
@@ -1757,8 +1795,6 @@ interface GetStatsMethod {
|
|
|
1757
1795
|
getStats(all?: false): StatsDefault;
|
|
1758
1796
|
getStats(all: true): StatsAll;
|
|
1759
1797
|
}
|
|
1760
|
-
//#endregion
|
|
1761
|
-
//#region src/validate-transaction-log.d.ts
|
|
1762
1798
|
/**
|
|
1763
1799
|
* The validation result for a single transaction log file within a store, as
|
|
1764
1800
|
* returned by {@link validateTransactionLogStore}.
|
|
@@ -1865,8 +1901,6 @@ interface ValidateTransactionLogStoreOptions {
|
|
|
1865
1901
|
* ```
|
|
1866
1902
|
*/
|
|
1867
1903
|
export declare function validateTransactionLogStore(path: string, options?: ValidateTransactionLogStoreOptions): Promise<TransactionLogStoreValidation>;
|
|
1868
|
-
//#endregion
|
|
1869
|
-
//#region src/load-binding.d.ts
|
|
1870
1904
|
/**
|
|
1871
1905
|
* The `Error` subclass passed to `'error'` event listeners and returned by
|
|
1872
1906
|
* `db.getLastError()` when RocksDB reports a background error (e.g. a write
|
|
@@ -1960,9 +1994,13 @@ type NativeTransaction = {
|
|
|
1960
1994
|
getCount(options?: RangeOptions): number;
|
|
1961
1995
|
getSync(keyLengthOrKeyBuffer: number | Buffer): Buffer | number | undefined;
|
|
1962
1996
|
getTimestamp(): number;
|
|
1997
|
+
lastConflictKind(): number;
|
|
1998
|
+
logWritten(): boolean;
|
|
1963
1999
|
putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
|
|
1964
2000
|
removeSync(key: Key): void;
|
|
2001
|
+
setParkDeadline(deadline: number): void;
|
|
1965
2002
|
setTimestamp(timestamp?: number): void;
|
|
2003
|
+
trimIterators(): void;
|
|
1966
2004
|
useLog(name: string | number, jsDatabase: NativeDatabase): TransactionLog;
|
|
1967
2005
|
};
|
|
1968
2006
|
type LogBuffer = Buffer & {
|
|
@@ -2038,6 +2076,16 @@ type TransactionLogStats = {
|
|
|
2038
2076
|
purgeRuns: number;
|
|
2039
2077
|
databaseFlushes: number;
|
|
2040
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;
|
|
2041
2089
|
};
|
|
2042
2090
|
config: {
|
|
2043
2091
|
maxFileSize: number;
|
|
@@ -2055,11 +2103,13 @@ export type TransactionLog = {
|
|
|
2055
2103
|
query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
|
|
2056
2104
|
_currentLogBuffer: WeakRef<LogBuffer> | undefined;
|
|
2057
2105
|
_findPosition(timestamp: number): number;
|
|
2106
|
+
_findExactStart(timestamp: number, span: Float64Array): number;
|
|
2058
2107
|
_getLastCommittedPosition(): Buffer;
|
|
2059
2108
|
_getLastFlushed(): number;
|
|
2060
2109
|
_getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
|
|
2061
2110
|
_lastCommittedPosition: Float64Array;
|
|
2062
2111
|
_nextLogId(sequenceId: number): number;
|
|
2112
|
+
_segmentRemovals(): number;
|
|
2063
2113
|
_logBuffers: Map<number, WeakRef<LogBuffer>>;
|
|
2064
2114
|
};
|
|
2065
2115
|
/**
|
|
@@ -2089,11 +2139,22 @@ type NativeIteratorResult = number | {
|
|
|
2089
2139
|
declare class NativeIteratorCls {
|
|
2090
2140
|
constructor(context: StoreContext, flags: number, startKeyEnd: number, endKeyStart: number, endKeyEnd: number, options?: NativeIteratorAdvancedOptions, transactionId?: number);
|
|
2091
2141
|
next(): NativeIteratorResult;
|
|
2092
|
-
|
|
2093
|
-
|
|
2142
|
+
/** Returns whether the native iterator went back to its transaction's pool. */
|
|
2143
|
+
return(): boolean;
|
|
2144
|
+
throw(err?: unknown): boolean;
|
|
2094
2145
|
}
|
|
2095
2146
|
type NativeDatabaseMode = "optimistic" | "pessimistic";
|
|
2096
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;
|
|
2097
2158
|
/**
|
|
2098
2159
|
* The friendly name of a compression algorithm compiled into this RocksDB
|
|
2099
2160
|
* build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
|
|
@@ -2267,6 +2328,7 @@ type NativeDatabase = {
|
|
|
2267
2328
|
dropSync(): void;
|
|
2268
2329
|
flush(resolve: ResolveCallback<void>, reject: RejectCallback, options?: FlushOptions): void;
|
|
2269
2330
|
flushSync(options?: FlushOptions): void;
|
|
2331
|
+
syncWal(resolve: ResolveCallback<void>, reject: RejectCallback): void;
|
|
2270
2332
|
notify(event: string | BufferWithDataView, args?: any[]): boolean;
|
|
2271
2333
|
get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
|
|
2272
2334
|
estimateCount(startKey?: Buffer, endKey?: Buffer): {
|
|
@@ -2356,6 +2418,24 @@ type RocksDatabaseConfig = {
|
|
|
2356
2418
|
* concurrent `commitSync()` calls always have. Open databases keep their limit.
|
|
2357
2419
|
*/
|
|
2358
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;
|
|
2359
2439
|
/**
|
|
2360
2440
|
* Number of slots in the process-global verification table. Each slot is
|
|
2361
2441
|
* 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
|
|
@@ -2404,7 +2484,27 @@ type RocksDatabaseConfig = {
|
|
|
2404
2484
|
* @default false
|
|
2405
2485
|
*/
|
|
2406
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;
|
|
2407
2506
|
};
|
|
2507
|
+
type WriteBufferManagerFlushPolicy = "oldest" | "largest" | "largestAcrossDBs";
|
|
2408
2508
|
type RegistryStatusTransaction = {
|
|
2409
2509
|
/** The transaction id assigned by the database descriptor. */
|
|
2410
2510
|
id: number;
|
|
@@ -2465,6 +2565,11 @@ type WriteBufferManagerStats = {
|
|
|
2465
2565
|
mutableMemoryUsage: number;
|
|
2466
2566
|
allowStall: boolean;
|
|
2467
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;
|
|
2468
2573
|
stallActive: boolean;
|
|
2469
2574
|
/**
|
|
2470
2575
|
* How long the current stall has been active, in milliseconds; 0 when not
|
|
@@ -2547,6 +2652,10 @@ export declare const constants: {
|
|
|
2547
2652
|
RETRY_NOW_VALUE: number;
|
|
2548
2653
|
TRANSACTION_LOG_TOKEN: number;
|
|
2549
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;
|
|
2550
2659
|
TRANSACTION_LOG_FILE_HEADER_SIZE: number;
|
|
2551
2660
|
ITERATOR_REVERSE_FLAG: number;
|
|
2552
2661
|
ITERATOR_INCLUSIVE_END_FLAG: number;
|
|
@@ -2557,6 +2666,7 @@ export declare const constants: {
|
|
|
2557
2666
|
ITERATOR_HAS_TRANSACTION_ID_FLAG: number;
|
|
2558
2667
|
ITERATOR_RESULT_DONE: number;
|
|
2559
2668
|
ITERATOR_RESULT_FAST: number;
|
|
2669
|
+
ITERATOR_RESULT_RELEASED: number;
|
|
2560
2670
|
};
|
|
2561
2671
|
/**
|
|
2562
2672
|
* The friendly names of every compression algorithm compiled into the loaded
|
|
@@ -2612,7 +2722,7 @@ export declare const currentThreadId: () => number;
|
|
|
2612
2722
|
* Reads the process-wide steady clock: `std::chrono::steady_clock` as
|
|
2613
2723
|
* fractional milliseconds from an unspecified origin that is fixed for the life
|
|
2614
2724
|
* of the process. Every sample in the process — main thread and every
|
|
2615
|
-
* `worker_threads` worker, whenever started or restarted, on Node
|
|
2725
|
+
* `worker_threads` worker, whenever started or restarted, on Node and Bun
|
|
2616
2726
|
* — is in one domain, and the difference between two samples is real elapsed
|
|
2617
2727
|
* time unaffected by wall-clock steps. Non-decreasing but not unique (two
|
|
2618
2728
|
* samples may be equal; treat `==` as "not later"). Windows QPC samples from
|
|
@@ -2668,8 +2778,6 @@ export declare const stats: {
|
|
|
2668
2778
|
All: number;
|
|
2669
2779
|
};
|
|
2670
2780
|
};
|
|
2671
|
-
//#endregion
|
|
2672
|
-
//#region src/backup-stream.d.ts
|
|
2673
2781
|
/**
|
|
2674
2782
|
* Options for streaming a backup via `db.backup(stream)`.
|
|
2675
2783
|
*/
|
|
@@ -2699,8 +2807,6 @@ interface BackupStreamOptions {
|
|
|
2699
2807
|
*/
|
|
2700
2808
|
transactionLogs?: boolean;
|
|
2701
2809
|
}
|
|
2702
|
-
//#endregion
|
|
2703
|
-
//#region src/count-estimator.d.ts
|
|
2704
2810
|
interface CountEstimatorOptions extends CountEstimateOptions {}
|
|
2705
2811
|
/**
|
|
2706
2812
|
* Progressively refines a range key-count estimate as an iterator traverses
|
|
@@ -2750,8 +2856,6 @@ export declare class CountEstimator {
|
|
|
2750
2856
|
*/
|
|
2751
2857
|
estimate(): CountEstimate;
|
|
2752
2858
|
}
|
|
2753
|
-
//#endregion
|
|
2754
|
-
//#region src/database.d.ts
|
|
2755
2859
|
type TransactionCallback<T> = (txn: Transaction, attempt: number) => T | PromiseLike<T>;
|
|
2756
2860
|
interface RocksDatabaseOptions extends StoreOptions {
|
|
2757
2861
|
/**
|
|
@@ -2771,7 +2875,8 @@ interface TransactionOptions extends NativeTransactionOptions {
|
|
|
2771
2875
|
/**
|
|
2772
2876
|
* Whether to retry the transaction if it fails with `IsBusy`.
|
|
2773
2877
|
*
|
|
2774
|
-
* @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`
|
|
2775
2880
|
*/
|
|
2776
2881
|
retryOnBusy?: boolean;
|
|
2777
2882
|
}
|
|
@@ -3104,6 +3209,17 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
3104
3209
|
* @return {void} Does not return a value.
|
|
3105
3210
|
*/
|
|
3106
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>;
|
|
3107
3223
|
/**
|
|
3108
3224
|
* Returns the most recent {@link BackgroundError} observed on this database, or
|
|
3109
3225
|
* `null` when none has occurred. The `'error'` event is the push counterpart;
|
|
@@ -3574,8 +3690,6 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
|
|
|
3574
3690
|
*/
|
|
3575
3691
|
withLock(key: Key, callback: () => void | Promise<void>): Promise<void> | undefined;
|
|
3576
3692
|
}
|
|
3577
|
-
//#endregion
|
|
3578
|
-
//#region src/parse-transaction-log.d.ts
|
|
3579
3693
|
interface LogEntry {
|
|
3580
3694
|
anomalies?: string[];
|
|
3581
3695
|
data?: Buffer;
|
|
@@ -3599,8 +3713,6 @@ interface TransactionLog$1 {
|
|
|
3599
3713
|
export declare function parseTransactionLog(path: string, options?: {
|
|
3600
3714
|
skipData?: boolean;
|
|
3601
3715
|
}): TransactionLog$1;
|
|
3602
|
-
//#endregion
|
|
3603
|
-
//#region src/transaction-log-reader.d.ts
|
|
3604
3716
|
/**
|
|
3605
3717
|
* Thrown when an entry's framing is broken. `resyncPosition` is the offset where valid framing
|
|
3606
3718
|
* resumes, when one was found: the frames after a mid-log break are intact and reachable, and
|
|
@@ -3621,12 +3733,29 @@ export declare class CorruptFrameError extends RangeError {
|
|
|
3621
3733
|
unreadableBytes: number;
|
|
3622
3734
|
constructor(message: string, logId: number, position: number, resyncPosition: number | undefined);
|
|
3623
3735
|
}
|
|
3624
|
-
|
|
3625
|
-
|
|
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
|
+
}
|
|
3626
3756
|
export declare const versions: {
|
|
3627
3757
|
rocksdb: string;
|
|
3628
3758
|
"rocksdb-js": string;
|
|
3629
3759
|
};
|
|
3630
|
-
|
|
3631
|
-
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 };
|
|
3632
3761
|
//# sourceMappingURL=index.d.mts.map
|