@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.
Files changed (83) hide show
  1. package/dist/src/cluster/i-cluster.d.ts +16 -1
  2. package/dist/src/cluster/i-cluster.d.ts.map +1 -1
  3. package/dist/src/cluster/structs.d.ts +60 -6
  4. package/dist/src/cluster/structs.d.ts.map +1 -1
  5. package/dist/src/cluster/structs.js +5 -0
  6. package/dist/src/cluster/structs.js.map +1 -1
  7. package/dist/src/collection/collection.d.ts.map +1 -1
  8. package/dist/src/collection/collection.js +5 -3
  9. package/dist/src/collection/collection.js.map +1 -1
  10. package/dist/src/index.d.ts +1 -0
  11. package/dist/src/index.d.ts.map +1 -1
  12. package/dist/src/index.js +1 -0
  13. package/dist/src/index.js.map +1 -1
  14. package/dist/src/network/durability.d.ts +17 -4
  15. package/dist/src/network/durability.d.ts.map +1 -1
  16. package/dist/src/network/durability.js +60 -15
  17. package/dist/src/network/durability.js.map +1 -1
  18. package/dist/src/network/i-key-network.d.ts +9 -0
  19. package/dist/src/network/i-key-network.d.ts.map +1 -1
  20. package/dist/src/network/struct.d.ts +45 -5
  21. package/dist/src/network/struct.d.ts.map +1 -1
  22. package/dist/src/network/struct.js.map +1 -1
  23. package/dist/src/transaction/coordinator.d.ts +23 -14
  24. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  25. package/dist/src/transaction/coordinator.js +84 -48
  26. package/dist/src/transaction/coordinator.js.map +1 -1
  27. package/dist/src/transaction/durability.d.ts +31 -0
  28. package/dist/src/transaction/durability.d.ts.map +1 -0
  29. package/dist/src/transaction/durability.js +36 -0
  30. package/dist/src/transaction/durability.js.map +1 -0
  31. package/dist/src/transaction/errors.d.ts +14 -6
  32. package/dist/src/transaction/errors.d.ts.map +1 -1
  33. package/dist/src/transaction/errors.js +16 -5
  34. package/dist/src/transaction/errors.js.map +1 -1
  35. package/dist/src/transaction/index.d.ts +2 -0
  36. package/dist/src/transaction/index.d.ts.map +1 -1
  37. package/dist/src/transaction/index.js +1 -0
  38. package/dist/src/transaction/index.js.map +1 -1
  39. package/dist/src/transaction/session.d.ts +2 -0
  40. package/dist/src/transaction/session.d.ts.map +1 -1
  41. package/dist/src/transaction/session.js +4 -2
  42. package/dist/src/transaction/session.js.map +1 -1
  43. package/dist/src/transaction/transaction.d.ts +9 -0
  44. package/dist/src/transaction/transaction.d.ts.map +1 -1
  45. package/dist/src/transaction/transaction.js.map +1 -1
  46. package/dist/src/transactor/change-notifier.d.ts +20 -8
  47. package/dist/src/transactor/change-notifier.d.ts.map +1 -1
  48. package/dist/src/transactor/change-notifier.js.map +1 -1
  49. package/dist/src/transactor/network-transactor.d.ts +48 -5
  50. package/dist/src/transactor/network-transactor.d.ts.map +1 -1
  51. package/dist/src/transactor/network-transactor.js +98 -22
  52. package/dist/src/transactor/network-transactor.js.map +1 -1
  53. package/dist/src/transactor/owed-cancels.d.ts +96 -0
  54. package/dist/src/transactor/owed-cancels.d.ts.map +1 -0
  55. package/dist/src/transactor/owed-cancels.js +211 -0
  56. package/dist/src/transactor/owed-cancels.js.map +1 -0
  57. package/dist/src/transactor/transactor-source.d.ts +5 -4
  58. package/dist/src/transactor/transactor-source.d.ts.map +1 -1
  59. package/dist/src/transactor/transactor-source.js +11 -6
  60. package/dist/src/transactor/transactor-source.js.map +1 -1
  61. package/dist/src/utility/unref-timer.d.ts +9 -0
  62. package/dist/src/utility/unref-timer.d.ts.map +1 -0
  63. package/dist/src/utility/unref-timer.js +15 -0
  64. package/dist/src/utility/unref-timer.js.map +1 -0
  65. package/package.json +1 -1
  66. package/src/cluster/i-cluster.ts +13 -2
  67. package/src/cluster/structs.ts +62 -6
  68. package/src/collection/collection.ts +5 -3
  69. package/src/index.ts +1 -0
  70. package/src/network/durability.ts +63 -15
  71. package/src/network/i-key-network.ts +10 -0
  72. package/src/network/struct.ts +45 -5
  73. package/src/transaction/coordinator.ts +130 -79
  74. package/src/transaction/durability.ts +60 -0
  75. package/src/transaction/errors.ts +18 -3
  76. package/src/transaction/index.ts +2 -0
  77. package/src/transaction/session.ts +4 -2
  78. package/src/transaction/transaction.ts +9 -0
  79. package/src/transactor/change-notifier.ts +20 -8
  80. package/src/transactor/network-transactor.ts +120 -29
  81. package/src/transactor/owed-cancels.ts +252 -0
  82. package/src/transactor/transactor-source.ts +11 -6
  83. package/src/utility/unref-timer.ts +15 -0
@@ -0,0 +1,211 @@
1
+ import { jitteredBackoffMs } from "../utility/backoff.js";
2
+ import { armUnrefTimer } from "../utility/unref-timer.js";
3
+ import { createLogger } from "../logger.js";
4
+ const log = createLogger('network-transactor');
5
+ /**
6
+ * Bounds the memory a writer spends on cancels it cannot land. Evicting an entry re-opens the wedge
7
+ * that entry was kept to close, so it is logged; a writer that owes this many is cut off from its
8
+ * cohorts, and its records are the node-side backstop's (backlog
9
+ * `debt-unpromotable-pending-records-need-a-sweep`).
10
+ */
11
+ const DEFAULT_MAX_OWED_ACTIONS = 256;
12
+ /** The backoff between re-sends of one owed cancel: a second at first, doubling to half a minute. */
13
+ const RETRY_BACKOFF = { baseMs: 1_000, capMs: 30_000 };
14
+ /**
15
+ * The cancels a writer could not discharge, kept and re-sent until they land.
16
+ *
17
+ * A cancel whose rounds all fall short — every one of them is a cluster transaction, so the member
18
+ * whose silence sank the commit sinks the cancel too — leaves pending records standing that make the
19
+ * members refuse every later write to those blocks, from any writer. Nothing else removes them while
20
+ * their slot is unreached (docs/repository.md, "A pending record's lifetime is bounded by its
21
+ * writer"), so the writer keeps the cancel and sends it again:
22
+ *
23
+ * - **before its own next pend of any of those blocks** ({@link beforePend}), which is what clears
24
+ * the leftover in front of the writer's next write to the block;
25
+ * - **on a backoff timer** while anything is owed, so other machines' writes, which the records also
26
+ * refuse, are freed without this writer writing the block again.
27
+ *
28
+ * Re-sending is safe whenever it arrives: a cancel deletes only the cancelled action's pending records
29
+ * and never moves a revision, so it commutes with every other action. The one exception is a re-pend
30
+ * of the SAME action id, whose new record a late cancel would delete — so a pend of an owed action
31
+ * supersedes the owed cancel for every block it names, and waits out any re-send of it already in
32
+ * flight before it goes out.
33
+ */
34
+ export class OwedCancels {
35
+ entries = new Map();
36
+ inFlight = new Map();
37
+ attempt;
38
+ now;
39
+ setTimer;
40
+ maxActions;
41
+ timer;
42
+ stopped = false;
43
+ constructor(init) {
44
+ this.attempt = init.attempt;
45
+ this.now = init.clock?.now ?? (() => Date.now());
46
+ this.setTimer = init.clock?.setTimer ?? armUnrefTimer;
47
+ this.maxActions = init.maxActions ?? DEFAULT_MAX_OWED_ACTIONS;
48
+ }
49
+ /** Every owed action with the blocks it still owes a cancel for. A snapshot. */
50
+ snapshot() {
51
+ return new Map(Array.from(this.entries, ([actionId, entry]) => [actionId, Array.from(entry.blockIds)]));
52
+ }
53
+ /** A cancel for `actionId` ran out of budget with `blockIds` still unanswered. */
54
+ record(actionId, blockIds, why) {
55
+ if (blockIds.length === 0)
56
+ return;
57
+ if (this.stopped) {
58
+ log('cancel:owed-abandoned actionId=%s blocks=%o why=stopped', actionId, blockIds);
59
+ return;
60
+ }
61
+ const existing = this.entries.get(actionId);
62
+ if (existing) {
63
+ for (const bid of blockIds)
64
+ existing.blockIds.add(bid);
65
+ existing.nextAttemptAt = this.now() + this.backoffMs(existing.attempts);
66
+ }
67
+ else {
68
+ const now = this.now();
69
+ this.entries.set(actionId, { blockIds: new Set(blockIds), since: now, attempts: 0, nextAttemptAt: now + this.backoffMs(0) });
70
+ this.evictOverflow();
71
+ }
72
+ log('cancel:owed actionId=%s blocks=%o why=%s', actionId, blockIds, why ?? 'unknown');
73
+ this.arm();
74
+ }
75
+ /** A cancel for `actionId` was answered for `blockIds` — whoever sent it, they are owed no longer. */
76
+ discharged(actionId, blockIds) {
77
+ const settled = this.remove(actionId, blockIds);
78
+ if (settled) {
79
+ log('cancel:owed-discharged actionId=%s attempts=%d stoodMs=%d', actionId, settled.attempts, this.now() - settled.since);
80
+ }
81
+ }
82
+ /**
83
+ * Re-sends nothing from here on: the timer is disarmed and every cancel still owed is logged
84
+ * (`cancel:owed-abandoned`) and forgotten, its records left to the node-side backstop. For when the
85
+ * node the re-sends go through stops — they could never land, and the timer would otherwise keep
86
+ * the transactor, and everything it reaches, alive for the life of the process.
87
+ */
88
+ stop() {
89
+ this.stopped = true;
90
+ this.timer?.cancel();
91
+ this.timer = undefined;
92
+ for (const [actionId, entry] of this.entries) {
93
+ log('cancel:owed-abandoned actionId=%s blocks=%o stoodMs=%d', actionId, Array.from(entry.blockIds), this.now() - entry.since);
94
+ }
95
+ this.entries.clear();
96
+ }
97
+ /**
98
+ * Runs ahead of every pend of `actionId` over `blockIds`: supersedes this action's own owed cancel
99
+ * for those blocks, then makes one attempt at every OTHER owed cancel that names any of them. A
100
+ * failed attempt stays owed and the pend proceeds; a cohort still unable to approve the cancel
101
+ * cannot approve the pend either, so one attempt — not a loop — is what the pend should wait for.
102
+ */
103
+ async beforePend(actionId, blockIds) {
104
+ if (this.entries.size === 0 && this.inFlight.size === 0)
105
+ return;
106
+ await this.supersede(actionId, blockIds);
107
+ const named = new Set(blockIds);
108
+ const overlapping = Array.from(this.entries)
109
+ .filter(([owedId, entry]) => owedId !== actionId && Array.from(entry.blockIds).some(bid => named.has(bid)))
110
+ .map(([owedId]) => owedId);
111
+ await Promise.all(overlapping.map(owedId => this.attemptOnce(owedId)));
112
+ }
113
+ /**
114
+ * A pend of `actionId` writes a fresh record on every block it names, which a late cancel for the
115
+ * same action id would delete. So those blocks leave the owed entry first — synchronously, so no
116
+ * re-send started from here on can carry them — and a re-send already in flight is waited out, so
117
+ * it lands before the pend rather than after it.
118
+ */
119
+ async supersede(actionId, blockIds) {
120
+ const entry = this.entries.get(actionId);
121
+ const superseded = entry ? blockIds.filter(bid => entry.blockIds.has(bid)) : [];
122
+ if (superseded.length > 0) {
123
+ log('cancel:owed-superseded actionId=%s blocks=%o', actionId, superseded);
124
+ this.remove(actionId, superseded);
125
+ }
126
+ await this.inFlight.get(actionId);
127
+ }
128
+ /** Takes `blockIds` off `actionId`'s entry, returning the entry when that emptied — and so removed — it. */
129
+ remove(actionId, blockIds) {
130
+ const entry = this.entries.get(actionId);
131
+ if (!entry)
132
+ return undefined;
133
+ for (const bid of blockIds)
134
+ entry.blockIds.delete(bid);
135
+ if (entry.blockIds.size > 0)
136
+ return undefined;
137
+ this.entries.delete(actionId);
138
+ this.arm();
139
+ return entry;
140
+ }
141
+ /** One re-send of `actionId`'s owed cancel, joining the one already in flight if there is one. */
142
+ attemptOnce(actionId) {
143
+ const running = this.inFlight.get(actionId);
144
+ if (running)
145
+ return running;
146
+ const entry = this.entries.get(actionId);
147
+ if (!entry)
148
+ return Promise.resolve();
149
+ ++entry.attempts;
150
+ const run = this.resend(actionId, Array.from(entry.blockIds))
151
+ .finally(() => {
152
+ if (this.inFlight.get(actionId) === run)
153
+ this.inFlight.delete(actionId);
154
+ this.arm();
155
+ });
156
+ this.inFlight.set(actionId, run);
157
+ return run;
158
+ }
159
+ async resend(actionId, blockIds) {
160
+ let answered;
161
+ try {
162
+ answered = await this.attempt({ actionId, blockIds });
163
+ }
164
+ catch (error) {
165
+ log('cancel:owed-retry-failed actionId=%s blocks=%d error=%s', actionId, blockIds.length, error?.message ?? String(error));
166
+ answered = new Set();
167
+ }
168
+ this.discharged(actionId, answered);
169
+ const entry = this.entries.get(actionId);
170
+ if (entry) {
171
+ entry.nextAttemptAt = this.now() + this.backoffMs(entry.attempts);
172
+ }
173
+ }
174
+ /** Arms the one timer at the earliest re-send due among the entries not already being re-sent, or disarms it. */
175
+ arm() {
176
+ let dueAt;
177
+ for (const [actionId, entry] of this.entries) {
178
+ if (this.inFlight.has(actionId))
179
+ continue;
180
+ if (dueAt === undefined || entry.nextAttemptAt < dueAt)
181
+ dueAt = entry.nextAttemptAt;
182
+ }
183
+ if (this.timer && (dueAt === undefined || this.timer.dueAt > dueAt)) {
184
+ this.timer.cancel();
185
+ this.timer = undefined;
186
+ }
187
+ if (dueAt === undefined || this.timer)
188
+ return;
189
+ this.timer = { cancel: this.setTimer(() => this.fire(), Math.max(0, dueAt - this.now())), dueAt };
190
+ }
191
+ fire() {
192
+ this.timer = undefined;
193
+ const now = this.now();
194
+ for (const [actionId, entry] of this.entries) {
195
+ if (entry.nextAttemptAt <= now)
196
+ void this.attemptOnce(actionId);
197
+ }
198
+ this.arm();
199
+ }
200
+ backoffMs(attempts) {
201
+ return jitteredBackoffMs(attempts, RETRY_BACKOFF);
202
+ }
203
+ evictOverflow() {
204
+ while (this.entries.size > this.maxActions) {
205
+ const [oldestId, oldest] = this.entries.entries().next().value;
206
+ this.entries.delete(oldestId);
207
+ log('cancel:owed-evicted actionId=%s blocks=%o stoodMs=%d', oldestId, Array.from(oldest.blockIds), this.now() - oldest.since);
208
+ }
209
+ }
210
+ }
211
+ //# sourceMappingURL=owed-cancels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owed-cancels.js","sourceRoot":"","sources":["../../../src/transactor/owed-cancels.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,GAAG,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;AA6B/C;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,qGAAqG;AACrG,MAAM,aAAa,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAWvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,OAAO,WAAW;IACN,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC9C,OAAO,CAA6B;IACpC,GAAG,CAAe;IAClB,QAAQ,CAA6D;IACrE,UAAU,CAAS;IAC5B,KAAK,CAA+D;IACpE,OAAO,GAA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E,CAAC;YAC5C,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAA8B,CAAC;YACxF,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,GAAG,CAAC,sDAAsD,EAAE,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC/H,CAAC;IACF,CAAC;CACD"}
@@ -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, or a {@link StaleFailure} if the pend or the commit
134
- * was refused. Success is deliberately NOT collapsed to `undefined` — the durability is the only thing
135
- * that tells a write every machine holds from one only this machine holds, and a caller that wants the
136
- * old boolean reads `result.success`. Test "is this completely saved" through `isFullyDurable`, never
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"],"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,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;IA6C7M;;;;;;;;;;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,17 +206,20 @@ 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, or a {@link StaleFailure} if the pend or the commit
209
- * was refused. Success is deliberately NOT collapsed to `undefined` — the durability is the only thing
210
- * that tells a write every machine holds from one only this machine holds, and a caller that wants the
211
- * old boolean reads `result.success`. Test "is this completely saved" through `isFullyDurable`, never
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) {
215
217
  const pendResult = await this.transactor.pend({
216
218
  transforms: transform, actionId, rev, policy: 'r',
217
219
  ...(priority > 0 ? { priority } : {}),
218
- ...baseRevsField(baseRevs)
220
+ ...baseRevsField(baseRevs),
221
+ // One collection, pended whole and then committed: the shape `PendRequest.soleReservation` names.
222
+ soleReservation: true
219
223
  });
220
224
  if (!pendResult.success) {
221
225
  return pendResult;
@@ -236,8 +240,9 @@ export class TransactorSource {
236
240
  // rebase — letting the cancel's own failure throw over it would turn a routine,
237
241
  // recoverable race into a hard failure. So the cancel fault is logged, not raised.
238
242
  await this.dischargePend(actionId, pendResult.blockIds);
243
+ return commitResult;
239
244
  }
240
- return commitResult;
245
+ return { ...commitResult, durability: withBlockRevs(commitResult.durability, pendResult.blockIds, rev) };
241
246
  }
242
247
  catch (e) {
243
248
  // `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/trans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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"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Keep a pending timer from holding a Node process open. Browsers and React Native return a number
3
+ * from `setTimeout` / `setInterval`, which has no `unref`, so the call is guarded. Every first-party
4
+ * `unref` goes through here; the `NO_TIMER_UNREF` lint rule in `eslint.config.js` enforces that.
5
+ */
6
+ export declare function unrefTimer<T>(handle: T): T;
7
+ /** Arm a one-shot timer that never holds a process open; returns its cancel. The default behind the injectable `setTimer` seams. */
8
+ export declare function armUnrefTimer(fn: () => void, ms: number): () => void;
9
+ //# sourceMappingURL=unref-timer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unref-timer.d.ts","sourceRoot":"","sources":["../../../src/utility/unref-timer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAG1C;AAED,oIAAoI;AACpI,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,IAAI,CAGpE"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Keep a pending timer from holding a Node process open. Browsers and React Native return a number
3
+ * from `setTimeout` / `setInterval`, which has no `unref`, so the call is guarded. Every first-party
4
+ * `unref` goes through here; the `NO_TIMER_UNREF` lint rule in `eslint.config.js` enforces that.
5
+ */
6
+ export function unrefTimer(handle) {
7
+ handle.unref?.();
8
+ return handle;
9
+ }
10
+ /** Arm a one-shot timer that never holds a process open; returns its cancel. The default behind the injectable `setTimer` seams. */
11
+ export function armUnrefTimer(fn, ms) {
12
+ const handle = unrefTimer(setTimeout(fn, ms));
13
+ return () => clearTimeout(handle);
14
+ }
15
+ //# sourceMappingURL=unref-timer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unref-timer.js","sourceRoot":"","sources":["../../../src/utility/unref-timer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAI,MAAS;IACrC,MAAiC,CAAC,KAAK,EAAE,EAAE,CAAC;IAC7C,OAAO,MAAM,CAAC;AACf,CAAC;AAED,oIAAoI;AACpI,MAAM,UAAU,aAAa,CAAC,EAAc,EAAE,EAAU;IACvD,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9C,OAAO,GAAS,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimystic/db-core",
3
- "version": "1.12.1",
3
+ "version": "1.14.0",
4
4
  "type": "module",
5
5
  "description": "Core database functionality for Optimystic",
6
6
  "main": "dist/src/index.js",
@@ -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
-
@@ -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 = {
@@ -325,6 +354,18 @@ export interface ClusterConsensusConfig {
325
354
  commitBroadcastRetryMaxAttempts?: number;
326
355
  /** Immediate in-line retries per failed peer inside the broadcast (default 1) */
327
356
  commitBroadcastImmediateRetries?: number;
357
+ /**
358
+ * How long a coordinator may hold back a pend's final "apply it" delivery to the other members, in
359
+ * ms (default 2000, `DEFAULT_PEND_DELIVERY_DEFERRAL_MS` in db-p2p), so it rides on the first request
360
+ * of the action's commit instead of costing a request of its own. Only for a pend on a two-member
361
+ * cohort that reached its commit majority without a commit round, whose writer marked it the action's
362
+ * only reservation (`PendRequest.soleReservation`), and only to a member this node can carry records
363
+ * to. When the time runs out first the delivery goes alone, and that does not count against
364
+ * `commitBroadcastRetryMaxAttempts`. `0` turns the deferral off: a
365
+ * single-collection write on a two-member cohort then costs the other member four requests instead
366
+ * of three.
367
+ */
368
+ pendDeliveryDeferralMs?: number;
328
369
  /**
329
370
  * Immediate in-line retries per peer while collecting promises (default 1).
330
371
  * The promise phase rides the same libp2p stream the commit broadcast does;
@@ -334,9 +375,22 @@ export interface ClusterConsensusConfig {
334
375
  * single reset here would otherwise drop the peer and sink super-majority.
335
376
  */
336
377
  promiseImmediateRetries?: number;
337
- /** Read-repair behavior: 'off' (only fetch on missing — legacy), 'lazy' (fetch when local age > window), 'paranoid' (always verify against cluster on read). Default 'lazy'. In every mode a block missing locally consults its cohort on every read. */
378
+ /**
379
+ * How a block the node HOLDS is re-verified against its cohort on a read. Default 'lazy'.
380
+ * - 'lazy': the held copy is served at once; when the block was last checked more than
381
+ * `readRepairWindowMs` ago (or never, as after a restart) the read also starts a cohort
382
+ * consult that runs BEHIND it, and what that consult learns (a repair, the window's stamp,
383
+ * the `unconfirmedAheadRev` doubt) reaches the next read of the block. A read never waits
384
+ * on a cohort peer that is connected but silent. A read carrying a floor above the held
385
+ * copy still waits for its consult, because the asker has proof the copy is too old.
386
+ * - 'paranoid': every read of a held block consults the cohort and waits for the consult —
387
+ * for callers that cannot tolerate any staleness, including the first read after a restart.
388
+ * - 'off': never consults for a held block (legacy; staleness unbounded).
389
+ * In every mode a block missing locally consults its cohort on every read, and that read waits.
390
+ * On a node, set through `clusterPolicy.readRepairMode`.
391
+ */
338
392
  readRepairMode?: 'off' | 'lazy' | 'paranoid';
339
- /** For 'lazy' mode: read-repair triggers when (now - localEntry.lastSeenCommitMs) > this. Default 10000. */
393
+ /** 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
394
  readRepairWindowMs?: number;
341
395
  /** Per-read probability of triggering read-repair in 'lazy' mode even within the window (0..1). Default 0 (no random check). */
342
396
  readRepairSampleRate?: number;
@@ -352,10 +406,12 @@ export interface ClusterConsensusConfig {
352
406
  * client's own dial and response defaults do not apply underneath it.
353
407
  *
354
408
  * 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 every fresh stream (dial
356
- * or reuse, protocol select, send, receive) must fit inside this budget or the peer counts as
357
- * silent. The protocol select costs a round trip even on an open connection, so a request over a
358
- * reused connection costs two. In a two-member cohort one late answer is the whole quorum, so the
409
+ * only through a public circuit relay have a round trip near 1.8s, and a request that opens its
410
+ * stream (dial or reuse, protocol select, send, receive) must fit inside this budget or the peer
411
+ * counts as silent. The protocol select costs a round trip even on an open connection, so such a
412
+ * request over a reused connection costs two. db-p2p negotiates the next stream to a peer it is
413
+ * talking to in advance, so a later request in a busy spell costs one, but the first after a quiet
414
+ * spell still costs two. In a two-member cohort one late answer is the whole quorum, so the
359
415
  * consult declines every time and a rejoining node never catches up.
360
416
  *
361
417
  * 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
- return lineage.durability;
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)];
package/src/index.ts CHANGED
@@ -24,3 +24,4 @@ export * from "./utility/ensured.js";
24
24
  export * from "./utility/pending.js";
25
25
  export * from "./utility/lru-map.js";
26
26
  export * from "./utility/backoff.js";
27
+ export * from "./utility/unref-timer.js";