@minnowdb/core 0.3.0 → 0.4.1
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 +4 -2
- package/dist/block-format/block.d.ts +32 -13
- package/dist/block-format/block.js +179 -55
- package/dist/block-format/checksum.d.ts +2 -1
- package/dist/block-format/checksum.js +5 -2
- package/dist/block-format/codecs.d.ts +7 -2
- package/dist/block-format/codecs.js +53 -12
- package/dist/block-format/column.d.ts +3 -2
- package/dist/block-format/column.js +96 -30
- package/dist/block-format/index.d.ts +2 -2
- package/dist/block-format/index.js +2 -2
- package/dist/block-format/physical.d.ts +8 -2
- package/dist/block-format/physical.js +14 -6
- package/dist/block-format/types.d.ts +7 -3
- package/dist/block-format/types.js +0 -1
- package/dist/block-format/unicode.d.ts +11 -0
- package/dist/block-format/unicode.js +46 -0
- package/dist/date-value.d.ts +15 -0
- package/dist/date-value.js +64 -0
- package/dist/engine/artifact-cache.d.ts +0 -1
- package/dist/engine/artifact-cache.js +0 -1
- package/dist/engine/batch.d.ts +5 -2
- package/dist/engine/batch.js +0 -1
- package/dist/engine/buffered-writer.d.ts +2 -1
- package/dist/engine/buffered-writer.js +34 -9
- package/dist/engine/cache-limits.d.ts +25 -0
- package/dist/engine/cache-limits.js +25 -0
- package/dist/engine/catalog.d.ts +5 -6
- package/dist/engine/catalog.js +5 -5
- package/dist/engine/client.d.ts +27 -7
- package/dist/engine/client.js +197 -31
- package/dist/engine/database.d.ts +161 -38
- package/dist/engine/database.js +4326 -1523
- package/dist/engine/defaults.d.ts +0 -1
- package/dist/engine/defaults.js +2 -4
- package/dist/engine/errors.d.ts +19 -1
- package/dist/engine/errors.js +32 -2
- package/dist/engine/fts.d.ts +0 -6
- package/dist/engine/fts.js +39 -14
- package/dist/engine/group-index.d.ts +0 -1
- package/dist/engine/group-index.js +6 -11
- package/dist/engine/index.d.ts +16 -11
- package/dist/engine/index.js +12 -10
- package/dist/engine/join-index.d.ts +0 -1
- package/dist/engine/join-index.js +2 -2
- package/dist/engine/keyed-live.d.ts +57 -0
- package/dist/engine/keyed-live.js +226 -0
- package/dist/engine/live-api.d.ts +4 -0
- package/dist/engine/live-api.js +4 -0
- package/dist/engine/live.d.ts +43 -26
- package/dist/engine/live.js +499 -129
- package/dist/engine/memory.d.ts +2 -1
- package/dist/engine/memory.js +3 -2
- package/dist/engine/optimizer.d.ts +0 -1
- package/dist/engine/optimizer.js +4 -4
- package/dist/engine/query-api.d.ts +3 -0
- package/dist/engine/query-api.js +3 -0
- package/dist/engine/query-cache.d.ts +0 -1
- package/dist/engine/query-cache.js +4 -4
- package/dist/engine/query.d.ts +4 -7
- package/dist/engine/query.js +348 -155
- package/dist/engine/result-wire.d.ts +0 -1
- package/dist/engine/result-wire.js +2 -2
- package/dist/engine/schema-wire.d.ts +1 -2
- package/dist/engine/schema-wire.js +0 -1
- package/dist/engine/schema.d.ts +3 -8
- package/dist/engine/schema.js +41 -24
- package/dist/engine/sort-keys.d.ts +0 -1
- package/dist/engine/sort-keys.js +2 -2
- package/dist/engine/sql-domains.d.ts +6 -1
- package/dist/engine/sql-domains.js +209 -45
- package/dist/engine/sql-driver.d.ts +2 -2
- package/dist/engine/sql-driver.js +0 -1
- package/dist/engine/sql-json.d.ts +0 -1
- package/dist/engine/sql-json.js +53 -7
- package/dist/engine/sql-semantics.d.ts +8 -5
- package/dist/engine/sql-semantics.js +427 -65
- package/dist/engine/typed-live.d.ts +67 -0
- package/dist/engine/typed-live.js +349 -0
- package/dist/engine/vector.d.ts +7 -1
- package/dist/engine/vector.js +202 -58
- package/dist/engine/worker-host.d.ts +8 -2
- package/dist/engine/worker-host.js +616 -152
- package/dist/engine/worker.d.ts +0 -1
- package/dist/engine/worker.js +3 -3
- package/dist/engine/write-block-planner.d.ts +18 -0
- package/dist/engine/write-block-planner.js +112 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/plan/index.d.ts +0 -1
- package/dist/plan/index.js +0 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.js +1 -1
- package/dist/storage/indexeddb.d.ts +74 -65
- package/dist/storage/indexeddb.js +12301 -2076
- package/dist/storage/memory.d.ts +56 -66
- package/dist/storage/memory.js +1004 -139
- package/dist/storage/opfs/files.d.ts +18 -7
- package/dist/storage/opfs/files.js +115 -28
- package/dist/storage/opfs/index.d.ts +1 -1
- package/dist/storage/opfs/index.js +1 -1
- package/dist/storage/opfs/leader.d.ts +403 -91
- package/dist/storage/opfs/leader.js +4318 -602
- package/dist/storage/opfs/rpc.d.ts +15 -3
- package/dist/storage/opfs/rpc.js +223 -2
- package/dist/storage/opfs/snapshot-ledger.d.ts +40 -0
- package/dist/storage/opfs/snapshot-ledger.js +281 -0
- package/dist/storage/opfs/store.d.ts +26 -121
- package/dist/storage/opfs/store.js +436 -388
- package/dist/storage/persistence.d.ts +37 -0
- package/dist/storage/persistence.js +78 -0
- package/dist/storage/snapshot-stream.d.ts +24 -0
- package/dist/storage/snapshot-stream.js +897 -0
- package/dist/storage/snapshot.d.ts +9 -99
- package/dist/storage/snapshot.js +33 -309
- package/dist/storage/toolkit/extents.d.ts +41 -7
- package/dist/storage/toolkit/extents.js +402 -39
- package/dist/storage/toolkit/index.d.ts +3 -4
- package/dist/storage/toolkit/index.js +27 -3
- package/dist/storage/toolkit/record-core.d.ts +174 -61
- package/dist/storage/toolkit/record-core.js +5401 -849
- package/dist/storage/toolkit/sync-file.d.ts +10 -1
- package/dist/storage/toolkit/sync-file.js +50 -2
- package/dist/storage/toolkit/wal.d.ts +23 -5
- package/dist/storage/toolkit/wal.js +89 -27
- package/dist/storage/toolkit/wire.d.ts +4 -6
- package/dist/storage/toolkit/wire.js +80 -25
- package/dist/storage/types.d.ts +1271 -218
- package/dist/storage/types.js +1471 -138
- package/dist/testing/block-store-conformance.d.ts +0 -1
- package/dist/testing/block-store-conformance.js +877 -138
- package/dist/testing/index.d.ts +42 -31
- package/dist/testing/index.js +100 -68
- package/dist/testing/opfs-shim.d.ts +13 -3
- package/dist/testing/opfs-shim.js +40 -6
- package/dist/testing/simulator.d.ts +0 -1
- package/dist/testing/simulator.js +43 -12
- package/dist/testing/sqllogictest.d.ts +0 -1
- package/dist/testing/sqllogictest.js +0 -1
- package/dist/transactions/index.d.ts +81 -20
- package/dist/transactions/index.js +1050 -268
- package/dist/worker-protocol/index.d.ts +3 -2
- package/dist/worker-protocol/index.js +2 -5
- package/package.json +49 -1
- package/dist/block-format/block.d.ts.map +0 -1
- package/dist/block-format/block.js.map +0 -1
- package/dist/block-format/checksum.d.ts.map +0 -1
- package/dist/block-format/checksum.js.map +0 -1
- package/dist/block-format/codecs.d.ts.map +0 -1
- package/dist/block-format/codecs.js.map +0 -1
- package/dist/block-format/column.d.ts.map +0 -1
- package/dist/block-format/column.js.map +0 -1
- package/dist/block-format/index.d.ts.map +0 -1
- package/dist/block-format/index.js.map +0 -1
- package/dist/block-format/physical.d.ts.map +0 -1
- package/dist/block-format/physical.js.map +0 -1
- package/dist/block-format/types.d.ts.map +0 -1
- package/dist/block-format/types.js.map +0 -1
- package/dist/engine/artifact-cache.d.ts.map +0 -1
- package/dist/engine/artifact-cache.js.map +0 -1
- package/dist/engine/batch.d.ts.map +0 -1
- package/dist/engine/batch.js.map +0 -1
- package/dist/engine/buffered-writer.d.ts.map +0 -1
- package/dist/engine/buffered-writer.js.map +0 -1
- package/dist/engine/catalog.d.ts.map +0 -1
- package/dist/engine/catalog.js.map +0 -1
- package/dist/engine/client.d.ts.map +0 -1
- package/dist/engine/client.js.map +0 -1
- package/dist/engine/coordinator.d.ts +0 -17
- package/dist/engine/coordinator.d.ts.map +0 -1
- package/dist/engine/coordinator.js +0 -60
- package/dist/engine/coordinator.js.map +0 -1
- package/dist/engine/database.d.ts.map +0 -1
- package/dist/engine/database.js.map +0 -1
- package/dist/engine/defaults.d.ts.map +0 -1
- package/dist/engine/defaults.js.map +0 -1
- package/dist/engine/errors.d.ts.map +0 -1
- package/dist/engine/errors.js.map +0 -1
- package/dist/engine/fts.d.ts.map +0 -1
- package/dist/engine/fts.js.map +0 -1
- package/dist/engine/group-index.d.ts.map +0 -1
- package/dist/engine/group-index.js.map +0 -1
- package/dist/engine/index.d.ts.map +0 -1
- package/dist/engine/index.js.map +0 -1
- package/dist/engine/join-index.d.ts.map +0 -1
- package/dist/engine/join-index.js.map +0 -1
- package/dist/engine/live.d.ts.map +0 -1
- package/dist/engine/live.js.map +0 -1
- package/dist/engine/memory.d.ts.map +0 -1
- package/dist/engine/memory.js.map +0 -1
- package/dist/engine/optimizer.d.ts.map +0 -1
- package/dist/engine/optimizer.js.map +0 -1
- package/dist/engine/query-cache.d.ts.map +0 -1
- package/dist/engine/query-cache.js.map +0 -1
- package/dist/engine/query.d.ts.map +0 -1
- package/dist/engine/query.js.map +0 -1
- package/dist/engine/result-wire.d.ts.map +0 -1
- package/dist/engine/result-wire.js.map +0 -1
- package/dist/engine/schema-wire.d.ts.map +0 -1
- package/dist/engine/schema-wire.js.map +0 -1
- package/dist/engine/schema.d.ts.map +0 -1
- package/dist/engine/schema.js.map +0 -1
- package/dist/engine/sort-keys.d.ts.map +0 -1
- package/dist/engine/sort-keys.js.map +0 -1
- package/dist/engine/sql-domains.d.ts.map +0 -1
- package/dist/engine/sql-domains.js.map +0 -1
- package/dist/engine/sql-driver.d.ts.map +0 -1
- package/dist/engine/sql-driver.js.map +0 -1
- package/dist/engine/sql-json.d.ts.map +0 -1
- package/dist/engine/sql-json.js.map +0 -1
- package/dist/engine/sql-semantics.d.ts.map +0 -1
- package/dist/engine/sql-semantics.js.map +0 -1
- package/dist/engine/vector.d.ts.map +0 -1
- package/dist/engine/vector.js.map +0 -1
- package/dist/engine/worker-host.d.ts.map +0 -1
- package/dist/engine/worker-host.js.map +0 -1
- package/dist/engine/worker.d.ts.map +0 -1
- package/dist/engine/worker.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plan/index.d.ts.map +0 -1
- package/dist/plan/index.js.map +0 -1
- package/dist/storage/fixture-shape.d.ts +0 -42
- package/dist/storage/fixture-shape.d.ts.map +0 -1
- package/dist/storage/fixture-shape.js +0 -146
- package/dist/storage/fixture-shape.js.map +0 -1
- package/dist/storage/index.d.ts.map +0 -1
- package/dist/storage/index.js.map +0 -1
- package/dist/storage/indexeddb.d.ts.map +0 -1
- package/dist/storage/indexeddb.js.map +0 -1
- package/dist/storage/memory.d.ts.map +0 -1
- package/dist/storage/memory.js.map +0 -1
- package/dist/storage/opfs/files.d.ts.map +0 -1
- package/dist/storage/opfs/files.js.map +0 -1
- package/dist/storage/opfs/index.d.ts.map +0 -1
- package/dist/storage/opfs/index.js.map +0 -1
- package/dist/storage/opfs/leader.d.ts.map +0 -1
- package/dist/storage/opfs/leader.js.map +0 -1
- package/dist/storage/opfs/rpc.d.ts.map +0 -1
- package/dist/storage/opfs/rpc.js.map +0 -1
- package/dist/storage/opfs/store.d.ts.map +0 -1
- package/dist/storage/opfs/store.js.map +0 -1
- package/dist/storage/snapshot.d.ts.map +0 -1
- package/dist/storage/snapshot.js.map +0 -1
- package/dist/storage/toolkit/extents.d.ts.map +0 -1
- package/dist/storage/toolkit/extents.js.map +0 -1
- package/dist/storage/toolkit/index.d.ts.map +0 -1
- package/dist/storage/toolkit/index.js.map +0 -1
- package/dist/storage/toolkit/record-core.d.ts.map +0 -1
- package/dist/storage/toolkit/record-core.js.map +0 -1
- package/dist/storage/toolkit/sync-file.d.ts.map +0 -1
- package/dist/storage/toolkit/sync-file.js.map +0 -1
- package/dist/storage/toolkit/wal.d.ts.map +0 -1
- package/dist/storage/toolkit/wal.js.map +0 -1
- package/dist/storage/toolkit/wire.d.ts.map +0 -1
- package/dist/storage/toolkit/wire.js.map +0 -1
- package/dist/storage/types.d.ts.map +0 -1
- package/dist/storage/types.js.map +0 -1
- package/dist/testing/block-store-conformance.d.ts.map +0 -1
- package/dist/testing/block-store-conformance.js.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/index.js.map +0 -1
- package/dist/testing/opfs-shim.d.ts.map +0 -1
- package/dist/testing/opfs-shim.js.map +0 -1
- package/dist/testing/seeds.d.ts +0 -11
- package/dist/testing/seeds.d.ts.map +0 -1
- package/dist/testing/seeds.js +0 -50
- package/dist/testing/seeds.js.map +0 -1
- package/dist/testing/simulator.d.ts.map +0 -1
- package/dist/testing/simulator.js.map +0 -1
- package/dist/testing/sqllogictest.d.ts.map +0 -1
- package/dist/testing/sqllogictest.js.map +0 -1
- package/dist/transactions/index.d.ts.map +0 -1
- package/dist/transactions/index.js.map +0 -1
- package/dist/worker-protocol/index.d.ts.map +0 -1
- package/dist/worker-protocol/index.js.map +0 -1
|
@@ -2,6 +2,17 @@ import { MinnowDatabase } from "../engine/database.js";
|
|
|
2
2
|
import { MemoryBlockStore } from "../storage/index.js";
|
|
3
3
|
import { FaultInjectingBlockStore } from "./index.js";
|
|
4
4
|
import { md5Hex } from "./sqllogictest.js";
|
|
5
|
+
async function collectStoragePages(read) {
|
|
6
|
+
const records = [];
|
|
7
|
+
let cursor = null;
|
|
8
|
+
for (;;) {
|
|
9
|
+
const page = await read(cursor);
|
|
10
|
+
records.push(...page.records);
|
|
11
|
+
if (page.nextCursor === null)
|
|
12
|
+
return records;
|
|
13
|
+
cursor = page.nextCursor;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
/** Chooses every storage completion from a seeded queue and keeps only a bounded trace tail. */
|
|
6
17
|
export class DeterministicScheduler {
|
|
7
18
|
#random;
|
|
@@ -40,6 +51,15 @@ export class DeterministicScheduler {
|
|
|
40
51
|
await Promise.resolve();
|
|
41
52
|
const pending = this.#pending.length;
|
|
42
53
|
if (pending === 0) {
|
|
54
|
+
// Production maintenance deliberately yields through a timer between bounded pages.
|
|
55
|
+
// A microtask-only poll can therefore declare deadlock while the next scheduled store
|
|
56
|
+
// call is merely waiting for its event-loop turn. Let timers advance before counting an
|
|
57
|
+
// empty turn; the chosen storage completion order remains seeded and deterministic.
|
|
58
|
+
await nextEventLoopTurn();
|
|
59
|
+
if (this.#pending.length > 0) {
|
|
60
|
+
emptyTurns = 0;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
43
63
|
emptyTurns++;
|
|
44
64
|
if (emptyTurns > 100) {
|
|
45
65
|
throw new Error("Deterministic simulator deadlocked with no scheduled storage operation");
|
|
@@ -72,6 +92,20 @@ export class DeterministicScheduler {
|
|
|
72
92
|
this.#trace.shift();
|
|
73
93
|
}
|
|
74
94
|
}
|
|
95
|
+
function nextEventLoopTurn() {
|
|
96
|
+
if (typeof MessageChannel === "undefined") {
|
|
97
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
98
|
+
}
|
|
99
|
+
return new Promise((resolve) => {
|
|
100
|
+
const channel = new MessageChannel();
|
|
101
|
+
channel.port1.onmessage = () => {
|
|
102
|
+
channel.port1.close();
|
|
103
|
+
channel.port2.close();
|
|
104
|
+
resolve();
|
|
105
|
+
};
|
|
106
|
+
channel.port2.postMessage(undefined);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
75
109
|
/** Wraps every asynchronous BlockStore entry point in the deterministic completion scheduler. */
|
|
76
110
|
export function scheduledBlockStore(store, scheduler) {
|
|
77
111
|
return new Proxy(store, {
|
|
@@ -288,20 +322,20 @@ export async function runSimulation(plan, options = {}) {
|
|
|
288
322
|
collectionTail.splice(0, collectionTail.length - 8);
|
|
289
323
|
await drive(scheduler, sweeper.close());
|
|
290
324
|
const rows = sortedRows(model);
|
|
291
|
-
const [
|
|
292
|
-
base.
|
|
293
|
-
base.
|
|
294
|
-
base.
|
|
295
|
-
base.listManifests(),
|
|
325
|
+
const [segments, transactions, manifests, currentManifest, leases, compactions, storageBytes] = await Promise.all([
|
|
326
|
+
collectStoragePages((cursor) => base.listSegmentPage(cursor, 256)),
|
|
327
|
+
collectStoragePages((cursor) => base.listTransactionPage(cursor, 256)),
|
|
328
|
+
collectStoragePages((cursor) => base.listManifestPage(cursor, 256)),
|
|
296
329
|
base.getCurrentManifest(),
|
|
297
330
|
base.listLeases(),
|
|
298
331
|
base.listCompactionJobs(),
|
|
299
332
|
base.getLogicalStorageBytes(),
|
|
300
333
|
]);
|
|
334
|
+
const blockCount = currentManifest?.liveBlockCount ?? 0;
|
|
301
335
|
const blockLimit = plan.keySpace * 16 + 64;
|
|
302
336
|
const segmentLimit = plan.keySpace + 16;
|
|
303
337
|
const transactionLimit = segmentLimit + 16;
|
|
304
|
-
if (
|
|
338
|
+
if (blockCount > blockLimit ||
|
|
305
339
|
segments.length > segmentLimit ||
|
|
306
340
|
transactions.length > transactionLimit) {
|
|
307
341
|
const transactionStates = transactions.reduce((counts, transaction) => {
|
|
@@ -312,12 +346,12 @@ export async function runSimulation(plan, options = {}) {
|
|
|
312
346
|
counts[compaction.state] = (counts[compaction.state] ?? 0) + 1;
|
|
313
347
|
return counts;
|
|
314
348
|
}, {});
|
|
315
|
-
throw new Error(`Storage did not compact to a bound: ${String(
|
|
349
|
+
throw new Error(`Storage did not compact to a bound: ${String(blockCount)}/${String(blockLimit)} live blocks, ` +
|
|
316
350
|
`${String(segments.length)}/${String(segmentLimit)} segments, ` +
|
|
317
351
|
`${String(transactions.length)}/${String(transactionLimit)} transactions; ` +
|
|
318
352
|
`${JSON.stringify(transactionStates)} transaction states, ` +
|
|
319
353
|
`${JSON.stringify(compactionStates)} compaction states, ` +
|
|
320
|
-
`${String(currentManifest?.
|
|
354
|
+
`${String(currentManifest?.liveBlockCount ?? 0)} current blocks, compaction stopped at ${compactionStop}, ` +
|
|
321
355
|
`${String(manifests.length)} manifests (${String(manifests.filter((manifest) => manifest.prunedAt !== undefined).length)} pruned) remain after ${String(maintenanceCompactions)} compactions ` +
|
|
322
356
|
`and ${String(collectionPasses)} collection passes; collection tail ${JSON.stringify(collectionTail)}`);
|
|
323
357
|
}
|
|
@@ -339,7 +373,7 @@ export async function runSimulation(plan, options = {}) {
|
|
|
339
373
|
collectionPasses,
|
|
340
374
|
collectionTail,
|
|
341
375
|
rows,
|
|
342
|
-
blockCount
|
|
376
|
+
blockCount,
|
|
343
377
|
segmentCount: segments.length,
|
|
344
378
|
transactionCount: transactions.length,
|
|
345
379
|
manifestCount: manifests.length,
|
|
@@ -435,8 +469,6 @@ function validateSteps(steps, clients, keySpace) {
|
|
|
435
469
|
"afterBlockWrite",
|
|
436
470
|
"beforeBlockRead",
|
|
437
471
|
"afterBlockRead",
|
|
438
|
-
"beforeManifestCommit",
|
|
439
|
-
"afterManifestCommit",
|
|
440
472
|
"beforeTransactionCommit",
|
|
441
473
|
"afterTransactionCommit",
|
|
442
474
|
]);
|
|
@@ -557,4 +589,3 @@ function greatestCommonDivisor(left, right) {
|
|
|
557
589
|
[a, b] = [b, a % b];
|
|
558
590
|
return a;
|
|
559
591
|
}
|
|
560
|
-
//# sourceMappingURL=simulator.js.map
|
|
@@ -87,4 +87,3 @@ export declare function renderSqlLogicValue(value: QueryValue, type: SqlLogicTyp
|
|
|
87
87
|
/** Small browser-safe MD5 implementation for compatibility with the original corpus hashes. */
|
|
88
88
|
export declare function md5Hex(input: string): string;
|
|
89
89
|
export {};
|
|
90
|
-
//# sourceMappingURL=sqllogictest.d.ts.map
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { type BlockStore, type BlockWrite, type LeaseKind, type LeaseRecord, type ManifestSummary, type RowIdRange, type SegmentRecord, type TransactionRecord, type FtsChanges, type UniqueKeyChanges } from "../storage/
|
|
1
|
+
import { type BlockStore, type BlockWrite, type LeaseKind, type LeaseRecord, MAX_LEASE_TTL_MS, type ManifestSummary, type RowIdRange, type SegmentRecord, type TableRecord, type TransactionRecord, type FtsChanges, type UniqueKeyChanges } from "../storage/types.js";
|
|
2
2
|
export interface TransactionManagerOptions {
|
|
3
3
|
now?: () => Date;
|
|
4
4
|
createId?: () => string;
|
|
5
|
+
/** Durable writer deadline; live transactions renew every third of this interval. */
|
|
6
|
+
transactionTtlMs?: number;
|
|
7
|
+
/** Test seam for deterministic collection of an abandoned transaction reference. */
|
|
8
|
+
createWeakRef?: (transaction: DatabaseTransaction) => {
|
|
9
|
+
deref(): DatabaseTransaction | undefined;
|
|
10
|
+
};
|
|
5
11
|
}
|
|
12
|
+
export declare const DEFAULT_TRANSACTION_TTL_MS = 30000;
|
|
13
|
+
export { MAX_LEASE_TTL_MS };
|
|
6
14
|
export interface RecoveryOptions {
|
|
7
15
|
staleBefore: Date;
|
|
8
16
|
removePendingBlocks?: boolean;
|
|
@@ -23,6 +31,14 @@ export interface OpenLeasedSnapshotOptions {
|
|
|
23
31
|
kind?: LeaseKind;
|
|
24
32
|
version?: number | null;
|
|
25
33
|
}
|
|
34
|
+
export interface BeginDeferredOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Pins the captured snapshot with a renewable durable reader lease until this transaction
|
|
37
|
+
* either persists its own durable owner or finishes. Enabled by default; tightly bounded
|
|
38
|
+
* internal statements that cannot idle may opt out to retain the one-write fast path.
|
|
39
|
+
*/
|
|
40
|
+
durableSnapshot?: boolean;
|
|
41
|
+
}
|
|
26
42
|
export declare class TransactionClosedError extends Error {
|
|
27
43
|
readonly transactionId: string;
|
|
28
44
|
readonly name = "TransactionClosedError";
|
|
@@ -35,23 +51,27 @@ export interface TransactionCheckpoint {
|
|
|
35
51
|
readonly pendingSegmentIds: readonly string[];
|
|
36
52
|
readonly uniqueKeyChanges: readonly UniqueKeyChanges[];
|
|
37
53
|
readonly ftsChanges: readonly FtsChanges[];
|
|
38
|
-
readonly
|
|
54
|
+
readonly compactionJobId: string | null;
|
|
55
|
+
readonly compactionSourceBlockIds: readonly string[];
|
|
56
|
+
readonly levelZeroSegmentLimits: ReadonlyArray<{
|
|
57
|
+
tableId: string;
|
|
58
|
+
limit: number;
|
|
59
|
+
}>;
|
|
39
60
|
readonly changedTableIds: readonly string[];
|
|
40
61
|
readonly logicallyUnchanged: boolean;
|
|
41
62
|
}
|
|
42
63
|
export declare class Snapshot {
|
|
43
|
-
#private;
|
|
44
64
|
private readonly store;
|
|
45
65
|
readonly version: number | null;
|
|
46
|
-
constructor(store: BlockStore, version: number | null
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
constructor(store: BlockStore, version: number | null);
|
|
67
|
+
hasBlock(id: string): Promise<boolean>;
|
|
68
|
+
hasBlocks(ids: readonly string[]): Promise<boolean[]>;
|
|
49
69
|
getBlock(id: string): Promise<Uint8Array | undefined>;
|
|
50
70
|
}
|
|
51
71
|
export declare class LeasedSnapshot extends Snapshot {
|
|
52
72
|
#private;
|
|
53
73
|
private readonly now;
|
|
54
|
-
constructor(store: BlockStore, version: number | null,
|
|
74
|
+
constructor(store: BlockStore, version: number | null, record: LeaseRecord, now: () => Date);
|
|
55
75
|
get leaseId(): string;
|
|
56
76
|
get expiresAt(): Date;
|
|
57
77
|
getBlock(id: string): Promise<Uint8Array | undefined>;
|
|
@@ -63,7 +83,7 @@ export declare class LeasedSnapshot extends Snapshot {
|
|
|
63
83
|
* (`SnapshotManifestMissingError`, `LeaseConflictError`) leave this snapshot open and pass
|
|
64
84
|
* through.
|
|
65
85
|
*/
|
|
66
|
-
moveTo(version: number | null, ttlMs: number
|
|
86
|
+
moveTo(version: number | null, ttlMs: number): Promise<LeasedSnapshot | undefined>;
|
|
67
87
|
release(): Promise<void>;
|
|
68
88
|
/** Closes this snapshot without touching the store — for a lease the store no longer holds. */
|
|
69
89
|
discard(): void;
|
|
@@ -72,15 +92,44 @@ export declare class DatabaseTransaction {
|
|
|
72
92
|
#private;
|
|
73
93
|
private readonly store;
|
|
74
94
|
private readonly now;
|
|
75
|
-
|
|
95
|
+
private readonly ttlMs;
|
|
96
|
+
constructor(store: BlockStore, record: TransactionRecord, now: () => Date, ttlMs: number, createWeakRef: (transaction: DatabaseTransaction) => {
|
|
97
|
+
deref(): DatabaseTransaction | undefined;
|
|
98
|
+
}, options?: {
|
|
76
99
|
persisted?: boolean;
|
|
100
|
+
initialCatalogProbe?: {
|
|
101
|
+
catalogEpoch: number;
|
|
102
|
+
manifestVersion: number | null;
|
|
103
|
+
schemaEpoch: number;
|
|
104
|
+
};
|
|
105
|
+
snapshotLease?: LeasedSnapshot;
|
|
77
106
|
});
|
|
78
107
|
get id(): string;
|
|
79
108
|
get status(): TransactionRecord["status"];
|
|
80
109
|
get snapshotVersion(): number | null;
|
|
81
110
|
get pendingBlockIds(): string[];
|
|
82
111
|
get pendingSegmentIds(): string[];
|
|
83
|
-
|
|
112
|
+
/** Process-local segments retained for a bounded single-shot commit. */
|
|
113
|
+
get deferredSegments(): SegmentRecord[];
|
|
114
|
+
get pendingTableNextRowId(): bigint | undefined;
|
|
115
|
+
get initialCatalogProbe(): {
|
|
116
|
+
catalogEpoch: number;
|
|
117
|
+
manifestVersion: number | null;
|
|
118
|
+
schemaEpoch: number;
|
|
119
|
+
} | undefined;
|
|
120
|
+
/** Exact local commit contribution; undefined until this transaction commits. */
|
|
121
|
+
get committedCatalogContribution(): {
|
|
122
|
+
transaction: TransactionRecord;
|
|
123
|
+
segments: SegmentRecord[];
|
|
124
|
+
initialCatalogProbe?: {
|
|
125
|
+
catalogEpoch: number;
|
|
126
|
+
manifestVersion: number | null;
|
|
127
|
+
schemaEpoch: number;
|
|
128
|
+
};
|
|
129
|
+
} | undefined;
|
|
130
|
+
get compactionSourceBlockIds(): string[];
|
|
131
|
+
/** Extends durable ownership; scope owners call this while user code is legitimately waiting. */
|
|
132
|
+
renew(): Promise<void>;
|
|
84
133
|
/**
|
|
85
134
|
* Counts every registration this transaction carries: staged blocks and segments, unique-key
|
|
86
135
|
* entries, full-text entries, and supersessions. A caller that fails part-way through a
|
|
@@ -91,6 +140,8 @@ export declare class DatabaseTransaction {
|
|
|
91
140
|
get stagedWorkCount(): number;
|
|
92
141
|
/** Captures all publish-relevant state; row-id/autoincrement reservations deliberately burn. */
|
|
93
142
|
checkpoint(): TransactionCheckpoint;
|
|
143
|
+
/** Conservative retained-size estimate used to refuse savepoint clones before allocating. */
|
|
144
|
+
checkpointRetainedBytes(): number;
|
|
94
145
|
/** Rewinds staged artifacts and every in-memory commit delta to one earlier checkpoint. */
|
|
95
146
|
rollbackTo(checkpoint: TransactionCheckpoint): Promise<void>;
|
|
96
147
|
snapshot(): Promise<Snapshot>;
|
|
@@ -125,6 +176,8 @@ export declare class DatabaseTransaction {
|
|
|
125
176
|
stageSegment(record: SegmentRecord): Promise<void>;
|
|
126
177
|
/** Reconciles a persisted segment whose journal update was interrupted. */
|
|
127
178
|
stageExistingSegment(segmentId: string): Promise<void>;
|
|
179
|
+
/** Atomically adopts an exact unpublished output left by an aborted attempt of this job. */
|
|
180
|
+
adoptAbortedCompactionSegment(record: SegmentRecord, abortedOwner: TransactionRecord): Promise<void>;
|
|
128
181
|
/**
|
|
129
182
|
* Records that this commit changes a table's logical content without staging a segment for
|
|
130
183
|
* it — dropping the table, for instance, whose only publish is the retirement of its blocks.
|
|
@@ -147,7 +200,14 @@ export declare class DatabaseTransaction {
|
|
|
147
200
|
* and token totals summed — so a scope can insert into one FTS table any number of times.
|
|
148
201
|
*/
|
|
149
202
|
setFtsChanges(changes: FtsChanges): void;
|
|
150
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Binds a physical retirement to one persisted compaction job. Stores revalidate the job,
|
|
205
|
+
* source segments, current manifest, and aliases atomically with publication; this in-memory
|
|
206
|
+
* declaration is intent, never authority to hide arbitrary blocks.
|
|
207
|
+
*/
|
|
208
|
+
setCompactionIntent(compactionJobId: string, sourceBlockIds: readonly string[]): void;
|
|
209
|
+
/** Adds an adapter-enforced post-commit level-zero ceiling for one table. */
|
|
210
|
+
limitLevelZeroSegments(tableId: string, limit: number): void;
|
|
151
211
|
commit(): Promise<ManifestSummary>;
|
|
152
212
|
rebase(): Promise<Snapshot>;
|
|
153
213
|
abort(): Promise<void>;
|
|
@@ -157,14 +217,16 @@ export declare class TransactionManager {
|
|
|
157
217
|
private readonly store;
|
|
158
218
|
constructor(store: BlockStore, options?: TransactionManagerOptions);
|
|
159
219
|
begin(): Promise<DatabaseTransaction>;
|
|
220
|
+
/** Atomically reserves an invisible catalog table for a create-and-populate transaction. */
|
|
221
|
+
beginWithPendingTable(record: TableRecord, expectedCatalogEpoch: number): Promise<DatabaseTransaction>;
|
|
160
222
|
/**
|
|
161
|
-
* Begins a transaction
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
223
|
+
* Begins without a transaction record. By default a renewable reader lease durably pins the
|
|
224
|
+
* probed manifest until the first two-step stage hands ownership to a transaction record. The
|
|
225
|
+
* record and lease are both omitted only for internal, uninterrupted single-shot writes that
|
|
226
|
+
* opt out and publish through `writeTransaction`. For writes whose artifacts need no prior
|
|
227
|
+
* reservation; `beginWithReservation` is the shape for the rest.
|
|
166
228
|
*/
|
|
167
|
-
beginDeferred(): Promise<DatabaseTransaction>;
|
|
229
|
+
beginDeferred(options?: BeginDeferredOptions): Promise<DatabaseTransaction>;
|
|
168
230
|
/**
|
|
169
231
|
* Begins a transaction at the current manifest version and optionally reserves row ids and
|
|
170
232
|
* auto-increment values in the same step. Stores implementing the atomic `beginTransaction`
|
|
@@ -186,7 +248,7 @@ export declare class TransactionManager {
|
|
|
186
248
|
}>;
|
|
187
249
|
resume(transactionId: string): Promise<DatabaseTransaction>;
|
|
188
250
|
openSnapshot(version?: number | null): Promise<Snapshot>;
|
|
189
|
-
openLeasedSnapshot(options: OpenLeasedSnapshotOptions
|
|
251
|
+
openLeasedSnapshot(options: OpenLeasedSnapshotOptions): Promise<LeasedSnapshot>;
|
|
190
252
|
/**
|
|
191
253
|
* Re-pins an open leased snapshot to another version — one reader moving on to a newer
|
|
192
254
|
* commit. With the store's atomic `moveLease` the record stays and moves in one round trip;
|
|
@@ -197,8 +259,7 @@ export declare class TransactionManager {
|
|
|
197
259
|
*/
|
|
198
260
|
moveLeasedSnapshot(snapshot: LeasedSnapshot, options: OpenLeasedSnapshotOptions & {
|
|
199
261
|
version: number | null;
|
|
200
|
-
}
|
|
262
|
+
}): Promise<LeasedSnapshot>;
|
|
201
263
|
removeExpiredLeases(at?: Date): Promise<string[]>;
|
|
202
264
|
recover(options: RecoveryOptions): Promise<RecoveryReport>;
|
|
203
265
|
}
|
|
204
|
-
//# sourceMappingURL=index.d.ts.map
|