@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":"change-notifier.js","sourceRoot":"","sources":["../../../src/transactor/change-notifier.ts"],"names":[],"mappings":"AA6EA,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC/C,OAAO,CAAC,CAAC,CAAC,IAAI,OAAQ,CAA0B,CAAC,kBAAkB,KAAK,UAAU,CAAC;AACpF,CAAC;
|
|
1
|
+
{"version":3,"file":"change-notifier.js","sourceRoot":"","sources":["../../../src/transactor/change-notifier.ts"],"names":[],"mappings":"AA6EA,MAAM,UAAU,qBAAqB,CAAC,CAAU;IAC/C,OAAO,CAAC,CAAC,CAAC,IAAI,OAAQ,CAA0B,CAAC,kBAAkB,KAAK,UAAU,CAAC;AACpF,CAAC;AA2DD,MAAM,UAAU,yBAAyB,CAAC,CAAU;IACnD,OAAO,CAAC,CAAC,CAAC,IAAI,OAAQ,CAA8B,CAAC,wBAAwB,KAAK,UAAU,CAAC;AAC9F,CAAC"}
|
|
@@ -130,10 +130,11 @@ export declare class TransactorSource<TBlock extends IBlock> implements BlockSou
|
|
|
130
130
|
* committed revision each update-only block's operations were computed against, from the same tracker
|
|
131
131
|
* (`Tracker.stagedBaseRevs`). Omitted from the pend request when empty, for the same preimage reason.
|
|
132
132
|
* @returns The transactor's own verdict, unflattened: a {@link CommitSuccess} carrying the
|
|
133
|
-
* {@link WriteDurability} of the committed revision
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
133
|
+
* {@link WriteDurability} of the committed revision — naming every block it committed at `rev`
|
|
134
|
+
* (`blockRevs`) — or a {@link StaleFailure} if the pend or the commit was refused. Success is
|
|
135
|
+
* deliberately NOT collapsed to `undefined` — the durability is the only thing that tells a write every
|
|
136
|
+
* machine holds from one only this machine holds, and a caller that wants the old boolean reads
|
|
137
|
+
* `result.success`. Test "is this completely saved" through `isFullyDurable`, never
|
|
137
138
|
* by comparing `quorum` (see {@link WriteDurability}).
|
|
138
139
|
*/
|
|
139
140
|
transact(transform: Transforms, actionId: ActionId, rev: number, headerId: BlockId, tailId: BlockId, priority?: number, blockDigests?: BlockContentDigests, baseRevs?: BlockBaseRevs): Promise<CommitResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactor-source.d.ts","sourceRoot":"","sources":["../../../src/transactor/transactor-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"transactor-source.d.ts","sourceRoot":"","sources":["../../../src/transactor/transactor-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE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EAAE,aAAa,GAAG,SAAS,EAC/C,SAAS,CAAC,EAAE,uBAAuB;IACnC;uGACmG;IAClF,MAAM,CAAC,EAAE,eAAe,YAAA;IAK1C,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,WAAW;IAQhE,UAAU,IAAI,OAAO;IAKf,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,GAAE,WAAqB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA6CtF;;+DAE2D;IAC3D,eAAe,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAIhD;;wFAEoF;IACpF,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAItD;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA4BqB;IACrB,OAAO,CAAC,SAAS;IAIjB,mBAAmB,IAAI,cAAc,EAAE;IAIvC;;;8EAG0E;IAC1E,YAAY,IAAI,uBAAuB;IAIvC,qBAAqB,IAAI,IAAI;IAI7B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,QAAQ,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,SAAI,EAAE,YAAY,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IA2C7M;;;;;;;;;;OAUG;YACW,aAAa;CAS3B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomBytes } from '@noble/hashes/utils.js';
|
|
2
2
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string';
|
|
3
3
|
import { BlockUnavailableError, BlockPossiblyStaleError } from "../network/struct.js";
|
|
4
|
+
import { withBlockRevs } from "../network/durability.js";
|
|
4
5
|
import { ReadDependencyCollector } from "../transaction/read-dependency-collector.js";
|
|
5
6
|
import { blockDigestsField, baseRevsField } from "../transform/digest.js";
|
|
6
7
|
import { createLogger } from "../logger.js";
|
|
@@ -205,10 +206,11 @@ export class TransactorSource {
|
|
|
205
206
|
* committed revision each update-only block's operations were computed against, from the same tracker
|
|
206
207
|
* (`Tracker.stagedBaseRevs`). Omitted from the pend request when empty, for the same preimage reason.
|
|
207
208
|
* @returns The transactor's own verdict, unflattened: a {@link CommitSuccess} carrying the
|
|
208
|
-
* {@link WriteDurability} of the committed revision
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
209
|
+
* {@link WriteDurability} of the committed revision — naming every block it committed at `rev`
|
|
210
|
+
* (`blockRevs`) — or a {@link StaleFailure} if the pend or the commit was refused. Success is
|
|
211
|
+
* deliberately NOT collapsed to `undefined` — the durability is the only thing that tells a write every
|
|
212
|
+
* machine holds from one only this machine holds, and a caller that wants the old boolean reads
|
|
213
|
+
* `result.success`. Test "is this completely saved" through `isFullyDurable`, never
|
|
212
214
|
* by comparing `quorum` (see {@link WriteDurability}).
|
|
213
215
|
*/
|
|
214
216
|
async transact(transform, actionId, rev, headerId, tailId, priority = 0, blockDigests, baseRevs) {
|
|
@@ -236,8 +238,9 @@ export class TransactorSource {
|
|
|
236
238
|
// rebase — letting the cancel's own failure throw over it would turn a routine,
|
|
237
239
|
// recoverable race into a hard failure. So the cancel fault is logged, not raised.
|
|
238
240
|
await this.dischargePend(actionId, pendResult.blockIds);
|
|
241
|
+
return commitResult;
|
|
239
242
|
}
|
|
240
|
-
return commitResult;
|
|
243
|
+
return { ...commitResult, durability: withBlockRevs(commitResult.durability, pendResult.blockIds, rev) };
|
|
241
244
|
}
|
|
242
245
|
catch (e) {
|
|
243
246
|
// `e` is the real cause — a transport fault, the thing the caller needs to see. A cancel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactor-source.js","sourceRoot":"","sources":["../../../src/transactor/transactor-source.ts"],"names":[],"mappings":"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AAM,CAAC,CAAC,YAAY,CAAC,CAAC;YAC3F,CAAC;YACD,MAAM,CAAC,CAAC;QACT,CAAC;IACF,CAAC;IAED;;;;;;;;;;OAUG;IACK,KAAK,CAAC,aAAa,CAAC,QAAkB,EAAE,QAAmB;QAClE,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACrD,OAAO,SAAS,CAAC;QAClB,CAAC;QAAC,OAAO,WAAW,EAAE,CAAC;YACtB,GAAG,CAAC,8EAA8E,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;YACrH,OAAO,WAAW,CAAC;QACpB,CAAC;IACF,CAAC;CACD"}
|
package/package.json
CHANGED
package/src/cluster/i-cluster.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type { ClusterRecord } from "./structs.js";
|
|
1
|
+
import type { CarriedOutcome, ClusterRecord } from "./structs.js";
|
|
2
2
|
|
|
3
3
|
export type ICluster = {
|
|
4
4
|
update(record: ClusterRecord): Promise<ClusterRecord>;
|
|
5
|
+
/**
|
|
6
|
+
* {@link update}, with already-decided records the member is still owed carried ahead of `record`.
|
|
7
|
+
* The member applies them first, in order, then handles `record`; `carried` in the answer reports
|
|
8
|
+
* each one, in the order sent. A carried record the member could not take — or every one, when the
|
|
9
|
+
* member predates carried records — comes back not delivered, and stays owed. Throws exactly when
|
|
10
|
+
* {@link update} would; the caller then treats every carried record as not delivered (a member
|
|
11
|
+
* that did apply one dedups its re-delivery).
|
|
12
|
+
*
|
|
13
|
+
* Optional: a member reached in process has nothing owed to it, and a client without it is sent
|
|
14
|
+
* owed records only by the coordinator's retry.
|
|
15
|
+
*/
|
|
16
|
+
updateCarrying?(record: ClusterRecord, carried: readonly ClusterRecord[]): Promise<{ answer: ClusterRecord; carried: CarriedOutcome[] }>;
|
|
5
17
|
}
|
|
6
|
-
|
package/src/cluster/structs.ts
CHANGED
|
@@ -157,6 +157,35 @@ export type MemberApplyOutcome = {
|
|
|
157
157
|
* for the operator's benefit — the coordinator reads only `success`.
|
|
158
158
|
*/
|
|
159
159
|
commit?: CommitResult;
|
|
160
|
+
/**
|
|
161
|
+
* This member applies decided records carried ahead of a request's own record
|
|
162
|
+
* ({@link CarriedOutcome}). Stamped on every answer, so a coordinator can tell a member that
|
|
163
|
+
* understands carried records from one on an older build, which never sets it; a coordinator
|
|
164
|
+
* carries records only to a member whose last answer stamped it.
|
|
165
|
+
*/
|
|
166
|
+
acceptsCarried?: true;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The most decided records one cluster request may carry ahead of its own record. A coordinator never
|
|
171
|
+
* sends more, and a member ignores a request's carried list that is longer.
|
|
172
|
+
*/
|
|
173
|
+
export const MaxCarriedRecords = 4;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* A member's answer for one decided record carried ahead of a request's own record — one per carried
|
|
177
|
+
* record, in the order sent. Compact on purpose: echoing whole records back would double the size of
|
|
178
|
+
* the response.
|
|
179
|
+
*/
|
|
180
|
+
export type CarriedOutcome = {
|
|
181
|
+
/** The carried record's `messageHash`. */
|
|
182
|
+
messageHash: string;
|
|
183
|
+
/** True only when the member ran `update` on the record without throwing and without redirecting it. */
|
|
184
|
+
delivered: boolean;
|
|
185
|
+
/** The member's own {@link ClusterRecord.applyOutcomes} entry from its answer to the carried record. */
|
|
186
|
+
outcome?: MemberApplyOutcome;
|
|
187
|
+
/** Why the member did not take the record, when it threw. */
|
|
188
|
+
error?: string;
|
|
160
189
|
};
|
|
161
190
|
|
|
162
191
|
export type ClusterRecord = {
|
|
@@ -334,9 +363,22 @@ export interface ClusterConsensusConfig {
|
|
|
334
363
|
* single reset here would otherwise drop the peer and sink super-majority.
|
|
335
364
|
*/
|
|
336
365
|
promiseImmediateRetries?: number;
|
|
337
|
-
/**
|
|
366
|
+
/**
|
|
367
|
+
* How a block the node HOLDS is re-verified against its cohort on a read. Default 'lazy'.
|
|
368
|
+
* - 'lazy': the held copy is served at once; when the block was last checked more than
|
|
369
|
+
* `readRepairWindowMs` ago (or never, as after a restart) the read also starts a cohort
|
|
370
|
+
* consult that runs BEHIND it, and what that consult learns (a repair, the window's stamp,
|
|
371
|
+
* the `unconfirmedAheadRev` doubt) reaches the next read of the block. A read never waits
|
|
372
|
+
* on a cohort peer that is connected but silent. A read carrying a floor above the held
|
|
373
|
+
* copy still waits for its consult, because the asker has proof the copy is too old.
|
|
374
|
+
* - 'paranoid': every read of a held block consults the cohort and waits for the consult —
|
|
375
|
+
* for callers that cannot tolerate any staleness, including the first read after a restart.
|
|
376
|
+
* - 'off': never consults for a held block (legacy; staleness unbounded).
|
|
377
|
+
* In every mode a block missing locally consults its cohort on every read, and that read waits.
|
|
378
|
+
* On a node, set through `clusterPolicy.readRepairMode`.
|
|
379
|
+
*/
|
|
338
380
|
readRepairMode?: 'off' | 'lazy' | 'paranoid';
|
|
339
|
-
/** For 'lazy' mode: read
|
|
381
|
+
/** For 'lazy' mode: a held block's read starts a cohort consult when (now - lastSeenCommitMs) > this. Default 10000. On a node, set through `clusterPolicy.readRepairWindowMs`. */
|
|
340
382
|
readRepairWindowMs?: number;
|
|
341
383
|
/** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
|
|
342
384
|
readRepairSampleRate?: number;
|
|
@@ -352,10 +394,12 @@ export interface ClusterConsensusConfig {
|
|
|
352
394
|
* client's own dial and response defaults do not apply underneath it.
|
|
353
395
|
*
|
|
354
396
|
* Raise it for a deployment whose links are slower than a LAN: two phones reaching each other
|
|
355
|
-
* only through a public circuit relay have a round trip near 1.8s, and
|
|
356
|
-
* or reuse, protocol select, send, receive) must fit inside this budget or the peer
|
|
357
|
-
* silent. The protocol select costs a round trip even on an open connection, so
|
|
358
|
-
* reused connection costs two.
|
|
397
|
+
* only through a public circuit relay have a round trip near 1.8s, and a request that opens its
|
|
398
|
+
* stream (dial or reuse, protocol select, send, receive) must fit inside this budget or the peer
|
|
399
|
+
* counts as silent. The protocol select costs a round trip even on an open connection, so such a
|
|
400
|
+
* request over a reused connection costs two. db-p2p negotiates the next stream to a peer it is
|
|
401
|
+
* talking to in advance, so a later request in a busy spell costs one, but the first after a quiet
|
|
402
|
+
* spell still costs two. In a two-member cohort one late answer is the whole quorum, so the
|
|
359
403
|
* consult declines every time and a rejoining node never catches up.
|
|
360
404
|
*
|
|
361
405
|
* Fractional values are accepted — this is a duration, not a count of peers. A value that is not
|
|
@@ -12,7 +12,7 @@ import { copyTransforms, isTransformsEmpty } from "../transform/helpers.js";
|
|
|
12
12
|
import { TransactorSource, answeredBlock, servedRevision } from "../transactor/transactor-source.js";
|
|
13
13
|
import { BlockFloors } from "../transactor/block-floors.js";
|
|
14
14
|
import type { WriteDurability } from "../network/struct.js";
|
|
15
|
-
import { mergeDurability } from "../network/durability.js";
|
|
15
|
+
import { mergeDurability, withBlockRevs } from "../network/durability.js";
|
|
16
16
|
import { highestStaleAt, isExpiryFailure } from "../network/stale-failure.js";
|
|
17
17
|
import { TransactionExpiredError } from "../network/transaction-expired-error.js";
|
|
18
18
|
import type { CollectionHeaderBlock, CollectionId, ICollection, SyncOptions, TornActionReason } from "./index.js";
|
|
@@ -827,10 +827,12 @@ export class Collection<TAction> implements ICollection<TAction> {
|
|
|
827
827
|
const discharged = await this.dischargeOwnPendings(entry);
|
|
828
828
|
const lineage = rev === undefined ? undefined : await this.lineageOfOwnEntry(entry, rev);
|
|
829
829
|
const unsaved = entry.blockIds.filter((blockId, i) => blockId !== tailId && lineage?.blocks[i] !== 'contains');
|
|
830
|
-
if (lineage !== undefined && unsaved.length === 0) {
|
|
830
|
+
if (lineage !== undefined && rev !== undefined && unsaved.length === 0) {
|
|
831
831
|
log('collection:own-entry-superseded-but-saved id=%s tag=%s action=%s rev=%d blocks=%d',
|
|
832
832
|
this.id, this.instanceTag, entry.actionId, rev, entry.blockIds.length);
|
|
833
|
-
|
|
833
|
+
// The write's own revision: what superseded it built on it at a later one, and an event
|
|
834
|
+
// covering that later revision covers this one too.
|
|
835
|
+
return lineage.durability === undefined ? undefined : withBlockRevs(lineage.durability, entry.blockIds, rev);
|
|
834
836
|
}
|
|
835
837
|
const cannotLand = lineage !== undefined && unsaved.every(blockId => {
|
|
836
838
|
const answer = lineage.blocks[entry.blockIds.indexOf(blockId)];
|
|
@@ -25,7 +25,8 @@ export function durabilityRank(q: DurabilityQuorum): number {
|
|
|
25
25
|
* Merge per-cohort reports into one action-level report: the weakest becomes the scalar answer and
|
|
26
26
|
* the rest become `otherCohorts`, so a consumer that reads only the scalar fields is reading the
|
|
27
27
|
* binding constraint. `torn` is the union across the inputs — an abandoned block is abandoned
|
|
28
|
-
* whichever cohort it ran on
|
|
28
|
+
* whichever cohort it ran on — and `blockRevs` the union at the higher revision per block, less
|
|
29
|
+
* every torn block. Reports that already carry `otherCohorts` are flattened first, so
|
|
29
30
|
* merging a merge is the same as merging its inputs. Identical reports collapse to one: a commit
|
|
30
31
|
* sends the tail and the sweep as separate batches, so ONE cohort routinely answers twice for one
|
|
31
32
|
* action, and without this a healthy single-cohort commit would list its own cohort under
|
|
@@ -46,39 +47,62 @@ export function mergeDurability(reports: readonly WriteDurability[]): WriteDurab
|
|
|
46
47
|
const ranked = [...flat].sort((a, b) => durabilityRank(a.quorum) - durabilityRank(b.quorum));
|
|
47
48
|
const weakest = ranked[0]!;
|
|
48
49
|
const others = ranked.slice(1);
|
|
49
|
-
// Over the ORIGINAL reports: flattening strips `torn` (
|
|
50
|
-
//
|
|
50
|
+
// Over the ORIGINAL reports: flattening strips `torn` and `blockRevs` (they are action-level),
|
|
51
|
+
// so both are taken before that or a torn input merges to an untorn answer.
|
|
51
52
|
const torn = unionTorn(reports);
|
|
53
|
+
const blockRevs = withoutBlocks(highestBlockRevs(reports), torn);
|
|
52
54
|
return {
|
|
53
55
|
...stripMergedFields(weakest),
|
|
54
56
|
...(others.length === 0 ? {} : { otherCohorts: others.map(stripMergedFields) }),
|
|
55
|
-
...(torn.length === 0 ? {} : { torn })
|
|
57
|
+
...(torn.length === 0 ? {} : { torn }),
|
|
58
|
+
...blockRevsField(blockRevs)
|
|
56
59
|
};
|
|
57
60
|
}
|
|
58
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Name the blocks a write committed, at the revision it committed them at — set where the commit is
|
|
64
|
+
* confirmed, by the db-core layer that issued it. A block already named keeps the higher revision,
|
|
65
|
+
* and a block in `d.torn` is left out: it holds nothing.
|
|
66
|
+
*/
|
|
67
|
+
export function withBlockRevs(d: WriteDurability, blockIds: readonly BlockId[], rev: number): WriteDurability {
|
|
68
|
+
const committed = Object.fromEntries(blockIds.map(blockId => [blockId, rev]));
|
|
69
|
+
const blockRevs = withoutBlocks(highestBlockRevs([d, { blockRevs: committed }]), d.torn ?? []);
|
|
70
|
+
return { ...d, ...blockRevsField(blockRevs) };
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
/**
|
|
60
74
|
* Clamp an action-level report below `full` when the action abandoned blocks. A cohort can hold
|
|
61
75
|
* every block it was asked to commit and the action still be incomplete — the blocks the sweep
|
|
62
76
|
* never reached are on nobody. Never raises the class; a report already below `full` keeps it.
|
|
63
|
-
* Idempotent, and a no-op for an
|
|
77
|
+
* A torn block leaves `blockRevs`, since it was not committed. Idempotent, and a no-op for an
|
|
78
|
+
* empty `torn`.
|
|
64
79
|
*/
|
|
65
80
|
export function withTornBlocks(d: WriteDurability, torn: readonly BlockId[]): WriteDurability {
|
|
66
81
|
if (torn.length === 0) return d;
|
|
67
82
|
const allTorn = Array.from(new Set([...(d.torn ?? []), ...torn]));
|
|
83
|
+
const { blockRevs: _blockRevs, ...rest } = d;
|
|
68
84
|
return {
|
|
69
|
-
...
|
|
85
|
+
...rest,
|
|
70
86
|
quorum: d.quorum === 'full' ? 'majority' : d.quorum,
|
|
71
|
-
torn: allTorn
|
|
87
|
+
torn: allTorn,
|
|
88
|
+
...blockRevsField(withoutBlocks(d.blockRevs ?? {}, allTorn))
|
|
72
89
|
};
|
|
73
90
|
}
|
|
74
91
|
|
|
75
|
-
/**
|
|
76
|
-
|
|
92
|
+
/**
|
|
93
|
+
* The single-node answer: this node holds it and nobody else does yet. `absent` names the cohort
|
|
94
|
+
* members this node knows of that the write ran without — they are part of the cohort the write is
|
|
95
|
+
* owed to, so they count in `cohort` and are listed in `unconfirmed`. With none, it is a one-machine
|
|
96
|
+
* write that is complete. `absent` needs `selfPeerId`: without it the answer cannot name the cohort.
|
|
97
|
+
*/
|
|
98
|
+
export function localDurability(selfPeerId?: string, absent: readonly string[] = []): WriteDurability {
|
|
99
|
+
if (selfPeerId === undefined) return { quorum: 'local', confirmed: 1, cohort: 1 };
|
|
77
100
|
return {
|
|
78
101
|
quorum: 'local',
|
|
79
102
|
confirmed: 1,
|
|
80
|
-
cohort: 1,
|
|
81
|
-
|
|
103
|
+
cohort: 1 + absent.length,
|
|
104
|
+
unconfirmed: [...absent],
|
|
105
|
+
cohortPeerIds: [selfPeerId, ...absent]
|
|
82
106
|
};
|
|
83
107
|
}
|
|
84
108
|
|
|
@@ -96,22 +120,25 @@ function flattenDurability(d: WriteDurability): WriteDurability[] {
|
|
|
96
120
|
return [stripMergedFields(d), ...(d.otherCohorts ?? [])];
|
|
97
121
|
}
|
|
98
122
|
|
|
99
|
-
/** The per-cohort fields only — `otherCohorts` and `
|
|
123
|
+
/** The per-cohort fields only — `otherCohorts`, `torn` and `blockRevs` are action-level and
|
|
124
|
+
* re-derived by the merge. */
|
|
100
125
|
function stripMergedFields(d: WriteDurability): WriteDurability {
|
|
101
|
-
const { otherCohorts: _otherCohorts, torn: _torn, ...cohortReport } = d;
|
|
126
|
+
const { otherCohorts: _otherCohorts, torn: _torn, blockRevs: _blockRevs, ...cohortReport } = d;
|
|
102
127
|
return cohortReport;
|
|
103
128
|
}
|
|
104
129
|
|
|
105
130
|
/**
|
|
106
131
|
* First occurrence of each structurally identical per-cohort report, input order kept. Peer lists
|
|
107
132
|
* compare as SETS: `findCluster` orders a cohort by routing distance to the block's key, so one
|
|
108
|
-
* cohort answering for two blocks lists the same members in two orders.
|
|
133
|
+
* cohort answering for two blocks lists the same members in two orders. `recordedBy` is part of the
|
|
134
|
+
* identity: two otherwise identical answers whose shortfalls two different ledgers recorded are two
|
|
135
|
+
* facts, and a consumer waiting on full-replication events needs to see both.
|
|
109
136
|
*/
|
|
110
137
|
function distinctReports(reports: readonly WriteDurability[]): WriteDurability[] {
|
|
111
138
|
const seen = new Set<string>();
|
|
112
139
|
const sorted = (ids: readonly string[] | undefined): string[] | null => ids === undefined ? null : [...ids].sort();
|
|
113
140
|
return reports.filter(r => {
|
|
114
|
-
const key = JSON.stringify([r.quorum, r.confirmed, r.cohort, sorted(r.unconfirmed), sorted(r.cohortPeerIds)]);
|
|
141
|
+
const key = JSON.stringify([r.quorum, r.confirmed, r.cohort, sorted(r.unconfirmed), sorted(r.cohortPeerIds), r.recordedBy ?? null]);
|
|
115
142
|
if (seen.has(key)) return false;
|
|
116
143
|
seen.add(key);
|
|
117
144
|
return true;
|
|
@@ -121,3 +148,24 @@ function distinctReports(reports: readonly WriteDurability[]): WriteDurability[]
|
|
|
121
148
|
function unionTorn(reports: readonly WriteDurability[]): BlockId[] {
|
|
122
149
|
return Array.from(new Set(reports.flatMap(r => r.torn ?? [])));
|
|
123
150
|
}
|
|
151
|
+
|
|
152
|
+
/** Every block any report names, at the highest revision any of them names it at. */
|
|
153
|
+
function highestBlockRevs(reports: readonly Pick<WriteDurability, 'blockRevs'>[]): Record<BlockId, number> {
|
|
154
|
+
// A Map, not assignment into `{}`: a header block's id is its collection id, which a caller
|
|
155
|
+
// names, and `__proto__` assigned into a plain object sets its prototype instead of a key.
|
|
156
|
+
const highest = new Map<BlockId, number>();
|
|
157
|
+
for (const [blockId, rev] of reports.flatMap(r => Object.entries(r.blockRevs ?? {}))) {
|
|
158
|
+
highest.set(blockId, Math.max(highest.get(blockId) ?? rev, rev));
|
|
159
|
+
}
|
|
160
|
+
return Object.fromEntries(highest);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function withoutBlocks(blockRevs: Readonly<Record<BlockId, number>>, excluded: readonly BlockId[]): Record<BlockId, number> {
|
|
164
|
+
const drop = new Set(excluded);
|
|
165
|
+
return Object.fromEntries(Object.entries(blockRevs).filter(([blockId]) => !drop.has(blockId)));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** The field, or nothing: an empty map is left off, as an empty `torn` is. */
|
|
169
|
+
function blockRevsField(blockRevs: Readonly<Record<BlockId, number>>): Pick<WriteDurability, 'blockRevs'> {
|
|
170
|
+
return Object.keys(blockRevs).length === 0 ? {} : { blockRevs };
|
|
171
|
+
}
|
|
@@ -71,4 +71,14 @@ export type IKeyNetwork = {
|
|
|
71
71
|
* such configuration omit this, which reads as "not awaiting".
|
|
72
72
|
*/
|
|
73
73
|
awaitingBootstrapContact?(): Promise<boolean>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Optionally name the peers this node knows serve this network that belong in `key`'s cohort but
|
|
77
|
+
* are missing from the cohort `findCluster` assembles now — typically members that are offline or
|
|
78
|
+
* unreachable. Peer-id strings, nearest the key first, never this node. A write made without them
|
|
79
|
+
* is owed to them, and naming them lets the writer's answer say so (`WriteDurability.unconfirmed`)
|
|
80
|
+
* and lets the copy be pushed to them as soon as they reconnect. Implementations that remember no
|
|
81
|
+
* such peers omit this, which reads as "none known".
|
|
82
|
+
*/
|
|
83
|
+
absentCohortMembers?(key: RoutingKey): Promise<string[]>;
|
|
74
84
|
}
|
package/src/network/struct.ts
CHANGED
|
@@ -97,12 +97,15 @@ export type DurabilityQuorum =
|
|
|
97
97
|
* (`withTornBlocks` clamps `full` down to this; `torn` then names the blocks, and `unconfirmed`
|
|
98
98
|
* may be empty). */
|
|
99
99
|
| 'majority'
|
|
100
|
-
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet.
|
|
100
|
+
/** The cohort resolved, and it is this node alone. Nobody else holds the revision yet. When this
|
|
101
|
+
* node knows of other members of the cohort that it could not reach (`IKeyNetwork.absentCohortMembers`),
|
|
102
|
+
* they are named in `unconfirmed` and counted in `cohort`: the write is owed to them. With none
|
|
103
|
+
* named, it is a correct, complete one-machine write. */
|
|
101
104
|
| 'local'
|
|
102
105
|
/** The cohort did NOT resolve: the lookup threw, or named nobody, or named a single peer that
|
|
103
106
|
* is not this node. The write is on this node's storage and the network was never consulted.
|
|
104
|
-
* Deliberately NOT `local`: a
|
|
105
|
-
* is a write whose correct destination is unknown. */
|
|
107
|
+
* Deliberately NOT `local`: a write that lands where its cohort resolved to is in the right
|
|
108
|
+
* place, whereas this is a write whose correct destination is unknown. */
|
|
106
109
|
| 'unrouted';
|
|
107
110
|
|
|
108
111
|
/** What the answering layer knows about who holds a successful write. Each layer refines it:
|
|
@@ -120,15 +123,24 @@ export type WriteDurability = {
|
|
|
120
123
|
* it means "accepted the pending record". The two are NOT comparable — a pend confers no
|
|
121
124
|
* storage durability (see the note in `CoordinatorRepo.pendThroughCluster`). */
|
|
122
125
|
readonly confirmed: number;
|
|
123
|
-
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'.
|
|
126
|
+
/** Size of the cohort the write ran on. Zero exactly when `quorum` is 'unrouted'. For `local`
|
|
127
|
+
* it is one plus the known members the write ran without, so `local` does not imply 1. */
|
|
124
128
|
readonly cohort: number;
|
|
125
129
|
/** Cohort members that did not confirm, by peer-id string. Empty when `quorum` is 'full'.
|
|
126
130
|
* ABSENT (not empty) when the answering layer could not name the cohort — an empty array
|
|
127
|
-
* here means "named the cohort, nobody is missing".
|
|
131
|
+
* here means "named the cohort, nobody is missing". On a `local` write these are the members
|
|
132
|
+
* this node knows of but could not reach when it wrote alone. */
|
|
128
133
|
readonly unconfirmed?: readonly string[];
|
|
129
134
|
/** The cohort the write ran on, by peer-id string. Absent where the answering layer has no
|
|
130
135
|
* cohort view at all (a bare `StorageRepo` verdict). */
|
|
131
136
|
readonly cohortPeerIds?: readonly string[];
|
|
137
|
+
/** Peer-id string of the node whose under-replication ledger recorded this write's missing
|
|
138
|
+
* copies — the one node that will fire `BlockDurabilityReachedEvent` for these blocks when they
|
|
139
|
+
* reach full replication. Set only below `full`, and only when every non-torn block's shortfall
|
|
140
|
+
* was recorded. Absent: no node is tracking the shortfall (nothing to push from the coordinator,
|
|
141
|
+
* a ledger fault, no ledger, a producer that predates the field), so no full-replication event
|
|
142
|
+
* should be expected. Per cohort answer: each `otherCohorts` entry carries its own. */
|
|
143
|
+
readonly recordedBy?: string;
|
|
132
144
|
/** Present only on an action-level result assembled from MORE THAN ONE distinct coordinator
|
|
133
145
|
* answer: the other answers. Identical answers are collapsed (`mergeDurability`), so a healthy
|
|
134
146
|
* single-cohort commit has none; one cohort answering differently for two batches appears
|
|
@@ -140,6 +152,14 @@ export type WriteDurability = {
|
|
|
140
152
|
* These blocks NEVER heal by replication: their transform is gone, and only the writer
|
|
141
153
|
* re-driving the action puts them back. */
|
|
142
154
|
readonly torn?: readonly BlockId[];
|
|
155
|
+
/** Action-level: every block this write committed, with the revision it committed at — what a
|
|
156
|
+
* host holds to match full-replication events (`BlockDurabilityReachedEvent`, keyed by block and
|
|
157
|
+
* revision) back to this write. Set by the db-core layer that issued the commit
|
|
158
|
+
* (`withBlockRevs`), never by a coordinator and never on the wire. Excludes `torn` blocks: they
|
|
159
|
+
* hold nothing. Merging two reports keeps, per block, the HIGHER revision — a block written at r
|
|
160
|
+
* and again at r+1 by one write is covered by an event at r+1 or later. A `Record` rather than a
|
|
161
|
+
* `Map` so the type stays plain JSON. */
|
|
162
|
+
readonly blockRevs?: Readonly<Record<BlockId, number>>;
|
|
143
163
|
};
|
|
144
164
|
|
|
145
165
|
export type PendSuccess = {
|