@toa.io/extensions.cadence 1.0.0-alpha.286 → 1.0.0-alpha.288

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.
@@ -5,9 +5,10 @@ import { BATCH, DISCRETENESS, LANES, number } from './const.js';
5
5
  * Makes the calls that were put off.
6
6
  *
7
7
  * Two tiers, which is what a store polled rarely and a call due to the second need between
8
- * them: the rows are the record, and one scan primes the next interval of them into timers.
9
- * A crash loses the timers and nothing else — the next scan reads what is overdue along with
10
- * what is upcoming, so a dispatcher that died mid-interval costs a delay and not a call.
8
+ * them: the rows are the record, and one scan primes the next two intervals of them into
9
+ * timers. A crash loses the timers and nothing else — the next scan reads what is overdue
10
+ * along with what is upcoming, so a dispatcher that died mid-interval costs a delay and not a
11
+ * call.
11
12
  *
12
13
  * Partitioned by lane exactly as the outbox is, so every replica scans and dispatches its own
13
14
  * share of every interval rather than taking turns at whole ones.
@@ -28,6 +29,8 @@ export class Dispatcher extends Connector {
28
29
  off;
29
30
  scanning = false;
30
31
  closing = false;
32
+ /** when the scan that is running started, so a tick that finds it can say how long */
33
+ started = 0;
31
34
  constructor(metronome, resolve, atom) {
32
35
  super();
33
36
  this.metronome = metronome;
@@ -58,9 +61,27 @@ export class Dispatcher extends Connector {
58
61
  }
59
62
  /** One scan at a time: a slow one must not have another started underneath it. */
60
63
  tick() {
61
- if (this.scanning || this.closing)
64
+ if (this.closing)
62
65
  return;
66
+ /*
67
+ * Skipped, and said so. The guard itself is right — a second scan on top of one that has
68
+ * not returned only makes it worse — but a pass that outlives its interval takes every
69
+ * pass after it with it, and nothing is dispatched at all while that lasts. Silently, it
70
+ * is a dispatcher that stops dispatching in a deployment that ran for months.
71
+ */
72
+ if (this.scanning) {
73
+ const running = Date.now() - this.started;
74
+ const details = { running, discreteness: this.discreteness };
75
+ const message = 'Delayed calls scan has not returned, so this pass is skipped';
76
+ // past a few intervals it is not a slow pass but a stuck one
77
+ if (running > STALLED * this.discreteness)
78
+ console.error(message, details);
79
+ else
80
+ console.warn(message, details);
81
+ return;
82
+ }
63
83
  this.scanning = true;
84
+ this.started = Date.now();
64
85
  void this.scan()
65
86
  .catch((error) => {
66
87
  console.error('Delayed calls scan failed', { error });
@@ -90,22 +111,64 @@ export class Dispatcher extends Connector {
90
111
  }
91
112
  }
92
113
  async scan() {
114
+ // ahead of the claim, because settling needs none: the rows are ones this replica has
115
+ // already called, and one left live is one the next owner of its lane calls again
116
+ await this.settle();
93
117
  const lanes = this.atom.slots(LANES);
94
118
  if (lanes === null || lanes.length === 0)
95
119
  return;
96
- await this.settle();
97
120
  const now = Date.now();
98
- const until = now + this.discreteness;
121
+ /*
122
+ * Two intervals, so that consecutive passes overlap by one whole one. Reaching exactly as
123
+ * far as the next pass leaves a sliver beyond the horizon that the next pass reads already
124
+ * overdue — the width of the drift between the two, which a row with a tight `overdue`
125
+ * does not survive. The overlap absorbs that, a settle that ran long, a tick skipped
126
+ * outright, and the clock skew between the replica that wrote `due` and this one.
127
+ *
128
+ * Reaching further costs nothing a cancellation would pay for, because what is armed is
129
+ * given up again the moment a scan stops reading it — see `forget`.
130
+ */
131
+ const until = now + 2 * this.discreteness;
99
132
  const rows = (await this.metronome.invoke('enumerate', {
100
133
  query: {
101
- // a call nothing was running to make in time has expired, and is simply not read
102
- criteria: `lane=in=(${lanes.join(',')});due<${until};expires>${now}`,
134
+ // expiry is not a criterion: a row nobody reads is a row nobody settles, and it would
135
+ // stay live for good. It is read, and settled without the call being made
136
+ criteria: `lane=in=(${lanes.join(',')});due<${until}`,
103
137
  sort: ['due:asc'],
104
138
  limit: BATCH
105
139
  }
106
140
  }));
141
+ // the horizon is truncated to the last row of a full batch, and everything past it arrives
142
+ // on a later pass already overdue. Where this is logged, the batch is too small for the rate
143
+ const truncated = rows.length === BATCH;
144
+ if (truncated)
145
+ console.warn('Delayed calls scan filled its batch', { limit: BATCH, lanes: lanes.length });
107
146
  for (const row of rows)
108
147
  this.arm(row);
148
+ if (!truncated)
149
+ this.forget(new Set(rows.map((row) => row.id)));
150
+ }
151
+ /**
152
+ * Gives up what the store no longer answers with. A scan reads everything still owed in the
153
+ * lanes this replica holds, so a row it armed before and does not read now is one nothing
154
+ * owes any more — cancelled, most of the time — and a timer left for it makes the call
155
+ * regardless.
156
+ *
157
+ * This is what lets a scan reach further ahead than the next one without a cancellation
158
+ * becoming any less reliable: a row is held only for as long as the store keeps saying it is
159
+ * owed, so what bounds cancelling is the period between passes and not how far one reaches.
160
+ *
161
+ * Two things are not evidence of a cancellation. A batch filled to its limit is a read that
162
+ * was cut short, and says nothing about what it did not reach. And a call already on its way
163
+ * is settled by its own path rather than by what a scan reads.
164
+ */
165
+ forget(read) {
166
+ for (const [id, { timer }] of this.armed) {
167
+ if (read.has(id) || this.called.has(id))
168
+ continue;
169
+ clearTimeout(timer);
170
+ this.armed.delete(id);
171
+ }
109
172
  }
110
173
  /**
111
174
  * A row already armed is left alone: a scan reads what it read before, because a row stays
@@ -114,9 +177,20 @@ export class Dispatcher extends Connector {
114
177
  arm(row) {
115
178
  if (this.armed.has(row.id) || this.called.has(row.id))
116
179
  return;
180
+ const now = Date.now();
181
+ /*
182
+ * Past the bound its caller gave it, so the call is not made — and the row is settled all
183
+ * the same, silently, because an expired call is not an event anything sees. Left unread
184
+ * it would never be settled either: a row nothing will ever act on, sitting in the
185
+ * collection and in front of every scan, for good.
186
+ */
187
+ if (row.expires <= now) {
188
+ this.called.add(row.id);
189
+ return;
190
+ }
117
191
  const timer = setTimeout(() => {
118
192
  void this.dispatch(row);
119
- }, Math.max(row.due - Date.now(), 0));
193
+ }, Math.max(row.due - now, 0));
120
194
  timer.unref();
121
195
  this.armed.set(row.id, { timer, lane: row.lane });
122
196
  }
@@ -184,4 +258,6 @@ export class Dispatcher extends Connector {
184
258
  this.called.delete(id);
185
259
  }
186
260
  }
261
+ /** intervals a scan may run for before it is a stuck pass rather than a slow one */
262
+ const STALLED = 5;
187
263
  //# sourceMappingURL=Dispatcher.js.map
@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-5,6 +5,12 @@ export declare const COMPONENT = "metronome";
5
5
  * Constant, never configuration: a row carries its lane, so lowering this would leave rows in
6
6
  * lanes nobody reads any more. It is also the ceiling on replicas dispatching, and a power of
7
7
  * two so that the common replica counts divide evenly. The outbox says the same of its own.
8
+ *
9
+ * A scan asks for its lanes as a set and sorts on `due`, which is the index's second key, so
10
+ * the plan that serves it explodes the set into one scan per lane and merges them in order.
11
+ * MongoDB stops exploding past `internalQueryMaxScansToExplode`, 200 by default, and falls
12
+ * back to sorting the whole result in memory — so this staying well under that is not
13
+ * incidental.
8
14
  */
9
15
  export declare const LANES = 128;
10
16
  /** seconds between passes over the calls waiting to be made, and how far ahead each reaches */
@@ -5,6 +5,12 @@ export const COMPONENT = 'metronome';
5
5
  * Constant, never configuration: a row carries its lane, so lowering this would leave rows in
6
6
  * lanes nobody reads any more. It is also the ceiling on replicas dispatching, and a power of
7
7
  * two so that the common replica counts divide evenly. The outbox says the same of its own.
8
+ *
9
+ * A scan asks for its lanes as a set and sorts on `due`, which is the index's second key, so
10
+ * the plan that serves it explodes the set into one scan per lane and merges them in order.
11
+ * MongoDB stops exploding past `internalQueryMaxScansToExplode`, 200 by default, and falls
12
+ * back to sorting the whole result in memory — so this staying well under that is not
13
+ * incidental.
8
14
  */
9
15
  export const LANES = 128;
10
16
  /** seconds between passes over the calls waiting to be made, and how far ahead each reaches */
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sourceRoot":"","sources":["../source/const.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,SAAS,CAAA;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB,+FAA+F;AAC/F,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAA;AAE9B,gCAAgC;AAChC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB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