@harperfast/rocksdb-js 2.12.0 → 2.14.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/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
  *
@@ -198,9 +197,7 @@ export declare const backups: {
198
197
  verifyTransactionLogs?: boolean;
199
198
  }): Promise<void>;
200
199
  };
201
- //#endregion
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,14 @@ 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;
685
+ /**
686
+ * Bits per key of the whole-key filter in each SST; `0` disables filters.
687
+ */
688
+ bloomFilterBitsPerKey?: number;
688
689
  /**
689
690
  * The function used to encode keys using the shared `keyBuffer`.
690
691
  */
@@ -904,6 +905,9 @@ interface GetOptions {
904
905
  * When `true`, after a DB read the native layer automatically seeds the
905
906
  * verification-table slot with the version extracted from the value.
906
907
  * Eliminates the need for a separate `populateVersion` call on cold reads.
908
+ * Seeds nothing unless this handle participates in the verification
909
+ * table: opened with `verificationTable: true`, or opened without the
910
+ * option on a column family another handle opened with it.
907
911
  *
908
912
  * @default false
909
913
  */
@@ -921,8 +925,6 @@ interface PutOptions {
921
925
  noDupData?: boolean;
922
926
  noOverwrite?: boolean;
923
927
  }
924
- //#endregion
925
- //#region src/transaction.d.ts
926
928
  /**
927
929
  * Sentinel value returned by `commit()` when `coordinatedRetry: true` and the
928
930
  * transaction encountered an IsBusy conflict. The native layer parks on VT
@@ -930,6 +932,35 @@ interface PutOptions {
930
932
  * intent, so callers should retry immediately without any backoff delay.
931
933
  */
932
934
  declare const RETRY_NOW: number;
935
+ /**
936
+ * `abort()` of a transaction whose transaction-log batch could not be marked aborted
937
+ * (`transactionLogAbortMarkers`). The batch stays unresolved, so committed readers do not pass it and
938
+ * the log store refuses appends, until a retry on the next append, database flush or store close
939
+ * marks it.
940
+ */
941
+ export declare class TransactionAbortUnresolvedError extends Error {
942
+ readonly code = "ERR_TRANSACTION_ABORT_UNRESOLVED";
943
+ readonly txn: Transaction;
944
+ constructor(error: Error, txn: Transaction);
945
+ }
946
+ /**
947
+ * Why a transaction's most recent attempt was refused or retried, from {@link Transaction.lastConflictKind}.
948
+ */
949
+ export declare const ConflictKind: {
950
+ readonly none: 0;
951
+ /** Refused on an older transaction's write intent before writing its log batch. */
952
+ readonly intentBeforeLog: 1;
953
+ /** Refused on an older transaction's write intent after its log batch was written. */
954
+ readonly intentAfterLog: 2;
955
+ /** RocksDB found a conflict at commit. */
956
+ readonly atCommit: 3;
957
+ /**
958
+ * RocksDB's conflict check, run before the log write, found a write that already committed, or,
959
+ * as at commit, could not validate because the memtable history it needs was flushed (needs a
960
+ * RocksDB build that exports the check).
961
+ */
962
+ readonly checkBeforeLog: 4;
963
+ };
933
964
  /**
934
965
  * Provides transaction level operations to a transaction callback.
935
966
  */
@@ -975,6 +1006,22 @@ export declare class Transaction extends DBI {
975
1006
  * @returns The transaction timestamp in milliseconds.
976
1007
  */
977
1008
  getTimestamp(): number;
1009
+ /**
1010
+ * Whether this transaction's batch is in the transaction log. A commit conflict after the batch
1011
+ * was written keeps it for the retry, which must not stage it again; an attempt refused before
1012
+ * writing it (`refusedBeforeLog`) leaves nothing.
1013
+ */
1014
+ logWritten(): boolean;
1015
+ /**
1016
+ * Why the most recent attempt was refused or retried; one of {@link ConflictKind}.
1017
+ */
1018
+ lastConflictKind(): number;
1019
+ /**
1020
+ * Bounds coordinated-retry parks: past `deadline` (epoch milliseconds) a parked commit resolves
1021
+ * `RETRY_NOW` at once, so a caller enforcing its own deadline can abort instead of waiting out
1022
+ * the default park bound. 0 clears it.
1023
+ */
1024
+ setParkDeadline(deadline: number): void;
978
1025
  /**
979
1026
  * Get the transaction id.
980
1027
  */
@@ -991,11 +1038,7 @@ export declare class Transaction extends DBI {
991
1038
  */
992
1039
  setTimestamp(timestamp?: number): void;
993
1040
  }
994
- //#endregion
995
- //#region src/util.d.ts
996
1041
  type MaybePromise<T> = T | Promise<T>;
997
- //#endregion
998
- //#region src/dbi.d.ts
999
1042
  interface RocksDBOptions {
1000
1043
  /**
1001
1044
  * When `true`, RocksDB will do some enhancements for prefetching the data.
@@ -1333,8 +1376,6 @@ export declare class DBI<T extends DBITransactional | unknown = unknown> {
1333
1376
  */
1334
1377
  useLog(name: string | number): TransactionLog;
1335
1378
  }
1336
- //#endregion
1337
- //#region src/stats.d.ts
1338
1379
  /**
1339
1380
  * Database-level RocksDB statistics types for `db.getStats()` / `db.getStat()`.
1340
1381
  *
@@ -1675,6 +1716,10 @@ type StatsAllExtras = {
1675
1716
  "rocksdb.checkpoint.read.bytes": number;
1676
1717
  "rocksdb.checkpoint.write.bytes": number;
1677
1718
  "rocksdb.file.submit.async.read.fallback": number;
1719
+ "rocksdb.blobdb.lazy.read.count": number;
1720
+ "rocksdb.blobdb.lazy.read.bytes": number;
1721
+ "rocksdb.blobdb.lazy.partial.read.count": number;
1722
+ "rocksdb.blobdb.lazy.partial.bytes.saved": number;
1678
1723
  "rocksdb.compaction.times.cpu_micros": StatsHistogramData;
1679
1724
  "rocksdb.subcompaction.setup.times.micros": StatsHistogramData;
1680
1725
  "rocksdb.table.sync.micros": StatsHistogramData;
@@ -1757,8 +1802,6 @@ interface GetStatsMethod {
1757
1802
  getStats(all?: false): StatsDefault;
1758
1803
  getStats(all: true): StatsAll;
1759
1804
  }
1760
- //#endregion
1761
- //#region src/validate-transaction-log.d.ts
1762
1805
  /**
1763
1806
  * The validation result for a single transaction log file within a store, as
1764
1807
  * returned by {@link validateTransactionLogStore}.
@@ -1865,8 +1908,6 @@ interface ValidateTransactionLogStoreOptions {
1865
1908
  * ```
1866
1909
  */
1867
1910
  export declare function validateTransactionLogStore(path: string, options?: ValidateTransactionLogStoreOptions): Promise<TransactionLogStoreValidation>;
1868
- //#endregion
1869
- //#region src/load-binding.d.ts
1870
1911
  /**
1871
1912
  * The `Error` subclass passed to `'error'` event listeners and returned by
1872
1913
  * `db.getLastError()` when RocksDB reports a background error (e.g. a write
@@ -1956,13 +1997,17 @@ type NativeTransaction = {
1956
1997
  abort(): void;
1957
1998
  commit(resolve: (retrySignal?: number) => void, reject: (err: Error) => void): void;
1958
1999
  commitSync(): void;
1959
- get(keyLengthOrKeyBuffer: number | Buffer, resolve: (value: Buffer | number) => void, reject: (err: Error) => void, txnIdIgnored?: number, expectedVersion?: number): number;
2000
+ get(keyLengthOrKeyBuffer: number | Buffer, resolve: (value: Buffer | number) => void, reject: (err: Error) => void, txnIdIgnored?: number, expectedVersion?: number, flags?: number): number;
1960
2001
  getCount(options?: RangeOptions): number;
1961
2002
  getSync(keyLengthOrKeyBuffer: number | Buffer): Buffer | number | undefined;
1962
2003
  getTimestamp(): number;
2004
+ lastConflictKind(): number;
2005
+ logWritten(): boolean;
1963
2006
  putSync(key: Key, value: Buffer | Uint8Array, txnId?: number): void;
1964
2007
  removeSync(key: Key): void;
2008
+ setParkDeadline(deadline: number): void;
1965
2009
  setTimestamp(timestamp?: number): void;
2010
+ trimIterators(): void;
1966
2011
  useLog(name: string | number, jsDatabase: NativeDatabase): TransactionLog;
1967
2012
  };
1968
2013
  type LogBuffer = Buffer & {
@@ -1978,7 +2023,20 @@ type TransactionLogQueryOptions = {
1978
2023
  startFromLastFlushed?: boolean;
1979
2024
  readUncommitted?: boolean;
1980
2025
  exclusiveStart?: boolean;
2026
+ /**
2027
+ * Stop before this same-log iterator's unread position, including a peeked entry.
2028
+ * Resumes when it advances; a closed iterator no longer bounds this query.
2029
+ * A pull short of the bound throws TransactionLogUntilUnreachedError.
2030
+ * Invalid or foreign-log iterators throw TypeError at query creation.
2031
+ */
2032
+ until?: TransactionLogIterator;
1981
2033
  };
2034
+ interface TransactionLogIterator extends IterableIterator<TransactionEntry> {
2035
+ /** Inspect the next entry without consuming it. A done result is never cached. */
2036
+ peek(): IteratorResult<TransactionEntry>;
2037
+ /** Permanently end this iterator and release any iterators bounded by it. */
2038
+ close(): void;
2039
+ }
1982
2040
  type TransactionEntry = {
1983
2041
  timestamp: number;
1984
2042
  data: Buffer;
@@ -2038,6 +2096,16 @@ type TransactionLogStats = {
2038
2096
  purgeRuns: number;
2039
2097
  databaseFlushes: number;
2040
2098
  writeFailures: number;
2099
+ /** Batches marked aborted (`transactionLogAbortMarkers`). */
2100
+ abortsMarked: number;
2101
+ /** Abort marker writes or syncs that failed; each leaves its batch unresolved until a retry. */
2102
+ abortMarkFailures: number;
2103
+ /**
2104
+ * Microseconds logged batches held the committed-read watermark back after their first commit
2105
+ * conflict, until they committed or ended; `pinnedTransactions` counts those batches.
2106
+ */
2107
+ watermarkPinnedUs: number;
2108
+ pinnedTransactions: number;
2041
2109
  };
2042
2110
  config: {
2043
2111
  maxFileSize: number;
@@ -2045,21 +2113,42 @@ type TransactionLogStats = {
2045
2113
  maxAgeThreshold: number;
2046
2114
  };
2047
2115
  };
2116
+ /**
2117
+ * Returned by {@link TransactionLog.getPurgeWatermark}. When `known`, `purgedThrough` is at or above
2118
+ * every entry key in every file deleted from the log (0 when none was). `known` is false when that
2119
+ * cannot be vouched for, such as a log created by a release without the watermark.
2120
+ */
2121
+ type TransactionLogPurgeWatermark = {
2122
+ known: true;
2123
+ purgedThrough: number;
2124
+ } | {
2125
+ known: false;
2126
+ };
2048
2127
  export type TransactionLog = {
2049
2128
  new (db: NativeDatabase, name: string): TransactionLog;
2050
2129
  addEntry(data: Buffer | Uint8Array, txnId?: number): void;
2130
+ /**
2131
+ * Whether `other` is the same logical log: the same database identity and log name.
2132
+ * Works after either database closes. A log destroyed and recreated under the same name
2133
+ * still compares equal.
2134
+ * Throws a TypeError when called on a receiver that is not a TransactionLog.
2135
+ */
2136
+ equals(other: unknown): boolean;
2051
2137
  getLogFileSize(sequenceId?: number): number;
2138
+ getPurgeWatermark(): TransactionLogPurgeWatermark;
2052
2139
  getStats(): TransactionLogStats;
2053
2140
  name: string;
2054
2141
  path: string;
2055
- query(options?: TransactionLogQueryOptions): IterableIterator<TransactionEntry>;
2142
+ query(options?: TransactionLogQueryOptions): TransactionLogIterator;
2056
2143
  _currentLogBuffer: WeakRef<LogBuffer> | undefined;
2057
2144
  _findPosition(timestamp: number): number;
2145
+ _findExactStart(timestamp: number, span: Float64Array): number;
2058
2146
  _getLastCommittedPosition(): Buffer;
2059
2147
  _getLastFlushed(): number;
2060
2148
  _getMemoryMapOfFile(sequenceId: number): LogBuffer | undefined;
2061
2149
  _lastCommittedPosition: Float64Array;
2062
2150
  _nextLogId(sequenceId: number): number;
2151
+ _segmentRemovals(): number;
2063
2152
  _logBuffers: Map<number, WeakRef<LogBuffer>>;
2064
2153
  };
2065
2154
  /**
@@ -2089,11 +2178,28 @@ type NativeIteratorResult = number | {
2089
2178
  declare class NativeIteratorCls {
2090
2179
  constructor(context: StoreContext, flags: number, startKeyEnd: number, endKeyStart: number, endKeyEnd: number, options?: NativeIteratorAdvancedOptions, transactionId?: number);
2091
2180
  next(): NativeIteratorResult;
2092
- return(): void;
2093
- throw(err?: unknown): void;
2181
+ /** Returns whether the native iterator went back to its transaction's pool. */
2182
+ return(): boolean;
2183
+ throw(err?: unknown): boolean;
2094
2184
  }
2095
2185
  type NativeDatabaseMode = "optimistic" | "pessimistic";
2096
2186
  type NativeDatabaseOptions = {
2187
+ /**
2188
+ * Memtable arena block size in bytes. Every column family that has been
2189
+ * written holds at least one block charged to the WriteBufferManager, so
2190
+ * with many column families this sets a floor on the manager's usage.
2191
+ * `0` (the default) is automatic: with a WriteBufferManager attached,
2192
+ * `writeBufferManagerSize / 2048` clamped to between 64 KiB and
2193
+ * `min(1 MiB, writeBufferSize / 8)`; without one, RocksDB's own
2194
+ * `min(1 MiB, writeBufferSize / 8)`.
2195
+ */
2196
+ arenaBlockSize?: number;
2197
+ /**
2198
+ * Bits per key of the whole-key filter written into each SST file (default
2199
+ * `10`, about a 1% false-positive rate); `0` writes no filter. Otherwise
2200
+ * 1 to 100, fractions allowed.
2201
+ */
2202
+ bloomFilterBitsPerKey?: number;
2097
2203
  /**
2098
2204
  * The friendly name of a compression algorithm compiled into this RocksDB
2099
2205
  * build (see `supportedCompression`), e.g. `'lz4'`, `'zstd'`, `'none'`. The
@@ -2178,7 +2284,10 @@ type NativeDatabaseOptions = {
2178
2284
  * When true, transaction writes to this column family invalidate the
2179
2285
  * VerificationTable slot for each written key at write time (not at
2180
2286
  * commit time). Enable only for column families whose records are
2181
- * cached (e.g. the primary CF of a table). Default: false.
2287
+ * cached (e.g. the primary CF of a table). Default: false. Left unset, a
2288
+ * handle joins a column family another handle opened with `true`; an
2289
+ * explicit `false` throws `ERR_VERIFICATION_TABLE_CONFLICT` while any
2290
+ * handle on that column family participates.
2182
2291
  */
2183
2292
  verificationTable?: boolean;
2184
2293
  writeBufferSize?: number;
@@ -2267,8 +2376,17 @@ type NativeDatabase = {
2267
2376
  dropSync(): void;
2268
2377
  flush(resolve: ResolveCallback<void>, reject: RejectCallback, options?: FlushOptions): void;
2269
2378
  flushSync(options?: FlushOptions): void;
2379
+ syncWal(resolve: ResolveCallback<void>, reject: RejectCallback): void;
2270
2380
  notify(event: string | BufferWithDataView, args?: any[]): boolean;
2271
- get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number): number;
2381
+ /**
2382
+ * Reads on the thread pool, applying `expectedVersion` and `POPULATE_VERSION_FLAG` like
2383
+ * `getSync()`. It neither probes the block cache nor answers from the verification table first:
2384
+ * the caller has already done both with `getSync(..., ONLY_IF_IN_MEMORY_CACHE_FLAG)`.
2385
+ *
2386
+ * Note that keyLengthOrKeyBuffer can be the length of the key if it was written into the shared
2387
+ * buffer, or a direct buffer.
2388
+ */
2389
+ get(keyLengthOrKeyBuffer: number | Buffer, resolve: ResolveCallback<Buffer | number>, reject: RejectCallback, txnId?: number, expectedVersion?: number, flags?: number): number;
2272
2390
  estimateCount(startKey?: Buffer, endKey?: Buffer): {
2273
2391
  count: number;
2274
2392
  confidence: number;
@@ -2356,6 +2474,24 @@ type RocksDatabaseConfig = {
2356
2474
  * concurrent `commitSync()` calls always have. Open databases keep their limit.
2357
2475
  */
2358
2476
  commitThreads?: number;
2477
+ /**
2478
+ * Marks a transaction-log batch aborted in place (`TRANSACTION_LOG_ENTRY_ABORTED_FLAG` on its
2479
+ * first entry) when its transaction ends without committing after the batch was written, so
2480
+ * readers skip it. Off by default: with it off, behavior is unchanged. Turn it on only once every
2481
+ * reader of these logs (replicas, restores, repair tools) skips aborted batches; an older reader
2482
+ * shows an aborted batch as live. Read when a transaction starts and when it is reset for a
2483
+ * retry, so it can change at runtime.
2484
+ */
2485
+ transactionLogAbortMarkers?: boolean;
2486
+ /**
2487
+ * With `transactionLogAbortMarkers` on, refuses a conflicting attempt before it writes its
2488
+ * transaction-log batch when an older transaction holds a write intent on one of its keys, and
2489
+ * (with `coordinatedRetry`) parks it until that holder ends. This bounds how long the losers of
2490
+ * heavily overlapping transactions wait, at the cost of more retries and less throughput when
2491
+ * transactions are large or contention is low. Off by default; no effect with abort markers off
2492
+ * or the verification table disabled. Read with `transactionLogAbortMarkers`.
2493
+ */
2494
+ transactionLogWriteIntents?: boolean;
2359
2495
  /**
2360
2496
  * Number of slots in the process-global verification table. Each slot is
2361
2497
  * 8 bytes; the default of 128K slots is 1 MB. Set to 0 to disable.
@@ -2365,6 +2501,19 @@ type RocksDatabaseConfig = {
2365
2501
  */
2366
2502
  verificationTableEntries?: number;
2367
2503
  compactOnClose?: boolean;
2504
+ /**
2505
+ * Whether the main thread runs `shutdown()` from a `process.on('exit')`
2506
+ * listener it registers when rocksdb-js loads, so `process.exit()` does
2507
+ * not skip the flush. Defaults to `true`. After it runs, databases are
2508
+ * closed and opening one throws, so an `exit` listener that still needs a
2509
+ * database must be added with `process.prependListener`. If data may be
2510
+ * left unflushed (a timed-out shutdown, or a failed final flush), it sets
2511
+ * `process.exitCode` to 1 unless it is already nonzero. Like the cleanup on a natural exit, it waits for in-flight native
2512
+ * work (a commit, flush, or backup) without a time limit. Set to `false` to
2513
+ * leave memtables unflushed at a Node `process.exit()`, e.g. to exercise
2514
+ * crash recovery; a natural exit still flushes from the native cleanup hook.
2515
+ */
2516
+ shutdownOnExit?: boolean;
2368
2517
  /**
2369
2518
  * Maximum seconds an open, destroy, or shutdown call waits for another
2370
2519
  * lifecycle operation. Defaults to 30.
@@ -2404,7 +2553,27 @@ type RocksDatabaseConfig = {
2404
2553
  * @default false
2405
2554
  */
2406
2555
  writeBufferManagerAllowStall?: boolean;
2556
+ /**
2557
+ * Which memtable the WriteBufferManager flushes when it is over budget:
2558
+ *
2559
+ * - `'oldest'`: the oldest memtable of the database being written.
2560
+ * - `'largest'`: the largest memtable of the database being written. Because
2561
+ * this library opens databases with atomic flush, this currently behaves
2562
+ * like `'oldest'`.
2563
+ * - `'largestAcrossDBs'`: a background thread flushes whichever database
2564
+ * holds the most memtable memory, whether or not it is being written.
2565
+ *
2566
+ * When unset, `'largestAcrossDBs'` while `writeBufferManagerAllowStall` is
2567
+ * on (and following later changes to it), otherwise `'oldest'`. With stalls
2568
+ * allowed, `'oldest'` can stall writes permanently: a writer to one database
2569
+ * waits for memory held by other databases that nothing is writing to, so
2570
+ * nothing flushes them. Without stalls, `'largestAcrossDBs'` has measured
2571
+ * slower. Can be changed while databases are open; an explicit value stays
2572
+ * in effect for the life of the process.
2573
+ */
2574
+ writeBufferManagerFlushPolicy?: WriteBufferManagerFlushPolicy;
2407
2575
  };
2576
+ type WriteBufferManagerFlushPolicy = "oldest" | "largest" | "largestAcrossDBs";
2408
2577
  type RegistryStatusTransaction = {
2409
2578
  /** The transaction id assigned by the database descriptor. */
2410
2579
  id: number;
@@ -2465,6 +2634,11 @@ type WriteBufferManagerStats = {
2465
2634
  mutableMemoryUsage: number;
2466
2635
  allowStall: boolean;
2467
2636
  costToCache: boolean;
2637
+ /**
2638
+ * The flush policy in effect: the live manager's, or the one a manager would
2639
+ * be created with (see `writeBufferManagerFlushPolicy`).
2640
+ */
2641
+ flushPolicy: WriteBufferManagerFlushPolicy;
2468
2642
  stallActive: boolean;
2469
2643
  /**
2470
2644
  * How long the current stall has been active, in milliseconds; 0 when not
@@ -2547,6 +2721,10 @@ export declare const constants: {
2547
2721
  RETRY_NOW_VALUE: number;
2548
2722
  TRANSACTION_LOG_TOKEN: number;
2549
2723
  TRANSACTION_LOG_ENTRY_HEADER_SIZE: number;
2724
+ TRANSACTION_LOG_ENTRY_LAST_FLAG: number;
2725
+ TRANSACTION_LOG_ENTRY_ABORTED_FLAG: number;
2726
+ /** 1 when the linked RocksDB exports the conflict check run before the log write. */
2727
+ PRELOG_CONFLICT_CHECK: number;
2550
2728
  TRANSACTION_LOG_FILE_HEADER_SIZE: number;
2551
2729
  ITERATOR_REVERSE_FLAG: number;
2552
2730
  ITERATOR_INCLUSIVE_END_FLAG: number;
@@ -2557,6 +2735,7 @@ export declare const constants: {
2557
2735
  ITERATOR_HAS_TRANSACTION_ID_FLAG: number;
2558
2736
  ITERATOR_RESULT_DONE: number;
2559
2737
  ITERATOR_RESULT_FAST: number;
2738
+ ITERATOR_RESULT_RELEASED: number;
2560
2739
  };
2561
2740
  /**
2562
2741
  * The friendly names of every compression algorithm compiled into the loaded
@@ -2582,7 +2761,7 @@ export declare const getRegistryStatus: () => RegistryStatus;
2582
2761
  */
2583
2762
  export declare const registryStatus: () => RegistryStatus;
2584
2763
  /**
2585
- * Flushes every open database and waits for outstanding compactions, then
2764
+ * Flushes every open database and cancels its outstanding compactions, then
2586
2765
  * releases the registry.
2587
2766
  *
2588
2767
  * **Throws** the first failure it encounters: a close whose native teardown
@@ -2592,19 +2771,10 @@ export declare const registryStatus: () => RegistryStatus;
2592
2771
  * `database:closeFailed`; a timeout has no event, so the throw is its only
2593
2772
  * signal.
2594
2773
  *
2595
- * A `process.on('exit')` listener must therefore wrap it: an exception thrown
2596
- * from an `exit` listener skips every `exit` listener registered after it (and
2597
- * sets exit code 1 unless an `uncaughtException` handler is installed).
2598
- *
2599
- * ```typescript
2600
- * process.on('exit', () => {
2601
- * try {
2602
- * shutdown();
2603
- * } catch (error) {
2604
- * console.error('rocksdb-js shutdown failed', error);
2605
- * }
2606
- * });
2607
- * ```
2774
+ * You do not need to call it at exit: when rocksdb-js loads on the main
2775
+ * thread it registers a `process.on('exit')` listener that does the same and
2776
+ * reports failures to stderr and the exit code instead of throwing (see the
2777
+ * `shutdownOnExit` config option). Calling it yourself as well is safe.
2608
2778
  */
2609
2779
  export declare const shutdown: () => void;
2610
2780
  export declare const currentThreadId: () => number;
@@ -2612,7 +2782,7 @@ export declare const currentThreadId: () => number;
2612
2782
  * Reads the process-wide steady clock: `std::chrono::steady_clock` as
2613
2783
  * fractional milliseconds from an unspecified origin that is fixed for the life
2614
2784
  * of the process. Every sample in the process — main thread and every
2615
- * `worker_threads` worker, whenever started or restarted, on Node, Bun and Deno
2785
+ * `worker_threads` worker, whenever started or restarted, on Node and Bun
2616
2786
  * — is in one domain, and the difference between two samples is real elapsed
2617
2787
  * time unaffected by wall-clock steps. Non-decreasing but not unique (two
2618
2788
  * samples may be equal; treat `==` as "not later"). Windows QPC samples from
@@ -2623,6 +2793,30 @@ export declare const currentThreadId: () => number;
2623
2793
  * platform-defined. No open database is needed.
2624
2794
  */
2625
2795
  export declare const steadyClockNow: () => number;
2796
+ /**
2797
+ * Raises the process-wide monotonic timestamp clock — the one behind
2798
+ * `db.getMonotonicTimestamp()`, every transaction's initial timestamp and so
2799
+ * every transaction-log batch key — to at least `timestamp` (Unix epoch
2800
+ * milliseconds). Every timestamp the process issues after the call is strictly
2801
+ * greater than `timestamp`, across every database and `worker_threads` worker.
2802
+ * Timestamps already issued and timestamps adopted with `txn.setTimestamp()`
2803
+ * are unaffected. No open database is needed.
2804
+ *
2805
+ * Use it to carry a floor the caller persisted across a restart, which a
2806
+ * backward wall-clock step would otherwise let the new process reissue. The
2807
+ * floor is in memory only and is not a fence: restore it before the process
2808
+ * starts any transaction it originates, and pass only floors this node
2809
+ * persisted itself, since the clock stays that far ahead until wall time
2810
+ * catches up.
2811
+ *
2812
+ * @returns `true` if the clock was raised: `timestamp` was ahead of both the
2813
+ * wall clock and every timestamp already issued. `false` if the clock was
2814
+ * already at or above it.
2815
+ * @throws {TypeError} If `timestamp` is not a number.
2816
+ * @throws {RangeError} If `timestamp` is not finite, is not greater than 0, is
2817
+ * not less than 8.64e15, or is more than ten years ahead of the wall clock.
2818
+ */
2819
+ export declare const raiseTimestampFloor: (timestamp: number) => boolean;
2626
2820
  /**
2627
2821
  * Advises the kernel that the file-backed pages of every mapped transaction log
2628
2822
  * are cold (Linux MADV_COLD), so they are reclaimed first under memory pressure
@@ -2668,8 +2862,6 @@ export declare const stats: {
2668
2862
  All: number;
2669
2863
  };
2670
2864
  };
2671
- //#endregion
2672
- //#region src/backup-stream.d.ts
2673
2865
  /**
2674
2866
  * Options for streaming a backup via `db.backup(stream)`.
2675
2867
  */
@@ -2699,8 +2891,6 @@ interface BackupStreamOptions {
2699
2891
  */
2700
2892
  transactionLogs?: boolean;
2701
2893
  }
2702
- //#endregion
2703
- //#region src/count-estimator.d.ts
2704
2894
  interface CountEstimatorOptions extends CountEstimateOptions {}
2705
2895
  /**
2706
2896
  * Progressively refines a range key-count estimate as an iterator traverses
@@ -2750,8 +2940,6 @@ export declare class CountEstimator {
2750
2940
  */
2751
2941
  estimate(): CountEstimate;
2752
2942
  }
2753
- //#endregion
2754
- //#region src/database.d.ts
2755
2943
  type TransactionCallback<T> = (txn: Transaction, attempt: number) => T | PromiseLike<T>;
2756
2944
  interface RocksDatabaseOptions extends StoreOptions {
2757
2945
  /**
@@ -2771,7 +2959,8 @@ interface TransactionOptions extends NativeTransactionOptions {
2771
2959
  /**
2772
2960
  * Whether to retry the transaction if it fails with `IsBusy`.
2773
2961
  *
2774
- * @default `true` when the transaction is bound to a transaction log, otherwise `false`
2962
+ * @default `true` when the transaction wrote a transaction-log batch or was refused before
2963
+ * writing one (`refusedBeforeLog`), otherwise `false`
2775
2964
  */
2776
2965
  retryOnBusy?: boolean;
2777
2966
  }
@@ -3104,6 +3293,17 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
3104
3293
  * @return {void} Does not return a value.
3105
3294
  */
3106
3295
  flushSync(options?: FlushOptions): void;
3296
+ /**
3297
+ * Syncs the write-ahead log to stable storage (`DB::SyncWAL`), so every WAL-backed write
3298
+ * committed before the call survives a power loss afterwards. Unlike {@link flush} it writes
3299
+ * no SST file and never stalls writers. Not covered: writes that skipped the WAL
3300
+ * (`disableWAL`), and transaction-log files, which keep their own durability. Runs on the
3301
+ * libuv threadpool; RocksDB serializes concurrent syncs of one WAL, so keep one in flight
3302
+ * per database rather than parking pool workers on a queue of them.
3303
+ *
3304
+ * On a read-only database the returned promise resolves without syncing.
3305
+ */
3306
+ syncWal(): Promise<void>;
3107
3307
  /**
3108
3308
  * Returns the most recent {@link BackgroundError} observed on this database, or
3109
3309
  * `null` when none has occurred. The `'error'` event is the push counterpart;
@@ -3574,8 +3774,6 @@ export declare class RocksDatabase extends DBI<DBITransactional> {
3574
3774
  */
3575
3775
  withLock(key: Key, callback: () => void | Promise<void>): Promise<void> | undefined;
3576
3776
  }
3577
- //#endregion
3578
- //#region src/parse-transaction-log.d.ts
3579
3777
  interface LogEntry {
3580
3778
  anomalies?: string[];
3581
3779
  data?: Buffer;
@@ -3599,8 +3797,6 @@ interface TransactionLog$1 {
3599
3797
  export declare function parseTransactionLog(path: string, options?: {
3600
3798
  skipData?: boolean;
3601
3799
  }): TransactionLog$1;
3602
- //#endregion
3603
- //#region src/transaction-log-reader.d.ts
3604
3800
  /**
3605
3801
  * Thrown when an entry's framing is broken. `resyncPosition` is the offset where valid framing
3606
3802
  * resumes, when one was found: the frames after a mid-log break are intact and reachable, and
@@ -3621,12 +3817,34 @@ export declare class CorruptFrameError extends RangeError {
3621
3817
  unreadableBytes: number;
3622
3818
  constructor(message: string, logId: number, position: number, resyncPosition: number | undefined);
3623
3819
  }
3624
- //#endregion
3625
- //#region src/index.d.ts
3820
+ /**
3821
+ * Thrown when an iterator advances past segments it never read and that can no longer be read —
3822
+ * typically ones retention purged while the reader lagged. The entries they held cannot be
3823
+ * recovered from this log, so a consumer replicating it must not treat the stream as contiguous.
3824
+ * Missing sequence numbers prove only that continuity is unknown, not that each held entries.
3825
+ *
3826
+ * The iterator is left positioned at the start of `resumeLogId`, so a caller that accepts the
3827
+ * discontinuity calls `next()` again to continue from there.
3828
+ *
3829
+ * Not a `RangeError`: this is not broken framing, and consumers classify those by class.
3830
+ */
3831
+ export declare class TransactionLogGapError extends Error {
3832
+ /** Sequence number of the last segment this iterator read up to. */
3833
+ logId: number;
3834
+ /** Sequence number of the segment iteration resumes in. */
3835
+ resumeLogId: number;
3836
+ /** Segments between `logId` and `resumeLogId` that could not be read. Empty segments are not counted. */
3837
+ unavailableLogCount: number;
3838
+ constructor(logId: number, resumeLogId: number, unavailableLogCount: number);
3839
+ }
3840
+ /** Readable input ended before the iterator's physical `until` bound. Retry after input is available. */
3841
+ export declare class TransactionLogUntilUnreachedError extends Error {
3842
+ logId: number;
3843
+ position: number;
3844
+ constructor(logId: number, position: number);
3845
+ }
3626
3846
  export declare const versions: {
3627
3847
  rocksdb: string;
3628
3848
  "rocksdb-js": string;
3629
3849
  };
3630
- //#endregion
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 };
3632
- //# sourceMappingURL=index.d.cts.map
3850
+ 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, TransactionLogIterator, TransactionLogPosition, TransactionLogPurgeWatermark, TransactionLogStats, TransactionLogStoreValidation, ValidateTransactionLogStoreOptions, WriteBufferManagerFlushPolicy, WriteBufferManagerStats };