@minnowdb/core 0.10.0 → 0.10.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/dist/engine/auto-store.d.ts +15 -3
- package/dist/engine/auto-store.js +48 -6
- package/dist/engine/client-audit-harness.js +123 -0
- package/dist/engine/client.js +21 -6
- package/dist/engine/database.js +223 -56
- package/dist/engine/worker-host.js +2 -0
- package/dist/engine/worker-server.js +4 -5
- package/dist/engine/worker-store-auto.js +2 -2
- package/dist/engine/write-coordinator.js +21 -1
- package/dist/storage/indexeddb-audit-helpers.js +269 -0
- package/dist/storage/indexeddb.js +107 -169
- package/dist/storage/opfs/coordination-helpers.js +54 -0
- package/dist/storage/opfs/index.d.ts +1 -1
- package/dist/storage/opfs/index.js +3 -2
- package/dist/storage/opfs/leader.js +44 -5
- package/dist/storage/opfs/power-loss-model.js +62 -0
- package/dist/storage/opfs/rpc.js +1 -0
- package/dist/storage/opfs/store.d.ts +12 -0
- package/dist/storage/opfs/store.js +59 -12
- package/dist/storage/toolkit/wal.js +16 -0
- package/dist/storage/toolkit/wire.js +3 -3
- package/dist/storage/types.d.ts +2 -2
- package/dist/transactions/index.d.ts +7 -0
- package/dist/transactions/index.js +17 -3
- package/package.json +1 -1
|
@@ -253,8 +253,7 @@ class IndexedDbBlockStore {
|
|
|
253
253
|
return result;
|
|
254
254
|
} catch (error) {
|
|
255
255
|
abortIfActive(transaction);
|
|
256
|
-
await
|
|
257
|
-
throw error;
|
|
256
|
+
throw await refusalBehindAbort(transaction, error);
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
async readManifestBlock(version, id) {
|
|
@@ -288,8 +287,7 @@ class IndexedDbBlockStore {
|
|
|
288
287
|
return bytes;
|
|
289
288
|
} catch (error) {
|
|
290
289
|
abortIfActive(transaction);
|
|
291
|
-
await
|
|
292
|
-
throw error;
|
|
290
|
+
throw await refusalBehindAbort(transaction, error);
|
|
293
291
|
}
|
|
294
292
|
}
|
|
295
293
|
async hasManifestBlocks(version, ids) {
|
|
@@ -314,8 +312,7 @@ class IndexedDbBlockStore {
|
|
|
314
312
|
return result;
|
|
315
313
|
} catch (error) {
|
|
316
314
|
abortIfActive(transaction);
|
|
317
|
-
await
|
|
318
|
-
throw error;
|
|
315
|
+
throw await refusalBehindAbort(transaction, error);
|
|
319
316
|
}
|
|
320
317
|
}
|
|
321
318
|
async listManifestBlockPage(input) {
|
|
@@ -346,8 +343,7 @@ class IndexedDbBlockStore {
|
|
|
346
343
|
};
|
|
347
344
|
} catch (error) {
|
|
348
345
|
abortIfActive(transaction);
|
|
349
|
-
await
|
|
350
|
-
throw error;
|
|
346
|
+
throw await refusalBehindAbort(transaction, error);
|
|
351
347
|
}
|
|
352
348
|
}
|
|
353
349
|
async listRetiredManifestBlockPage(input) {
|
|
@@ -372,8 +368,7 @@ class IndexedDbBlockStore {
|
|
|
372
368
|
};
|
|
373
369
|
} catch (error) {
|
|
374
370
|
abortIfActive(transaction);
|
|
375
|
-
await
|
|
376
|
-
throw error;
|
|
371
|
+
throw await refusalBehindAbort(transaction, error);
|
|
377
372
|
}
|
|
378
373
|
}
|
|
379
374
|
async putTempRunPage(page) {
|
|
@@ -392,8 +387,7 @@ class IndexedDbBlockStore {
|
|
|
392
387
|
await transactionDone(transaction);
|
|
393
388
|
} catch (error) {
|
|
394
389
|
abortIfActive(transaction);
|
|
395
|
-
await
|
|
396
|
-
throw error;
|
|
390
|
+
throw await refusalBehindAbort(transaction, error);
|
|
397
391
|
}
|
|
398
392
|
}
|
|
399
393
|
async getTempRunPage(ownerId, runId, pageIndex) {
|
|
@@ -412,8 +406,7 @@ class IndexedDbBlockStore {
|
|
|
412
406
|
await transactionDone(transaction);
|
|
413
407
|
} catch (error) {
|
|
414
408
|
abortIfActive(transaction);
|
|
415
|
-
await
|
|
416
|
-
throw error;
|
|
409
|
+
throw await refusalBehindAbort(transaction, error);
|
|
417
410
|
}
|
|
418
411
|
}
|
|
419
412
|
async removeTempOwner(ownerId) {
|
|
@@ -425,8 +418,7 @@ class IndexedDbBlockStore {
|
|
|
425
418
|
await transactionDone(transaction);
|
|
426
419
|
} catch (error) {
|
|
427
420
|
abortIfActive(transaction);
|
|
428
|
-
await
|
|
429
|
-
throw error;
|
|
421
|
+
throw await refusalBehindAbort(transaction, error);
|
|
430
422
|
}
|
|
431
423
|
}
|
|
432
424
|
async createTempOwner(record) {
|
|
@@ -448,8 +440,7 @@ class IndexedDbBlockStore {
|
|
|
448
440
|
await transactionDone(transaction);
|
|
449
441
|
} catch (error) {
|
|
450
442
|
abortIfActive(transaction);
|
|
451
|
-
await
|
|
452
|
-
throw error;
|
|
443
|
+
throw await refusalBehindAbort(transaction, error);
|
|
453
444
|
}
|
|
454
445
|
}
|
|
455
446
|
async getTempOwner(ownerId) {
|
|
@@ -589,8 +580,7 @@ class IndexedDbBlockStore {
|
|
|
589
580
|
await transactionDone(transaction);
|
|
590
581
|
} catch (error) {
|
|
591
582
|
abortIfActive(transaction);
|
|
592
|
-
await
|
|
593
|
-
throw error;
|
|
583
|
+
throw await refusalBehindAbort(transaction, error);
|
|
594
584
|
}
|
|
595
585
|
}
|
|
596
586
|
async getTable(id) {
|
|
@@ -780,8 +770,7 @@ class IndexedDbBlockStore {
|
|
|
780
770
|
return updated;
|
|
781
771
|
} catch (error) {
|
|
782
772
|
abortIfActive(transaction);
|
|
783
|
-
await
|
|
784
|
-
throw error;
|
|
773
|
+
throw await refusalBehindAbort(transaction, error);
|
|
785
774
|
}
|
|
786
775
|
}
|
|
787
776
|
async beginUniqueKeyBuild(input) {
|
|
@@ -836,8 +825,7 @@ class IndexedDbBlockStore {
|
|
|
836
825
|
return structuredClone(record);
|
|
837
826
|
} catch (error) {
|
|
838
827
|
abortIfActive(transaction);
|
|
839
|
-
await
|
|
840
|
-
throw error;
|
|
828
|
+
throw await refusalBehindAbort(transaction, error);
|
|
841
829
|
}
|
|
842
830
|
}
|
|
843
831
|
async getUniqueKeyBuild(buildId) {
|
|
@@ -872,8 +860,7 @@ class IndexedDbBlockStore {
|
|
|
872
860
|
return structuredClone(record);
|
|
873
861
|
} catch (error) {
|
|
874
862
|
abortIfActive(transaction);
|
|
875
|
-
await
|
|
876
|
-
throw error;
|
|
863
|
+
throw await refusalBehindAbort(transaction, error);
|
|
877
864
|
}
|
|
878
865
|
}
|
|
879
866
|
async appendUniqueKeyBuildChunk(input) {
|
|
@@ -946,8 +933,7 @@ class IndexedDbBlockStore {
|
|
|
946
933
|
return structuredClone(record);
|
|
947
934
|
} catch (error) {
|
|
948
935
|
abortIfActive(transaction);
|
|
949
|
-
await
|
|
950
|
-
throw error;
|
|
936
|
+
throw await refusalBehindAbort(transaction, error);
|
|
951
937
|
}
|
|
952
938
|
}
|
|
953
939
|
async finishUniqueKeyBuild(input) {
|
|
@@ -1039,8 +1025,7 @@ class IndexedDbBlockStore {
|
|
|
1039
1025
|
return structuredClone(updated);
|
|
1040
1026
|
} catch (error) {
|
|
1041
1027
|
abortIfActive(transaction);
|
|
1042
|
-
await
|
|
1043
|
-
throw error;
|
|
1028
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1044
1029
|
}
|
|
1045
1030
|
}
|
|
1046
1031
|
async abortUniqueKeyBuild(input) {
|
|
@@ -1067,8 +1052,7 @@ class IndexedDbBlockStore {
|
|
|
1067
1052
|
await transactionDone(transaction);
|
|
1068
1053
|
} catch (error) {
|
|
1069
1054
|
abortIfActive(transaction);
|
|
1070
|
-
await
|
|
1071
|
-
throw error;
|
|
1055
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1072
1056
|
}
|
|
1073
1057
|
await this.#cleanupUniqueKeyBuildArtifacts(input.buildId);
|
|
1074
1058
|
return true;
|
|
@@ -1093,8 +1077,7 @@ class IndexedDbBlockStore {
|
|
|
1093
1077
|
}
|
|
1094
1078
|
} catch (error) {
|
|
1095
1079
|
abortIfActive(transaction);
|
|
1096
|
-
await
|
|
1097
|
-
throw error;
|
|
1080
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1098
1081
|
}
|
|
1099
1082
|
}
|
|
1100
1083
|
async dropTable(input) {
|
|
@@ -1187,8 +1170,7 @@ class IndexedDbBlockStore {
|
|
|
1187
1170
|
return manifest;
|
|
1188
1171
|
} catch (error) {
|
|
1189
1172
|
abortIfActive(transaction);
|
|
1190
|
-
await
|
|
1191
|
-
throw error;
|
|
1173
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1192
1174
|
}
|
|
1193
1175
|
}
|
|
1194
1176
|
async dropTableColumn(input) {
|
|
@@ -1325,8 +1307,7 @@ class IndexedDbBlockStore {
|
|
|
1325
1307
|
return manifest;
|
|
1326
1308
|
} catch (error) {
|
|
1327
1309
|
abortIfActive(transaction);
|
|
1328
|
-
await
|
|
1329
|
-
throw error;
|
|
1310
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1330
1311
|
}
|
|
1331
1312
|
}
|
|
1332
1313
|
async writeFtsBase(tableId, columnId, input) {
|
|
@@ -1462,8 +1443,7 @@ class IndexedDbBlockStore {
|
|
|
1462
1443
|
await transactionDone(transaction);
|
|
1463
1444
|
} catch (error) {
|
|
1464
1445
|
abortIfActive(transaction);
|
|
1465
|
-
await
|
|
1466
|
-
throw error;
|
|
1446
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1467
1447
|
}
|
|
1468
1448
|
}
|
|
1469
1449
|
async writeFtsBaseBuildChunk(input) {
|
|
@@ -1881,8 +1861,7 @@ class IndexedDbBlockStore {
|
|
|
1881
1861
|
};
|
|
1882
1862
|
} catch (error) {
|
|
1883
1863
|
abortIfActive(transaction);
|
|
1884
|
-
await
|
|
1885
|
-
throw error;
|
|
1864
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1886
1865
|
}
|
|
1887
1866
|
}
|
|
1888
1867
|
async removeAbortedSegment(segmentId, expectedTransactionId) {
|
|
@@ -1958,8 +1937,7 @@ class IndexedDbBlockStore {
|
|
|
1958
1937
|
return true;
|
|
1959
1938
|
} catch (error) {
|
|
1960
1939
|
abortIfActive(transaction);
|
|
1961
|
-
await
|
|
1962
|
-
throw error;
|
|
1940
|
+
throw await refusalBehindAbort(transaction, error);
|
|
1963
1941
|
}
|
|
1964
1942
|
}
|
|
1965
1943
|
async adoptAbortedSegment(input) {
|
|
@@ -2100,8 +2078,7 @@ class IndexedDbBlockStore {
|
|
|
2100
2078
|
return structuredClone(updatedReplacement);
|
|
2101
2079
|
} catch (error) {
|
|
2102
2080
|
abortIfActive(transaction);
|
|
2103
|
-
await
|
|
2104
|
-
throw error;
|
|
2081
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2105
2082
|
}
|
|
2106
2083
|
}
|
|
2107
2084
|
async reserveRowIds(tableId, count) {
|
|
@@ -2123,8 +2100,7 @@ class IndexedDbBlockStore {
|
|
|
2123
2100
|
return { start, endExclusive };
|
|
2124
2101
|
} catch (error) {
|
|
2125
2102
|
abortIfActive(transaction);
|
|
2126
|
-
await
|
|
2127
|
-
throw error;
|
|
2103
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2128
2104
|
}
|
|
2129
2105
|
}
|
|
2130
2106
|
async reserveAutoIncrement(tableId, columnId, count, atLeast) {
|
|
@@ -2145,8 +2121,7 @@ class IndexedDbBlockStore {
|
|
|
2145
2121
|
return { start, endExclusive };
|
|
2146
2122
|
} catch (error) {
|
|
2147
2123
|
abortIfActive(transaction);
|
|
2148
|
-
await
|
|
2149
|
-
throw error;
|
|
2124
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2150
2125
|
}
|
|
2151
2126
|
}
|
|
2152
2127
|
async getExistingUniqueKeys(tableId, keyTokens) {
|
|
@@ -2255,8 +2230,7 @@ class IndexedDbBlockStore {
|
|
|
2255
2230
|
};
|
|
2256
2231
|
} catch (error) {
|
|
2257
2232
|
abortIfActive(transaction);
|
|
2258
|
-
await
|
|
2259
|
-
throw error;
|
|
2233
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2260
2234
|
}
|
|
2261
2235
|
}
|
|
2262
2236
|
async getCurrentManifest() {
|
|
@@ -2393,8 +2367,7 @@ class IndexedDbBlockStore {
|
|
|
2393
2367
|
};
|
|
2394
2368
|
} catch (error) {
|
|
2395
2369
|
abortIfActive(transaction);
|
|
2396
|
-
await
|
|
2397
|
-
throw error;
|
|
2370
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2398
2371
|
}
|
|
2399
2372
|
}
|
|
2400
2373
|
async createTransaction(record) {
|
|
@@ -2440,8 +2413,7 @@ class IndexedDbBlockStore {
|
|
|
2440
2413
|
await transactionDone(transaction);
|
|
2441
2414
|
} catch (error) {
|
|
2442
2415
|
abortIfActive(transaction);
|
|
2443
|
-
await
|
|
2444
|
-
throw error;
|
|
2416
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2445
2417
|
}
|
|
2446
2418
|
}
|
|
2447
2419
|
async getTransaction(id) {
|
|
@@ -2511,15 +2483,14 @@ class IndexedDbBlockStore {
|
|
|
2511
2483
|
});
|
|
2512
2484
|
}
|
|
2513
2485
|
if (addedBlocks.length > 0 || addedSegments.length > 0) {
|
|
2514
|
-
appendTransactionJournalChunks(transaction, stored,
|
|
2486
|
+
appendTransactionJournalChunks(transaction, stored, await readTransactionJournalTail(transaction, stored), addedBlocks, addedSegments);
|
|
2515
2487
|
}
|
|
2516
2488
|
putStoredTransactionRecord(transaction, storedTransactionRecord(updated));
|
|
2517
2489
|
await transactionDone(transaction);
|
|
2518
2490
|
return updated;
|
|
2519
2491
|
} catch (error) {
|
|
2520
2492
|
abortIfActive(transaction);
|
|
2521
|
-
await
|
|
2522
|
-
throw error;
|
|
2493
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2523
2494
|
}
|
|
2524
2495
|
}
|
|
2525
2496
|
async renewTransaction(input) {
|
|
@@ -2550,8 +2521,7 @@ class IndexedDbBlockStore {
|
|
|
2550
2521
|
return true;
|
|
2551
2522
|
} catch (error) {
|
|
2552
2523
|
abortIfActive(transaction);
|
|
2553
|
-
await
|
|
2554
|
-
throw error;
|
|
2524
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2555
2525
|
}
|
|
2556
2526
|
}
|
|
2557
2527
|
async abortTransactionIfExpired(input) {
|
|
@@ -2588,8 +2558,7 @@ class IndexedDbBlockStore {
|
|
|
2588
2558
|
return structuredClone(updated);
|
|
2589
2559
|
} catch (error) {
|
|
2590
2560
|
abortIfActive(transaction);
|
|
2591
|
-
await
|
|
2592
|
-
throw error;
|
|
2561
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2593
2562
|
}
|
|
2594
2563
|
}
|
|
2595
2564
|
async stageTransactionArtifacts(input) {
|
|
@@ -2694,8 +2663,7 @@ class IndexedDbBlockStore {
|
|
|
2694
2663
|
return transactionRecordWithJournal(updated, journal.blockIds, journal.segmentIds);
|
|
2695
2664
|
} catch (error) {
|
|
2696
2665
|
abortIfActive(transaction);
|
|
2697
|
-
await
|
|
2698
|
-
throw error;
|
|
2666
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2699
2667
|
}
|
|
2700
2668
|
}
|
|
2701
2669
|
async #journaledIds(transaction, stored, tail) {
|
|
@@ -2849,8 +2817,7 @@ class IndexedDbBlockStore {
|
|
|
2849
2817
|
return structuredClone(updated);
|
|
2850
2818
|
} catch (error) {
|
|
2851
2819
|
abortIfActive(transaction);
|
|
2852
|
-
await
|
|
2853
|
-
throw error;
|
|
2820
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2854
2821
|
}
|
|
2855
2822
|
}
|
|
2856
2823
|
async commitTransaction(input) {
|
|
@@ -2881,8 +2848,7 @@ class IndexedDbBlockStore {
|
|
|
2881
2848
|
return outcome.manifest;
|
|
2882
2849
|
} catch (error) {
|
|
2883
2850
|
abortIfActive(transaction);
|
|
2884
|
-
await
|
|
2885
|
-
throw error;
|
|
2851
|
+
throw await refusalBehindAbort(transaction, error);
|
|
2886
2852
|
}
|
|
2887
2853
|
}
|
|
2888
2854
|
async writeTransaction(input) {
|
|
@@ -3014,8 +2980,7 @@ class IndexedDbBlockStore {
|
|
|
3014
2980
|
return outcome.manifest;
|
|
3015
2981
|
} catch (error) {
|
|
3016
2982
|
abortIfActive(transaction);
|
|
3017
|
-
await
|
|
3018
|
-
throw error;
|
|
2983
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3019
2984
|
}
|
|
3020
2985
|
}
|
|
3021
2986
|
async #commitInTransaction(transaction, record, journal, input) {
|
|
@@ -3076,15 +3041,11 @@ class IndexedDbBlockStore {
|
|
|
3076
3041
|
if (pendingRemovedBlock !== void 0) {
|
|
3077
3042
|
throw new Error(`Cannot supersede a pending block: ${pendingRemovedBlock}`);
|
|
3078
3043
|
}
|
|
3079
|
-
let baseBlockIdSet;
|
|
3080
3044
|
const removedMembership = await manifestBlockMembershipInTransaction(catalog, input.expectedManifestVersion, removedBlockIds);
|
|
3081
3045
|
const invalidRemovedIndex = removedMembership.findIndex((present) => !present);
|
|
3082
3046
|
if (invalidRemovedIndex >= 0) {
|
|
3083
3047
|
throw new Error(`Cannot supersede a block outside the transaction snapshot: ${removedBlockIds[invalidRemovedIndex] ?? ""}`);
|
|
3084
3048
|
}
|
|
3085
|
-
if ((input.levelZeroSegmentLimits?.length ?? 0) > 0) {
|
|
3086
|
-
baseBlockIdSet = await resolveManifestBlockSetInTransaction(catalog, input.expectedManifestVersion);
|
|
3087
|
-
}
|
|
3088
3049
|
if (removedBlockIds.length > 0) {
|
|
3089
3050
|
await assertCompactionRetirementInTransaction(transaction, record, input, removedBlockIds);
|
|
3090
3051
|
}
|
|
@@ -3106,7 +3067,7 @@ class IndexedDbBlockStore {
|
|
|
3106
3067
|
throw new Error(`Segment ${foreignSegment.id} belongs to another transaction`);
|
|
3107
3068
|
}
|
|
3108
3069
|
await assertCompactionOutputSegmentsInTransaction(transaction, record, input.compactionJobId, pendingSegments);
|
|
3109
|
-
await assertLevelZeroSegmentLimits(transaction, input.levelZeroSegmentLimits ?? [], pendingSegments,
|
|
3070
|
+
await assertLevelZeroSegmentLimits(transaction, input.levelZeroSegmentLimits ?? [], pendingSegments, input.expectedManifestVersion, pendingTable);
|
|
3110
3071
|
const uniqueKeyEntries = input.uniqueKeyChanges ?? [];
|
|
3111
3072
|
const coveredUniqueNamespaces = new Set(uniqueKeyEntries.map((entry) => entry.tableId));
|
|
3112
3073
|
const changedTableIds = /* @__PURE__ */ new Set([
|
|
@@ -3547,8 +3508,7 @@ class IndexedDbBlockStore {
|
|
|
3547
3508
|
await transactionDone(transaction);
|
|
3548
3509
|
} catch (error) {
|
|
3549
3510
|
abortIfActive(transaction);
|
|
3550
|
-
await
|
|
3551
|
-
throw error;
|
|
3511
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3552
3512
|
}
|
|
3553
3513
|
}
|
|
3554
3514
|
async getLease(id) {
|
|
@@ -3627,8 +3587,7 @@ class IndexedDbBlockStore {
|
|
|
3627
3587
|
return structuredClone(renewed);
|
|
3628
3588
|
} catch (error) {
|
|
3629
3589
|
abortIfActive(transaction);
|
|
3630
|
-
await
|
|
3631
|
-
throw error;
|
|
3590
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3632
3591
|
}
|
|
3633
3592
|
}
|
|
3634
3593
|
async moveLease(input) {
|
|
@@ -3669,8 +3628,7 @@ class IndexedDbBlockStore {
|
|
|
3669
3628
|
return structuredClone(moved);
|
|
3670
3629
|
} catch (error) {
|
|
3671
3630
|
abortIfActive(transaction);
|
|
3672
|
-
await
|
|
3673
|
-
throw error;
|
|
3631
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3674
3632
|
}
|
|
3675
3633
|
}
|
|
3676
3634
|
async removeLeaseIfExpired(id, expectedRevision, expiresAtCutoff) {
|
|
@@ -3937,8 +3895,7 @@ class IndexedDbBlockStore {
|
|
|
3937
3895
|
return true;
|
|
3938
3896
|
} catch (error) {
|
|
3939
3897
|
abortIfActive(transaction);
|
|
3940
|
-
await
|
|
3941
|
-
throw error;
|
|
3898
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3942
3899
|
}
|
|
3943
3900
|
}
|
|
3944
3901
|
async createGarbageCollectionJob(input) {
|
|
@@ -3978,8 +3935,7 @@ class IndexedDbBlockStore {
|
|
|
3978
3935
|
return structuredClone(record);
|
|
3979
3936
|
} catch (error) {
|
|
3980
3937
|
abortIfActive(transaction);
|
|
3981
|
-
await
|
|
3982
|
-
throw error;
|
|
3938
|
+
throw await refusalBehindAbort(transaction, error);
|
|
3983
3939
|
}
|
|
3984
3940
|
}
|
|
3985
3941
|
async updateGarbageCollectionPlanning(input) {
|
|
@@ -4007,8 +3963,7 @@ class IndexedDbBlockStore {
|
|
|
4007
3963
|
return structuredClone(updated);
|
|
4008
3964
|
} catch (error) {
|
|
4009
3965
|
abortIfActive(transaction);
|
|
4010
|
-
await
|
|
4011
|
-
throw error;
|
|
3966
|
+
throw await refusalBehindAbort(transaction, error);
|
|
4012
3967
|
}
|
|
4013
3968
|
}
|
|
4014
3969
|
async getGarbageCollectionJob(id) {
|
|
@@ -4259,8 +4214,7 @@ class IndexedDbBlockStore {
|
|
|
4259
4214
|
};
|
|
4260
4215
|
} catch (error) {
|
|
4261
4216
|
abortIfActive(transaction);
|
|
4262
|
-
await
|
|
4263
|
-
throw error;
|
|
4217
|
+
throw await refusalBehindAbort(transaction, error);
|
|
4264
4218
|
}
|
|
4265
4219
|
}
|
|
4266
4220
|
async removePrunedManifestRecords(maxItems) {
|
|
@@ -4322,8 +4276,7 @@ class IndexedDbBlockStore {
|
|
|
4322
4276
|
return removed;
|
|
4323
4277
|
} catch (error) {
|
|
4324
4278
|
abortIfActive(transaction);
|
|
4325
|
-
await
|
|
4326
|
-
throw error;
|
|
4279
|
+
throw await refusalBehindAbort(transaction, error);
|
|
4327
4280
|
}
|
|
4328
4281
|
}
|
|
4329
4282
|
async removeGarbageCollectionJob(id) {
|
|
@@ -4426,8 +4379,7 @@ class IndexedDbBlockStore {
|
|
|
4426
4379
|
};
|
|
4427
4380
|
} catch (error) {
|
|
4428
4381
|
abortIfActive(transaction);
|
|
4429
|
-
await
|
|
4430
|
-
throw error;
|
|
4382
|
+
throw await refusalBehindAbort(transaction, error);
|
|
4431
4383
|
}
|
|
4432
4384
|
}
|
|
4433
4385
|
async getStorageStats() {
|
|
@@ -5619,8 +5571,7 @@ class IndexedDbBlockStore {
|
|
|
5619
5571
|
return { sessionId, ownerId: input.ownerId, expiresAt: input.expiresAt, header };
|
|
5620
5572
|
} catch (error) {
|
|
5621
5573
|
abortIfActive(transaction);
|
|
5622
|
-
await
|
|
5623
|
-
throw error;
|
|
5574
|
+
throw await refusalBehindAbort(transaction, error);
|
|
5624
5575
|
}
|
|
5625
5576
|
}
|
|
5626
5577
|
async readSnapshotExportFrame(input) {
|
|
@@ -5696,8 +5647,7 @@ class IndexedDbBlockStore {
|
|
|
5696
5647
|
return frame;
|
|
5697
5648
|
} catch (error) {
|
|
5698
5649
|
abortIfActive(transaction);
|
|
5699
|
-
await
|
|
5700
|
-
throw error;
|
|
5650
|
+
throw await refusalBehindAbort(transaction, error);
|
|
5701
5651
|
}
|
|
5702
5652
|
}
|
|
5703
5653
|
async closeSnapshotFrameExport(input) {
|
|
@@ -5725,8 +5675,7 @@ class IndexedDbBlockStore {
|
|
|
5725
5675
|
return true;
|
|
5726
5676
|
} catch (error) {
|
|
5727
5677
|
abortIfActive(transaction);
|
|
5728
|
-
await
|
|
5729
|
-
throw error;
|
|
5678
|
+
throw await refusalBehindAbort(transaction, error);
|
|
5730
5679
|
}
|
|
5731
5680
|
}
|
|
5732
5681
|
async beginSnapshotFrameImport(input) {
|
|
@@ -5857,8 +5806,7 @@ class IndexedDbBlockStore {
|
|
|
5857
5806
|
return snapshotFrameImportSession(marker);
|
|
5858
5807
|
} catch (error) {
|
|
5859
5808
|
abortIfActive(transaction);
|
|
5860
|
-
await
|
|
5861
|
-
throw error;
|
|
5809
|
+
throw await refusalBehindAbort(transaction, error);
|
|
5862
5810
|
}
|
|
5863
5811
|
}
|
|
5864
5812
|
async renewSnapshotFrameImport(input) {
|
|
@@ -5876,8 +5824,7 @@ class IndexedDbBlockStore {
|
|
|
5876
5824
|
return snapshotFrameImportSession(renewed);
|
|
5877
5825
|
} catch (error) {
|
|
5878
5826
|
abortIfActive(transaction);
|
|
5879
|
-
await
|
|
5880
|
-
throw error;
|
|
5827
|
+
throw await refusalBehindAbort(transaction, error);
|
|
5881
5828
|
}
|
|
5882
5829
|
}
|
|
5883
5830
|
async appendSnapshotImportFrames(input) {
|
|
@@ -5998,8 +5945,7 @@ class IndexedDbBlockStore {
|
|
|
5998
5945
|
return snapshotFrameImportSession(marker);
|
|
5999
5946
|
} catch (error) {
|
|
6000
5947
|
abortIfActive(transaction);
|
|
6001
|
-
await
|
|
6002
|
-
throw error;
|
|
5948
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6003
5949
|
}
|
|
6004
5950
|
}
|
|
6005
5951
|
async finishSnapshotFrameImport(input) {
|
|
@@ -6055,8 +6001,7 @@ class IndexedDbBlockStore {
|
|
|
6055
6001
|
this.#journalCache = void 0;
|
|
6056
6002
|
} catch (error) {
|
|
6057
6003
|
abortIfActive(transaction);
|
|
6058
|
-
await
|
|
6059
|
-
throw error;
|
|
6004
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6060
6005
|
}
|
|
6061
6006
|
}
|
|
6062
6007
|
async cancelSnapshotFrameImport(input) {
|
|
@@ -6099,8 +6044,7 @@ class IndexedDbBlockStore {
|
|
|
6099
6044
|
};
|
|
6100
6045
|
} catch (error) {
|
|
6101
6046
|
abortIfActive(transaction);
|
|
6102
|
-
await
|
|
6103
|
-
throw error;
|
|
6047
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6104
6048
|
}
|
|
6105
6049
|
}
|
|
6106
6050
|
close() {
|
|
@@ -6157,8 +6101,7 @@ class IndexedDbBlockStore {
|
|
|
6157
6101
|
return true;
|
|
6158
6102
|
} catch (error) {
|
|
6159
6103
|
abortIfActive(transaction);
|
|
6160
|
-
await
|
|
6161
|
-
throw error;
|
|
6104
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6162
6105
|
}
|
|
6163
6106
|
}
|
|
6164
6107
|
}
|
|
@@ -6174,8 +6117,7 @@ class IndexedDbBlockStore {
|
|
|
6174
6117
|
return;
|
|
6175
6118
|
} catch (error) {
|
|
6176
6119
|
abortIfActive(transaction);
|
|
6177
|
-
await
|
|
6178
|
-
throw error;
|
|
6120
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6179
6121
|
}
|
|
6180
6122
|
}
|
|
6181
6123
|
}
|
|
@@ -6205,8 +6147,7 @@ class IndexedDbBlockStore {
|
|
|
6205
6147
|
await transactionDone(transaction);
|
|
6206
6148
|
} catch (error) {
|
|
6207
6149
|
abortIfActive(transaction);
|
|
6208
|
-
await
|
|
6209
|
-
throw error;
|
|
6150
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6210
6151
|
}
|
|
6211
6152
|
if (cleanup)
|
|
6212
6153
|
await this.#cleanupUniqueKeyBuildArtifacts(buildId);
|
|
@@ -6237,8 +6178,7 @@ class IndexedDbBlockStore {
|
|
|
6237
6178
|
return;
|
|
6238
6179
|
} catch (error) {
|
|
6239
6180
|
abortIfActive(transaction);
|
|
6240
|
-
await
|
|
6241
|
-
throw error;
|
|
6181
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6242
6182
|
}
|
|
6243
6183
|
}
|
|
6244
6184
|
}
|
|
@@ -6373,8 +6313,7 @@ class IndexedDbBlockStore {
|
|
|
6373
6313
|
await transactionDone(transaction);
|
|
6374
6314
|
} catch (error) {
|
|
6375
6315
|
abortIfActive(transaction);
|
|
6376
|
-
await
|
|
6377
|
-
throw error;
|
|
6316
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6378
6317
|
}
|
|
6379
6318
|
}
|
|
6380
6319
|
async #cleanupFtsRetirementPage() {
|
|
@@ -6390,8 +6329,7 @@ class IndexedDbBlockStore {
|
|
|
6390
6329
|
await transactionDone(transaction);
|
|
6391
6330
|
} catch (error) {
|
|
6392
6331
|
abortIfActive(transaction);
|
|
6393
|
-
await
|
|
6394
|
-
throw error;
|
|
6332
|
+
throw await refusalBehindAbort(transaction, error);
|
|
6395
6333
|
}
|
|
6396
6334
|
}
|
|
6397
6335
|
#transaction(stores, mode, options = {}) {
|
|
@@ -7050,6 +6988,14 @@ async function ignoreAbort(transaction) {
|
|
|
7050
6988
|
} catch {
|
|
7051
6989
|
}
|
|
7052
6990
|
}
|
|
6991
|
+
async function refusalBehindAbort(transaction, error) {
|
|
6992
|
+
await ignoreAbort(transaction);
|
|
6993
|
+
const refusal = transaction.error;
|
|
6994
|
+
if (refusal !== null && error instanceof DOMException && error.name === "AbortError") {
|
|
6995
|
+
return refusal;
|
|
6996
|
+
}
|
|
6997
|
+
return error;
|
|
6998
|
+
}
|
|
7053
6999
|
function corruption(location, message) {
|
|
7054
7000
|
return new StorageCorruptionError("indexeddb", location, message);
|
|
7055
7001
|
}
|
|
@@ -8929,8 +8875,12 @@ function asTableRecord(value, location = "catalog/table") {
|
|
|
8929
8875
|
"defaultValue",
|
|
8930
8876
|
"backfill",
|
|
8931
8877
|
"enumValues",
|
|
8932
|
-
"hidden"
|
|
8878
|
+
"hidden",
|
|
8879
|
+
"generatedValue"
|
|
8933
8880
|
], `${location}/columns/${String(index)}`);
|
|
8881
|
+
if (isRecord(column.generatedValue)) {
|
|
8882
|
+
assertKnownFields(column.generatedValue, ["kind", "sql"], `${location}/columns/${String(index)}/generatedValue`);
|
|
8883
|
+
}
|
|
8934
8884
|
if (isRecord(column.sqlDomain)) {
|
|
8935
8885
|
const domainFields = column.sqlDomain.kind === "numeric" ? ["kind", "precision", "scale"] : column.sqlDomain.kind === "array" ? ["kind", "element"] : column.sqlDomain.kind === "enum" ? ["kind", "name", "values"] : ["kind"];
|
|
8936
8886
|
assertKnownFields(column.sqlDomain, domainFields, `${location}/columns/${String(index)}/sqlDomain`);
|
|
@@ -9447,7 +9397,7 @@ async function assertCompactionOutputSegmentsInTransaction(transaction, committi
|
|
|
9447
9397
|
}));
|
|
9448
9398
|
assertCompactionOutputProvenance(job, table, committingTransaction, sourceSegments, pendingSegments);
|
|
9449
9399
|
}
|
|
9450
|
-
async function assertLevelZeroSegmentLimits(transaction, limits, pendingSegments,
|
|
9400
|
+
async function assertLevelZeroSegmentLimits(transaction, limits, pendingSegments, version, pendingTable) {
|
|
9451
9401
|
const pendingTables = new Set(pendingSegments.filter((segment) => segment.level === 0).map((segment) => segment.tableId));
|
|
9452
9402
|
if (limits.length !== pendingTables.size) {
|
|
9453
9403
|
throw new TypeError("Level-zero segment limits must exactly cover pending level-zero tables");
|
|
@@ -9472,7 +9422,7 @@ async function assertLevelZeroSegmentLimits(transaction, limits, pendingSegments
|
|
|
9472
9422
|
if (table === void 0) {
|
|
9473
9423
|
throw new Error(`Level-zero segment limit references missing table: ${entry.tableId}`);
|
|
9474
9424
|
}
|
|
9475
|
-
const existing = await countVisibleLevelZeroSegments(segmentIndex, transaction.objectStore("transactions"), entry.tableId
|
|
9425
|
+
const existing = await countVisibleLevelZeroSegments(segmentIndex, transaction.objectStore("transactions"), catalog, version, entry.tableId);
|
|
9476
9426
|
const added = pendingSegments.reduce((count2, segment) => count2 + (segment.tableId === entry.tableId && segment.level === 0 ? 1 : 0), 0);
|
|
9477
9427
|
const count = existing + added;
|
|
9478
9428
|
if (count > entry.limit) {
|
|
@@ -9480,66 +9430,54 @@ async function assertLevelZeroSegmentLimits(transaction, limits, pendingSegments
|
|
|
9480
9430
|
}
|
|
9481
9431
|
}
|
|
9482
9432
|
}
|
|
9483
|
-
function countVisibleLevelZeroSegments(index, transactions,
|
|
9484
|
-
|
|
9485
|
-
const
|
|
9486
|
-
let count = 0;
|
|
9433
|
+
async function countVisibleLevelZeroSegments(index, transactions, catalog, version, tableId) {
|
|
9434
|
+
const candidates = await new Promise((resolve, reject) => {
|
|
9435
|
+
const found = [];
|
|
9487
9436
|
const request = index.openCursor(tableId);
|
|
9488
9437
|
request.onerror = () => reject(request.error ?? new Error("IndexedDB segment cursor failed"));
|
|
9489
9438
|
request.onsuccess = () => {
|
|
9490
9439
|
const cursor = request.result;
|
|
9491
9440
|
if (cursor === null) {
|
|
9492
|
-
resolve(
|
|
9441
|
+
resolve(found);
|
|
9493
9442
|
return;
|
|
9494
9443
|
}
|
|
9495
|
-
let segment;
|
|
9496
9444
|
try {
|
|
9497
|
-
segment = asSegmentRecord(cursor.value);
|
|
9445
|
+
const segment = asSegmentRecord(cursor.value);
|
|
9498
9446
|
if (segment.id !== cursor.primaryKey || segment.tableId !== tableId) {
|
|
9499
9447
|
throw corruption(`segments/${segment.id}`, "table index does not match its record");
|
|
9500
9448
|
}
|
|
9501
|
-
if (segment.level
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
}
|
|
9505
|
-
const blockIds = segmentBlockIds(segment);
|
|
9506
|
-
const visibleBlockCount = blockIds.filter((id) => currentBlockIds.has(id)).length;
|
|
9507
|
-
if (visibleBlockCount > 0 && visibleBlockCount < blockIds.length) {
|
|
9508
|
-
throw corruption(`segments/${segment.id}`, "only part of the segment is manifest-live");
|
|
9509
|
-
}
|
|
9510
|
-
if (blockIds.length > 0 && visibleBlockCount === 0) {
|
|
9511
|
-
cursor.continue();
|
|
9512
|
-
return;
|
|
9513
|
-
}
|
|
9449
|
+
if (segment.level === 0)
|
|
9450
|
+
found.push(segment);
|
|
9451
|
+
cursor.continue();
|
|
9514
9452
|
} catch (error) {
|
|
9515
9453
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
9516
|
-
return;
|
|
9517
|
-
}
|
|
9518
|
-
const knownStatus = statuses.get(segment.transactionId);
|
|
9519
|
-
if (knownStatus !== void 0) {
|
|
9520
|
-
if (knownStatus === "committed")
|
|
9521
|
-
count += 1;
|
|
9522
|
-
cursor.continue();
|
|
9523
|
-
return;
|
|
9524
9454
|
}
|
|
9525
|
-
const ownerRequest = transactions.get(segment.transactionId);
|
|
9526
|
-
ownerRequest.onerror = () => reject(ownerRequest.error ?? new Error("IndexedDB transaction lookup failed"));
|
|
9527
|
-
ownerRequest.onsuccess = () => {
|
|
9528
|
-
try {
|
|
9529
|
-
if (ownerRequest.result === void 0) {
|
|
9530
|
-
throw corruption(`segments/${segment.id}`, `owning transaction ${segment.transactionId} is missing`);
|
|
9531
|
-
}
|
|
9532
|
-
const owner = asStoredTransactionRecord(ownerRequest.result, segment.transactionId);
|
|
9533
|
-
statuses.set(owner.id, owner.status);
|
|
9534
|
-
if (owner.status === "committed")
|
|
9535
|
-
count += 1;
|
|
9536
|
-
cursor.continue();
|
|
9537
|
-
} catch (error) {
|
|
9538
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
9539
|
-
}
|
|
9540
|
-
};
|
|
9541
9455
|
};
|
|
9542
9456
|
});
|
|
9457
|
+
const memberships = await Promise.all(candidates.map((segment) => manifestBlockMembershipInTransaction(catalog, version, segmentBlockIds(segment))));
|
|
9458
|
+
const statuses = /* @__PURE__ */ new Map();
|
|
9459
|
+
let count = 0;
|
|
9460
|
+
for (const [position, segment] of candidates.entries()) {
|
|
9461
|
+
const membership = memberships[position] ?? [];
|
|
9462
|
+
const visibleBlockCount = membership.filter((present) => present).length;
|
|
9463
|
+
if (visibleBlockCount > 0 && visibleBlockCount < membership.length) {
|
|
9464
|
+
throw corruption(`segments/${segment.id}`, "only part of the segment is manifest-live");
|
|
9465
|
+
}
|
|
9466
|
+
if (membership.length > 0 && visibleBlockCount === 0)
|
|
9467
|
+
continue;
|
|
9468
|
+
let status = statuses.get(segment.transactionId);
|
|
9469
|
+
if (status === void 0) {
|
|
9470
|
+
const owner = await requestResult(transactions.get(segment.transactionId));
|
|
9471
|
+
if (owner === void 0) {
|
|
9472
|
+
throw corruption(`segments/${segment.id}`, `owning transaction ${segment.transactionId} is missing`);
|
|
9473
|
+
}
|
|
9474
|
+
status = asStoredTransactionRecord(owner, segment.transactionId).status;
|
|
9475
|
+
statuses.set(segment.transactionId, status);
|
|
9476
|
+
}
|
|
9477
|
+
if (status === "committed")
|
|
9478
|
+
count += 1;
|
|
9479
|
+
}
|
|
9480
|
+
return count;
|
|
9543
9481
|
}
|
|
9544
9482
|
async function compactionJobRemovalPreservesProvenance(transaction, removedJob) {
|
|
9545
9483
|
const rootedBlocks = /* @__PURE__ */ new Set();
|