@fluidframework/container-runtime 2.0.0-internal.1.4.1 → 2.0.0-internal.2.0.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/batchManager.d.ts +2 -3
- package/dist/batchManager.d.ts.map +1 -1
- package/dist/batchManager.js +3 -8
- package/dist/batchManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +43 -16
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +107 -83
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +4 -20
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +17 -47
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +2 -5
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +3 -11
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +1 -10
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +43 -51
- package/dist/garbageCollection.js.map +1 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +3 -12
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +6 -26
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +42 -62
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summarizer.js +7 -2
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +19 -2
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts +4 -2
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +10 -6
- package/dist/summaryManager.js.map +1 -1
- package/lib/batchManager.d.ts +2 -3
- package/lib/batchManager.d.ts.map +1 -1
- package/lib/batchManager.js +3 -8
- package/lib/batchManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +43 -16
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +108 -84
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +4 -20
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +18 -48
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +2 -5
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +3 -11
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +1 -10
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +42 -50
- package/lib/garbageCollection.js.map +1 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +3 -12
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/index.d.ts +3 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +6 -26
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +42 -62
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summarizer.js +7 -2
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +19 -2
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts +4 -2
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +10 -6
- package/lib/summaryManager.js.map +1 -1
- package/package.json +40 -38
- package/src/batchManager.ts +7 -11
- package/src/containerRuntime.ts +149 -102
- package/src/dataStoreContext.ts +20 -62
- package/src/dataStores.ts +2 -10
- package/src/garbageCollection.ts +45 -55
- package/src/gcSweepReadyUsageDetection.ts +2 -10
- package/src/index.ts +2 -3
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +57 -96
- package/src/scheduleManager.ts +1 -0
- package/src/summarizer.ts +6 -6
- package/src/summarizerTypes.ts +20 -7
- package/src/summaryFormat.ts +4 -2
- package/src/summaryManager.ts +18 -7
|
@@ -10,7 +10,6 @@ import { DataProcessingError } from "@fluidframework/container-utils";
|
|
|
10
10
|
import {
|
|
11
11
|
ISequencedDocumentMessage,
|
|
12
12
|
} from "@fluidframework/protocol-definitions";
|
|
13
|
-
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
14
13
|
import Deque from "double-ended-queue";
|
|
15
14
|
import { ContainerMessageType } from "./containerRuntime";
|
|
16
15
|
import { pkgVersion } from "./packageVersion";
|
|
@@ -29,15 +28,6 @@ export interface IPendingMessage {
|
|
|
29
28
|
opMetadata: Record<string, unknown> | undefined;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
/**
|
|
33
|
-
* This represents a FlushMode update and is added to the pending queue when `setFlushMode` is called on the
|
|
34
|
-
* ContainerRuntime and the FlushMode changes.
|
|
35
|
-
*/
|
|
36
|
-
export interface IPendingFlushMode {
|
|
37
|
-
type: "flushMode";
|
|
38
|
-
flushMode: FlushMode;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
31
|
/**
|
|
42
32
|
* This represents an explicit flush call and is added to the pending queue when flush is called on the ContainerRuntime
|
|
43
33
|
* to flush pending messages.
|
|
@@ -46,7 +36,7 @@ export interface IPendingFlush {
|
|
|
46
36
|
type: "flush";
|
|
47
37
|
}
|
|
48
38
|
|
|
49
|
-
export type IPendingState = IPendingMessage |
|
|
39
|
+
export type IPendingState = IPendingMessage | IPendingFlush;
|
|
50
40
|
|
|
51
41
|
export interface IPendingLocalState {
|
|
52
42
|
/**
|
|
@@ -58,8 +48,6 @@ export interface IPendingLocalState {
|
|
|
58
48
|
export interface IRuntimeStateHandler{
|
|
59
49
|
connected(): boolean;
|
|
60
50
|
clientId(): string | undefined;
|
|
61
|
-
flushMode(): FlushMode;
|
|
62
|
-
setFlushMode(mode: FlushMode): void;
|
|
63
51
|
close(error?: ICriticalContainerError): void;
|
|
64
52
|
applyStashedOp: (type: ContainerMessageType, content: ISequencedDocumentMessage) => Promise<unknown>;
|
|
65
53
|
flush(): void;
|
|
@@ -68,13 +56,18 @@ export interface IRuntimeStateHandler{
|
|
|
68
56
|
content: any,
|
|
69
57
|
localOpMetadata: unknown,
|
|
70
58
|
opMetadata: Record<string, unknown> | undefined): void;
|
|
59
|
+
rollback(
|
|
60
|
+
type: ContainerMessageType,
|
|
61
|
+
content: any,
|
|
62
|
+
localOpMetadata: unknown): void;
|
|
63
|
+
orderSequentially(callback: () => void): void;
|
|
71
64
|
}
|
|
72
65
|
|
|
73
66
|
/**
|
|
74
67
|
* PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been
|
|
75
68
|
* acknowledged by the server. It also maintains the batch information for both automatically and manually flushed
|
|
76
69
|
* batches along with the messages.
|
|
77
|
-
* When the Container reconnects, it replays the pending states, which includes
|
|
70
|
+
* When the Container reconnects, it replays the pending states, which includes manual flushing
|
|
78
71
|
* of messages and triggering resubmission of unacked ops.
|
|
79
72
|
*
|
|
80
73
|
* It verifies that all the ops are acked, are received in the right order and batch information is correct.
|
|
@@ -100,13 +93,6 @@ export class PendingStateManager implements IDisposable {
|
|
|
100
93
|
// the correct batch metadata.
|
|
101
94
|
private pendingBatchBeginMessage: ISequencedDocumentMessage | undefined;
|
|
102
95
|
|
|
103
|
-
/**
|
|
104
|
-
* This tracks the flush mode for the next message in the pending state queue. When replaying messages, we need to
|
|
105
|
-
* first set the flush mode to this value and then send ops. It is important to do this info because the flush
|
|
106
|
-
* mode could have been updated.
|
|
107
|
-
*/
|
|
108
|
-
private flushModeForNextMessage: FlushMode;
|
|
109
|
-
|
|
110
96
|
private clientId: string | undefined;
|
|
111
97
|
|
|
112
98
|
/**
|
|
@@ -131,13 +117,9 @@ export class PendingStateManager implements IDisposable {
|
|
|
131
117
|
|
|
132
118
|
constructor(
|
|
133
119
|
private readonly stateHandler: IRuntimeStateHandler,
|
|
134
|
-
initialFlushMode: FlushMode,
|
|
135
120
|
initialLocalState: IPendingLocalState | undefined,
|
|
136
121
|
) {
|
|
137
122
|
this.initialStates = new Deque<IPendingState>(initialLocalState?.pendingStates ?? []);
|
|
138
|
-
|
|
139
|
-
this.flushModeForNextMessage = initialFlushMode;
|
|
140
|
-
this.onFlushModeUpdated(initialFlushMode);
|
|
141
123
|
}
|
|
142
124
|
|
|
143
125
|
public get disposed() { return this.disposeOnce.evaluated; }
|
|
@@ -174,24 +156,10 @@ export class PendingStateManager implements IDisposable {
|
|
|
174
156
|
this._pendingMessagesCount++;
|
|
175
157
|
}
|
|
176
158
|
|
|
177
|
-
/**
|
|
178
|
-
* Called when the FlushMode is updated. Adds the FlushMode to the pending state queue.
|
|
179
|
-
* @param flushMode - The flushMode that was updated.
|
|
180
|
-
*/
|
|
181
|
-
public onFlushModeUpdated(flushMode: FlushMode) {
|
|
182
|
-
this.pendingStates.push({ type: "flushMode", flushMode });
|
|
183
|
-
}
|
|
184
|
-
|
|
185
159
|
/**
|
|
186
160
|
* Called when flush() is called on the ContainerRuntime to manually flush messages.
|
|
187
161
|
*/
|
|
188
162
|
public onFlush() {
|
|
189
|
-
// If the FlushMode is Immediate, we don't need to track an explicit flush call because every message is
|
|
190
|
-
// automatically flushed. So, flush is a no-op.
|
|
191
|
-
if (this.stateHandler.flushMode() === FlushMode.Immediate) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
163
|
// If the previous state is not a message, flush is a no-op.
|
|
196
164
|
const previousState = this.pendingStates.peekBack();
|
|
197
165
|
if (previousState?.type !== "message") {
|
|
@@ -279,11 +247,6 @@ export class PendingStateManager implements IDisposable {
|
|
|
279
247
|
* @param message - The message that is being processed.
|
|
280
248
|
*/
|
|
281
249
|
private maybeProcessBatchBegin(message: ISequencedDocumentMessage) {
|
|
282
|
-
// Tracks the last FlushMode that was set before this message was sent.
|
|
283
|
-
let pendingFlushMode: FlushMode | undefined;
|
|
284
|
-
// Tracks whether a flush was called before this message was sent.
|
|
285
|
-
let pendingFlush: boolean = false;
|
|
286
|
-
|
|
287
250
|
/**
|
|
288
251
|
* We are checking if the next message is the start of a batch. It can happen in the following scenarios:
|
|
289
252
|
*
|
|
@@ -295,34 +258,12 @@ export class PendingStateManager implements IDisposable {
|
|
|
295
258
|
* Keep reading pending states from the queue until we encounter a message. It's possible that the FlushMode was
|
|
296
259
|
* updated a bunch of times without sending any messages.
|
|
297
260
|
*/
|
|
298
|
-
|
|
299
|
-
while (nextPendingState.type !== "message") {
|
|
300
|
-
if (nextPendingState.type === "flushMode") {
|
|
301
|
-
pendingFlushMode = nextPendingState.flushMode;
|
|
302
|
-
}
|
|
303
|
-
if (nextPendingState.type === "flush") {
|
|
304
|
-
pendingFlush = true;
|
|
305
|
-
}
|
|
261
|
+
while (this.peekNextPendingState().type !== "message") {
|
|
306
262
|
this.pendingStates.shift();
|
|
307
|
-
nextPendingState = this.peekNextPendingState();
|
|
308
263
|
}
|
|
309
264
|
|
|
310
|
-
if
|
|
311
|
-
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// If the FlushMode was set to Immediate before this message was sent, this message won't be a batch message
|
|
315
|
-
// because in Immediate mode, every message is flushed individually.
|
|
316
|
-
if (pendingFlushMode === FlushMode.Immediate) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* This message is the first in a batch if before it was sent either the FlushMode was set to TurnBased or there
|
|
322
|
-
* was an explicit flush call. Note that a flush call is tracked only in TurnBased mode and it indicates the end
|
|
323
|
-
* of one batch and beginning of another.
|
|
324
|
-
*/
|
|
325
|
-
if (pendingFlushMode === FlushMode.TurnBased || pendingFlush) {
|
|
265
|
+
// This message is the first in a batch if the "batch" property on the metadata is set to true
|
|
266
|
+
if (message.metadata?.batch) {
|
|
326
267
|
// We should not already be processing a batch and there should be no pending batch begin message.
|
|
327
268
|
assert(!this.isProcessingBatch && this.pendingBatchBeginMessage === undefined,
|
|
328
269
|
0x16b /* "The pending batch state indicates we are already processing a batch" */);
|
|
@@ -347,16 +288,6 @@ export class PendingStateManager implements IDisposable {
|
|
|
347
288
|
return;
|
|
348
289
|
}
|
|
349
290
|
|
|
350
|
-
/**
|
|
351
|
-
* We are in the middle of processing a batch. The batch ends when we see an explicit flush. We should never see
|
|
352
|
-
* a FlushMode before flush. This is true because we track batches only when FlushMode is TurnBased and in this
|
|
353
|
-
* mode, a batch ends either by calling flush or by changing the mode to Immediate which also triggers a flush.
|
|
354
|
-
*/
|
|
355
|
-
assert(
|
|
356
|
-
nextPendingState.type !== "flushMode",
|
|
357
|
-
0x2bd /* "We should not see a pending FlushMode until we see a flush when processing a batch" */,
|
|
358
|
-
);
|
|
359
|
-
|
|
360
291
|
// There should be a pending batch begin message.
|
|
361
292
|
assert(this.pendingBatchBeginMessage !== undefined, 0x16d /* "There is no pending batch begin message" */);
|
|
362
293
|
|
|
@@ -406,7 +337,7 @@ export class PendingStateManager implements IDisposable {
|
|
|
406
337
|
|
|
407
338
|
/**
|
|
408
339
|
* Called when the Container's connection state changes. If the Container gets connected, it replays all the pending
|
|
409
|
-
* states in its queue. This includes
|
|
340
|
+
* states in its queue. This includes triggering resubmission of unacked ops.
|
|
410
341
|
*/
|
|
411
342
|
public replayPendingStates() {
|
|
412
343
|
assert(this.stateHandler.connected(), 0x172 /* "The connection state is not consistent with the runtime" */);
|
|
@@ -426,12 +357,7 @@ export class PendingStateManager implements IDisposable {
|
|
|
426
357
|
// Reset the pending message count because all these messages will be removed from the queue.
|
|
427
358
|
this._pendingMessagesCount = 0;
|
|
428
359
|
|
|
429
|
-
|
|
430
|
-
const savedFlushMode = this.stateHandler.flushMode();
|
|
431
|
-
|
|
432
|
-
// Set the flush mode for the next message. This step is important because the flush mode may have been changed
|
|
433
|
-
// after the next pending message was sent.
|
|
434
|
-
this.stateHandler.setFlushMode(this.flushModeForNextMessage);
|
|
360
|
+
const messageBatchQueue = new Deque<IPendingMessage>();
|
|
435
361
|
|
|
436
362
|
// Process exactly `pendingStatesCount` items in the queue as it represents the number of states that were
|
|
437
363
|
// pending when we connected. This is important because the `reSubmitFn` might add more items in the queue
|
|
@@ -441,16 +367,43 @@ export class PendingStateManager implements IDisposable {
|
|
|
441
367
|
const pendingState = this.pendingStates.shift()!;
|
|
442
368
|
switch (pendingState.type) {
|
|
443
369
|
case "message":
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
370
|
+
assert(pendingState.opMetadata?.batch !== false || messageBatchQueue.length > 0,
|
|
371
|
+
0x41b /* We cannot process batches in chunks */);
|
|
372
|
+
/**
|
|
373
|
+
* We want to ensure grouped messages get processed in a batch.
|
|
374
|
+
* Note: It is not possible for the PendingStateManager to receive a partially acked batch. It will
|
|
375
|
+
* either receive the whole batch ack or nothing at all.
|
|
376
|
+
*/
|
|
377
|
+
if (messageBatchQueue.length > 0 || pendingState.opMetadata?.batch) {
|
|
378
|
+
messageBatchQueue.enqueue(pendingState);
|
|
379
|
+
} else {
|
|
380
|
+
this.stateHandler.reSubmit(
|
|
381
|
+
pendingState.messageType,
|
|
382
|
+
pendingState.content,
|
|
383
|
+
pendingState.localOpMetadata,
|
|
384
|
+
pendingState.opMetadata);
|
|
385
|
+
}
|
|
452
386
|
break;
|
|
453
387
|
case "flush":
|
|
388
|
+
/**
|
|
389
|
+
* A "flush" call can indicate the end of a batch.
|
|
390
|
+
* We can't rely on the "batch" property in the message metadata as it gets
|
|
391
|
+
* updated elsewhere and it is not the same object instance that gets updated.
|
|
392
|
+
*/
|
|
393
|
+
if (messageBatchQueue.length > 0) {
|
|
394
|
+
this.stateHandler.orderSequentially(() => {
|
|
395
|
+
while (messageBatchQueue.length > 0) {
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
397
|
+
const message = messageBatchQueue.dequeue()!;
|
|
398
|
+
this.stateHandler.reSubmit(
|
|
399
|
+
message.messageType,
|
|
400
|
+
message.content,
|
|
401
|
+
message.localOpMetadata,
|
|
402
|
+
message.opMetadata);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
assert(messageBatchQueue.length === 0, 0x41c /* cannot flush in the middle of a batch */);
|
|
454
407
|
this.stateHandler.flush();
|
|
455
408
|
break;
|
|
456
409
|
default:
|
|
@@ -459,7 +412,15 @@ export class PendingStateManager implements IDisposable {
|
|
|
459
412
|
pendingStatesCount--;
|
|
460
413
|
}
|
|
461
414
|
|
|
462
|
-
//
|
|
463
|
-
|
|
415
|
+
// There are some cases where ops are stashed but not flushed. We need to ensure they are resubmitted
|
|
416
|
+
while (messageBatchQueue.length > 0) {
|
|
417
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
418
|
+
const message = messageBatchQueue.dequeue()!;
|
|
419
|
+
this.stateHandler.reSubmit(
|
|
420
|
+
message.messageType,
|
|
421
|
+
message.content,
|
|
422
|
+
message.localOpMetadata,
|
|
423
|
+
message.opMetadata);
|
|
424
|
+
}
|
|
464
425
|
}
|
|
465
426
|
}
|
package/src/scheduleManager.ts
CHANGED
package/src/summarizer.ts
CHANGED
|
@@ -334,7 +334,7 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
334
334
|
const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);
|
|
335
335
|
|
|
336
336
|
coordinatorCreateP.then((runCoordinator) => {
|
|
337
|
-
//
|
|
337
|
+
// Successfully created the cancellation token. Start the summarizer.
|
|
338
338
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
339
339
|
const startP = this.start(this.runtime.clientId!, runCoordinator);
|
|
340
340
|
startP.then(async (runningSummarizer) => {
|
|
@@ -382,11 +382,11 @@ export class Summarizer extends EventEmitter implements ISummarizer {
|
|
|
382
382
|
// executing the refreshLatestSummaryAck.
|
|
383
383
|
// https://dev.azure.com/fluidframework/internal/_workitems/edit/779
|
|
384
384
|
await this.runningSummarizer.lockedRefreshSummaryAckAction(async () =>
|
|
385
|
-
this.internalsProvider.refreshLatestSummaryAck(
|
|
386
|
-
summaryOpHandle,
|
|
387
|
-
summaryAckHandle,
|
|
388
|
-
refSequenceNumber,
|
|
389
|
-
summaryLogger,
|
|
385
|
+
this.internalsProvider.refreshLatestSummaryAck({
|
|
386
|
+
proposalHandle: summaryOpHandle,
|
|
387
|
+
ackHandle: summaryAckHandle,
|
|
388
|
+
summaryRefSeq: refSequenceNumber,
|
|
389
|
+
summaryLogger },
|
|
390
390
|
).catch(async (error) => {
|
|
391
391
|
// If the error is 404, so maybe the fetched version no longer exists on server. We just
|
|
392
392
|
// ignore this error in that case, as that means we will have another summaryAck for the
|
package/src/summarizerTypes.ts
CHANGED
|
@@ -61,12 +61,7 @@ export interface ISummarizerInternalsProvider {
|
|
|
61
61
|
submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult>;
|
|
62
62
|
|
|
63
63
|
/** Callback whenever a new SummaryAck is received, to update internal tracking state */
|
|
64
|
-
refreshLatestSummaryAck(
|
|
65
|
-
proposalHandle: string,
|
|
66
|
-
ackHandle: string,
|
|
67
|
-
summaryRefSeq: number,
|
|
68
|
-
summaryLogger: ITelemetryLogger,
|
|
69
|
-
): Promise<void>;
|
|
64
|
+
refreshLatestSummaryAck(options: IRefreshSummaryAckOptions): Promise<void>;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
/**
|
|
@@ -114,6 +109,20 @@ export interface ISummarizeOptions {
|
|
|
114
109
|
readonly refreshLatestAck?: boolean;
|
|
115
110
|
}
|
|
116
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Data required to update internal tracking state after receiving a Summary Ack.
|
|
114
|
+
*/
|
|
115
|
+
export interface IRefreshSummaryAckOptions {
|
|
116
|
+
/** Handle from the ack's summary op. */
|
|
117
|
+
readonly proposalHandle: string | undefined;
|
|
118
|
+
/** Handle from the summary ack just received */
|
|
119
|
+
readonly ackHandle: string;
|
|
120
|
+
/** Reference sequence number from the ack's summary op */
|
|
121
|
+
readonly summaryRefSeq: number;
|
|
122
|
+
/** Telemetry logger to which telemetry events will be forwarded. */
|
|
123
|
+
readonly summaryLogger: ITelemetryLogger;
|
|
124
|
+
}
|
|
125
|
+
|
|
117
126
|
export interface ISubmitSummaryOptions extends ISummarizeOptions {
|
|
118
127
|
/** Logger to use for correlated summary events */
|
|
119
128
|
readonly summaryLogger: ITelemetryLogger;
|
|
@@ -292,7 +301,11 @@ export type SummarizerStopReason =
|
|
|
292
301
|
* client to no longer be elected as responsible for summaries. Then it
|
|
293
302
|
* tries to stop its spawned summarizer client.
|
|
294
303
|
*/
|
|
295
|
-
| "
|
|
304
|
+
| "notElectedParent"
|
|
305
|
+
/**
|
|
306
|
+
* We are not already running the summarizer and we are not the current elected client id.
|
|
307
|
+
*/
|
|
308
|
+
| "notElectedClient"
|
|
296
309
|
/** Summarizer client was disconnected */
|
|
297
310
|
| "summarizerClientDisconnected"
|
|
298
311
|
/* running summarizer threw an exception */
|
package/src/summaryFormat.ts
CHANGED
|
@@ -99,14 +99,16 @@ export interface IGCMetadata {
|
|
|
99
99
|
* - A value greater than 0 means GC is enabled.
|
|
100
100
|
*/
|
|
101
101
|
readonly gcFeature?: GCVersion;
|
|
102
|
-
/** If this is present, the session for this container will expire after this time and the container will close */
|
|
103
|
-
readonly sessionExpiryTimeoutMs?: number;
|
|
104
102
|
/**
|
|
105
103
|
* Tells whether the GC sweep phase is enabled for this container.
|
|
106
104
|
* - True means sweep phase is enabled.
|
|
107
105
|
* - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.
|
|
108
106
|
*/
|
|
109
107
|
readonly sweepEnabled?: boolean;
|
|
108
|
+
/** If this is present, the session for this container will expire after this time and the container will close */
|
|
109
|
+
readonly sessionExpiryTimeoutMs?: number;
|
|
110
|
+
/** How long to wait after an object is unreferenced before deleting it via GC Sweep */
|
|
111
|
+
readonly sweepTimeoutMs?: number;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
/** The properties of an ISequencedDocumentMessage to be stored in the metadata blob in summary. */
|
package/src/summaryManager.ts
CHANGED
|
@@ -29,7 +29,8 @@ export enum SummaryManagerState {
|
|
|
29
29
|
// Please note that all reasons in this list are not errors,
|
|
30
30
|
// and thus they are not raised today to parent container as error.
|
|
31
31
|
// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer
|
|
32
|
-
type StopReason = Extract<SummarizerStopReason,
|
|
32
|
+
type StopReason = Extract<SummarizerStopReason,
|
|
33
|
+
"parentNotConnected" | "notElectedParent" | "notElectedClient">;
|
|
33
34
|
type ShouldSummarizeState =
|
|
34
35
|
| { shouldSummarize: true; }
|
|
35
36
|
| { shouldSummarize: false; stopReason: StopReason; };
|
|
@@ -141,13 +142,23 @@ export class SummaryManager implements IDisposable {
|
|
|
141
142
|
// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should
|
|
142
143
|
// only transition to Stopping when the electedParentId changes. Stopping the summarizer without
|
|
143
144
|
// changing the electedParent will just cause us to transition to Starting again.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return { shouldSummarize: false, stopReason: "
|
|
148
|
-
}
|
|
145
|
+
|
|
146
|
+
// New Parent has been elected and it is not the current client, or
|
|
147
|
+
if (this.connectedState.clientId !== this.clientElection.electedParentId) {
|
|
148
|
+
return { shouldSummarize: false, stopReason: "notElectedParent" };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// We are not already running the summarizer and we are not the current elected client id.
|
|
152
|
+
if (this.state !== SummaryManagerState.Running &&
|
|
153
|
+
this.connectedState.clientId !== this.clientElection.electedClientId) {
|
|
154
|
+
return { shouldSummarize: false, stopReason: "notElectedClient" };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (!this.connectedState.connected) {
|
|
149
158
|
return { shouldSummarize: false, stopReason: "parentNotConnected" };
|
|
150
|
-
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (this.disposed) {
|
|
151
162
|
assert(false, 0x260 /* "Disposed should mean disconnected!" */);
|
|
152
163
|
} else {
|
|
153
164
|
return { shouldSummarize: true };
|