@optimystic/db-core 1.12.1 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cluster/i-cluster.d.ts +16 -1
- package/dist/src/cluster/i-cluster.d.ts.map +1 -1
- package/dist/src/cluster/structs.d.ts +48 -6
- package/dist/src/cluster/structs.d.ts.map +1 -1
- package/dist/src/cluster/structs.js +5 -0
- package/dist/src/cluster/structs.js.map +1 -1
- package/dist/src/collection/collection.d.ts.map +1 -1
- package/dist/src/collection/collection.js +5 -3
- package/dist/src/collection/collection.js.map +1 -1
- package/dist/src/network/durability.d.ts +17 -4
- package/dist/src/network/durability.d.ts.map +1 -1
- package/dist/src/network/durability.js +60 -15
- package/dist/src/network/durability.js.map +1 -1
- package/dist/src/network/i-key-network.d.ts +9 -0
- package/dist/src/network/i-key-network.d.ts.map +1 -1
- package/dist/src/network/struct.d.ts +25 -5
- package/dist/src/network/struct.d.ts.map +1 -1
- package/dist/src/network/struct.js.map +1 -1
- package/dist/src/transaction/coordinator.d.ts +23 -14
- package/dist/src/transaction/coordinator.d.ts.map +1 -1
- package/dist/src/transaction/coordinator.js +73 -45
- package/dist/src/transaction/coordinator.js.map +1 -1
- package/dist/src/transaction/durability.d.ts +31 -0
- package/dist/src/transaction/durability.d.ts.map +1 -0
- package/dist/src/transaction/durability.js +36 -0
- package/dist/src/transaction/durability.js.map +1 -0
- package/dist/src/transaction/errors.d.ts +14 -6
- package/dist/src/transaction/errors.d.ts.map +1 -1
- package/dist/src/transaction/errors.js +16 -5
- package/dist/src/transaction/errors.js.map +1 -1
- package/dist/src/transaction/index.d.ts +2 -0
- package/dist/src/transaction/index.d.ts.map +1 -1
- package/dist/src/transaction/index.js +1 -0
- package/dist/src/transaction/index.js.map +1 -1
- package/dist/src/transaction/session.d.ts +2 -0
- package/dist/src/transaction/session.d.ts.map +1 -1
- package/dist/src/transaction/session.js +4 -2
- package/dist/src/transaction/session.js.map +1 -1
- package/dist/src/transaction/transaction.d.ts +9 -0
- package/dist/src/transaction/transaction.d.ts.map +1 -1
- package/dist/src/transaction/transaction.js.map +1 -1
- package/dist/src/transactor/change-notifier.d.ts +20 -8
- package/dist/src/transactor/change-notifier.d.ts.map +1 -1
- package/dist/src/transactor/change-notifier.js.map +1 -1
- package/dist/src/transactor/transactor-source.d.ts +5 -4
- package/dist/src/transactor/transactor-source.d.ts.map +1 -1
- package/dist/src/transactor/transactor-source.js +8 -5
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/package.json +1 -1
- package/src/cluster/i-cluster.ts +13 -2
- package/src/cluster/structs.ts +50 -6
- package/src/collection/collection.ts +5 -3
- package/src/network/durability.ts +63 -15
- package/src/network/i-key-network.ts +10 -0
- package/src/network/struct.ts +25 -5
- package/src/transaction/coordinator.ts +119 -76
- package/src/transaction/durability.ts +60 -0
- package/src/transaction/errors.ts +18 -3
- package/src/transaction/index.ts +2 -0
- package/src/transaction/session.ts +4 -2
- package/src/transaction/transaction.ts +9 -0
- package/src/transactor/change-notifier.ts +20 -8
- package/src/transactor/transactor-source.ts +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.js","sourceRoot":"","sources":["../../../src/network/durability.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,CAAkB;IAChD,OAAO,CAAC,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,CAAmB;IACjD,QAAQ,CAAC,EAAE,CAAC;QACX,KAAK,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;QACvB,KAAK,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QAC1B,KAAK,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AG,IAAI,GAAG,EAAmB,CAAC;IAC3C,KAAK,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACtF,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,aAAa,CAAC,SAA4C,EAAE,QAA4B;IAChG,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAChG,CAAC;AAED,8EAA8E;AAC9E,SAAS,cAAc,CAAC,SAA4C;IACnE,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -64,5 +64,14 @@ export type IKeyNetwork = {
|
|
|
64
64
|
* such configuration omit this, which reads as "not awaiting".
|
|
65
65
|
*/
|
|
66
66
|
awaitingBootstrapContact?(): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Optionally name the peers this node knows serve this network that belong in `key`'s cohort but
|
|
69
|
+
* are missing from the cohort `findCluster` assembles now — typically members that are offline or
|
|
70
|
+
* unreachable. Peer-id strings, nearest the key first, never this node. A write made without them
|
|
71
|
+
* is owed to them, and naming them lets the writer's answer say so (`WriteDurability.unconfirmed`)
|
|
72
|
+
* and lets the copy be pushed to them as soon as they reconnect. Implementations that remember no
|
|
73
|
+
* such peers omit this, which reads as "none known".
|
|
74
|
+
*/
|
|
75
|
+
absentCohortMembers?(key: RoutingKey): Promise<string[]>;
|
|
67
76
|
};
|
|
68
77
|
//# sourceMappingURL=i-key-network.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i-key-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACpC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7F;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1E;;;;;;OAMG;IACH,wBAAwB,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"i-key-network.d.ts","sourceRoot":"","sources":["../../../src/network/i-key-network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,sBAAsB,GAAG;IACpC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7F;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAEpD;;;;;;;OAOG;IACH,iBAAiB,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE1E;;;;;;OAMG;IACH,wBAAwB,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAE9C;;;;;;;OAOG;IACH,mBAAmB,CAAC,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACzD,CAAA"}
|
|
@@ -90,12 +90,15 @@ export type DurabilityQuorum =
|
|
|
90
90
|
* (`withTornBlocks` clamps `full` down to this; `torn` then names the blocks, and `unconfirmed`
|
|
91
91
|
* may be empty). */
|
|
92
92
|
| 'majority'
|
|
93
|
-
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet.
|
|
93
|
+
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet. When this
|
|
94
|
+
* node knows of other members of the cohort that it could not reach (`IKeyNetwork.absentCohortMembers`),
|
|
95
|
+
* they are named in `unconfirmed` and counted in `cohort`: the write is owed to them. With none
|
|
96
|
+
* named, it is a correct, complete one-machine write. */
|
|
94
97
|
| 'local'
|
|
95
98
|
/** The cohort did NOT resolve: the lookup threw, or named nobody, or named a single peer that
|
|
96
99
|
* is not this node. The write is on this node's storage and the network was never consulted.
|
|
97
|
-
* Deliberately NOT `local`: a
|
|
98
|
-
* is a write whose correct destination is unknown. */
|
|
100
|
+
* Deliberately NOT `local`: a write that lands where its cohort resolved to is in the right
|
|
101
|
+
* place, whereas this is a write whose correct destination is unknown. */
|
|
99
102
|
| 'unrouted';
|
|
100
103
|
/** What the answering layer knows about who holds a successful write. Each layer refines it:
|
|
101
104
|
* `StorageRepo` answers for itself alone, `CoordinatorRepo` answers for the cohort the write ran
|
|
@@ -112,15 +115,24 @@ export type WriteDurability = {
|
|
|
112
115
|
* it means "accepted the pending record". The two are NOT comparable — a pend confers no
|
|
113
116
|
* storage durability (see the note in `CoordinatorRepo.pendThroughCluster`). */
|
|
114
117
|
readonly confirmed: number;
|
|
115
|
-
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'.
|
|
118
|
+
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'. For `local`
|
|
119
|
+
* it is one plus the known members the write ran without, so `local` does not imply 1. */
|
|
116
120
|
readonly cohort: number;
|
|
117
121
|
/** Cohort members that did not confirm, by peer-id string. Empty when `quorum` is 'full'.
|
|
118
122
|
* ABSENT (not empty) when the answering layer could not name the cohort — an empty array
|
|
119
|
-
* here means "named the cohort, nobody is missing".
|
|
123
|
+
* here means "named the cohort, nobody is missing". On a `local` write these are the members
|
|
124
|
+
* this node knows of but could not reach when it wrote alone. */
|
|
120
125
|
readonly unconfirmed?: readonly string[];
|
|
121
126
|
/** The cohort the write ran on, by peer-id string. Absent where the answering layer has no
|
|
122
127
|
* cohort view at all (a bare `StorageRepo` verdict). */
|
|
123
128
|
readonly cohortPeerIds?: readonly string[];
|
|
129
|
+
/** Peer-id string of the node whose under-replication ledger recorded this write's missing
|
|
130
|
+
* copies — the one node that will fire `BlockDurabilityReachedEvent` for these blocks when they
|
|
131
|
+
* reach full replication. Set only below `full`, and only when every non-torn block's shortfall
|
|
132
|
+
* was recorded. Absent: no node is tracking the shortfall (nothing to push from the coordinator,
|
|
133
|
+
* a ledger fault, no ledger, a producer that predates the field), so no full-replication event
|
|
134
|
+
* should be expected. Per cohort answer: each `otherCohorts` entry carries its own. */
|
|
135
|
+
readonly recordedBy?: string;
|
|
124
136
|
/** Present only on an action-level result assembled from MORE THAN ONE distinct coordinator
|
|
125
137
|
* answer: the other answers. Identical answers are collapsed (`mergeDurability`), so a healthy
|
|
126
138
|
* single-cohort commit has none; one cohort answering differently for two batches appears
|
|
@@ -132,6 +144,14 @@ export type WriteDurability = {
|
|
|
132
144
|
* These blocks NEVER heal by replication: their transform is gone, and only the writer
|
|
133
145
|
* re-driving the action puts them back. */
|
|
134
146
|
readonly torn?: readonly BlockId[];
|
|
147
|
+
/** Action-level: every block this write committed, with the revision it committed at — what a
|
|
148
|
+
* host holds to match full-replication events (`BlockDurabilityReachedEvent`, keyed by block and
|
|
149
|
+
* revision) back to this write. Set by the db-core layer that issued the commit
|
|
150
|
+
* (`withBlockRevs`), never by a coordinator and never on the wire. Excludes `torn` blocks: they
|
|
151
|
+
* hold nothing. Merging two reports keeps, per block, the HIGHER revision — a block written at r
|
|
152
|
+
* and again at r+1 by one write is covered by an event at r+1 or later. A `Record` rather than a
|
|
153
|
+
* `Map` so the type stays plain JSON. */
|
|
154
|
+
readonly blockRevs?: Readonly<Record<BlockId, number>>;
|
|
135
155
|
};
|
|
136
156
|
export type PendSuccess = {
|
|
137
157
|
success: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.d.ts","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG;IAC5C;;;2FAGuF;IACvF,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE;QACZ,kDAAkD;QAClD,WAAW,EAAE,W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M,oBAAoB,GAAG;IAClC,gCAAgC;IAChC,KAAK,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAChC,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,MAAM,KAClB,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnC,2CAA2C;AAC3C,MAAM,MAAM,SAAS,GAAG,YAAY,CAAC;AACrC,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAC7C,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;AAC3C,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"struct.js","sourceRoot":"","sources":["../../../src/network/struct.ts"],"names":[],"mappings":"AAmgBA;;;;;GAKG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC1B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,MAA8B;QAC7E,KAAK,CAAC,SAAS,OAAO,oBAAoB,MAAM,mDAAmD,CAAC,CAAC;QADjF,YAAO,GAAP,OAAO,CAAS;QAAW,WAAM,GAAN,MAAM,CAAwB;QAE7E,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC5B;IAA2B;IAAhD,YAAqB,OAAgB,EAAW,UAAkB;QACjE,KAAK,CAAC,SAAS,OAAO,4CAA4C,UAAU,wDAAwD,CAAC,CAAC;QADlH,YAAO,GAAP,OAAO,CAAS;QAAW,eAAU,GAAV,UAAU,CAAQ;QAEjE,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD"}
|
|
@@ -2,6 +2,7 @@ import type { ITransactor, CollectionId, Transforms } from "../index.js";
|
|
|
2
2
|
import type { Transaction, ExecutionResult, ITransactionEngine, CollectionActions, ReadDependency } from "./transaction.js";
|
|
3
3
|
import type { Collection } from "../collection/collection.js";
|
|
4
4
|
import type { SyncOptions } from "../collection/index.js";
|
|
5
|
+
import { type TransactionDurability } from "./durability.js";
|
|
5
6
|
/**
|
|
6
7
|
* What a pend this coordinator sends carries for the receiving cluster members to re-check.
|
|
7
8
|
*
|
|
@@ -173,24 +174,26 @@ export declare class TransactionCoordinator {
|
|
|
173
174
|
*
|
|
174
175
|
* Defaults are safe out of the box: a caller that passes no options gets bounded, jittered retry.
|
|
175
176
|
*
|
|
176
|
-
* NOTE: this returns nothing, so a multi-collection commit reports NO durability — unlike
|
|
177
|
-
* `Collection.sync`, which now answers with the {@link WriteDurability} of what it committed. The
|
|
178
|
-
* gap is deliberate and tracked in `tickets/backlog/feat-multi-collection-commit-reports-durability.md`:
|
|
179
|
-
* folding a class across collections that may individually have committed or been dropped (see
|
|
180
|
-
* {@link CoordinatorPartialCommitError}) is its own design problem, not a pass-through. Until that
|
|
181
|
-
* lands, a caller that needs to know whether a write is fully held has to use the single-collection
|
|
182
|
-
* path; do not infer one here from a plain successful return.
|
|
183
|
-
*
|
|
184
177
|
* @param transaction - The transaction to commit
|
|
185
178
|
* @param options - Retry knobs; shares the {@link SyncOptions} vocabulary with `Collection.sync`.
|
|
179
|
+
* @returns who holds what the commit wrote — per collection, across every attempt (a participant
|
|
180
|
+
* the refresh between attempts saved included), with `overall` the weakest of them. Test it
|
|
181
|
+
* through `isFullyDurable(overall)`; an absent `overall` means some collection is saved but who
|
|
182
|
+
* holds it is unknown. `undefined` means NOTHING was written — nothing was staged, or a retry's
|
|
183
|
+
* replay dropped every staged action — exactly as `Collection.sync` reports an empty sync. Every
|
|
184
|
+
* other successful return carries a report; a failure after something was written carries the
|
|
185
|
+
* committed half's on {@link CoordinatorPartialCommitError.durability}.
|
|
186
186
|
*/
|
|
187
|
-
commit(transaction: Transaction, options?: SyncOptions): Promise<
|
|
187
|
+
commit(transaction: Transaction, options?: SyncOptions): Promise<TransactionDurability | undefined>;
|
|
188
188
|
/** The retry loop behind {@link commit}: every attempt, and the refresh between them. Records
|
|
189
|
-
* what it learns in `cycle`; {@link commit} owns turning a failure into the right report.
|
|
189
|
+
* what it learns in `cycle`; {@link commit} owns turning a failure into the right report. On
|
|
190
|
+
* success, reports every participant the cycle saved together with what the final attempt
|
|
191
|
+
* committed (see {@link commit}'s return). */
|
|
190
192
|
private commitAttempts;
|
|
191
193
|
/**
|
|
192
194
|
* Refresh every registered collection between attempts, recording in `cycle.saved` each one
|
|
193
|
-
* whose refresh finished this transaction's own log entry (see {@link Collection.refreshInFlight})
|
|
195
|
+
* whose refresh finished this transaction's own log entry (see {@link Collection.refreshInFlight}),
|
|
196
|
+
* with who holds it — `undefined` when the refresh could not say, which still records it as saved.
|
|
194
197
|
*
|
|
195
198
|
* Visits EVERY collection even after one throws. Stopping at the first throw would leave a
|
|
196
199
|
* participant later in the map unfinished whenever an earlier one is torn — its log tail stored
|
|
@@ -233,6 +236,7 @@ export declare class TransactionCoordinator {
|
|
|
233
236
|
*
|
|
234
237
|
* - `committedCollections`: every refresh-saved participant, plus the committed set of `err`
|
|
235
238
|
* when it is itself a partial landing (merged, never wrapped twice — its `reason` is kept);
|
|
239
|
+
* `durability` carries who holds each of them, merged the same way;
|
|
236
240
|
* - `failedCollections`: every other participant of any attempt. Empty when a failure came after
|
|
237
241
|
* every participant was saved (a refresh that finished its entry and then threw, say);
|
|
238
242
|
* - `reason`: the original error.
|
|
@@ -267,6 +271,8 @@ export declare class TransactionCoordinator {
|
|
|
267
271
|
* `cycle.inFlightDisposers`. REQUIRED, so a future caller cannot silently reintroduce the
|
|
268
272
|
* unmarked refresh the disposers exist to prevent, nor lose track of who took part. The caller
|
|
269
273
|
* owns clearing the marks, because they have to survive past this attempt.
|
|
274
|
+
* @returns every collection this attempt committed, with who holds it — empty when nothing was
|
|
275
|
+
* staged, so the attempt wrote nothing.
|
|
270
276
|
*/
|
|
271
277
|
private commitOnce;
|
|
272
278
|
/**
|
|
@@ -277,8 +283,10 @@ export declare class TransactionCoordinator {
|
|
|
277
283
|
* is latch-free by contract.
|
|
278
284
|
*
|
|
279
285
|
* `cycle` is written only on a partial landing that is retried forward: the participants this
|
|
280
|
-
* attempt committed go into `cycle.saved`, so the retry loop reports every
|
|
281
|
-
* partial landing it is (see {@link reportSaved}).
|
|
286
|
+
* attempt committed go into `cycle.saved`, with who holds each, so the retry loop reports every
|
|
287
|
+
* later failure as the partial landing it is (see {@link reportSaved}).
|
|
288
|
+
*
|
|
289
|
+
* @returns on success, every participant with who holds it (see {@link commitOnce}).
|
|
282
290
|
*/
|
|
283
291
|
private commitOnceLatched;
|
|
284
292
|
/**
|
|
@@ -394,7 +402,8 @@ export declare class TransactionCoordinator {
|
|
|
394
402
|
/**
|
|
395
403
|
* Commit a single collection's pended blocks, retrying transient failures up to three
|
|
396
404
|
* times (forward recovery). Always resolves — success is carried in the returned
|
|
397
|
-
* `committed` flag — so the fan-out in
|
|
405
|
+
* `committed` flag, with the commit's `durability` beside it — so the fan-out in
|
|
406
|
+
* {@link commitPhase} can aggregate every result.
|
|
398
407
|
*/
|
|
399
408
|
private commitCollection;
|
|
400
409
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/transaction/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAW,YAAY,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/transaction/coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAW,YAAY,EAAE,UAAU,EAAyD,MAAM,aAAa,CAAC;AACzI,OAAO,KAAK,EAAE,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AE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAgCzG;;;kDAG8C;YAChC,cAAc;IAqG5B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;YACW,sBAAsB;IA0BpC;;;;;;;;;6CASyC;IACzC,OAAO,CAAC,iBAAiB;IAUzB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,WAAW;IAuBnB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;YACW,UAAU;IAgExB;;;;;;;;;;;;OAYG;YACW,iBAAiB;IAoN/B;;;;;;;;;;;;;;;;;;;OAmBG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC9C;;;;;;OAMG;IACH,aAAa,IAAI,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC;IAe9C;;;;;OAKG;IACH,eAAe,IAAI,IAAI;IAMvB;;OAEG;IACH,mBAAmB,IAAI,cAAc,EAAE;IAQvC;;OAEG;IACH,qBAAqB,IAAI,IAAI;IAM7B;;;;;;;;OAQG;IACG,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC;IAiT7F;;;;OAIG;YACW,wBAAwB;IA6FtC;;;;;;;;;;;OAWG;YACW,qBAAqB;IAoEnC;;;;;;;OAOG;YACW,WAAW;IAmCzB;;;;;;;;;;;;OAYG;YACW,SAAS;IAkEvB;;;;OAIG;YACW,cAAc;IA0D5B;;;;;;OAMG;YACW,WAAW;IAiEzB;;;;;OAKG;YACW,gBAAgB;IAwF9B;;;;;OAKG;YACW,WAAW;CAsBzB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isConflictFailure, isExpiryFailure } from "../network/stale-failure.js";
|
|
2
|
+
import { withBlockRevs } from "../network/durability.js";
|
|
2
3
|
import { TransactionExpiredError } from "../network/transaction-expired-error.js";
|
|
3
4
|
import { TornActionError } from "../collection/struct.js";
|
|
4
5
|
import { isTransactionExpired, clampPriority } from "./transaction.js";
|
|
@@ -7,6 +8,7 @@ import { blockIdsForTransforms, copyTransforms } from "../transform/helpers.js";
|
|
|
7
8
|
import { computeBlockContentDigests, blockDigestsField, baseRevsField } from "../transform/digest.js";
|
|
8
9
|
import { collectOperations, hashOperations } from "./operations-hash.js";
|
|
9
10
|
import { CoordinatorConcurrentStampError, CoordinatorPartialCommitError, CoordinatorStaleLossError } from "./errors.js";
|
|
11
|
+
import { recordCollectionDurability, transactionDurability } from "./durability.js";
|
|
10
12
|
import { jitteredBackoffMs, abortableDelay, makeAbortError } from "../utility/backoff.js";
|
|
11
13
|
import { createLogger } from "../logger.js";
|
|
12
14
|
const log = createLogger('trx:coordinator');
|
|
@@ -37,6 +39,12 @@ class PendRejectedError extends Error {
|
|
|
37
39
|
this.name = 'PendRejectedError';
|
|
38
40
|
}
|
|
39
41
|
}
|
|
42
|
+
/** What a successful commit wrote: `written` folded into one report, or `undefined` when it holds
|
|
43
|
+
* nothing (nothing was staged, so there was no pend and no commit — the same hole
|
|
44
|
+
* `Collection.sync` has). */
|
|
45
|
+
function writtenDurability(written) {
|
|
46
|
+
return written.size === 0 ? undefined : transactionDurability(written);
|
|
47
|
+
}
|
|
40
48
|
/**
|
|
41
49
|
* Coordinates multi-collection transactions.
|
|
42
50
|
*
|
|
@@ -241,16 +249,15 @@ export class TransactionCoordinator {
|
|
|
241
249
|
*
|
|
242
250
|
* Defaults are safe out of the box: a caller that passes no options gets bounded, jittered retry.
|
|
243
251
|
*
|
|
244
|
-
* NOTE: this returns nothing, so a multi-collection commit reports NO durability — unlike
|
|
245
|
-
* `Collection.sync`, which now answers with the {@link WriteDurability} of what it committed. The
|
|
246
|
-
* gap is deliberate and tracked in `tickets/backlog/feat-multi-collection-commit-reports-durability.md`:
|
|
247
|
-
* folding a class across collections that may individually have committed or been dropped (see
|
|
248
|
-
* {@link CoordinatorPartialCommitError}) is its own design problem, not a pass-through. Until that
|
|
249
|
-
* lands, a caller that needs to know whether a write is fully held has to use the single-collection
|
|
250
|
-
* path; do not infer one here from a plain successful return.
|
|
251
|
-
*
|
|
252
252
|
* @param transaction - The transaction to commit
|
|
253
253
|
* @param options - Retry knobs; shares the {@link SyncOptions} vocabulary with `Collection.sync`.
|
|
254
|
+
* @returns who holds what the commit wrote — per collection, across every attempt (a participant
|
|
255
|
+
* the refresh between attempts saved included), with `overall` the weakest of them. Test it
|
|
256
|
+
* through `isFullyDurable(overall)`; an absent `overall` means some collection is saved but who
|
|
257
|
+
* holds it is unknown. `undefined` means NOTHING was written — nothing was staged, or a retry's
|
|
258
|
+
* replay dropped every staged action — exactly as `Collection.sync` reports an empty sync. Every
|
|
259
|
+
* other successful return carries a report; a failure after something was written carries the
|
|
260
|
+
* committed half's on {@link CoordinatorPartialCommitError.durability}.
|
|
254
261
|
*/
|
|
255
262
|
async commit(transaction, options) {
|
|
256
263
|
// At most one open stamp (see the invariant on stampData). Checked once, BEFORE the retry
|
|
@@ -265,10 +272,10 @@ export class TransactionCoordinator {
|
|
|
265
272
|
const cycle = {
|
|
266
273
|
inFlightDisposers: [],
|
|
267
274
|
participants: new Set(),
|
|
268
|
-
saved: new
|
|
275
|
+
saved: new Map(),
|
|
269
276
|
};
|
|
270
277
|
try {
|
|
271
|
-
await this.commitAttempts(transaction, cycle, options);
|
|
278
|
+
return await this.commitAttempts(transaction, cycle, options);
|
|
272
279
|
}
|
|
273
280
|
catch (err) {
|
|
274
281
|
// The ONE place a failure leaves this commit, so no exit — present or future — can skip
|
|
@@ -285,7 +292,9 @@ export class TransactionCoordinator {
|
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
/** The retry loop behind {@link commit}: every attempt, and the refresh between them. Records
|
|
288
|
-
* what it learns in `cycle`; {@link commit} owns turning a failure into the right report.
|
|
295
|
+
* what it learns in `cycle`; {@link commit} owns turning a failure into the right report. On
|
|
296
|
+
* success, reports every participant the cycle saved together with what the final attempt
|
|
297
|
+
* committed (see {@link commit}'s return). */
|
|
289
298
|
async commitAttempts(transaction, cycle, options) {
|
|
290
299
|
const maxAttempts = options?.maxAttempts ?? DefaultMaxAttempts;
|
|
291
300
|
const baseBackoffMs = options?.baseBackoffMs ?? DefaultBaseBackoffMs;
|
|
@@ -316,8 +325,14 @@ export class TransactionCoordinator {
|
|
|
316
325
|
transaction.priority = clampPriority(staleLosses);
|
|
317
326
|
}
|
|
318
327
|
try {
|
|
319
|
-
await this.commitOnce(transaction, cycle);
|
|
320
|
-
|
|
328
|
+
const committed = await this.commitOnce(transaction, cycle);
|
|
329
|
+
// Merged, not overwritten, should one participant be both saved and committed (see the
|
|
330
|
+
// NOTE in reportSaved).
|
|
331
|
+
const written = new Map(cycle.saved);
|
|
332
|
+
for (const [collectionId, durability] of committed) {
|
|
333
|
+
recordCollectionDurability(written, collectionId, durability);
|
|
334
|
+
}
|
|
335
|
+
return writtenDurability(written);
|
|
321
336
|
}
|
|
322
337
|
catch (err) {
|
|
323
338
|
// Only a CLEAN stale loss is retryable. A partial landing, an expired transaction, an
|
|
@@ -372,14 +387,15 @@ export class TransactionCoordinator {
|
|
|
372
387
|
// can be saved and still hold actions staged after the attempt began, and those
|
|
373
388
|
// the next attempt must commit.
|
|
374
389
|
this.stampData.delete(transaction.stamp.id);
|
|
375
|
-
return;
|
|
390
|
+
return transactionDurability(cycle.saved);
|
|
376
391
|
}
|
|
377
392
|
}
|
|
378
393
|
}
|
|
379
394
|
}
|
|
380
395
|
/**
|
|
381
396
|
* Refresh every registered collection between attempts, recording in `cycle.saved` each one
|
|
382
|
-
* whose refresh finished this transaction's own log entry (see {@link Collection.refreshInFlight})
|
|
397
|
+
* whose refresh finished this transaction's own log entry (see {@link Collection.refreshInFlight}),
|
|
398
|
+
* with who holds it — `undefined` when the refresh could not say, which still records it as saved.
|
|
383
399
|
*
|
|
384
400
|
* Visits EVERY collection even after one throws. Stopping at the first throw would leave a
|
|
385
401
|
* participant later in the map unfinished whenever an earlier one is torn — its log tail stored
|
|
@@ -420,7 +436,7 @@ export class TransactionCoordinator {
|
|
|
420
436
|
// Read after the try, not only on success: a refresh can throw AFTER it finished the
|
|
421
437
|
// entry, and that participant is saved either way.
|
|
422
438
|
if (report.ownEntryFinished !== undefined) {
|
|
423
|
-
cycle.saved.
|
|
439
|
+
recordCollectionDurability(cycle.saved, collectionId, report.ownEntryFinished.durability);
|
|
424
440
|
}
|
|
425
441
|
}
|
|
426
442
|
if (terminal !== undefined) {
|
|
@@ -456,6 +472,7 @@ export class TransactionCoordinator {
|
|
|
456
472
|
*
|
|
457
473
|
* - `committedCollections`: every refresh-saved participant, plus the committed set of `err`
|
|
458
474
|
* when it is itself a partial landing (merged, never wrapped twice — its `reason` is kept);
|
|
475
|
+
* `durability` carries who holds each of them, merged the same way;
|
|
459
476
|
* - `failedCollections`: every other participant of any attempt. Empty when a failure came after
|
|
460
477
|
* every participant was saved (a refresh that finished its entry and then threw, say);
|
|
461
478
|
* - `reason`: the original error.
|
|
@@ -469,11 +486,12 @@ export class TransactionCoordinator {
|
|
|
469
486
|
if (cycle.saved.size === 0) {
|
|
470
487
|
return err;
|
|
471
488
|
}
|
|
472
|
-
const committed = new
|
|
489
|
+
const committed = new Map(cycle.saved);
|
|
473
490
|
let reason = err;
|
|
474
491
|
if (err instanceof CoordinatorPartialCommitError) {
|
|
475
|
-
for (const id of err.
|
|
476
|
-
committed
|
|
492
|
+
for (const [id, durability] of err.durability.collections) {
|
|
493
|
+
recordCollectionDurability(committed, id, durability);
|
|
494
|
+
}
|
|
477
495
|
reason = err.reason;
|
|
478
496
|
}
|
|
479
497
|
// NOTE: a participant is in exactly one list, so one saved by a refresh that ALSO held actions
|
|
@@ -481,9 +499,9 @@ export class TransactionCoordinator {
|
|
|
481
499
|
// committed. Unreachable while a session stages and commits on one call path; if staging ever
|
|
482
500
|
// races a commit, report such a participant in both lists.
|
|
483
501
|
const failed = [...cycle.participants].filter(id => !committed.has(id));
|
|
484
|
-
log('commit:partial-after-refresh tx=%s committed=%o failed=%o reason=%s', transaction.id, [...committed], failed, reason instanceof Error ? reason.name : String(reason));
|
|
502
|
+
log('commit:partial-after-refresh tx=%s committed=%o failed=%o reason=%s', transaction.id, [...committed.keys()], failed, reason instanceof Error ? reason.name : String(reason));
|
|
485
503
|
this.stampData.delete(transaction.stamp.id);
|
|
486
|
-
return new CoordinatorPartialCommitError(
|
|
504
|
+
return new CoordinatorPartialCommitError(committed, failed, reason);
|
|
487
505
|
}
|
|
488
506
|
/**
|
|
489
507
|
* Commit a transaction (single attempt): materialise a log entry from each collection's staged
|
|
@@ -509,6 +527,8 @@ export class TransactionCoordinator {
|
|
|
509
527
|
* `cycle.inFlightDisposers`. REQUIRED, so a future caller cannot silently reintroduce the
|
|
510
528
|
* unmarked refresh the disposers exist to prevent, nor lose track of who took part. The caller
|
|
511
529
|
* owns clearing the marks, because they have to survive past this attempt.
|
|
530
|
+
* @returns every collection this attempt committed, with who holds it — empty when nothing was
|
|
531
|
+
* staged, so the attempt wrote nothing.
|
|
512
532
|
*/
|
|
513
533
|
async commitOnce(transaction, cycle) {
|
|
514
534
|
if (isTransactionExpired(transaction.stamp)) {
|
|
@@ -521,7 +541,7 @@ export class TransactionCoordinator {
|
|
|
521
541
|
// or a read-only transaction that opened one (the empty pre-stage barrier) wedges every
|
|
522
542
|
// later stamp on this coordinator.
|
|
523
543
|
this.stampData.delete(transaction.stamp.id);
|
|
524
|
-
return;
|
|
544
|
+
return new Map();
|
|
525
545
|
}
|
|
526
546
|
for (const { collectionId } of collectionData) {
|
|
527
547
|
cycle.participants.add(collectionId);
|
|
@@ -562,7 +582,7 @@ export class TransactionCoordinator {
|
|
|
562
582
|
// non-participant is left unmarked and its refresh behaves exactly as a reader's.
|
|
563
583
|
cycle.inFlightDisposers.push(collection.beginInFlightAction(transaction.id));
|
|
564
584
|
}
|
|
565
|
-
await this.commitOnceLatched(transaction, collectionData, cycle);
|
|
585
|
+
return await this.commitOnceLatched(transaction, collectionData, cycle);
|
|
566
586
|
}
|
|
567
587
|
finally {
|
|
568
588
|
for (const release of latchReleases.reverse()) {
|
|
@@ -578,8 +598,10 @@ export class TransactionCoordinator {
|
|
|
578
598
|
* is latch-free by contract.
|
|
579
599
|
*
|
|
580
600
|
* `cycle` is written only on a partial landing that is retried forward: the participants this
|
|
581
|
-
* attempt committed go into `cycle.saved`, so the retry loop reports every
|
|
582
|
-
* partial landing it is (see {@link reportSaved}).
|
|
601
|
+
* attempt committed go into `cycle.saved`, with who holds each, so the retry loop reports every
|
|
602
|
+
* later failure as the partial landing it is (see {@link reportSaved}).
|
|
603
|
+
*
|
|
604
|
+
* @returns on success, every participant with who holds it (see {@link commitOnce}).
|
|
583
605
|
*/
|
|
584
606
|
async commitOnceLatched(transaction, collectionData, cycle) {
|
|
585
607
|
// Append each collection's staged actions to its log, then collect the
|
|
@@ -649,7 +671,7 @@ export class TransactionCoordinator {
|
|
|
649
671
|
throw err;
|
|
650
672
|
}
|
|
651
673
|
if (!coordResult.success) {
|
|
652
|
-
const committed = coordResult.committedCollections ?? new
|
|
674
|
+
const committed = coordResult.committedCollections ?? new Map();
|
|
653
675
|
// Keep exactly what each participant that did NOT commit sent, BEFORE the restores below
|
|
654
676
|
// swap its tracker out. A refused commit is not proof nothing landed: a participant's log
|
|
655
677
|
// tail is committed first and can be stored while the answer is still a failure, and
|
|
@@ -718,9 +740,10 @@ export class TransactionCoordinator {
|
|
|
718
740
|
// ABOVE the held revision. Collection.consumeOwnEntry is therefore unreachable for
|
|
719
741
|
// a sibling committed here, and no attempt was retained for it (the loop above
|
|
720
742
|
// skips committed participants) — the refresh is a reader's, at a cost of one walk.
|
|
721
|
-
for (const collectionId of committed)
|
|
722
|
-
cycle.saved
|
|
723
|
-
|
|
743
|
+
for (const [collectionId, durability] of committed) {
|
|
744
|
+
recordCollectionDurability(cycle.saved, collectionId, durability);
|
|
745
|
+
}
|
|
746
|
+
log('commit:partial-retry tx=%s committed=%o failed=%o reason=%s', transaction.id, [...committed.keys()], failed, coordResult.error);
|
|
724
747
|
throw new CoordinatorStaleLossError(failed, coordResult.error);
|
|
725
748
|
}
|
|
726
749
|
// Half-landed on a HARD failure (the transport budget spent on a thrown fault, a
|
|
@@ -728,7 +751,7 @@ export class TransactionCoordinator {
|
|
|
728
751
|
// stamp tracking (the success path does the same at the end) and surface the
|
|
729
752
|
// structured signal for reconciliation at once.
|
|
730
753
|
this.stampData.delete(transaction.stamp.id);
|
|
731
|
-
throw new CoordinatorPartialCommitError(
|
|
754
|
+
throw new CoordinatorPartialCommitError(committed, failed, coordResult.expired ?? coordResult.error);
|
|
732
755
|
}
|
|
733
756
|
// EMPTY committed set: PEND failed, or the whole commit failed cleanly with
|
|
734
757
|
// nothing durable. Restore every tracker so each is pristine for retry.
|
|
@@ -769,6 +792,7 @@ export class TransactionCoordinator {
|
|
|
769
792
|
// precisely because the coordinator enforces at most ONE open stamp (the invariant on
|
|
770
793
|
// stampData): no sibling stamp's snapshot exists to go stale against this commit.
|
|
771
794
|
this.stampData.delete(transaction.stamp.id);
|
|
795
|
+
return coordResult.committedCollections;
|
|
772
796
|
}
|
|
773
797
|
/**
|
|
774
798
|
* Rollback a transaction (undo only the given stampId's applied actions).
|
|
@@ -1077,7 +1101,7 @@ export class TransactionCoordinator {
|
|
|
1077
1101
|
// (docs/transactions.md). If a host ever commits multi-collection transactions
|
|
1078
1102
|
// through execute(), route its coordination through commit()'s retry rather than
|
|
1079
1103
|
// duplicating that recovery here.
|
|
1080
|
-
const committed = coordResult.committedCollections ?? new
|
|
1104
|
+
const committed = coordResult.committedCollections ?? new Map();
|
|
1081
1105
|
if (committed.size > 0) {
|
|
1082
1106
|
for (const collectionId of batches.keys()) {
|
|
1083
1107
|
const collection = this.collections.get(collectionId);
|
|
@@ -1112,7 +1136,9 @@ export class TransactionCoordinator {
|
|
|
1112
1136
|
return {
|
|
1113
1137
|
success: false,
|
|
1114
1138
|
error: coordResult.error,
|
|
1115
|
-
|
|
1139
|
+
...(committed.size > 0
|
|
1140
|
+
? { committedCollections: [...committed.keys()], durability: transactionDurability(committed) }
|
|
1141
|
+
: {}),
|
|
1116
1142
|
failedCollections: coordResult.failedCollections ? [...coordResult.failedCollections] : undefined,
|
|
1117
1143
|
};
|
|
1118
1144
|
}
|
|
@@ -1136,6 +1162,7 @@ export class TransactionCoordinator {
|
|
|
1136
1162
|
}
|
|
1137
1163
|
// Clean up stamp tracking data
|
|
1138
1164
|
this.stampData.delete(transaction.stamp.id);
|
|
1165
|
+
const durability = writtenDurability(coordResult.committedCollections);
|
|
1139
1166
|
// 6. Return results from actions.
|
|
1140
1167
|
// `actions` is the engine's ORIGINAL batch list, un-coalesced — the field is documented
|
|
1141
1168
|
// as "the actions produced by executing the transaction", and the caller's own shape is
|
|
@@ -1146,7 +1173,8 @@ export class TransactionCoordinator {
|
|
|
1146
1173
|
return {
|
|
1147
1174
|
success: true,
|
|
1148
1175
|
actions: result.actions,
|
|
1149
|
-
results: actionResults
|
|
1176
|
+
results: actionResults,
|
|
1177
|
+
...(durability === undefined ? {} : { durability })
|
|
1150
1178
|
};
|
|
1151
1179
|
}
|
|
1152
1180
|
finally {
|
|
@@ -1277,7 +1305,7 @@ export class TransactionCoordinator {
|
|
|
1277
1305
|
// 4. PROPAGATE and CHECKPOINT phases are handled by clusters automatically
|
|
1278
1306
|
// (as per user's note: "managed by each cluster, the client doesn't have to worry about them")
|
|
1279
1307
|
log('trx:phases trxId=%s gather=%dms pend=%dms commit=%dms total=%dms', trxId, gatherMs, pendMs, commitMs, Date.now() - t0);
|
|
1280
|
-
return { success: true };
|
|
1308
|
+
return { success: true, committedCollections: commitResult.committedCollections };
|
|
1281
1309
|
}
|
|
1282
1310
|
/**
|
|
1283
1311
|
* GATHER phase: Collect nominees from critical clusters.
|
|
@@ -1437,7 +1465,7 @@ export class TransactionCoordinator {
|
|
|
1437
1465
|
// Fan out the independent per-collection commit-with-retry concurrently, then
|
|
1438
1466
|
// aggregate the committed/failed partition from the settled results.
|
|
1439
1467
|
const outcomes = await Promise.allSettled(Array.from(pendedBlockIds.entries()).map(([collectionId, blockIds]) => this.commitCollection(actionId, criticalBlockIds, collectionId, blockIds, pendedRevs.get(collectionId))));
|
|
1440
|
-
const committedCollections = new
|
|
1468
|
+
const committedCollections = new Map();
|
|
1441
1469
|
const failedCollections = new Set();
|
|
1442
1470
|
const errors = [];
|
|
1443
1471
|
// Classify failures: a returned stale loss (someone committed a newer rev) is retryable after
|
|
@@ -1449,19 +1477,18 @@ export class TransactionCoordinator {
|
|
|
1449
1477
|
let expired;
|
|
1450
1478
|
for (const outcome of outcomes) {
|
|
1451
1479
|
if (outcome.status === 'fulfilled') {
|
|
1452
|
-
const
|
|
1453
|
-
if (committed) {
|
|
1454
|
-
committedCollections.
|
|
1480
|
+
const result = outcome.value;
|
|
1481
|
+
if (result.committed) {
|
|
1482
|
+
committedCollections.set(result.collectionId, result.durability);
|
|
1455
1483
|
}
|
|
1456
1484
|
else {
|
|
1457
|
-
failedCollections.add(collectionId);
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
if (stale)
|
|
1485
|
+
failedCollections.add(result.collectionId);
|
|
1486
|
+
errors.push(result.error);
|
|
1487
|
+
if (result.stale)
|
|
1461
1488
|
anyStale = true;
|
|
1462
1489
|
else
|
|
1463
1490
|
anyHard = true;
|
|
1464
|
-
expired ??=
|
|
1491
|
+
expired ??= result.expired;
|
|
1465
1492
|
}
|
|
1466
1493
|
}
|
|
1467
1494
|
else {
|
|
@@ -1486,7 +1513,8 @@ export class TransactionCoordinator {
|
|
|
1486
1513
|
/**
|
|
1487
1514
|
* Commit a single collection's pended blocks, retrying transient failures up to three
|
|
1488
1515
|
* times (forward recovery). Always resolves — success is carried in the returned
|
|
1489
|
-
* `committed` flag — so the fan-out in
|
|
1516
|
+
* `committed` flag, with the commit's `durability` beside it — so the fan-out in
|
|
1517
|
+
* {@link commitPhase} can aggregate every result.
|
|
1490
1518
|
*/
|
|
1491
1519
|
async commitCollection(actionId, criticalBlockIds, collectionId, blockIds,
|
|
1492
1520
|
/** The revision this collection PENDED at, threaded from the log append — the same bug
|
|
@@ -1530,7 +1558,7 @@ export class TransactionCoordinator {
|
|
|
1530
1558
|
try {
|
|
1531
1559
|
const commitResult = await this.transactor.commit(commitRequest);
|
|
1532
1560
|
if (commitResult.success) {
|
|
1533
|
-
return { collectionId, committed: true };
|
|
1561
|
+
return { collectionId, committed: true, durability: withBlockRevs(commitResult.durability, blockIds, rev) };
|
|
1534
1562
|
}
|
|
1535
1563
|
if (isExpiryFailure(commitResult)) {
|
|
1536
1564
|
// Not a stale loss: a re-drive's expiration comes from the same clock.
|