@optimystic/db-core 1.12.1 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +60 -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/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.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 +45 -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 +84 -48
- 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/network-transactor.d.ts +48 -5
- package/dist/src/transactor/network-transactor.d.ts.map +1 -1
- package/dist/src/transactor/network-transactor.js +98 -22
- package/dist/src/transactor/network-transactor.js.map +1 -1
- package/dist/src/transactor/owed-cancels.d.ts +96 -0
- package/dist/src/transactor/owed-cancels.d.ts.map +1 -0
- package/dist/src/transactor/owed-cancels.js +211 -0
- package/dist/src/transactor/owed-cancels.js.map +1 -0
- 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 +11 -6
- package/dist/src/transactor/transactor-source.js.map +1 -1
- package/dist/src/utility/unref-timer.d.ts +9 -0
- package/dist/src/utility/unref-timer.d.ts.map +1 -0
- package/dist/src/utility/unref-timer.js +15 -0
- package/dist/src/utility/unref-timer.js.map +1 -0
- package/package.json +1 -1
- package/src/cluster/i-cluster.ts +13 -2
- package/src/cluster/structs.ts +62 -6
- package/src/collection/collection.ts +5 -3
- package/src/index.ts +1 -0
- package/src/network/durability.ts +63 -15
- package/src/network/i-key-network.ts +10 -0
- package/src/network/struct.ts +45 -5
- package/src/transaction/coordinator.ts +130 -79
- 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/network-transactor.ts +120 -29
- package/src/transactor/owed-cancels.ts +252 -0
- package/src/transactor/transactor-source.ts +11 -6
- package/src/utility/unref-timer.ts +15 -0
|
@@ -20,7 +20,8 @@ export function durabilityRank(q) {
|
|
|
20
20
|
* Merge per-cohort reports into one action-level report: the weakest becomes the scalar answer and
|
|
21
21
|
* the rest become `otherCohorts`, so a consumer that reads only the scalar fields is reading the
|
|
22
22
|
* binding constraint. `torn` is the union across the inputs — an abandoned block is abandoned
|
|
23
|
-
* whichever cohort it ran on
|
|
23
|
+
* whichever cohort it ran on — and `blockRevs` the union at the higher revision per block, less
|
|
24
|
+
* every torn block. Reports that already carry `otherCohorts` are flattened first, so
|
|
24
25
|
* merging a merge is the same as merging its inputs. Identical reports collapse to one: a commit
|
|
25
26
|
* sends the tail and the sweep as separate batches, so ONE cohort routinely answers twice for one
|
|
26
27
|
* action, and without this a healthy single-cohort commit would list its own cohort under
|
|
@@ -41,38 +42,61 @@ export function mergeDurability(reports) {
|
|
|
41
42
|
const ranked = [...flat].sort((a, b) => durabilityRank(a.quorum) - durabilityRank(b.quorum));
|
|
42
43
|
const weakest = ranked[0];
|
|
43
44
|
const others = ranked.slice(1);
|
|
44
|
-
// Over the ORIGINAL reports: flattening strips `torn` (
|
|
45
|
-
//
|
|
45
|
+
// Over the ORIGINAL reports: flattening strips `torn` and `blockRevs` (they are action-level),
|
|
46
|
+
// so both are taken before that or a torn input merges to an untorn answer.
|
|
46
47
|
const torn = unionTorn(reports);
|
|
48
|
+
const blockRevs = withoutBlocks(highestBlockRevs(reports), torn);
|
|
47
49
|
return {
|
|
48
50
|
...stripMergedFields(weakest),
|
|
49
51
|
...(others.length === 0 ? {} : { otherCohorts: others.map(stripMergedFields) }),
|
|
50
|
-
...(torn.length === 0 ? {} : { torn })
|
|
52
|
+
...(torn.length === 0 ? {} : { torn }),
|
|
53
|
+
...blockRevsField(blockRevs)
|
|
51
54
|
};
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Name the blocks a write committed, at the revision it committed them at — set where the commit is
|
|
58
|
+
* confirmed, by the db-core layer that issued it. A block already named keeps the higher revision,
|
|
59
|
+
* and a block in `d.torn` is left out: it holds nothing.
|
|
60
|
+
*/
|
|
61
|
+
export function withBlockRevs(d, blockIds, rev) {
|
|
62
|
+
const committed = Object.fromEntries(blockIds.map(blockId => [blockId, rev]));
|
|
63
|
+
const blockRevs = withoutBlocks(highestBlockRevs([d, { blockRevs: committed }]), d.torn ?? []);
|
|
64
|
+
return { ...d, ...blockRevsField(blockRevs) };
|
|
65
|
+
}
|
|
53
66
|
/**
|
|
54
67
|
* Clamp an action-level report below `full` when the action abandoned blocks. A cohort can hold
|
|
55
68
|
* every block it was asked to commit and the action still be incomplete — the blocks the sweep
|
|
56
69
|
* never reached are on nobody. Never raises the class; a report already below `full` keeps it.
|
|
57
|
-
* Idempotent, and a no-op for an
|
|
70
|
+
* A torn block leaves `blockRevs`, since it was not committed. Idempotent, and a no-op for an
|
|
71
|
+
* empty `torn`.
|
|
58
72
|
*/
|
|
59
73
|
export function withTornBlocks(d, torn) {
|
|
60
74
|
if (torn.length === 0)
|
|
61
75
|
return d;
|
|
62
76
|
const allTorn = Array.from(new Set([...(d.torn ?? []), ...torn]));
|
|
77
|
+
const { blockRevs: _blockRevs, ...rest } = d;
|
|
63
78
|
return {
|
|
64
|
-
...
|
|
79
|
+
...rest,
|
|
65
80
|
quorum: d.quorum === 'full' ? 'majority' : d.quorum,
|
|
66
|
-
torn: allTorn
|
|
81
|
+
torn: allTorn,
|
|
82
|
+
...blockRevsField(withoutBlocks(d.blockRevs ?? {}, allTorn))
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
85
|
+
/**
|
|
86
|
+
* The single-node answer: this node holds it and nobody else does yet. `absent` names the cohort
|
|
87
|
+
* members this node knows of that the write ran without — they are part of the cohort the write is
|
|
88
|
+
* owed to, so they count in `cohort` and are listed in `unconfirmed`. With none, it is a one-machine
|
|
89
|
+
* write that is complete. `absent` needs `selfPeerId`: without it the answer cannot name the cohort.
|
|
90
|
+
*/
|
|
91
|
+
export function localDurability(selfPeerId, absent = []) {
|
|
92
|
+
if (selfPeerId === undefined)
|
|
93
|
+
return { quorum: 'local', confirmed: 1, cohort: 1 };
|
|
71
94
|
return {
|
|
72
95
|
quorum: 'local',
|
|
73
96
|
confirmed: 1,
|
|
74
|
-
cohort: 1,
|
|
75
|
-
|
|
97
|
+
cohort: 1 + absent.length,
|
|
98
|
+
unconfirmed: [...absent],
|
|
99
|
+
cohortPeerIds: [selfPeerId, ...absent]
|
|
76
100
|
};
|
|
77
101
|
}
|
|
78
102
|
/**
|
|
@@ -87,21 +111,24 @@ export function unroutedDurability() {
|
|
|
87
111
|
function flattenDurability(d) {
|
|
88
112
|
return [stripMergedFields(d), ...(d.otherCohorts ?? [])];
|
|
89
113
|
}
|
|
90
|
-
/** The per-cohort fields only — `otherCohorts` and `
|
|
114
|
+
/** The per-cohort fields only — `otherCohorts`, `torn` and `blockRevs` are action-level and
|
|
115
|
+
* re-derived by the merge. */
|
|
91
116
|
function stripMergedFields(d) {
|
|
92
|
-
const { otherCohorts: _otherCohorts, torn: _torn, ...cohortReport } = d;
|
|
117
|
+
const { otherCohorts: _otherCohorts, torn: _torn, blockRevs: _blockRevs, ...cohortReport } = d;
|
|
93
118
|
return cohortReport;
|
|
94
119
|
}
|
|
95
120
|
/**
|
|
96
121
|
* First occurrence of each structurally identical per-cohort report, input order kept. Peer lists
|
|
97
122
|
* compare as SETS: `findCluster` orders a cohort by routing distance to the block's key, so one
|
|
98
|
-
* cohort answering for two blocks lists the same members in two orders.
|
|
123
|
+
* cohort answering for two blocks lists the same members in two orders. `recordedBy` is part of the
|
|
124
|
+
* identity: two otherwise identical answers whose shortfalls two different ledgers recorded are two
|
|
125
|
+
* facts, and a consumer waiting on full-replication events needs to see both.
|
|
99
126
|
*/
|
|
100
127
|
function distinctReports(reports) {
|
|
101
128
|
const seen = new Set();
|
|
102
129
|
const sorted = (ids) => ids === undefined ? null : [...ids].sort();
|
|
103
130
|
return reports.filter(r => {
|
|
104
|
-
const key = JSON.stringify([r.quorum, r.confirmed, r.cohort, sorted(r.unconfirmed), sorted(r.cohortPeerIds)]);
|
|
131
|
+
const key = JSON.stringify([r.quorum, r.confirmed, r.cohort, sorted(r.unconfirmed), sorted(r.cohortPeerIds), r.recordedBy ?? null]);
|
|
105
132
|
if (seen.has(key))
|
|
106
133
|
return false;
|
|
107
134
|
seen.add(key);
|
|
@@ -111,4 +138,22 @@ function distinctReports(reports) {
|
|
|
111
138
|
function unionTorn(reports) {
|
|
112
139
|
return Array.from(new Set(reports.flatMap(r => r.torn ?? [])));
|
|
113
140
|
}
|
|
141
|
+
/** Every block any report names, at the highest revision any of them names it at. */
|
|
142
|
+
function highestBlockRevs(reports) {
|
|
143
|
+
// A Map, not assignment into `{}`: a header block's id is its collection id, which a caller
|
|
144
|
+
// names, and `__proto__` assigned into a plain object sets its prototype instead of a key.
|
|
145
|
+
const highest = new Map();
|
|
146
|
+
for (const [blockId, rev] of reports.flatMap(r => Object.entries(r.blockRevs ?? {}))) {
|
|
147
|
+
highest.set(blockId, Math.max(highest.get(blockId) ?? rev, rev));
|
|
148
|
+
}
|
|
149
|
+
return Object.fromEntries(highest);
|
|
150
|
+
}
|
|
151
|
+
function withoutBlocks(blockRevs, excluded) {
|
|
152
|
+
const drop = new Set(excluded);
|
|
153
|
+
return Object.fromEntries(Object.entries(blockRevs).filter(([blockId]) => !drop.has(blockId)));
|
|
154
|
+
}
|
|
155
|
+
/** The field, or nothing: an empty map is left off, as an empty `torn` is. */
|
|
156
|
+
function blockRevsField(blockRevs) {
|
|
157
|
+
return Object.keys(blockRevs).length === 0 ? {} : { blockRevs };
|
|
158
|
+
}
|
|
114
159
|
//# sourceMappingURL=durability.js.map
|
|
@@ -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,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,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;;;;O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,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"}
|
|
@@ -77,6 +77,26 @@ export type PendRequest = ActionTransforms & {
|
|
|
77
77
|
* pend named no base, not the primary check.
|
|
78
78
|
*/
|
|
79
79
|
baseRevs?: BlockBaseRevs;
|
|
80
|
+
/**
|
|
81
|
+
* The writer's word that this pend is the action's only one — every block the action will commit
|
|
82
|
+
* is in this one request — and that the action's commit goes to the coordinator this pend goes
|
|
83
|
+
* to. Only then may a coordinator hold back the pend's final delivery to the other members and
|
|
84
|
+
* send it inside the commit's first request (`ClusterCoordinator.mayDeferPendDelivery` in db-p2p):
|
|
85
|
+
* a member that refuses the pend late refuses that one commit, before anything of the action is
|
|
86
|
+
* durable. A send that pends several requests before committing any — several collections under
|
|
87
|
+
* one action id, or one collection split across coordinators — must never carry it: one request's
|
|
88
|
+
* late refusal would surface while another request's commit may already have landed, tearing the
|
|
89
|
+
* action.
|
|
90
|
+
*
|
|
91
|
+
* Set by `TransactorSource.transact` and by `TransactionCoordinator` for a transaction of exactly
|
|
92
|
+
* one collection; `NetworkTransactor.pend` keeps it only on a request carrying the whole pend.
|
|
93
|
+
* `Collection.completeOwnEntry` re-sends one participant of a half-landed multi-collection action
|
|
94
|
+
* through `transact`, and carries it too: that re-send pends and commits its one collection on its
|
|
95
|
+
* own, so its late refusal stops only its own commit, as an on-time refusal would.
|
|
96
|
+
* Omitted rather than `false`, for the same preimage reason as {@link baseRevs}; a coordinator on
|
|
97
|
+
* an older build ignores it, and then delivers at once as it always did.
|
|
98
|
+
*/
|
|
99
|
+
soleReservation?: true;
|
|
80
100
|
};
|
|
81
101
|
export type BlockActionStatus = ActionBlocks & {
|
|
82
102
|
statuses: ('pending' | 'committed' | 'checkpointed' | 'aborted' | 'committed-invalidated')[];
|
|
@@ -90,12 +110,15 @@ export type DurabilityQuorum =
|
|
|
90
110
|
* (`withTornBlocks` clamps `full` down to this; `torn` then names the blocks, and `unconfirmed`
|
|
91
111
|
* may be empty). */
|
|
92
112
|
| 'majority'
|
|
93
|
-
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet.
|
|
113
|
+
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet. When this
|
|
114
|
+
* node knows of other members of the cohort that it could not reach (`IKeyNetwork.absentCohortMembers`),
|
|
115
|
+
* they are named in `unconfirmed` and counted in `cohort`: the write is owed to them. With none
|
|
116
|
+
* named, it is a correct, complete one-machine write. */
|
|
94
117
|
| 'local'
|
|
95
118
|
/** The cohort did NOT resolve: the lookup threw, or named nobody, or named a single peer that
|
|
96
119
|
* 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. */
|
|
120
|
+
* Deliberately NOT `local`: a write that lands where its cohort resolved to is in the right
|
|
121
|
+
* place, whereas this is a write whose correct destination is unknown. */
|
|
99
122
|
| 'unrouted';
|
|
100
123
|
/** What the answering layer knows about who holds a successful write. Each layer refines it:
|
|
101
124
|
* `StorageRepo` answers for itself alone, `CoordinatorRepo` answers for the cohort the write ran
|
|
@@ -112,15 +135,24 @@ export type WriteDurability = {
|
|
|
112
135
|
* it means "accepted the pending record". The two are NOT comparable — a pend confers no
|
|
113
136
|
* storage durability (see the note in `CoordinatorRepo.pendThroughCluster`). */
|
|
114
137
|
readonly confirmed: number;
|
|
115
|
-
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'.
|
|
138
|
+
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'. For `local`
|
|
139
|
+
* it is one plus the known members the write ran without, so `local` does not imply 1. */
|
|
116
140
|
readonly cohort: number;
|
|
117
141
|
/** Cohort members that did not confirm, by peer-id string. Empty when `quorum` is 'full'.
|
|
118
142
|
* ABSENT (not empty) when the answering layer could not name the cohort — an empty array
|
|
119
|
-
* here means "named the cohort, nobody is missing".
|
|
143
|
+
* here means "named the cohort, nobody is missing". On a `local` write these are the members
|
|
144
|
+
* this node knows of but could not reach when it wrote alone. */
|
|
120
145
|
readonly unconfirmed?: readonly string[];
|
|
121
146
|
/** The cohort the write ran on, by peer-id string. Absent where the answering layer has no
|
|
122
147
|
* cohort view at all (a bare `StorageRepo` verdict). */
|
|
123
148
|
readonly cohortPeerIds?: readonly string[];
|
|
149
|
+
/** Peer-id string of the node whose under-replication ledger recorded this write's missing
|
|
150
|
+
* copies — the one node that will fire `BlockDurabilityReachedEvent` for these blocks when they
|
|
151
|
+
* reach full replication. Set only below `full`, and only when every non-torn block's shortfall
|
|
152
|
+
* was recorded. Absent: no node is tracking the shortfall (nothing to push from the coordinator,
|
|
153
|
+
* a ledger fault, no ledger, a producer that predates the field), so no full-replication event
|
|
154
|
+
* should be expected. Per cohort answer: each `otherCohorts` entry carries its own. */
|
|
155
|
+
readonly recordedBy?: string;
|
|
124
156
|
/** Present only on an action-level result assembled from MORE THAN ONE distinct coordinator
|
|
125
157
|
* answer: the other answers. Identical answers are collapsed (`mergeDurability`), so a healthy
|
|
126
158
|
* single-cohort commit has none; one cohort answering differently for two batches appears
|
|
@@ -132,6 +164,14 @@ export type WriteDurability = {
|
|
|
132
164
|
* These blocks NEVER heal by replication: their transform is gone, and only the writer
|
|
133
165
|
* re-driving the action puts them back. */
|
|
134
166
|
readonly torn?: readonly BlockId[];
|
|
167
|
+
/** Action-level: every block this write committed, with the revision it committed at — what a
|
|
168
|
+
* host holds to match full-replication events (`BlockDurabilityReachedEvent`, keyed by block and
|
|
169
|
+
* revision) back to this write. Set by the db-core layer that issued the commit
|
|
170
|
+
* (`withBlockRevs`), never by a coordinator and never on the wire. Excludes `torn` blocks: they
|
|
171
|
+
* hold nothing. Merging two reports keeps, per block, the HIGHER revision — a block written at r
|
|
172
|
+
* and again at r+1 by one write is covered by an event at r+1 or later. A `Record` rather than a
|
|
173
|
+
* `Map` so the type stays plain JSON. */
|
|
174
|
+
readonly blockRevs?: Readonly<Record<BlockId, number>>;
|
|
135
175
|
};
|
|
136
176
|
export type PendSuccess = {
|
|
137
177
|
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,CAA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AAM,MAAM,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":"AAuhBA;;;;;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,KAA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