@fluidframework/container-runtime 2.0.0-internal.2.3.1 → 2.0.0-internal.2.4.1
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/blobManager.d.ts +3 -1
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +35 -2
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +33 -29
- package/dist/containerRuntime.js.map +1 -1
- package/dist/garbageCollection.d.ts +17 -9
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +101 -41
- package/dist/garbageCollection.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/summarizer.js.map +1 -1
- package/lib/blobManager.d.ts +3 -1
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +35 -2
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +33 -29
- package/lib/containerRuntime.js.map +1 -1
- package/lib/garbageCollection.d.ts +17 -9
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +102 -42
- package/lib/garbageCollection.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/summarizer.js.map +1 -1
- package/package.json +20 -19
- package/src/blobManager.ts +41 -2
- package/src/containerRuntime.ts +67 -47
- package/src/garbageCollection.ts +109 -42
- package/src/packageVersion.ts +1 -1
- package/src/summarizer.ts +1 -1
|
@@ -80,11 +80,13 @@ export interface IGarbageCollector {
|
|
|
80
80
|
/** Returns the GC details generated from the base snapshot. */
|
|
81
81
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
82
82
|
/** Called when the latest summary of the system has been refreshed. */
|
|
83
|
-
refreshLatestSummary(
|
|
83
|
+
refreshLatestSummary(proposalHandle: string | undefined, result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;
|
|
84
84
|
/** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */
|
|
85
85
|
nodeUpdated(nodePath: string, reason: "Loaded" | "Changed", timestampMs?: number, packagePath?: readonly string[], requestHeaders?: IRequestHeader): void;
|
|
86
86
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
87
87
|
addedOutboundReference(fromNodePath: string, toNodePath: string): void;
|
|
88
|
+
/** Returns true if this node has been deleted by GC during sweep phase. */
|
|
89
|
+
isNodeDeleted(nodePath: string): boolean;
|
|
88
90
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
89
91
|
dispose(): void;
|
|
90
92
|
}
|
|
@@ -227,6 +229,7 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
227
229
|
private gcDataFromLastRun;
|
|
228
230
|
private readonly newReferencesSinceLastRun;
|
|
229
231
|
private tombstones;
|
|
232
|
+
private deletedNodes;
|
|
230
233
|
/**
|
|
231
234
|
* Keeps track of the GC data from the latest summary successfully submitted to and acked from the server.
|
|
232
235
|
*/
|
|
@@ -265,9 +268,8 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
265
268
|
private readonly sweepReadyUsageHandler;
|
|
266
269
|
protected constructor(createParams: IGarbageCollectorCreateParams);
|
|
267
270
|
/**
|
|
268
|
-
* Called during container initialization. Initialize the tombstone state
|
|
269
|
-
*
|
|
270
|
-
* in use or not.
|
|
271
|
+
* Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done
|
|
272
|
+
* during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.
|
|
271
273
|
*/
|
|
272
274
|
initializeBaseState(): Promise<void>;
|
|
273
275
|
/**
|
|
@@ -307,11 +309,12 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
307
309
|
*/
|
|
308
310
|
summarize(fullTree: boolean, trackState: boolean, telemetryContext?: ITelemetryContext): ISummarizeResult | undefined;
|
|
309
311
|
/**
|
|
310
|
-
* Builds the GC summary tree which contains GC state and
|
|
311
|
-
* If trackState is false,
|
|
312
|
-
* If trackState is true,
|
|
312
|
+
* Builds the GC summary tree which contains GC state, deleted nodes and tombstones.
|
|
313
|
+
* If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.
|
|
314
|
+
* If trackState is true, only states that changed are written. Rest are written as handles.
|
|
313
315
|
* @param serializedGCState - The GC state serialized as string.
|
|
314
|
-
* @param serializedTombstones -
|
|
316
|
+
* @param serializedTombstones - The tombstone state serialized as string.
|
|
317
|
+
* @param serializedDeletedNodes - Deleted nodes serialized as string.
|
|
315
318
|
* @param trackState - Whether we are tracking GC state across summaries.
|
|
316
319
|
* @returns the GC summary tree.
|
|
317
320
|
*/
|
|
@@ -326,7 +329,7 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
326
329
|
* Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot
|
|
327
330
|
* is downloaded and should be used to update the state.
|
|
328
331
|
*/
|
|
329
|
-
refreshLatestSummary(
|
|
332
|
+
refreshLatestSummary(proposalHandle: string | undefined, result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;
|
|
330
333
|
/**
|
|
331
334
|
* Called when a node with the given id is updated. If the node is inactive, log an error.
|
|
332
335
|
* @param nodePath - The id of the node that changed.
|
|
@@ -344,6 +347,11 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
344
347
|
* @param toNodePath - The node to which the reference is added.
|
|
345
348
|
*/
|
|
346
349
|
addedOutboundReference(fromNodePath: string, toNodePath: string): void;
|
|
350
|
+
/**
|
|
351
|
+
* Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
|
|
352
|
+
* cases where objects are used after they are deleted and throw / log errors accordingly.
|
|
353
|
+
*/
|
|
354
|
+
isNodeDeleted(nodePath: string): boolean;
|
|
347
355
|
dispose(): void;
|
|
348
356
|
/**
|
|
349
357
|
* Updates the state of the system as per the current GC run. It does the following:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAIH,sBAAsB,EACtB,6BAA6B,EAG7B,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAIH,sBAAsB,EACtB,6BAA6B,EAG7B,gBAAgB,EAChB,iBAAiB,EAKpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGH,gBAAgB,EAChB,oBAAoB,EAEvB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,EAAE,iBAAiB,EAAkB,MAAM,oBAAoB,CAAC;AAmBvE,OAAO,EAGH,yBAAyB,EAIzB,WAAW,EACX,wBAAwB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACrB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,mBAAmB,EAAE,MAAM,CAAC;IAC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AAI;IAKtB;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAiD1B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,uBAAuB;IA2E/B;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,6BAA6B;IA0CrC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAyDrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAiCtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;YAoFV,qBAAqB;CAmCtC"}
|
|
@@ -145,7 +145,10 @@ class GarbageCollector {
|
|
|
145
145
|
// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of
|
|
146
146
|
// outbound routes from that node.
|
|
147
147
|
this.newReferencesSinceLastRun = new Map();
|
|
148
|
+
// A list of nodes that have been tombstoned.
|
|
148
149
|
this.tombstones = [];
|
|
150
|
+
// A list of nodes that have been deleted during sweep phase.
|
|
151
|
+
this.deletedNodes = new Set();
|
|
149
152
|
// Map of node ids to their unreferenced state tracker.
|
|
150
153
|
this.unreferencedNodesState = new Map();
|
|
151
154
|
// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one
|
|
@@ -214,8 +217,7 @@ class GarbageCollector {
|
|
|
214
217
|
// flag in GC options to false.
|
|
215
218
|
this.gcEnabled = this.gcOptions.gcAllowed !== false;
|
|
216
219
|
// The sweep phase has to be explicitly enabled by setting the sweepAllowed flag in GC options to true.
|
|
217
|
-
|
|
218
|
-
this.sweepEnabled = this.gcOptions.sweepAllowed === true || testOverrideSweepTimeoutMs !== undefined;
|
|
220
|
+
this.sweepEnabled = this.gcOptions.sweepAllowed === true;
|
|
219
221
|
// Set the Session Expiry only if the flag is enabled and GC is enabled.
|
|
220
222
|
if (this.mc.config.getBoolean(garbageCollectionConstants_1.runSessionExpiryKey) && this.gcEnabled) {
|
|
221
223
|
this.sessionExpiryTimeoutMs = (_c = this.gcOptions.sessionExpiryTimeoutMs) !== null && _c !== void 0 ? _c : garbageCollectionConstants_1.defaultSessionExpiryDurationMs;
|
|
@@ -271,8 +273,9 @@ class GarbageCollector {
|
|
|
271
273
|
}
|
|
272
274
|
// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
|
|
273
275
|
this.testMode = (_h = this.mc.config.getBoolean(garbageCollectionConstants_1.gcTestModeKey)) !== null && _h !== void 0 ? _h : this.gcOptions.runGCInTestMode === true;
|
|
274
|
-
// Whether we are running in tombstone mode. This is
|
|
275
|
-
|
|
276
|
+
// Whether we are running in tombstone mode. This is enabled by default if sweep won't run. It can be disabled
|
|
277
|
+
// via feature flags.
|
|
278
|
+
this.tombstoneMode = !this.shouldRunSweep && this.mc.config.getBoolean(garbageCollectionConstants_1.disableTombstoneKey) !== true;
|
|
276
279
|
// If GC ran in the container that generated the base snapshot, it will have a GC tree.
|
|
277
280
|
this.wasGCRunInLatestSummary = (baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.trees[runtime_definitions_1.gcTreeKey]) !== undefined;
|
|
278
281
|
// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
|
|
@@ -322,7 +325,9 @@ class GarbageCollector {
|
|
|
322
325
|
}
|
|
323
326
|
// If there is only one node (root node just added above), either GC is disabled or we are loading from
|
|
324
327
|
// the first summary generated by detached container. In both cases, GC was not run - return undefined.
|
|
325
|
-
return Object.keys(gcState.gcNodes).length === 1
|
|
328
|
+
return Object.keys(gcState.gcNodes).length === 1
|
|
329
|
+
? undefined
|
|
330
|
+
: { gcState, tombstones: undefined, deletedNodes: undefined };
|
|
326
331
|
}
|
|
327
332
|
catch (error) {
|
|
328
333
|
const dpe = container_utils_1.DataProcessingError.wrapIfUnrecognized(error, "FailedToInitializeGC");
|
|
@@ -435,24 +440,31 @@ class GarbageCollector {
|
|
|
435
440
|
return Object.assign({ gcEnabled: this.gcEnabled, sweepEnabled: this.sweepEnabled, runGC: this.shouldRunGC, runSweep: this.shouldRunSweep, testMode: this.testMode, tombstoneMode: this.tombstoneMode, sessionExpiry: this.sessionExpiryTimeoutMs, sweepTimeout: this.sweepTimeoutMs, inactiveTimeout: this.inactiveTimeoutMs, trackGCState: this.trackGCState }, this.gcOptions);
|
|
436
441
|
}
|
|
437
442
|
/**
|
|
438
|
-
* Called during container initialization. Initialize the tombstone state
|
|
439
|
-
*
|
|
440
|
-
* in use or not.
|
|
443
|
+
* Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done
|
|
444
|
+
* during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.
|
|
441
445
|
*/
|
|
442
446
|
async initializeBaseState() {
|
|
443
447
|
const baseSnapshotData = await this.baseSnapshotDataP;
|
|
444
448
|
/**
|
|
445
|
-
* The base snapshot data
|
|
449
|
+
* The base snapshot data will not be present if the container is loaded from:
|
|
446
450
|
* 1. The first summary created by the detached container.
|
|
447
451
|
* 2. A summary that was generated with GC disabled.
|
|
448
452
|
* 3. A summary that was generated before GC even existed.
|
|
449
|
-
* 4. A summary that was generated with tombstone feature disabled.
|
|
450
453
|
*/
|
|
451
|
-
if (
|
|
454
|
+
if (baseSnapshotData === undefined) {
|
|
452
455
|
return;
|
|
453
456
|
}
|
|
454
|
-
|
|
455
|
-
|
|
457
|
+
// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not
|
|
458
|
+
// to identify deleted nodes' usage.
|
|
459
|
+
if (baseSnapshotData.deletedNodes !== undefined) {
|
|
460
|
+
this.deletedNodes = new Set(baseSnapshotData.deletedNodes);
|
|
461
|
+
}
|
|
462
|
+
// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of
|
|
463
|
+
// tombstone routes.
|
|
464
|
+
if (this.tombstoneMode && baseSnapshotData.tombstones !== undefined) {
|
|
465
|
+
this.tombstones = Array.from(baseSnapshotData.tombstones);
|
|
466
|
+
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
467
|
+
}
|
|
456
468
|
}
|
|
457
469
|
/**
|
|
458
470
|
* Update state from the given snapshot data. This is done during load and during refreshing state from a snapshot.
|
|
@@ -479,9 +491,30 @@ class GarbageCollector {
|
|
|
479
491
|
}
|
|
480
492
|
;
|
|
481
493
|
this.unreferencedNodesState.clear();
|
|
482
|
-
// If
|
|
483
|
-
//
|
|
484
|
-
|
|
494
|
+
// If running sweep, the tombstone state represents the list of nodes that have been deleted during sweep.
|
|
495
|
+
// If running in tombstone mode, the tombstone state represents the list of nodes that have been marked as
|
|
496
|
+
// tombstones.
|
|
497
|
+
// If this call is because we are refreshing from a snapshot due to an ack, it is likely that the GC state
|
|
498
|
+
// in the snapshot is newer than this client's. And so, the deleted / tombstone nodes need to be updated.
|
|
499
|
+
if (this.shouldRunSweep) {
|
|
500
|
+
const snapshotDeletedNodes = (snapshotData === null || snapshotData === void 0 ? void 0 : snapshotData.tombstones) ? new Set(snapshotData.tombstones) : undefined;
|
|
501
|
+
// If the snapshot contains deleted nodes that are not yet deleted by this client, ask the runtime to
|
|
502
|
+
// delete them.
|
|
503
|
+
if (snapshotDeletedNodes !== undefined) {
|
|
504
|
+
const newDeletedNodes = [];
|
|
505
|
+
for (const nodeId of snapshotDeletedNodes) {
|
|
506
|
+
if (!this.deletedNodes.has(nodeId)) {
|
|
507
|
+
newDeletedNodes.push(nodeId);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (newDeletedNodes.length > 0) {
|
|
511
|
+
// Call container runtime to delete these nodes and add deleted nodes to this.deletedNodes.
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else if (this.tombstoneMode) {
|
|
516
|
+
// The snapshot may contain more or fewer tombstone nodes than this client. Update tombstone state and
|
|
517
|
+
// notify the runtime to update its state as well.
|
|
485
518
|
this.tombstones = (snapshotData === null || snapshotData === void 0 ? void 0 : snapshotData.tombstones) ? Array.from(snapshotData.tombstones) : [];
|
|
486
519
|
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
487
520
|
}
|
|
@@ -506,6 +539,7 @@ class GarbageCollector {
|
|
|
506
539
|
this.latestSummaryData = {
|
|
507
540
|
serializedGCState: JSON.stringify(generateSortedGCState(snapshotData.gcState)),
|
|
508
541
|
serializedTombstones: JSON.stringify(snapshotData.tombstones),
|
|
542
|
+
serializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),
|
|
509
543
|
};
|
|
510
544
|
}
|
|
511
545
|
}
|
|
@@ -625,17 +659,25 @@ class GarbageCollector {
|
|
|
625
659
|
};
|
|
626
660
|
}
|
|
627
661
|
const serializedGCState = JSON.stringify(generateSortedGCState(gcState));
|
|
662
|
+
// Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so
|
|
663
|
+
// to identify deleted nodes' usage.
|
|
664
|
+
const serializedDeletedNodes = this.deletedNodes.size > 0
|
|
665
|
+
? JSON.stringify(Array.from(this.deletedNodes).sort())
|
|
666
|
+
: undefined;
|
|
667
|
+
// If running in tombstone mode, serialize and write tombstones, if any.
|
|
628
668
|
const serializedTombstones = this.tombstoneMode
|
|
629
669
|
? (this.tombstones.length > 0 ? JSON.stringify(this.tombstones.sort()) : undefined)
|
|
630
670
|
: undefined;
|
|
631
671
|
/**
|
|
632
|
-
* Incremental summary of GC data - If
|
|
633
|
-
*
|
|
672
|
+
* Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,
|
|
673
|
+
* write summary handle instead of summary tree for GC.
|
|
674
|
+
* Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and
|
|
675
|
+
* for each of these that did not change, write a summary handle.
|
|
634
676
|
*/
|
|
635
677
|
if (this.trackGCState) {
|
|
636
|
-
this.pendingSummaryData = { serializedGCState, serializedTombstones };
|
|
678
|
+
this.pendingSummaryData = { serializedGCState, serializedTombstones, serializedDeletedNodes };
|
|
637
679
|
if (trackState && !fullTree && this.latestSummaryData !== undefined) {
|
|
638
|
-
// If
|
|
680
|
+
// If nothing changed since last summary, send a summary handle for the entire GC data.
|
|
639
681
|
if (this.latestSummaryData.serializedGCState === serializedGCState
|
|
640
682
|
&& this.latestSummaryData.serializedTombstones === serializedTombstones) {
|
|
641
683
|
const stats = (0, runtime_utils_1.mergeStats)();
|
|
@@ -649,24 +691,25 @@ class GarbageCollector {
|
|
|
649
691
|
stats,
|
|
650
692
|
};
|
|
651
693
|
}
|
|
652
|
-
// If
|
|
653
|
-
return this.buildGCSummaryTree(serializedGCState, serializedTombstones, true /* trackState */);
|
|
694
|
+
// If some state changed, build a GC summary tree.
|
|
695
|
+
return this.buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, true /* trackState */);
|
|
654
696
|
}
|
|
655
697
|
}
|
|
656
698
|
// If not tracking GC state, build a GC summary tree without any summary handles.
|
|
657
|
-
return this.buildGCSummaryTree(serializedGCState, serializedTombstones, false /* trackState */);
|
|
699
|
+
return this.buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, false /* trackState */);
|
|
658
700
|
}
|
|
659
701
|
/**
|
|
660
|
-
* Builds the GC summary tree which contains GC state and
|
|
661
|
-
* If trackState is false,
|
|
662
|
-
* If trackState is true,
|
|
702
|
+
* Builds the GC summary tree which contains GC state, deleted nodes and tombstones.
|
|
703
|
+
* If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.
|
|
704
|
+
* If trackState is true, only states that changed are written. Rest are written as handles.
|
|
663
705
|
* @param serializedGCState - The GC state serialized as string.
|
|
664
|
-
* @param serializedTombstones -
|
|
706
|
+
* @param serializedTombstones - The tombstone state serialized as string.
|
|
707
|
+
* @param serializedDeletedNodes - Deleted nodes serialized as string.
|
|
665
708
|
* @param trackState - Whether we are tracking GC state across summaries.
|
|
666
709
|
* @returns the GC summary tree.
|
|
667
710
|
*/
|
|
668
|
-
buildGCSummaryTree(serializedGCState, serializedTombstones, trackState) {
|
|
669
|
-
var _a, _b;
|
|
711
|
+
buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, trackState) {
|
|
712
|
+
var _a, _b, _c;
|
|
670
713
|
const gcStateBlobKey = `${runtime_definitions_1.gcBlobPrefix}_root`;
|
|
671
714
|
const builder = new runtime_utils_1.SummaryTreeBuilder();
|
|
672
715
|
// If the GC state hasn't changed, write a summary handle, else write a summary blob for it.
|
|
@@ -676,16 +719,26 @@ class GarbageCollector {
|
|
|
676
719
|
else {
|
|
677
720
|
builder.addBlob(gcStateBlobKey, serializedGCState);
|
|
678
721
|
}
|
|
679
|
-
// If
|
|
680
|
-
|
|
722
|
+
// If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a
|
|
723
|
+
// summary blob.
|
|
724
|
+
if (serializedTombstones !== undefined) {
|
|
725
|
+
if (((_b = this.latestSummaryData) === null || _b === void 0 ? void 0 : _b.serializedTombstones) === serializedTombstones && trackState) {
|
|
726
|
+
builder.addHandle(runtime_definitions_1.gcTombstoneBlobKey, protocol_definitions_1.SummaryType.Blob, `/${runtime_definitions_1.gcTreeKey}/${runtime_definitions_1.gcTombstoneBlobKey}`);
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
builder.addBlob(runtime_definitions_1.gcTombstoneBlobKey, serializedTombstones);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
// If there are no deleted nodes, return the summary tree.
|
|
733
|
+
if (serializedDeletedNodes === undefined) {
|
|
681
734
|
return builder.getSummaryTree();
|
|
682
735
|
}
|
|
683
|
-
// If the
|
|
684
|
-
if (((
|
|
685
|
-
builder.addHandle(runtime_definitions_1.
|
|
736
|
+
// If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.
|
|
737
|
+
if (((_c = this.latestSummaryData) === null || _c === void 0 ? void 0 : _c.serializedDeletedNodes) === serializedDeletedNodes && trackState) {
|
|
738
|
+
builder.addHandle(runtime_definitions_1.gcDeletedBlobKey, protocol_definitions_1.SummaryType.Blob, `/${runtime_definitions_1.gcTreeKey}/${runtime_definitions_1.gcDeletedBlobKey}`);
|
|
686
739
|
}
|
|
687
740
|
else {
|
|
688
|
-
builder.addBlob(runtime_definitions_1.
|
|
741
|
+
builder.addBlob(runtime_definitions_1.gcDeletedBlobKey, serializedDeletedNodes);
|
|
689
742
|
}
|
|
690
743
|
return builder.getSummaryTree();
|
|
691
744
|
}
|
|
@@ -712,7 +765,7 @@ class GarbageCollector {
|
|
|
712
765
|
* Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot
|
|
713
766
|
* is downloaded and should be used to update the state.
|
|
714
767
|
*/
|
|
715
|
-
async refreshLatestSummary(
|
|
768
|
+
async refreshLatestSummary(proposalHandle, result, readAndParseBlob) {
|
|
716
769
|
// If the latest summary was updated and the summary was tracked, this client is the one that generated this
|
|
717
770
|
// summary. So, update wasGCRunInLatestSummary.
|
|
718
771
|
// Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return
|
|
@@ -734,8 +787,8 @@ class GarbageCollector {
|
|
|
734
787
|
return;
|
|
735
788
|
}
|
|
736
789
|
// If the summary was not tracked by this client, the state should be updated from the downloaded snapshot.
|
|
737
|
-
const
|
|
738
|
-
const metadataBlobId =
|
|
790
|
+
const snapshotTree = result.snapshotTree;
|
|
791
|
+
const metadataBlobId = snapshotTree.blobs[summaryFormat_1.metadataBlobName];
|
|
739
792
|
if (metadataBlobId) {
|
|
740
793
|
const metadata = await readAndParseBlob(metadataBlobId);
|
|
741
794
|
this.latestSummaryGCVersion = (0, summaryFormat_1.getGCVersion)(metadata);
|
|
@@ -744,9 +797,9 @@ class GarbageCollector {
|
|
|
744
797
|
// to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.
|
|
745
798
|
const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
|
|
746
799
|
if (currentReferenceTimestampMs === undefined) {
|
|
747
|
-
throw container_utils_1.DataProcessingError.create("No reference timestamp when updating GC state from snapshot", "refreshLatestSummary", undefined, { proposalHandle, summaryRefSeq, details: JSON.stringify(this.configs) });
|
|
800
|
+
throw container_utils_1.DataProcessingError.create("No reference timestamp when updating GC state from snapshot", "refreshLatestSummary", undefined, { proposalHandle, summaryRefSeq: result.summaryRefSeq, details: JSON.stringify(this.configs) });
|
|
748
801
|
}
|
|
749
|
-
const gcSnapshotTree =
|
|
802
|
+
const gcSnapshotTree = snapshotTree.trees[runtime_definitions_1.gcTreeKey];
|
|
750
803
|
// If GC ran in the container that generated this snapshot, it will have a GC tree.
|
|
751
804
|
this.wasGCRunInLatestSummary = gcSnapshotTree !== undefined;
|
|
752
805
|
let latestGCData;
|
|
@@ -810,6 +863,13 @@ class GarbageCollector {
|
|
|
810
863
|
}, undefined /* packagePath */);
|
|
811
864
|
}
|
|
812
865
|
}
|
|
866
|
+
/**
|
|
867
|
+
* Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
|
|
868
|
+
* cases where objects are used after they are deleted and throw / log errors accordingly.
|
|
869
|
+
*/
|
|
870
|
+
isNodeDeleted(nodePath) {
|
|
871
|
+
return this.deletedNodes.has(nodePath);
|
|
872
|
+
}
|
|
813
873
|
dispose() {
|
|
814
874
|
var _a;
|
|
815
875
|
(_a = this.sessionExpiryTimer) === null || _a === void 0 ? void 0 : _a.clear();
|
|
@@ -1121,7 +1181,7 @@ class GarbageCollector {
|
|
|
1121
1181
|
this.mc.logger.sendErrorEvent(event);
|
|
1122
1182
|
}
|
|
1123
1183
|
}
|
|
1124
|
-
// If SweepReady Usage Detection is
|
|
1184
|
+
// If SweepReady Usage Detection is enabled, the handler may close the interactive container.
|
|
1125
1185
|
// Once Sweep is fully implemented, this will be removed since the objects will be gone
|
|
1126
1186
|
// and errors will arise elsewhere in the runtime
|
|
1127
1187
|
if (state === exports.UnreferencedState.SweepReady) {
|