@quereus/quereus 4.7.0 → 4.8.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/src/common/types.d.ts +19 -0
- package/dist/src/common/types.d.ts.map +1 -1
- package/dist/src/common/types.js.map +1 -1
- package/dist/src/core/database.d.ts +39 -1
- package/dist/src/core/database.d.ts.map +1 -1
- package/dist/src/core/database.js +186 -1
- package/dist/src/core/database.js.map +1 -1
- package/dist/src/core/statement.d.ts.map +1 -1
- package/dist/src/core/statement.js +86 -0
- package/dist/src/core/statement.js.map +1 -1
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/runtime/emit/remote-query.d.ts.map +1 -1
- package/dist/src/runtime/emit/remote-query.js +8 -3
- package/dist/src/runtime/emit/remote-query.js.map +1 -1
- package/dist/src/runtime/emit/scan.d.ts.map +1 -1
- package/dist/src/runtime/emit/scan.js +4 -1
- package/dist/src/runtime/emit/scan.js.map +1 -1
- package/dist/src/runtime/emit/schema-declarative.js +2 -2
- package/dist/src/runtime/emit/schema-declarative.js.map +1 -1
- package/dist/src/runtime/parallel-driver.d.ts +4 -3
- package/dist/src/runtime/parallel-driver.d.ts.map +1 -1
- package/dist/src/runtime/parallel-driver.js +8 -3
- package/dist/src/runtime/parallel-driver.js.map +1 -1
- package/dist/src/runtime/types.d.ts +10 -0
- package/dist/src/runtime/types.d.ts.map +1 -1
- package/dist/src/runtime/types.js.map +1 -1
- package/dist/src/runtime/utils.d.ts.map +1 -1
- package/dist/src/runtime/utils.js +11 -0
- package/dist/src/runtime/utils.js.map +1 -1
- package/dist/src/util/abort-signal.d.ts +25 -0
- package/dist/src/util/abort-signal.d.ts.map +1 -0
- package/dist/src/util/abort-signal.js +40 -0
- package/dist/src/util/abort-signal.js.map +1 -0
- package/dist/src/vtab/concurrency.d.ts +15 -0
- package/dist/src/vtab/concurrency.d.ts.map +1 -1
- package/dist/src/vtab/concurrency.js +17 -0
- package/dist/src/vtab/concurrency.js.map +1 -1
- package/dist/src/vtab/memory/layer/base.d.ts +10 -0
- package/dist/src/vtab/memory/layer/base.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/base.js +10 -0
- package/dist/src/vtab/memory/layer/base.js.map +1 -1
- package/dist/src/vtab/memory/layer/interface.d.ts +24 -0
- package/dist/src/vtab/memory/layer/interface.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.d.ts +21 -3
- package/dist/src/vtab/memory/layer/manager.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/manager.js +104 -88
- package/dist/src/vtab/memory/layer/manager.js.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.d.ts +11 -0
- package/dist/src/vtab/memory/layer/transaction.d.ts.map +1 -1
- package/dist/src/vtab/memory/layer/transaction.js +19 -0
- package/dist/src/vtab/memory/layer/transaction.js.map +1 -1
- package/dist/src/vtab/memory/module.d.ts +41 -0
- package/dist/src/vtab/memory/module.d.ts.map +1 -1
- package/dist/src/vtab/memory/module.js +41 -0
- package/dist/src/vtab/memory/module.js.map +1 -1
- package/dist/src/vtab/memory/table.d.ts +12 -1
- package/dist/src/vtab/memory/table.d.ts.map +1 -1
- package/dist/src/vtab/memory/table.js +12 -1
- package/dist/src/vtab/memory/table.js.map +1 -1
- package/dist/src/vtab/module.d.ts +33 -0
- package/dist/src/vtab/module.d.ts.map +1 -1
- package/dist/src/vtab/test-support/commit-stall.d.ts +53 -0
- package/dist/src/vtab/test-support/commit-stall.d.ts.map +1 -0
- package/dist/src/vtab/test-support/commit-stall.js +73 -0
- package/dist/src/vtab/test-support/commit-stall.js.map +1 -0
- package/dist/src/vtab/test-support/committed-read-conformance.d.ts +96 -0
- package/dist/src/vtab/test-support/committed-read-conformance.d.ts.map +1 -0
- package/dist/src/vtab/test-support/committed-read-conformance.js +364 -0
- package/dist/src/vtab/test-support/committed-read-conformance.js.map +1 -0
- package/package.json +3 -3
|
@@ -49,6 +49,25 @@ export interface StatementOptions {
|
|
|
49
49
|
* before any work is performed.
|
|
50
50
|
*/
|
|
51
51
|
signal?: AbortSignal;
|
|
52
|
+
/**
|
|
53
|
+
* Read concurrency for this execution.
|
|
54
|
+
*
|
|
55
|
+
* - `'serialized'` (default) — queue behind the execution mutex. The read
|
|
56
|
+
* sees whatever an already-queued write left behind, exactly as today.
|
|
57
|
+
* - `'committed'` — when the statement is eligible (a read-only query in
|
|
58
|
+
* autocommit mode whose every table's module declares
|
|
59
|
+
* `readCommittedSnapshot`), run WITHOUT the mutex against each table's last
|
|
60
|
+
* committed state, so the read completes even while another statement is
|
|
61
|
+
* blocked in its virtual-table commit. An ineligible statement silently
|
|
62
|
+
* falls back to `'serialized'` — never an error.
|
|
63
|
+
*
|
|
64
|
+
* `'committed'` deliberately gives up the ordering guarantee that
|
|
65
|
+
* `void db.exec(insert); await db.get(select)` shows the insert — the read
|
|
66
|
+
* may serve the pre-insert state. That is why it is opt-in per call.
|
|
67
|
+
* Honored by the row-returning entry points (`Database.get`, `Database.eval`,
|
|
68
|
+
* `Statement.get/all/iterateRows/run`); `Database.exec` ignores it.
|
|
69
|
+
*/
|
|
70
|
+
readConcurrency?: 'serialized' | 'committed';
|
|
52
71
|
}
|
|
53
72
|
/**
|
|
54
73
|
* Standard status/error codes that significantly match SQLite.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,MAAM,YAAY,CAAC,CAAC,IACzB,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAA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AG,CAAC,EAAE,GAAG,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,GAAG,EAAE,CAAA;CAAE,GAC5E;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAE7F;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC;IAAC,WAAW,CAAC,EAAE,SAAS,GAAG,EAAE,CAAA;CAAE,CAEvI;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,cAAc,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,GAAG,CAAA;CAAE,CAE/J;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAQ5D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAShE;AAED,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/common/types.ts"],"names":[],"mappings":"AAmFA;;;GAGG;AACH,MAAM,CAAN,IAAY,UAgCX;AAhCD,WAAY,UAAU;IACrB,uCAAM,CAAA;IACN,6CAAS,CAAA;IACT,mDAAY,C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,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvF,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7C,iDAAiD;IACjD,IAAI,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/G,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACvD,MAAM,CAAC,GAAG,OAAO,KAAK,CAAC;IACvB,IAAI,CAAC,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,KAAK,YAAY,UAAU;YAAE,OAAO,YAAY,CAAC;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,cAAc,CAAC;QAChD,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS;YAAE,OAAO,eAAe,CAAC;QAC9E,OAAQ,KAAgB,CAAC,WAAW,EAAE,IAAI,IAAI,QAAQ,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -31,6 +31,24 @@ export interface BuildPlanResult {
|
|
|
31
31
|
plan: BlockNode;
|
|
32
32
|
schemaDependencies: BuildTimeDependencyTracker;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Live handle for one mutex-free committed read (see
|
|
36
|
+
* {@link import('../common/types.js').StatementOptions.readConcurrency}).
|
|
37
|
+
* Minted by {@link Database._beginConcurrentRead}; the read combines `signal`
|
|
38
|
+
* with the caller's own signal and MUST call `end()` on every exit path
|
|
39
|
+
* (completion, break, error, abort) — {@link Database.close} awaits `done`,
|
|
40
|
+
* so a leaked scope hangs close.
|
|
41
|
+
*/
|
|
42
|
+
export interface ConcurrentReadScope {
|
|
43
|
+
/** Fired by {@link Database.close} so an in-flight read unwinds (with an
|
|
44
|
+
* AbortError) at its next row boundary. */
|
|
45
|
+
readonly signal: AbortSignal;
|
|
46
|
+
/** Resolves once {@link end} has run — i.e. the read's teardown (scan
|
|
47
|
+
* connection disconnects included) is complete. */
|
|
48
|
+
readonly done: Promise<void>;
|
|
49
|
+
/** Marks the read finished. Idempotent. */
|
|
50
|
+
end(): void;
|
|
51
|
+
}
|
|
34
52
|
/** Options accepted by {@link Database.registerCollation}'s third argument. */
|
|
35
53
|
export interface RegisterCollationOptions {
|
|
36
54
|
normalizer?: (s: string) => string;
|
|
@@ -56,6 +74,13 @@ export declare class Database implements TransactionManagerContext, AssertionEva
|
|
|
56
74
|
* Mutex for serializing statement execution.
|
|
57
75
|
* This prevents concurrent statements from interfering with each other's
|
|
58
76
|
* transaction state, matching SQLite's behavior of serializing writes.
|
|
77
|
+
*
|
|
78
|
+
* Not quite unconditional: a read-only statement executed with
|
|
79
|
+
* `readConcurrency: 'committed'` (see {@link StatementOptions}) that passes
|
|
80
|
+
* {@link _isConcurrentReadEligible} runs WITHOUT this mutex against each
|
|
81
|
+
* table's last committed state, so it completes even while another statement
|
|
82
|
+
* is blocked in its virtual-table commit. Everything else — every write, every
|
|
83
|
+
* default read — still serializes here.
|
|
59
84
|
*/
|
|
60
85
|
private execMutex;
|
|
61
86
|
/**
|
|
@@ -66,6 +91,12 @@ export declare class Database implements TransactionManagerContext, AssertionEva
|
|
|
66
91
|
* detect it must defer rather than deadlock on the held mutex.
|
|
67
92
|
*/
|
|
68
93
|
private execMutexDepth;
|
|
94
|
+
/**
|
|
95
|
+
* Live mutex-free committed-read scopes → their abort controllers.
|
|
96
|
+
* {@link close} aborts each and awaits its `done` before tearing down shared
|
|
97
|
+
* state, so no read is left iterating a schema being cleared.
|
|
98
|
+
*/
|
|
99
|
+
private readonly concurrentReads;
|
|
69
100
|
/** Database-level event emitter for unified reactivity */
|
|
70
101
|
private readonly eventEmitter;
|
|
71
102
|
/** Transaction management */
|
|
@@ -150,7 +181,9 @@ export declare class Database implements TransactionManagerContext, AssertionEva
|
|
|
150
181
|
* @param params Optional parameters to bind.
|
|
151
182
|
* @param options Optional execution options (e.g. an `AbortSignal` for
|
|
152
183
|
* cooperative cancellation — checked before preparing and at the row
|
|
153
|
-
* boundary while the first row is produced
|
|
184
|
+
* boundary while the first row is produced; or `readConcurrency:
|
|
185
|
+
* 'committed'` to run an eligible read-only query mutex-free against
|
|
186
|
+
* committed state — honored via `Statement.get`).
|
|
154
187
|
* @returns A Promise resolving to the first result row as an object, or undefined if no rows.
|
|
155
188
|
* @throws QuereusError on failure (an `AbortError` if the signal fired).
|
|
156
189
|
*/
|
|
@@ -183,6 +216,11 @@ export declare class Database implements TransactionManagerContext, AssertionEva
|
|
|
183
216
|
* surrounding explicit transaction until the user issues `COMMIT` or
|
|
184
217
|
* `ROLLBACK`.
|
|
185
218
|
*
|
|
219
|
+
* `options.readConcurrency` is IGNORED here: `exec` returns no rows, so a
|
|
220
|
+
* concurrent committed read through it would have no consumer, and its
|
|
221
|
+
* per-statement implicit-transaction loop is exactly the machinery the
|
|
222
|
+
* mutex-free path must not touch. Use `get`/`eval` for concurrent reads.
|
|
223
|
+
*
|
|
186
224
|
* @param sql The SQL string(s) to execute.
|
|
187
225
|
* @param params Optional parameters to bind.
|
|
188
226
|
* @param options Optional execution options (e.g. an `AbortSignal` for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../../src/core/database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtI,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,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extMap, wrapTableContextsStrict } from '../runtime/s
|
|
|
18
18
|
import { BuildTimeDependencyTracker } from '../planner/planning-context.js';
|
|
19
19
|
import { ParameterScope } from '../planner/scopes/param.js';
|
|
20
20
|
import { GlobalScope } from '../planner/scopes/global.js';
|
|
21
|
+
import { PlanNode, isRelationalNode } from '../planner/nodes/plan-node.js';
|
|
22
|
+
import { TableReferenceNode } from '../planner/nodes/reference.js';
|
|
23
|
+
import { PlanNodeType } from '../planner/nodes/plan-node-type.js';
|
|
24
|
+
import { getModuleReadCommittedSnapshot } from '../vtab/concurrency.js';
|
|
21
25
|
import { registerEmitters } from '../runtime/register.js';
|
|
22
26
|
import { serializePlanTree, formatPlanTree } from '../planner/debug.js';
|
|
23
27
|
import { EmissionContext } from '../runtime/emission-context.js';
|
|
@@ -69,6 +73,13 @@ export class Database {
|
|
|
69
73
|
* Mutex for serializing statement execution.
|
|
70
74
|
* This prevents concurrent statements from interfering with each other's
|
|
71
75
|
* transaction state, matching SQLite's behavior of serializing writes.
|
|
76
|
+
*
|
|
77
|
+
* Not quite unconditional: a read-only statement executed with
|
|
78
|
+
* `readConcurrency: 'committed'` (see {@link StatementOptions}) that passes
|
|
79
|
+
* {@link _isConcurrentReadEligible} runs WITHOUT this mutex against each
|
|
80
|
+
* table's last committed state, so it completes even while another statement
|
|
81
|
+
* is blocked in its virtual-table commit. Everything else — every write, every
|
|
82
|
+
* default read — still serializes here.
|
|
72
83
|
*/
|
|
73
84
|
execMutex = Promise.resolve();
|
|
74
85
|
/**
|
|
@@ -79,6 +90,12 @@ export class Database {
|
|
|
79
90
|
* detect it must defer rather than deadlock on the held mutex.
|
|
80
91
|
*/
|
|
81
92
|
execMutexDepth = 0;
|
|
93
|
+
/**
|
|
94
|
+
* Live mutex-free committed-read scopes → their abort controllers.
|
|
95
|
+
* {@link close} aborts each and awaits its `done` before tearing down shared
|
|
96
|
+
* state, so no read is left iterating a schema being cleared.
|
|
97
|
+
*/
|
|
98
|
+
concurrentReads = new Map();
|
|
82
99
|
/** Database-level event emitter for unified reactivity */
|
|
83
100
|
eventEmitter = new DatabaseEventEmitter();
|
|
84
101
|
/** Transaction management */
|
|
@@ -397,7 +414,9 @@ export class Database {
|
|
|
397
414
|
* @param params Optional parameters to bind.
|
|
398
415
|
* @param options Optional execution options (e.g. an `AbortSignal` for
|
|
399
416
|
* cooperative cancellation — checked before preparing and at the row
|
|
400
|
-
* boundary while the first row is produced
|
|
417
|
+
* boundary while the first row is produced; or `readConcurrency:
|
|
418
|
+
* 'committed'` to run an eligible read-only query mutex-free against
|
|
419
|
+
* committed state — honored via `Statement.get`).
|
|
401
420
|
* @returns A Promise resolving to the first result row as an object, or undefined if no rows.
|
|
402
421
|
* @throws QuereusError on failure (an `AbortError` if the signal fired).
|
|
403
422
|
*/
|
|
@@ -459,6 +478,106 @@ export class Database {
|
|
|
459
478
|
_isExecuting() {
|
|
460
479
|
return this.execMutexDepth > 0;
|
|
461
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* @internal True when this optimized block may run on the mutex-free
|
|
483
|
+
* committed-read path. Pure predicate — no side effects, no awaits. All of
|
|
484
|
+
* the following must hold, else the caller falls back to the serialized path
|
|
485
|
+
* (falling back is always correct, so this never throws):
|
|
486
|
+
*
|
|
487
|
+
* - No EXPLICIT transaction is open. A read inside a user `BEGIN` must see
|
|
488
|
+
* the transaction's own writes, so it always serializes. An *implicit*
|
|
489
|
+
* transaction (another statement's in-flight autocommit wrapper — including
|
|
490
|
+
* one parked in its virtual-table commit, the motivating case) does NOT
|
|
491
|
+
* disqualify: the committed read never joins it and serves the last
|
|
492
|
+
* committed state.
|
|
493
|
+
* - Every statement in the block is relational (row-producing). Transaction
|
|
494
|
+
* control and DDL lower to void nodes whose `physical.readonly` does not
|
|
495
|
+
* model their engine-level effects, so `readonly` alone is not a safe gate.
|
|
496
|
+
* - No node in any statement's subtree has side effects.
|
|
497
|
+
* - Every {@link TableReferenceNode} resolves to a module declaring
|
|
498
|
+
* `readCommittedSnapshot` (universal, not existential — one unqualified
|
|
499
|
+
* table makes the whole block serialize). Checked on the OPTIMIZED plan, so
|
|
500
|
+
* tables reached through views and materialized views are covered.
|
|
501
|
+
* - No table-valued function is called. A TVF reaches its data outside the
|
|
502
|
+
* `TableReferenceNode` gate above, and `TableFunctionCallNode` reports
|
|
503
|
+
* `readonly: true` unconditionally, so neither of the other checks can see
|
|
504
|
+
* what it does — `execution_trace('insert ...')`, for one, prepares and
|
|
505
|
+
* runs arbitrary SQL. Fail closed, matching the module contract's
|
|
506
|
+
* opt-in-or-serialize discipline.
|
|
507
|
+
*
|
|
508
|
+
* Evaluated at routing time; a `BEGIN` landing after routing does not
|
|
509
|
+
* invalidate an in-flight concurrent read — that read is already pinned to a
|
|
510
|
+
* committed snapshot and simply does not see the new transaction's writes,
|
|
511
|
+
* which is the documented semantics.
|
|
512
|
+
*
|
|
513
|
+
* NOTE: deliberately no plan-time schema gate. `Statement.compile()` is
|
|
514
|
+
* synchronous (cannot observe half-applied multi-step DDL), captured schema
|
|
515
|
+
* objects re-validate at execution start, and for the long window (the scan
|
|
516
|
+
* itself) the `readCommittedSnapshot` obligation requires the module to keep
|
|
517
|
+
* serving its pinned snapshot across concurrent DDL. A shared/exclusive gate
|
|
518
|
+
* becomes necessary only if a module that cannot pin across DDL ever wants
|
|
519
|
+
* onto this path — see backlog/debt-concurrent-reads-schema-gate.
|
|
520
|
+
*/
|
|
521
|
+
_isConcurrentReadEligible(block) {
|
|
522
|
+
if (!this.isOpen)
|
|
523
|
+
return false;
|
|
524
|
+
if (!this.transactionManager.getAutocommit() && !this.transactionManager.isImplicitTransaction()) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
if (block.statements.length === 0)
|
|
528
|
+
return false;
|
|
529
|
+
return block.statements.every(stmt => isRelationalNode(stmt) && Database.isCommittedReadSafeSubtree(stmt));
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* @internal Single walk over one optimized statement tree: rejects on any
|
|
533
|
+
* side-effecting node, any table-valued function call, or any table whose
|
|
534
|
+
* module does not declare `readCommittedSnapshot`. See
|
|
535
|
+
* {@link _isConcurrentReadEligible} for why each is disqualifying.
|
|
536
|
+
*/
|
|
537
|
+
static isCommittedReadSafeSubtree(root) {
|
|
538
|
+
const stack = [root];
|
|
539
|
+
while (stack.length > 0) {
|
|
540
|
+
const node = stack.pop();
|
|
541
|
+
if (PlanNode.hasSideEffects(node.physical))
|
|
542
|
+
return false;
|
|
543
|
+
// NOTE: rejects every TVF, pure ones (`json_each`) included, because no
|
|
544
|
+
// declaration distinguishes them from `execution_trace`, which runs
|
|
545
|
+
// arbitrary SQL. If a pure TVF ever needs this path, add an explicit
|
|
546
|
+
// opt-in flag to the table-valued function schema and gate on it here.
|
|
547
|
+
if (node.nodeType === PlanNodeType.TableFunctionCall)
|
|
548
|
+
return false;
|
|
549
|
+
if (node instanceof TableReferenceNode && !getModuleReadCommittedSnapshot(node.vtabModule)) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
for (const child of node.getChildren()) {
|
|
553
|
+
stack.push(child);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
return true;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* @internal Registers a mutex-free committed read. The returned scope's
|
|
560
|
+
* `signal` fires when {@link close} runs; the read must call `end()` on every
|
|
561
|
+
* exit path or `close()` waits forever on `done`.
|
|
562
|
+
*/
|
|
563
|
+
_beginConcurrentRead() {
|
|
564
|
+
this.checkOpen();
|
|
565
|
+
const controller = new AbortController();
|
|
566
|
+
let resolveDone;
|
|
567
|
+
const done = new Promise(resolve => {
|
|
568
|
+
resolveDone = resolve;
|
|
569
|
+
});
|
|
570
|
+
const scope = {
|
|
571
|
+
signal: controller.signal,
|
|
572
|
+
done,
|
|
573
|
+
end: () => {
|
|
574
|
+
if (this.concurrentReads.delete(scope))
|
|
575
|
+
resolveDone();
|
|
576
|
+
},
|
|
577
|
+
};
|
|
578
|
+
this.concurrentReads.set(scope, controller);
|
|
579
|
+
return scope;
|
|
580
|
+
}
|
|
462
581
|
/**
|
|
463
582
|
* Executes a function with the execution mutex held.
|
|
464
583
|
* The mutex serializes all database access to prevent concurrent interference.
|
|
@@ -626,6 +745,11 @@ export class Database {
|
|
|
626
745
|
* surrounding explicit transaction until the user issues `COMMIT` or
|
|
627
746
|
* `ROLLBACK`.
|
|
628
747
|
*
|
|
748
|
+
* `options.readConcurrency` is IGNORED here: `exec` returns no rows, so a
|
|
749
|
+
* concurrent committed read through it would have no consumer, and its
|
|
750
|
+
* per-statement implicit-transaction loop is exactly the machinery the
|
|
751
|
+
* mutex-free path must not touch. Use `get`/`eval` for concurrent reads.
|
|
752
|
+
*
|
|
629
753
|
* @param sql The SQL string(s) to execute.
|
|
630
754
|
* @param params Optional parameters to bind.
|
|
631
755
|
* @param options Optional execution options (e.g. an `AbortSignal` for
|
|
@@ -929,6 +1053,16 @@ export class Database {
|
|
|
929
1053
|
}
|
|
930
1054
|
log("Closing database...");
|
|
931
1055
|
this.isOpen = false;
|
|
1056
|
+
// Abort every live mutex-free committed read and wait for each to tear
|
|
1057
|
+
// down (its scan connections disconnect in the read's own finally) before
|
|
1058
|
+
// touching shared state. A read parked at a yield unwinds at the
|
|
1059
|
+
// consumer's next pull/return — close() waits for that, so an abandoned,
|
|
1060
|
+
// never-again-pulled iterator delays close (same discipline as any held
|
|
1061
|
+
// iterator).
|
|
1062
|
+
for (const controller of this.concurrentReads.values()) {
|
|
1063
|
+
controller.abort();
|
|
1064
|
+
}
|
|
1065
|
+
await Promise.all(Array.from(this.concurrentReads.keys()).map(scope => scope.done));
|
|
932
1066
|
// Disconnect all active connections first
|
|
933
1067
|
await this.disconnectAllConnections();
|
|
934
1068
|
// Drain the internal FK/DDL statement pool (finalizes its cached statements,
|
|
@@ -1589,8 +1723,59 @@ export class Database {
|
|
|
1589
1723
|
* ```
|
|
1590
1724
|
*/
|
|
1591
1725
|
eval(sql, params, options) {
|
|
1726
|
+
if (options?.readConcurrency === 'committed') {
|
|
1727
|
+
// Routing (parse + compile + eligibility) happens at first pull inside the
|
|
1728
|
+
// delegating generator, so an unconsumed iterator holds no resources.
|
|
1729
|
+
return this._evalRoutedGenerator(sql, params, options);
|
|
1730
|
+
}
|
|
1592
1731
|
return wrapAsyncIterator(this._evalGenerator(sql, params, options?.signal), (commit, error) => this._finalizeImplicitTransaction(commit, error));
|
|
1593
1732
|
}
|
|
1733
|
+
/**
|
|
1734
|
+
* @internal Committed-read routing for {@link eval}: a SINGLE-statement,
|
|
1735
|
+
* concurrent-read-eligible batch runs mutex-free against committed state
|
|
1736
|
+
* (never touching the implicit-transaction lifecycle — the writer owns any
|
|
1737
|
+
* open one); everything else — multi-statement batches included — delegates
|
|
1738
|
+
* to the serialized path with identical semantics. `yield*` forwards
|
|
1739
|
+
* `return()`/`throw()` into the wrapped serialized iterator, so its
|
|
1740
|
+
* transaction-finalize cleanup still runs on early exit.
|
|
1741
|
+
*/
|
|
1742
|
+
async *_evalRoutedGenerator(sql, params, options) {
|
|
1743
|
+
this.checkOpen();
|
|
1744
|
+
throwIfAborted(options?.signal);
|
|
1745
|
+
let stmt = null;
|
|
1746
|
+
try {
|
|
1747
|
+
const candidate = this.prepare(sql, params);
|
|
1748
|
+
let eligible = false;
|
|
1749
|
+
if (candidate.astBatch.length === 1) {
|
|
1750
|
+
try {
|
|
1751
|
+
// compile() is synchronous — no awaited DDL can interleave.
|
|
1752
|
+
eligible = this._isConcurrentReadEligible(candidate.compile());
|
|
1753
|
+
}
|
|
1754
|
+
catch (e) {
|
|
1755
|
+
// A compile error re-surfaces identically on the serialized path
|
|
1756
|
+
// below (compile failures are not memoized), so routing stays
|
|
1757
|
+
// error-free. Logged for diagnosability, not swallowed.
|
|
1758
|
+
log('eval committed-read routing declined (compile failed): %O', e);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (!eligible) {
|
|
1762
|
+
await candidate.finalize();
|
|
1763
|
+
yield* wrapAsyncIterator(this._evalGenerator(sql, params, options?.signal), (commit, error) => this._finalizeImplicitTransaction(commit, error));
|
|
1764
|
+
return;
|
|
1765
|
+
}
|
|
1766
|
+
stmt = candidate;
|
|
1767
|
+
// Params were already bound by prepare(); passing them again would rebind.
|
|
1768
|
+
const names = stmt.getColumnNames();
|
|
1769
|
+
for await (const row of stmt._iterateConcurrent(undefined, options)) {
|
|
1770
|
+
yield rowToObject(row, names);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
finally {
|
|
1774
|
+
if (stmt) {
|
|
1775
|
+
await stmt.finalize();
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1594
1779
|
/**
|
|
1595
1780
|
* Internal generator for eval() that yields result rows.
|
|
1596
1781
|
* Transaction finalization is handled by the wrapper returned by eval().
|