@fluidframework/container-runtime 2.0.0-internal.3.3.1 → 2.0.0-internal.3.4.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/blobManager.d.ts +17 -11
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +89 -58
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +5 -0
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +11 -10
- package/dist/containerRuntime.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +4 -5
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +25 -22
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +28 -3
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +15 -2
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +25 -5
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +38 -5
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.d.ts +5 -7
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +16 -25
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/index.d.ts +2 -2
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +3 -1
- package/dist/gc/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/summary/summaryFormat.d.ts +2 -0
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryFormat.js.map +1 -1
- package/lib/blobManager.d.ts +17 -11
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +89 -58
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +5 -0
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +11 -10
- package/lib/containerRuntime.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +4 -5
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +25 -22
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +28 -3
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +14 -1
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +25 -5
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +36 -4
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.d.ts +5 -7
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +16 -25
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/index.d.ts +2 -2
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +2 -2
- package/lib/gc/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/summary/summaryFormat.d.ts +2 -0
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +23 -24
- package/src/blobManager.ts +108 -77
- package/src/containerRuntime.ts +12 -4
- package/src/gc/garbageCollection.ts +4 -8
- package/src/gc/gcConfigs.ts +26 -12
- package/src/gc/gcDefinitions.ts +28 -3
- package/src/gc/gcHelpers.ts +45 -4
- package/src/gc/gcSummaryStateTracker.ts +17 -29
- package/src/gc/index.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/src/summary/summaryFormat.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../../src/gc/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAGN,6BAA6B,EAG7B,gBAAgB,EAChB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAEN,gBAAgB,EAChB,oBAAoB,EACpB,MAAM,+BAA+B,CAAC;AAavC,OAAO,EAGN,iBAAiB,EACjB,6BAA6B,EAE7B,QAAQ,EAER,WAAW,EAEX,MAAM,iBAAiB,CAAC;AAqBzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;WAC3C,MAAM,CAAC,YAAY,EAAE,6BAA6B,GAAG,iBAAiB;IAIpF,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IAEvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IAEnD,IAAW,WAAW,IAAI,OAAO,CAEhC;IAGD,OAAO,CAAC,iBAAiB,CAAqC;IAG9D,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAoC;IAE9E,OAAO,CAAC,UAAU,CAAgB;IAElC,OAAO,CAAC,YAAY,CAA0B;IAG9C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsD;IAExF,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAgB;IAEnE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyC;IAExE,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAoD;IAE3F,OAAO,CAAC,kBAAkB,CAAoB;IAI9C,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAA0B;IAEnE,OAAO,CAAC,kBAA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;OAcG;IACH,OAAO,CAAC,gCAAgC;IA2ExC;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,6BAA6B;IA6CrC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA0DrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAoCtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;YA0FV,qBAAqB;CA2CnC"}
|
|
@@ -92,7 +92,7 @@ class GarbageCollector {
|
|
|
92
92
|
});
|
|
93
93
|
this.sessionExpiryTimer.start();
|
|
94
94
|
}
|
|
95
|
-
this.summaryStateTracker = new gcSummaryStateTracker_1.GCSummaryStateTracker(this.
|
|
95
|
+
this.summaryStateTracker = new gcSummaryStateTracker_1.GCSummaryStateTracker(this.configs, (baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.trees[runtime_definitions_1.gcTreeKey]) !== undefined /* wasGCRunInBaseSnapshot */);
|
|
96
96
|
// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
|
|
97
97
|
// it involves fetching blobs from storage which is expensive.
|
|
98
98
|
this.baseSnapshotDataP = new common_utils_1.LazyPromise(async () => {
|
|
@@ -185,7 +185,7 @@ class GarbageCollector {
|
|
|
185
185
|
return this.configs.shouldRunGC;
|
|
186
186
|
}
|
|
187
187
|
get summaryStateNeedsReset() {
|
|
188
|
-
return this.summaryStateTracker.doesSummaryStateNeedReset
|
|
188
|
+
return this.summaryStateTracker.doesSummaryStateNeedReset;
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done
|
|
@@ -316,8 +316,7 @@ class GarbageCollector {
|
|
|
316
316
|
*/
|
|
317
317
|
async collectGarbage(options, telemetryContext) {
|
|
318
318
|
var _a;
|
|
319
|
-
const fullGC = (_a = options.fullGC) !== null && _a !== void 0 ? _a : (this.configs.runFullGC === true ||
|
|
320
|
-
this.summaryStateTracker.doesSummaryStateNeedReset());
|
|
319
|
+
const fullGC = (_a = options.fullGC) !== null && _a !== void 0 ? _a : (this.configs.runFullGC === true || this.summaryStateTracker.doesSummaryStateNeedReset);
|
|
321
320
|
const logger = options.logger
|
|
322
321
|
? telemetry_utils_1.ChildLogger.create(options.logger, undefined, {
|
|
323
322
|
all: { completedGCRuns: () => this.completedRuns },
|
|
@@ -423,7 +422,7 @@ class GarbageCollector {
|
|
|
423
422
|
gcFeature: this.configs.gcEnabled ? this.summaryStateTracker.currentGCVersion : 0,
|
|
424
423
|
gcFeatureMatrix: this.configs.persistedGcFeatureMatrix,
|
|
425
424
|
sessionExpiryTimeoutMs: this.configs.sessionExpiryTimeoutMs,
|
|
426
|
-
sweepEnabled:
|
|
425
|
+
sweepEnabled: false,
|
|
427
426
|
sweepTimeoutMs: this.configs.sweepTimeoutMs,
|
|
428
427
|
};
|
|
429
428
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../../src/gc/garbageCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAGH,+DAA0E;AAC1E,qEAAiG;AAEjG,yEAO2C;AAC3C,6EAQ6C;AAC7C,iEAIuC;AACvC,qEAOyC;AAEzC,0DAAqD;AAErD,2CAAgD;AAChD,mDAUyB;AACzB,2CAA+F;AAC/F,mEAAgE;AAChE,6EAA+E;AAC/E,6EAAwE;AAiBxE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,gBAAgB;IAiE5B,YAAsB,YAA2C;QAlDjE,6GAA6G;QAC7G,kCAAkC;QACjB,8BAAyB,GAA0B,IAAI,GAAG,EAAE,CAAC;QAC9E,6CAA6C;QACrC,eAAU,GAAa,EAAE,CAAC;QAClC,6DAA6D;QACrD,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAQ9C,uDAAuD;QACtC,2BAAsB,GAA0C,IAAI,GAAG,EAAE,CAAC;QAI3F,iHAAiH;QACjH,sBAAsB;QACL,6BAAwB,GAAgB,IAAI,G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AE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,kCAAgB,CAAC,YAAY,EAAE;wBAClE,CAAC,CAAC,SAAS,GACZ,CAAC;gBAEF,IAAI,KAAK,KAAK,iCAAiB,CAAC,QAAQ,EAAE;oBACzC,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;iBACjC;qBAAM;oBACN,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;iBAC7B;aACD;SACD;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD;AAjpCD,4CAipCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { ClientSessionExpiredError, DataProcessingError } from \"@fluidframework/container-utils\";\nimport { IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport {\n\tcloneGCData,\n\tconcatGarbageCollectionData,\n\tgetGCDataFromSnapshot,\n\tIGCResult,\n\trunGarbageCollection,\n\ttrimLeadingSlashes,\n} from \"@fluidframework/garbage-collector\";\nimport {\n\tgcTreeKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tpackagePathToTelemetryProperty,\n\tReadAndParseBlob,\n\tRefreshSummaryResult,\n} from \"@fluidframework/runtime-utils\";\nimport {\n\tChildLogger,\n\tgenerateStack,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\n\nimport { RuntimeHeaders } from \"../containerRuntime\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport { generateGCConfigs } from \"./gcConfigs\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tIGarbageCollector,\n\tIGarbageCollectorCreateParams,\n\tIGarbageCollectionRuntime,\n\tIGCStats,\n\tUnreferencedState,\n\tIGCMetadata,\n\tIGarbageCollectorConfigs,\n} from \"./gcDefinitions\";\nimport { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent } from \"./gcHelpers\";\nimport { GCSummaryStateTracker } from \"./gcSummaryStateTracker\";\nimport { SweepReadyUsageDetectionHandler } from \"./gcSweepReadyUsageDetection\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps {\n\tusageType: \"Changed\" | \"Loaded\" | \"Revived\";\n\tstate: UnreferencedState;\n\tid: string;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\tcompletedGCRuns: number;\n\tfromId?: string;\n\ttimeout?: number;\n\tlastSummaryTime?: number;\n\tviaHandle?: boolean;\n}\n\n/**\n * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains\n * its state across summaries.\n *\n * Node - represented as nodeId, it's a node on the GC graph\n *\n * Outbound Route - a path from one node to another node, think `nodeA` -\\> `nodeB`\n *\n * Graph - all nodes with their respective routes\n *\n * ```\n *\t\t\t GC Graph\n *\n *\t\t\t Node\n *\t\tNodeId = \"datastore1\"\n *\t\t /\t\t\t \\\\\n *\tOutboundRoute OutboundRoute\n *\t\t /\t\t\t\t \\\\\n *\t Node\t\t\t Node\n * NodeId = \"dds1\"\t NodeId = \"dds2\"\n * ```\n */\nexport class GarbageCollector implements IGarbageCollector {\n\tpublic static create(createParams: IGarbageCollectorCreateParams): IGarbageCollector {\n\t\treturn new GarbageCollector(createParams);\n\t}\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly configs: IGarbageCollectorConfigs;\n\n\tpublic get shouldRunGC(): boolean {\n\t\treturn this.configs.shouldRunGC;\n\t}\n\n\t// Keeps track of the GC state from the last run.\n\tprivate gcDataFromLastRun: IGarbageCollectionData | undefined;\n\t// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n\t// outbound routes from that node.\n\tprivate readonly newReferencesSinceLastRun: Map<string, string[]> = new Map();\n\t// A list of nodes that have been tombstoned.\n\tprivate tombstones: string[] = [];\n\t// A list of nodes that have been deleted during sweep phase.\n\tprivate deletedNodes: Set<string> = new Set();\n\n\t// Promise when resolved returns the GC data data in the base snapshot.\n\tprivate readonly baseSnapshotDataP: Promise<IGarbageCollectionSnapshotData | undefined>;\n\t// Promise when resolved initializes the GC state from the data in the base snapshot.\n\tprivate readonly initializeGCStateFromBaseSnapshotP: Promise<void>;\n\t// The GC details generated from the base snapshot.\n\tprivate readonly baseGCDetailsP: Promise<IGarbageCollectionDetailsBase>;\n\t// Map of node ids to their unreferenced state tracker.\n\tprivate readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n\t// The Timer responsible for closing the container when the session has expired\n\tprivate sessionExpiryTimer: Timer | undefined;\n\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\t// The number of times GC has successfully completed on this instance of GarbageCollector.\n\tprivate completedRuns = 0;\n\n\tprivate readonly runtime: IGarbageCollectionRuntime;\n\tprivate readonly createContainerMetadata: ICreateContainerMetadata;\n\tprivate readonly isSummarizerClient: boolean;\n\n\tprivate readonly summaryStateTracker: GCSummaryStateTracker;\n\n\t/** For a given node path, returns the node's package path. */\n\tprivate readonly getNodePackagePath: (\n\t\tnodePath: string,\n\t) => Promise<readonly string[] | undefined>;\n\t/** Returns the timestamp of the last summary generated for this container. */\n\tprivate readonly getLastSummaryTimestampMs: () => number | undefined;\n\t/** Returns true if connection is active, i.e. it's \"write\" connection and the runtime is connected. */\n\tprivate readonly activeConnection: () => boolean;\n\n\tpublic get summaryStateNeedsReset(): boolean {\n\t\treturn this.summaryStateTracker.doesSummaryStateNeedReset();\n\t}\n\n\t/** Handler to respond to when a SweepReady object is used */\n\tprivate readonly sweepReadyUsageHandler: SweepReadyUsageDetectionHandler;\n\n\tprotected constructor(createParams: IGarbageCollectorCreateParams) {\n\t\tthis.runtime = createParams.runtime;\n\t\tthis.isSummarizerClient = createParams.isSummarizerClient;\n\t\tthis.createContainerMetadata = createParams.createContainerMetadata;\n\t\tthis.getNodePackagePath = createParams.getNodePackagePath;\n\t\tthis.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;\n\t\tthis.activeConnection = createParams.activeConnection;\n\n\t\tconst baseSnapshot = createParams.baseSnapshot;\n\t\tconst readAndParseBlob = createParams.readAndParseBlob;\n\n\t\tthis.mc = loggerToMonitoringContext(\n\t\t\tChildLogger.create(createParams.baseLogger, \"GarbageCollector\", {\n\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t}),\n\t\t);\n\n\t\tthis.sweepReadyUsageHandler = new SweepReadyUsageDetectionHandler(\n\t\t\tcreateParams.getContainerDiagnosticId(),\n\t\t\tthis.mc,\n\t\t\tthis.runtime.closeFn,\n\t\t);\n\n\t\tthis.configs = generateGCConfigs(this.mc, createParams);\n\n\t\t// If session expiry is enabled, we need to close the container when the session expiry timeout expires.\n\t\tif (this.configs.sessionExpiryTimeoutMs !== undefined) {\n\t\t\t// If Test Override config is set, override Session Expiry timeout.\n\t\t\tconst overrideSessionExpiryTimeoutMs = this.mc.config.getNumber(\n\t\t\t\t\"Fluid.GarbageCollection.TestOverride.SessionExpiryMs\",\n\t\t\t);\n\t\t\tconst timeoutMs = overrideSessionExpiryTimeoutMs ?? this.configs.sessionExpiryTimeoutMs;\n\n\t\t\tthis.sessionExpiryTimer = new Timer(timeoutMs, () => {\n\t\t\t\tthis.runtime.closeFn(\n\t\t\t\t\tnew ClientSessionExpiredError(`Client session expired.`, timeoutMs),\n\t\t\t\t);\n\t\t\t});\n\t\t\tthis.sessionExpiryTimer.start();\n\t\t}\n\n\t\tthis.summaryStateTracker = new GCSummaryStateTracker(\n\t\t\tthis.shouldRunGC,\n\t\t\tthis.configs.tombstoneMode,\n\t\t\tthis.mc,\n\t\t\tbaseSnapshot?.trees[gcTreeKey] !== undefined /* wasGCRunInBaseSnapshot */,\n\t\t\tthis.configs.gcVersionInBaseSnapshot,\n\t\t);\n\n\t\t// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it\n\t\t// it involves fetching blobs from storage which is expensive.\n\t\tthis.baseSnapshotDataP = new LazyPromise<IGarbageCollectionSnapshotData | undefined>(\n\t\t\tasync () => {\n\t\t\t\tif (baseSnapshot === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\t// For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n\t\t\t\t\tconst gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n\t\t\t\t\tif (gcSnapshotTree !== undefined) {\n\t\t\t\t\t\treturn getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\t\t\t\t\t}\n\n\t\t\t\t\t// back-compat - Older documents will have the GC blobs in each data store's snapshot tree.\n\t\t\t\t\treturn getSnapshotDataFromOldSnapshotFormat(\n\t\t\t\t\t\tbaseSnapshot,\n\t\t\t\t\t\tcreateParams.metadata,\n\t\t\t\t\t\treadAndParseBlob,\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst dpe = DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terror,\n\t\t\t\t\t\t\"FailedToInitializeGC\",\n\t\t\t\t\t);\n\t\t\t\t\tdpe.addTelemetryProperties({\n\t\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t\t});\n\t\t\t\t\tthrow dpe;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\t/**\n\t\t * Set up the initializer which initializes the GC state from the data in base snapshot. This is done when\n\t\t * connected in write mode or when GC runs the first time. It sets up all unreferenced nodes from the base\n\t\t * GC state and updates their inactive or sweep ready state.\n\t\t */\n\t\tthis.initializeGCStateFromBaseSnapshotP = new LazyPromise<void>(async () => {\n\t\t\t/**\n\t\t\t * If there is no current reference timestamp, skip initialization. We need the current timestamp to track\n\t\t\t * how long objects have been unreferenced and if they can be deleted.\n\t\t\t *\n\t\t\t * Note that the only scenario where there is no reference timestamp is when no ops have ever been processed\n\t\t\t * for this container and it is in read mode. In this scenario, there is no point in running GC anyway\n\t\t\t * because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t\t */\n\t\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"GarbageCollectorInitializedWithoutTimestamp\",\n\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t/**\n\t\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t\t * 1. The first summary created by the detached container.\n\t\t\t * 2. A summary that was generated with GC disabled.\n\t\t\t * 3. A summary that was generated before GC even existed.\n\t\t\t */\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.updateStateFromSnapshotData(baseSnapshotData, currentReferenceTimestampMs);\n\t\t});\n\n\t\t// Get the GC details from the GC state in the base summary. This is returned in getBaseGCDetails which is\n\t\t// used to initialize the GC state of all the nodes in the container.\n\t\tthis.baseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\t\tfor (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n\t\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t\t}\n\t\t\t// Run GC on the nodes in the base summary to get the routes used in each node in the container.\n\t\t\t// This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n\t\t\t// each node in the summary.\n\t\t\tconst usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n\n\t\t\treturn { gcData: { gcNodes }, usedRoutes };\n\t\t});\n\n\t\t// Log all the GC options and the state determined by the garbage collector. This is interesting only for the\n\t\t// summarizer client since it is the only one that runs GC. It also helps keep the telemetry less noisy.\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"GarbageCollectorLoaded\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\tgcOptions: JSON.stringify(createParams.gcOptions),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done\n\t * during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.\n\t */\n\tpublic async initializeBaseState(): Promise<void> {\n\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t/**\n\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t * 1. The first summary created by the detached container.\n\t\t * 2. A summary that was generated with GC disabled.\n\t\t * 3. A summary that was generated before GC even existed.\n\t\t */\n\t\tif (baseSnapshotData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not\n\t\t// to identify deleted nodes' usage.\n\t\tif (baseSnapshotData.deletedNodes !== undefined) {\n\t\t\tthis.deletedNodes = new Set(baseSnapshotData.deletedNodes);\n\t\t}\n\n\t\t// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of\n\t\t// tombstone routes.\n\t\tif (this.configs.tombstoneMode && baseSnapshotData.tombstones !== undefined) {\n\t\t\t// Create a copy since we are writing from a source we don't control\n\t\t\tthis.tombstones = Array.from(baseSnapshotData.tombstones);\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\t}\n\n\t/**\n\t * Update state from the given snapshot data. This is done during load and during refreshing state from a snapshot.\n\t * All current tracking is reset and updated from the data in the snapshot.\n\t * @param snapshotData - The snapshot data to update state from. If this is undefined, all GC state and tracking\n\t * is reset.\n\t * @param currentReferenceTimestampMs - The current reference timestamp for marking unreferenced nodes' unreferenced\n\t * timestamp.\n\t */\n\tprivate updateStateFromSnapshotData(\n\t\tsnapshotData: IGarbageCollectionSnapshotData | undefined,\n\t\tcurrentReferenceTimestampMs: number,\n\t) {\n\t\t/**\n\t\t * Note: \"newReferencesSinceLastRun\" is not reset here. This is done because there may be references since the\n\t\t * snapshot that we are updating state from. For example, this client may have processed ops till seq#1000 and\n\t\t * its refreshing state from a summary that happened at seq#900. In this case, there may be references between\n\t\t * seq#901 and seq#1000 that we don't want to reset.\n\t\t * Unfortunately, there is no way to track the seq# of ops that add references, so we choose to not reset any\n\t\t * references here. This should be fine because, in the worst case, we may end up updating the unreferenced\n\t\t * timestamp of a node which will delay its deletion. Although not ideal, this will only happen in rare\n\t\t * scenarios, so it should be okay.\n\t\t */\n\n\t\t// Clear all existing unreferenced state tracking.\n\t\tfor (const [, nodeStateTracker] of this.unreferencedNodesState) {\n\t\t\tnodeStateTracker.stopTracking();\n\t\t}\n\t\tthis.unreferencedNodesState.clear();\n\n\t\t// If running sweep, the tombstone state represents the list of nodes that have been deleted during sweep.\n\t\t// If running in tombstone mode, the tombstone state represents the list of nodes that have been marked as\n\t\t// tombstones.\n\t\t// If this call is because we are refreshing from a snapshot due to an ack, it is likely that the GC state\n\t\t// in the snapshot is newer than this client's. And so, the deleted / tombstone nodes need to be updated.\n\t\tif (this.configs.shouldRunSweep) {\n\t\t\tconst snapshotDeletedNodes = snapshotData?.deletedNodes\n\t\t\t\t? new Set(snapshotData.deletedNodes)\n\t\t\t\t: undefined;\n\t\t\t// If the snapshot contains deleted nodes that are not yet deleted by this client, ask the runtime to\n\t\t\t// delete them.\n\t\t\tif (snapshotDeletedNodes !== undefined) {\n\t\t\t\tconst newDeletedNodes: string[] = [];\n\t\t\t\tfor (const nodeId of snapshotDeletedNodes) {\n\t\t\t\t\tif (!this.deletedNodes.has(nodeId)) {\n\t\t\t\t\t\tnewDeletedNodes.push(nodeId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (newDeletedNodes.length > 0) {\n\t\t\t\t\t// Call container runtime to delete these nodes and add deleted nodes to this.deletedNodes.\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.configs.tombstoneMode) {\n\t\t\t// The snapshot may contain more or fewer tombstone nodes than this client. Update tombstone state and\n\t\t\t// notify the runtime to update its state as well.\n\t\t\tthis.tombstones = snapshotData?.tombstones ? Array.from(snapshotData.tombstones) : [];\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\t// Update the summary state tracker's state from this snapshot.\n\t\tthis.summaryStateTracker.updateStateFromSnapshotData(snapshotData);\n\n\t\t// If there is no snapshot data, it means this snapshot was generated with GC disabled. Unset all GC state.\n\t\tif (snapshotData === undefined) {\n\t\t\tthis.gcDataFromLastRun = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\t// Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun\n\t\t// to the GC data from the snapshot data.\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [nodeId, nodeData] of Object.entries(snapshotData.gcState.gcNodes)) {\n\t\t\tif (nodeData.unreferencedTimestampMs !== undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tnodeData.unreferencedTimestampMs,\n\t\t\t\t\t\tthis.configs.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t}\n\t\tthis.gcDataFromLastRun = { gcNodes };\n\t}\n\n\t/**\n\t * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this\n\t * to initialize the base state for non-summarizer clients so that they can track inactive / sweep ready nodes.\n\t * @param connected - Whether the runtime connected / disconnected.\n\t * @param clientId - The clientId of this runtime.\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string | undefined): void {\n\t\t/**\n\t\t * For all clients, initialize the base state when the container becomes active, i.e., it transitions\n\t\t * to \"write\" mode. This will ensure that the container's own join op is processed and there is a recent\n\t\t * reference timestamp that will be used to update the state of unreferenced nodes. Also, all trailing ops which\n\t\t * could affect the GC state will have been processed.\n\t\t *\n\t\t * If GC is up-to-date for the client and the summarizing client, there will be an doubling of both\n\t\t * InactiveObject_Loaded and SweepReady_Loaded errors, as there will be one from the sending client and one from\n\t\t * the receiving summarizer client.\n\t\t *\n\t\t * Ideally, this initialization should only be done for summarizer client. However, we are currently rolling out\n\t\t * sweep in phases and we want to track when inactive and sweep ready objects are used in any client.\n\t\t */\n\t\tif (this.activeConnection() && this.configs.shouldRunGC) {\n\t\t\tthis.initializeGCStateFromBaseSnapshotP.catch((error) => {});\n\t\t}\n\t}\n\n\t/**\n\t * Runs garbage collection and updates the reference / used state of the nodes in the container.\n\t * @returns stats of the GC run or undefined if GC did not run.\n\t */\n\tpublic async collectGarbage(\n\t\toptions: {\n\t\t\t/** Logger to use for logging GC events */\n\t\t\tlogger?: ITelemetryLogger;\n\t\t\t/** True to run GC sweep phase after the mark phase */\n\t\t\trunSweep?: boolean;\n\t\t\t/** True to generate full GC data */\n\t\t\tfullGC?: boolean;\n\t\t},\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<IGCStats | undefined> {\n\t\tconst fullGC =\n\t\t\toptions.fullGC ??\n\t\t\t(this.configs.runFullGC === true ||\n\t\t\t\tthis.summaryStateTracker.doesSummaryStateNeedReset());\n\t\tconst logger = options.logger\n\t\t\t? ChildLogger.create(options.logger, undefined, {\n\t\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t })\n\t\t\t: this.mc.logger;\n\n\t\t/**\n\t\t * If there is no current reference timestamp, skip running GC. We need the current timestamp to track\n\t\t * how long objects have been unreferenced and if they should be deleted.\n\t\t *\n\t\t * Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever\n\t\t * been processed for this container and it is in read mode. In this scenario, there is no point in running GC\n\t\t * anyway because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t */\n\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"CollectGarbageCalledWithoutTimestamp\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t});\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Add the options that are used to run GC to the telemetry context.\n\t\ttelemetryContext?.setMultiple(\"fluid_GC\", \"Options\", {\n\t\t\tfullGC,\n\t\t\trunSweep: options.runSweep,\n\t\t});\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"GarbageCollection\" },\n\t\t\tasync (event) => {\n\t\t\t\tawait this.runPreGCSteps();\n\n\t\t\t\t// Get the runtime's GC data and run GC on the reference graph in it.\n\t\t\t\tconst gcData = await this.runtime.getGCData(fullGC);\n\t\t\t\tconst gcResult = runGarbageCollection(gcData.gcNodes, [\"/\"]);\n\n\t\t\t\tconst gcStats = await this.runPostGCSteps(\n\t\t\t\t\tgcData,\n\t\t\t\t\tgcResult,\n\t\t\t\t\tlogger,\n\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t);\n\t\t\t\tevent.end({ ...gcStats, timestamp: currentReferenceTimestampMs });\n\t\t\t\tthis.completedRuns++;\n\t\t\t\treturn gcStats;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate async runPreGCSteps() {\n\t\t// Ensure that state has been initialized from the base snapshot data.\n\t\tawait this.initializeGCStateFromBaseSnapshotP;\n\t\t// Let the runtime update its pending state before GC runs.\n\t\tawait this.runtime.updateStateBeforeGC();\n\t}\n\n\tprivate async runPostGCSteps(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tlogger: ITelemetryLogger,\n\t\tcurrentReferenceTimestampMs: number,\n\t): Promise<IGCStats> {\n\t\t// Generate statistics from the current run. This is done before updating the current state because it\n\t\t// generates some of its data based on previous state of the system.\n\t\tconst gcStats = this.generateStats(gcResult);\n\n\t\t// Update the current mark state and update the runtime of all used routes or ids that used as per the GC run.\n\t\tconst sweepReadyNodes = this.updateMarkPhase(\n\t\t\tgcData,\n\t\t\tgcResult,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tlogger,\n\t\t);\n\t\tthis.runtime.updateUsedRoutes(gcResult.referencedNodeIds);\n\n\t\t// Log events for objects that are ready to be deleted by sweep. When we have sweep enabled, we will\n\t\t// delete these objects here instead.\n\t\tthis.logSweepEvents(logger, currentReferenceTimestampMs);\n\n\t\tlet updatedGCData: IGarbageCollectionData = gcData;\n\n\t\tif (this.configs.shouldRunSweep) {\n\t\t\tupdatedGCData = this.runSweepPhase(sweepReadyNodes, gcData);\n\t\t} else if (this.configs.testMode) {\n\t\t\t// If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n\t\t\t// involving access to deleted data.\n\t\t\tthis.runtime.updateUnusedRoutes(gcResult.deletedNodeIds);\n\t\t} else if (this.configs.tombstoneMode) {\n\t\t\tthis.tombstones = sweepReadyNodes;\n\t\t\t// If we are running in GC tombstone mode, update tombstoned routes. This enables testing scenarios\n\t\t\t// involving access to \"deleted\" data without actually deleting the data from summaries.\n\t\t\t// Note: we will not tombstone in test mode.\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\tthis.gcDataFromLastRun = cloneGCData(updatedGCData);\n\n\t\t// Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and\n\t\t// updates its state so that we don't send false positives based on intermediate state. For example, we may get\n\t\t// reference to an unreferenced node from another unreferenced node which means the node wasn't revived.\n\t\tawait this.logUnreferencedEvents(logger);\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * Summarizes the GC data and returns it as a summary tree.\n\t * We current write the entire GC state in a single blob. This can be modified later to write multiple\n\t * blobs. All the blob keys should start with `gcBlobPrefix`.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined {\n\t\tif (!this.configs.shouldRunGC || this.gcDataFromLastRun === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst gcState: IGarbageCollectionState = { gcNodes: {} };\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n\t\t\tgcState.gcNodes[nodeId] = {\n\t\t\t\toutboundRoutes,\n\t\t\t\tunreferencedTimestampMs:\n\t\t\t\t\tthis.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n\t\t\t};\n\t\t}\n\n\t\treturn this.summaryStateTracker.summarize(\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\tgcState,\n\t\t\tthis.deletedNodes,\n\t\t\tthis.tombstones,\n\t\t);\n\t}\n\n\tpublic getMetadata(): IGCMetadata {\n\t\treturn {\n\t\t\t/**\n\t\t\t * If GC is enabled, the GC data is written using the current GC version and that is the gcFeature that goes\n\t\t\t * into the metadata blob. If GC is disabled, the gcFeature is 0.\n\t\t\t */\n\t\t\tgcFeature: this.configs.gcEnabled ? this.summaryStateTracker.currentGCVersion : 0,\n\t\t\tgcFeatureMatrix: this.configs.persistedGcFeatureMatrix,\n\t\t\tsessionExpiryTimeoutMs: this.configs.sessionExpiryTimeoutMs,\n\t\t\tsweepEnabled: this.configs.sweepEnabled,\n\t\t\tsweepTimeoutMs: this.configs.sweepTimeoutMs,\n\t\t};\n\t}\n\n\t/**\n\t * Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes\n\t * in the container.\n\t */\n\tpublic async getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase> {\n\t\treturn this.baseGCDetailsP;\n\t}\n\n\t/**\n\t * Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot\n\t * is downloaded and should be used to update the state.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tresult: RefreshSummaryResult,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\tconst latestSnapshotData = await this.summaryStateTracker.refreshLatestSummary(\n\t\t\tproposalHandle,\n\t\t\tresult,\n\t\t\treadAndParseBlob,\n\t\t);\n\n\t\t// If the latest summary was updated but it was not tracked by this client, our state needs to be updated from\n\t\t// this snapshot data.\n\t\tif (this.shouldRunGC && result.latestSummaryUpdated && !result.wasSummaryTracked) {\n\t\t\t// The current reference timestamp should be available if we are refreshing state from a snapshot. There has\n\t\t\t// to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.\n\t\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t\"No reference timestamp when updating GC state from snapshot\",\n\t\t\t\t\t\"refreshLatestSummary\",\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\tsummaryRefSeq: result.summaryRefSeq,\n\t\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.updateStateFromSnapshotData(latestSnapshotData, currentReferenceTimestampMs);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a node with the given id is updated. If the node is inactive, log an error.\n\t * @param nodePath - The id of the node that changed.\n\t * @param reason - Whether the node was loaded or changed.\n\t * @param timestampMs - The timestamp when the node changed.\n\t * @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.\n\t * @param requestHeaders - If the node was loaded via request path, the headers in the request.\n\t */\n\tpublic nodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\n\t\t\t\treason,\n\t\t\t\tnodePath,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tundefined /* fromNodeId */,\n\t\t\t\tpackagePath,\n\t\t\t\ttimestampMs,\n\t\t\t\trequestHeaders,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n\t * referenced between summaries so that their unreferenced timestamp can be reset.\n\t *\n\t * @param fromNodePath - The node from which the reference is added.\n\t * @param toNodePath - The node to which the reference is added.\n\t */\n\tpublic addedOutboundReference(fromNodePath: string, toNodePath: string) {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];\n\t\toutboundRoutes.push(toNodePath);\n\t\tthis.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(toNodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\"Revived\", toNodePath, nodeStateTracker, fromNodePath);\n\t\t}\n\n\t\tif (this.tombstones.includes(toNodePath)) {\n\t\t\tconst nodeType = this.runtime.getNodeType(toNodePath);\n\n\t\t\tlet eventName = \"GC_Tombstone_SubDatastore_Revived\";\n\t\t\tif (nodeType === GCNodeType.DataStore) {\n\t\t\t\teventName = \"GC_Tombstone_Datastore_Revived\";\n\t\t\t} else if (nodeType === GCNodeType.Blob) {\n\t\t\t\teventName = \"GC_Tombstone_Blob_Revived\";\n\t\t\t}\n\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\turl: trimLeadingSlashes(toNodePath),\n\t\t\t\t\tnodeType,\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify\n\t * cases where objects are used after they are deleted and throw / log errors accordingly.\n\t */\n\tpublic isNodeDeleted(nodePath: string): boolean {\n\t\treturn this.deletedNodes.has(nodePath);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.sessionExpiryTimer?.clear();\n\t\tthis.sessionExpiryTimer = undefined;\n\t}\n\n\t/**\n\t * Updates the state of the system as per the current GC run. It does the following:\n\t * 1. Sets up the current GC state as per the gcData.\n\t * 2. Starts tracking for nodes that have become unreferenced in this run.\n\t * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n\t * @param gcData - The data representing the reference graph on which GC is run.\n\t * @param gcResult - The result of the GC run on the gcData.\n\t * @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.\n\t * @returns - A list of sweep ready nodes. (Nodes ready to be deleted)\n\t */\n\tprivate updateMarkPhase(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tlogger: ITelemetryLogger,\n\t) {\n\t\t// Get references from the current GC run + references between previous and current run and then update each\n\t\t// node's state\n\t\tconst allNodesReferencedBetweenGCs =\n\t\t\tthis.findAllNodesReferencedBetweenGCs(gcData, this.gcDataFromLastRun, logger) ??\n\t\t\tgcResult.referencedNodeIds;\n\t\tthis.newReferencesSinceLastRun.clear();\n\n\t\t// Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n\t\tfor (const nodeId of allNodesReferencedBetweenGCs) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * If a node became unreferenced in this run, start tracking it.\n\t\t * If a node was already unreferenced, update its tracking information. Since the current reference time is\n\t\t * from the ops seen, this will ensure that we keep updating the unreferenced state as time moves forward.\n\t\t *\n\t\t * If a node is sweep ready, store and then return it.\n\t\t */\n\t\tconst sweepReadyNodes: string[] = [];\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker === undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tnodeStateTracker.updateTracking(currentReferenceTimestampMs);\n\t\t\t\tif (nodeStateTracker.state === UnreferencedState.SweepReady) {\n\t\t\t\t\tsweepReadyNodes.push(nodeId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn sweepReadyNodes;\n\t}\n\n\t/**\n\t * Deletes nodes from both the runtime and garbage collection\n\t * @param sweepReadyNodes - nodes that are ready to be deleted\n\t */\n\tprivate runSweepPhase(sweepReadyNodes: string[], gcData: IGarbageCollectionData) {\n\t\t// TODO: GC:Validation - validate that removed routes are not double deleted\n\t\t// TODO: GC:Validation - validate that the child routes of removed routes are deleted as well\n\t\tconst sweptRoutes = this.runtime.deleteSweepReadyNodes(sweepReadyNodes);\n\t\tconst updatedGCData = this.deleteSweptRoutes(sweptRoutes, gcData);\n\n\t\tfor (const nodeId of sweptRoutes) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\t// TODO: GC:Validation - assert that the nodeStateTracker is defined\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t\t// TODO: GC:Validation - assert that the deleted node is not a duplicate\n\t\t\tthis.deletedNodes.add(nodeId);\n\t\t}\n\n\t\treturn updatedGCData;\n\t}\n\n\t/**\n\t * @returns IGarbageCollectionData after deleting the sweptRoutes from the gcData\n\t */\n\tprivate deleteSweptRoutes(\n\t\tsweptRoutes: string[],\n\t\tgcData: IGarbageCollectionData,\n\t): IGarbageCollectionData {\n\t\tconst sweptRoutesSet = new Set<string>(sweptRoutes);\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\t\tif (!sweptRoutesSet.has(id)) {\n\t\t\t\tgcNodes[id] = Array.from(outboundRoutes);\n\t\t\t}\n\t\t}\n\n\t\t// TODO: GC:Validation - assert that the nodeId is in gcData\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n\n\t/**\n\t * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n\t * time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be\n\t * updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of\n\t * these objects while there can be in-memory referenced to it:\n\t * 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is\n\t * added, the object may have been accessed and in-memory reference to it added.\n\t * 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were\n\t * unreferenced, they could have been accessed and in-memory reference to them added.\n\t *\n\t * This function identifies nodes that were referenced since the last run.\n\t * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n\t *\n\t * @returns - a list of all nodes referenced from the last local summary until now.\n\t */\n\tprivate findAllNodesReferencedBetweenGCs(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData | undefined,\n\t\tlogger: ITelemetryLogger,\n\t): string[] | undefined {\n\t\t// If we haven't run GC before there is nothing to do.\n\t\t// No previousGCData, means nothing is unreferenced, and there are no reference state trackers to clear\n\t\tif (previousGCData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Find any references that haven't been identified correctly.\n\t\tconst missingExplicitReferences = this.findMissingExplicitReferences(\n\t\t\tcurrentGCData,\n\t\t\tpreviousGCData,\n\t\t\tthis.newReferencesSinceLastRun,\n\t\t);\n\n\t\tif (missingExplicitReferences.length > 0) {\n\t\t\tmissingExplicitReferences.forEach((missingExplicitReference) => {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\tgcNodeId: missingExplicitReference[0],\n\t\t\t\t\tgcRoutes: JSON.stringify(missingExplicitReference[1]),\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t// No references were added since the last run so we don't have to update reference states of any unreferenced\n\t\t// nodes. There is no in between state at this point.\n\t\tif (this.newReferencesSinceLastRun.size === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t/**\n\t\t * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n\t\t * edges that have been added since then. To do this, combine the GC data from the last run and the current\n\t\t * run, and then add the references since last run.\n\t\t *\n\t\t * Note on why we need to combine the data from previous run, current run and all references in between -\n\t\t * 1. We need data from last run because some of its references may have been deleted since then. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 3. We need data from the current run because currently we may not detect when DDSes are referenced:\n\t\t * - We don't require DDSes handles to be stored in a referenced DDS.\n\t\t * - A new data store may have \"root\" DDSes already created and we don't detect them today.\n\t\t */\n\t\tconst gcDataSuperSet = concatGarbageCollectionData(previousGCData, currentGCData);\n\t\tconst newOutboundRoutesSinceLastRun: string[] = [];\n\t\tthis.newReferencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n\t\t\tif (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n\t\t\t} else {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n\t\t\t}\n\t\t\tnewOutboundRoutesSinceLastRun.push(...outboundRoutes);\n\t\t});\n\n\t\t/**\n\t\t * Run GC on the above reference graph starting with root and all new outbound routes. This will generate a\n\t\t * list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,\n\t\t * unreferenced, stop tracking them and remove from unreferenced list.\n\t\t * Note that some of these nodes may be unreferenced now and if so, the current run will mark them as\n\t\t * unreferenced and add unreferenced state.\n\t\t */\n\t\tconst gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\n\t\t\t\"/\",\n\t\t\t...newOutboundRoutesSinceLastRun,\n\t\t]);\n\t\treturn gcResult.referencedNodeIds;\n\t}\n\n\t/**\n\t * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t * @returns - a list of missing explicit references\n\t */\n\tprivate findMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t): [string, string[]][] {\n\t\tassert(\n\t\t\tpreviousGCData !== undefined,\n\t\t\t0x2b7 /* \"Can't validate correctness without GC data from last run\" */,\n\t\t);\n\n\t\tconst currentGraph = Object.entries(currentGCData.gcNodes);\n\t\tconst missingExplicitReferences: [string, string[]][] = [];\n\t\tcurrentGraph.forEach(([nodeId, currentOutboundRoutes]) => {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tcurrentOutboundRoutes.forEach((route) => {\n\t\t\t\tconst nodeType = this.runtime.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tmissingExplicitReferences.push([nodeId, missingExplicitRoutes]);\n\t\t\t}\n\t\t});\n\n\t\t// Ideally missingExplicitReferences should always have a size 0\n\t\treturn missingExplicitReferences;\n\t}\n\n\t/**\n\t * Generates the stats of a garbage collection run from the given results of the run.\n\t * @param gcResult - The result of a GC run.\n\t * @returns the GC stats of the GC run.\n\t */\n\tprivate generateStats(gcResult: IGCResult): IGCStats {\n\t\tconst gcStats: IGCStats = {\n\t\t\tnodeCount: 0,\n\t\t\tdataStoreCount: 0,\n\t\t\tattachmentBlobCount: 0,\n\t\t\tunrefNodeCount: 0,\n\t\t\tunrefDataStoreCount: 0,\n\t\t\tunrefAttachmentBlobCount: 0,\n\t\t\tupdatedNodeCount: 0,\n\t\t\tupdatedDataStoreCount: 0,\n\t\t\tupdatedAttachmentBlobCount: 0,\n\t\t};\n\n\t\tconst updateNodeStats = (nodeId: string, referenced: boolean) => {\n\t\t\tgcStats.nodeCount++;\n\t\t\t// If there is no previous GC data, every node's state is generated and is considered as updated.\n\t\t\t// Otherwise, find out if any node went from referenced to unreferenced or vice-versa.\n\t\t\tconst stateUpdated =\n\t\t\t\tthis.gcDataFromLastRun === undefined ||\n\t\t\t\tthis.unreferencedNodesState.has(nodeId) === referenced;\n\t\t\tif (stateUpdated) {\n\t\t\t\tgcStats.updatedNodeCount++;\n\t\t\t}\n\t\t\tif (!referenced) {\n\t\t\t\tgcStats.unrefNodeCount++;\n\t\t\t}\n\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {\n\t\t\t\tgcStats.dataStoreCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedDataStoreCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefDataStoreCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {\n\t\t\t\tgcStats.attachmentBlobCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfor (const nodeId of gcResult.referencedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, true /* referenced */);\n\t\t}\n\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, false /* referenced */);\n\t\t}\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tprivate logSweepEvents(logger: ITelemetryLogger, currentReferenceTimestampMs: number) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unreferencedNodesState.forEach((nodeStateTracker, nodeId) => {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GCObjectDeleted\",\n\t\t\t\tid: nodeId,\n\t\t\t\ttype: nodeType,\n\t\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.\n\t */\n\tprivate inactiveNodeUsed(\n\t\tusageType: \"Changed\" | \"Loaded\" | \"Revived\",\n\t\tnodeId: string,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tfromNodeId?: string,\n\t\tpackagePath?: readonly string[],\n\t\tcurrentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(),\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is active, skip logging.\n\t\tif (\n\t\t\tcurrentReferenceTimestampMs === undefined ||\n\t\t\tnodeStateTracker.state === UnreferencedState.Active\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We only care about data stores and attachment blobs for this telemetry since GC only marks these objects\n\t\t// as unreferenced. Also, if an inactive DDS is used, the corresponding data store store will also be used.\n\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${nodeId}-${usageType}`;\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst propsToLog = {\n\t\t\tid: nodeId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t...this.createContainerMetadata,\n\t\t\tviaHandle: requestHeaders?.[RuntimeHeaders.viaHandle],\n\t\t\tfromId: fromNodeId,\n\t\t};\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({ ...propsToLog, usageType, state });\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: packagePathToTelemetryProperty(packagePath),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If SweepReady Usage Detection is enabled, the handler may close the interactive container.\n\t\t\t// Once Sweep is fully implemented, this will be removed since the objects will be gone\n\t\t\t// and errors will arise elsewhere in the runtime\n\t\t\tif (state === UnreferencedState.SweepReady) {\n\t\t\t\tthis.sweepReadyUsageHandler.usageDetectedInInteractiveClient({\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\tusageType,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async logUnreferencedEvents(logger: ITelemetryLogger) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(eventProps.id);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: pkg\n\t\t\t\t\t\t? { value: pkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tfromPkg: fromPkg\n\t\t\t\t\t\t? { value: fromPkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../../src/gc/garbageCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;AAGH,+DAA0E;AAC1E,qEAAiG;AAEjG,yEAO2C;AAC3C,6EAQ6C;AAC7C,iEAIuC;AACvC,qEAOyC;AAEzC,0DAAqD;AAErD,2CAAgD;AAChD,mDAUyB;AACzB,2CAA+F;AAC/F,mEAAgE;AAChE,6EAA+E;AAC/E,6EAAwE;AAiBxE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,gBAAgB;IAiE5B,YAAsB,YAA2C;QAlDjE,6GAA6G;QAC7G,kCAAkC;QACjB,8BAAyB,GAA0B,IAAI,GAAG,EAAE,CAAC;QAC9E,6CAA6C;QACrC,eAAU,GAAa,EAAE,CAAC;QAClC,6DAA6D;QACrD,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAQ9C,uDAAuD;QACtC,2BAAsB,GAA0C,IAAI,GAAG,EAAE,CAAC;QAI3F,iHAAiH;QACjH,sBAAsB;QACL,6BAAwB,GAAgB,IAAI,GAAG,EAAE,CAAC;QACnE,6EAA6E;QACrE,uBAAkB,GAA8B,EAAE,CAAC;QAE3D,0FAA0F;QAClF,kBAAa,GAAG,CAAC,CAAC;QAyBzB,IAAI,CAAC,OAAO,GAAG,YAAY,CAA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iBAC7B;aACD;SACD;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD;AA7oCD,4CA6oCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { ClientSessionExpiredError, DataProcessingError } from \"@fluidframework/container-utils\";\nimport { IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport {\n\tcloneGCData,\n\tconcatGarbageCollectionData,\n\tgetGCDataFromSnapshot,\n\tIGCResult,\n\trunGarbageCollection,\n\ttrimLeadingSlashes,\n} from \"@fluidframework/garbage-collector\";\nimport {\n\tgcTreeKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tISummarizeResult,\n\tITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tpackagePathToTelemetryProperty,\n\tReadAndParseBlob,\n\tRefreshSummaryResult,\n} from \"@fluidframework/runtime-utils\";\nimport {\n\tChildLogger,\n\tgenerateStack,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\n\nimport { RuntimeHeaders } from \"../containerRuntime\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport { generateGCConfigs } from \"./gcConfigs\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tIGarbageCollector,\n\tIGarbageCollectorCreateParams,\n\tIGarbageCollectionRuntime,\n\tIGCStats,\n\tUnreferencedState,\n\tIGCMetadata,\n\tIGarbageCollectorConfigs,\n} from \"./gcDefinitions\";\nimport { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent } from \"./gcHelpers\";\nimport { GCSummaryStateTracker } from \"./gcSummaryStateTracker\";\nimport { SweepReadyUsageDetectionHandler } from \"./gcSweepReadyUsageDetection\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps {\n\tusageType: \"Changed\" | \"Loaded\" | \"Revived\";\n\tstate: UnreferencedState;\n\tid: string;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\tcompletedGCRuns: number;\n\tfromId?: string;\n\ttimeout?: number;\n\tlastSummaryTime?: number;\n\tviaHandle?: boolean;\n}\n\n/**\n * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains\n * its state across summaries.\n *\n * Node - represented as nodeId, it's a node on the GC graph\n *\n * Outbound Route - a path from one node to another node, think `nodeA` -\\> `nodeB`\n *\n * Graph - all nodes with their respective routes\n *\n * ```\n *\t\t\t GC Graph\n *\n *\t\t\t Node\n *\t\tNodeId = \"datastore1\"\n *\t\t /\t\t\t \\\\\n *\tOutboundRoute OutboundRoute\n *\t\t /\t\t\t\t \\\\\n *\t Node\t\t\t Node\n * NodeId = \"dds1\"\t NodeId = \"dds2\"\n * ```\n */\nexport class GarbageCollector implements IGarbageCollector {\n\tpublic static create(createParams: IGarbageCollectorCreateParams): IGarbageCollector {\n\t\treturn new GarbageCollector(createParams);\n\t}\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly configs: IGarbageCollectorConfigs;\n\n\tpublic get shouldRunGC(): boolean {\n\t\treturn this.configs.shouldRunGC;\n\t}\n\n\t// Keeps track of the GC state from the last run.\n\tprivate gcDataFromLastRun: IGarbageCollectionData | undefined;\n\t// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n\t// outbound routes from that node.\n\tprivate readonly newReferencesSinceLastRun: Map<string, string[]> = new Map();\n\t// A list of nodes that have been tombstoned.\n\tprivate tombstones: string[] = [];\n\t// A list of nodes that have been deleted during sweep phase.\n\tprivate deletedNodes: Set<string> = new Set();\n\n\t// Promise when resolved returns the GC data data in the base snapshot.\n\tprivate readonly baseSnapshotDataP: Promise<IGarbageCollectionSnapshotData | undefined>;\n\t// Promise when resolved initializes the GC state from the data in the base snapshot.\n\tprivate readonly initializeGCStateFromBaseSnapshotP: Promise<void>;\n\t// The GC details generated from the base snapshot.\n\tprivate readonly baseGCDetailsP: Promise<IGarbageCollectionDetailsBase>;\n\t// Map of node ids to their unreferenced state tracker.\n\tprivate readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n\t// The Timer responsible for closing the container when the session has expired\n\tprivate sessionExpiryTimer: Timer | undefined;\n\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\t// The number of times GC has successfully completed on this instance of GarbageCollector.\n\tprivate completedRuns = 0;\n\n\tprivate readonly runtime: IGarbageCollectionRuntime;\n\tprivate readonly createContainerMetadata: ICreateContainerMetadata;\n\tprivate readonly isSummarizerClient: boolean;\n\n\tprivate readonly summaryStateTracker: GCSummaryStateTracker;\n\n\t/** For a given node path, returns the node's package path. */\n\tprivate readonly getNodePackagePath: (\n\t\tnodePath: string,\n\t) => Promise<readonly string[] | undefined>;\n\t/** Returns the timestamp of the last summary generated for this container. */\n\tprivate readonly getLastSummaryTimestampMs: () => number | undefined;\n\t/** Returns true if connection is active, i.e. it's \"write\" connection and the runtime is connected. */\n\tprivate readonly activeConnection: () => boolean;\n\n\tpublic get summaryStateNeedsReset(): boolean {\n\t\treturn this.summaryStateTracker.doesSummaryStateNeedReset;\n\t}\n\n\t/** Handler to respond to when a SweepReady object is used */\n\tprivate readonly sweepReadyUsageHandler: SweepReadyUsageDetectionHandler;\n\n\tprotected constructor(createParams: IGarbageCollectorCreateParams) {\n\t\tthis.runtime = createParams.runtime;\n\t\tthis.isSummarizerClient = createParams.isSummarizerClient;\n\t\tthis.createContainerMetadata = createParams.createContainerMetadata;\n\t\tthis.getNodePackagePath = createParams.getNodePackagePath;\n\t\tthis.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;\n\t\tthis.activeConnection = createParams.activeConnection;\n\n\t\tconst baseSnapshot = createParams.baseSnapshot;\n\t\tconst readAndParseBlob = createParams.readAndParseBlob;\n\n\t\tthis.mc = loggerToMonitoringContext(\n\t\t\tChildLogger.create(createParams.baseLogger, \"GarbageCollector\", {\n\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t}),\n\t\t);\n\n\t\tthis.sweepReadyUsageHandler = new SweepReadyUsageDetectionHandler(\n\t\t\tcreateParams.getContainerDiagnosticId(),\n\t\t\tthis.mc,\n\t\t\tthis.runtime.closeFn,\n\t\t);\n\n\t\tthis.configs = generateGCConfigs(this.mc, createParams);\n\n\t\t// If session expiry is enabled, we need to close the container when the session expiry timeout expires.\n\t\tif (this.configs.sessionExpiryTimeoutMs !== undefined) {\n\t\t\t// If Test Override config is set, override Session Expiry timeout.\n\t\t\tconst overrideSessionExpiryTimeoutMs = this.mc.config.getNumber(\n\t\t\t\t\"Fluid.GarbageCollection.TestOverride.SessionExpiryMs\",\n\t\t\t);\n\t\t\tconst timeoutMs = overrideSessionExpiryTimeoutMs ?? this.configs.sessionExpiryTimeoutMs;\n\n\t\t\tthis.sessionExpiryTimer = new Timer(timeoutMs, () => {\n\t\t\t\tthis.runtime.closeFn(\n\t\t\t\t\tnew ClientSessionExpiredError(`Client session expired.`, timeoutMs),\n\t\t\t\t);\n\t\t\t});\n\t\t\tthis.sessionExpiryTimer.start();\n\t\t}\n\n\t\tthis.summaryStateTracker = new GCSummaryStateTracker(\n\t\t\tthis.configs,\n\t\t\tbaseSnapshot?.trees[gcTreeKey] !== undefined /* wasGCRunInBaseSnapshot */,\n\t\t);\n\n\t\t// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it\n\t\t// it involves fetching blobs from storage which is expensive.\n\t\tthis.baseSnapshotDataP = new LazyPromise<IGarbageCollectionSnapshotData | undefined>(\n\t\t\tasync () => {\n\t\t\t\tif (baseSnapshot === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\t// For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n\t\t\t\t\tconst gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n\t\t\t\t\tif (gcSnapshotTree !== undefined) {\n\t\t\t\t\t\treturn getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\t\t\t\t\t}\n\n\t\t\t\t\t// back-compat - Older documents will have the GC blobs in each data store's snapshot tree.\n\t\t\t\t\treturn getSnapshotDataFromOldSnapshotFormat(\n\t\t\t\t\t\tbaseSnapshot,\n\t\t\t\t\t\tcreateParams.metadata,\n\t\t\t\t\t\treadAndParseBlob,\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst dpe = DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terror,\n\t\t\t\t\t\t\"FailedToInitializeGC\",\n\t\t\t\t\t);\n\t\t\t\t\tdpe.addTelemetryProperties({\n\t\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t\t});\n\t\t\t\t\tthrow dpe;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\t/**\n\t\t * Set up the initializer which initializes the GC state from the data in base snapshot. This is done when\n\t\t * connected in write mode or when GC runs the first time. It sets up all unreferenced nodes from the base\n\t\t * GC state and updates their inactive or sweep ready state.\n\t\t */\n\t\tthis.initializeGCStateFromBaseSnapshotP = new LazyPromise<void>(async () => {\n\t\t\t/**\n\t\t\t * If there is no current reference timestamp, skip initialization. We need the current timestamp to track\n\t\t\t * how long objects have been unreferenced and if they can be deleted.\n\t\t\t *\n\t\t\t * Note that the only scenario where there is no reference timestamp is when no ops have ever been processed\n\t\t\t * for this container and it is in read mode. In this scenario, there is no point in running GC anyway\n\t\t\t * because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t\t */\n\t\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"GarbageCollectorInitializedWithoutTimestamp\",\n\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t/**\n\t\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t\t * 1. The first summary created by the detached container.\n\t\t\t * 2. A summary that was generated with GC disabled.\n\t\t\t * 3. A summary that was generated before GC even existed.\n\t\t\t */\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.updateStateFromSnapshotData(baseSnapshotData, currentReferenceTimestampMs);\n\t\t});\n\n\t\t// Get the GC details from the GC state in the base summary. This is returned in getBaseGCDetails which is\n\t\t// used to initialize the GC state of all the nodes in the container.\n\t\tthis.baseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\t\tfor (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n\t\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t\t}\n\t\t\t// Run GC on the nodes in the base summary to get the routes used in each node in the container.\n\t\t\t// This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n\t\t\t// each node in the summary.\n\t\t\tconst usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n\n\t\t\treturn { gcData: { gcNodes }, usedRoutes };\n\t\t});\n\n\t\t// Log all the GC options and the state determined by the garbage collector. This is interesting only for the\n\t\t// summarizer client since it is the only one that runs GC. It also helps keep the telemetry less noisy.\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"GarbageCollectorLoaded\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\tgcOptions: JSON.stringify(createParams.gcOptions),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done\n\t * during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.\n\t */\n\tpublic async initializeBaseState(): Promise<void> {\n\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t/**\n\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t * 1. The first summary created by the detached container.\n\t\t * 2. A summary that was generated with GC disabled.\n\t\t * 3. A summary that was generated before GC even existed.\n\t\t */\n\t\tif (baseSnapshotData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not\n\t\t// to identify deleted nodes' usage.\n\t\tif (baseSnapshotData.deletedNodes !== undefined) {\n\t\t\tthis.deletedNodes = new Set(baseSnapshotData.deletedNodes);\n\t\t}\n\n\t\t// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of\n\t\t// tombstone routes.\n\t\tif (this.configs.tombstoneMode && baseSnapshotData.tombstones !== undefined) {\n\t\t\t// Create a copy since we are writing from a source we don't control\n\t\t\tthis.tombstones = Array.from(baseSnapshotData.tombstones);\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\t}\n\n\t/**\n\t * Update state from the given snapshot data. This is done during load and during refreshing state from a snapshot.\n\t * All current tracking is reset and updated from the data in the snapshot.\n\t * @param snapshotData - The snapshot data to update state from. If this is undefined, all GC state and tracking\n\t * is reset.\n\t * @param currentReferenceTimestampMs - The current reference timestamp for marking unreferenced nodes' unreferenced\n\t * timestamp.\n\t */\n\tprivate updateStateFromSnapshotData(\n\t\tsnapshotData: IGarbageCollectionSnapshotData | undefined,\n\t\tcurrentReferenceTimestampMs: number,\n\t) {\n\t\t/**\n\t\t * Note: \"newReferencesSinceLastRun\" is not reset here. This is done because there may be references since the\n\t\t * snapshot that we are updating state from. For example, this client may have processed ops till seq#1000 and\n\t\t * its refreshing state from a summary that happened at seq#900. In this case, there may be references between\n\t\t * seq#901 and seq#1000 that we don't want to reset.\n\t\t * Unfortunately, there is no way to track the seq# of ops that add references, so we choose to not reset any\n\t\t * references here. This should be fine because, in the worst case, we may end up updating the unreferenced\n\t\t * timestamp of a node which will delay its deletion. Although not ideal, this will only happen in rare\n\t\t * scenarios, so it should be okay.\n\t\t */\n\n\t\t// Clear all existing unreferenced state tracking.\n\t\tfor (const [, nodeStateTracker] of this.unreferencedNodesState) {\n\t\t\tnodeStateTracker.stopTracking();\n\t\t}\n\t\tthis.unreferencedNodesState.clear();\n\n\t\t// If running sweep, the tombstone state represents the list of nodes that have been deleted during sweep.\n\t\t// If running in tombstone mode, the tombstone state represents the list of nodes that have been marked as\n\t\t// tombstones.\n\t\t// If this call is because we are refreshing from a snapshot due to an ack, it is likely that the GC state\n\t\t// in the snapshot is newer than this client's. And so, the deleted / tombstone nodes need to be updated.\n\t\tif (this.configs.shouldRunSweep) {\n\t\t\tconst snapshotDeletedNodes = snapshotData?.deletedNodes\n\t\t\t\t? new Set(snapshotData.deletedNodes)\n\t\t\t\t: undefined;\n\t\t\t// If the snapshot contains deleted nodes that are not yet deleted by this client, ask the runtime to\n\t\t\t// delete them.\n\t\t\tif (snapshotDeletedNodes !== undefined) {\n\t\t\t\tconst newDeletedNodes: string[] = [];\n\t\t\t\tfor (const nodeId of snapshotDeletedNodes) {\n\t\t\t\t\tif (!this.deletedNodes.has(nodeId)) {\n\t\t\t\t\t\tnewDeletedNodes.push(nodeId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (newDeletedNodes.length > 0) {\n\t\t\t\t\t// Call container runtime to delete these nodes and add deleted nodes to this.deletedNodes.\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.configs.tombstoneMode) {\n\t\t\t// The snapshot may contain more or fewer tombstone nodes than this client. Update tombstone state and\n\t\t\t// notify the runtime to update its state as well.\n\t\t\tthis.tombstones = snapshotData?.tombstones ? Array.from(snapshotData.tombstones) : [];\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\t// Update the summary state tracker's state from this snapshot.\n\t\tthis.summaryStateTracker.updateStateFromSnapshotData(snapshotData);\n\n\t\t// If there is no snapshot data, it means this snapshot was generated with GC disabled. Unset all GC state.\n\t\tif (snapshotData === undefined) {\n\t\t\tthis.gcDataFromLastRun = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\t// Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun\n\t\t// to the GC data from the snapshot data.\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [nodeId, nodeData] of Object.entries(snapshotData.gcState.gcNodes)) {\n\t\t\tif (nodeData.unreferencedTimestampMs !== undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tnodeData.unreferencedTimestampMs,\n\t\t\t\t\t\tthis.configs.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t}\n\t\tthis.gcDataFromLastRun = { gcNodes };\n\t}\n\n\t/**\n\t * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this\n\t * to initialize the base state for non-summarizer clients so that they can track inactive / sweep ready nodes.\n\t * @param connected - Whether the runtime connected / disconnected.\n\t * @param clientId - The clientId of this runtime.\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string | undefined): void {\n\t\t/**\n\t\t * For all clients, initialize the base state when the container becomes active, i.e., it transitions\n\t\t * to \"write\" mode. This will ensure that the container's own join op is processed and there is a recent\n\t\t * reference timestamp that will be used to update the state of unreferenced nodes. Also, all trailing ops which\n\t\t * could affect the GC state will have been processed.\n\t\t *\n\t\t * If GC is up-to-date for the client and the summarizing client, there will be an doubling of both\n\t\t * InactiveObject_Loaded and SweepReady_Loaded errors, as there will be one from the sending client and one from\n\t\t * the receiving summarizer client.\n\t\t *\n\t\t * Ideally, this initialization should only be done for summarizer client. However, we are currently rolling out\n\t\t * sweep in phases and we want to track when inactive and sweep ready objects are used in any client.\n\t\t */\n\t\tif (this.activeConnection() && this.configs.shouldRunGC) {\n\t\t\tthis.initializeGCStateFromBaseSnapshotP.catch((error) => {});\n\t\t}\n\t}\n\n\t/**\n\t * Runs garbage collection and updates the reference / used state of the nodes in the container.\n\t * @returns stats of the GC run or undefined if GC did not run.\n\t */\n\tpublic async collectGarbage(\n\t\toptions: {\n\t\t\t/** Logger to use for logging GC events */\n\t\t\tlogger?: ITelemetryLogger;\n\t\t\t/** True to run GC sweep phase after the mark phase */\n\t\t\trunSweep?: boolean;\n\t\t\t/** True to generate full GC data */\n\t\t\tfullGC?: boolean;\n\t\t},\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<IGCStats | undefined> {\n\t\tconst fullGC =\n\t\t\toptions.fullGC ??\n\t\t\t(this.configs.runFullGC === true || this.summaryStateTracker.doesSummaryStateNeedReset);\n\t\tconst logger = options.logger\n\t\t\t? ChildLogger.create(options.logger, undefined, {\n\t\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t })\n\t\t\t: this.mc.logger;\n\n\t\t/**\n\t\t * If there is no current reference timestamp, skip running GC. We need the current timestamp to track\n\t\t * how long objects have been unreferenced and if they should be deleted.\n\t\t *\n\t\t * Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever\n\t\t * been processed for this container and it is in read mode. In this scenario, there is no point in running GC\n\t\t * anyway because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t */\n\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"CollectGarbageCalledWithoutTimestamp\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t});\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Add the options that are used to run GC to the telemetry context.\n\t\ttelemetryContext?.setMultiple(\"fluid_GC\", \"Options\", {\n\t\t\tfullGC,\n\t\t\trunSweep: options.runSweep,\n\t\t});\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"GarbageCollection\" },\n\t\t\tasync (event) => {\n\t\t\t\tawait this.runPreGCSteps();\n\n\t\t\t\t// Get the runtime's GC data and run GC on the reference graph in it.\n\t\t\t\tconst gcData = await this.runtime.getGCData(fullGC);\n\t\t\t\tconst gcResult = runGarbageCollection(gcData.gcNodes, [\"/\"]);\n\n\t\t\t\tconst gcStats = await this.runPostGCSteps(\n\t\t\t\t\tgcData,\n\t\t\t\t\tgcResult,\n\t\t\t\t\tlogger,\n\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t);\n\t\t\t\tevent.end({ ...gcStats, timestamp: currentReferenceTimestampMs });\n\t\t\t\tthis.completedRuns++;\n\t\t\t\treturn gcStats;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate async runPreGCSteps() {\n\t\t// Ensure that state has been initialized from the base snapshot data.\n\t\tawait this.initializeGCStateFromBaseSnapshotP;\n\t\t// Let the runtime update its pending state before GC runs.\n\t\tawait this.runtime.updateStateBeforeGC();\n\t}\n\n\tprivate async runPostGCSteps(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tlogger: ITelemetryLogger,\n\t\tcurrentReferenceTimestampMs: number,\n\t): Promise<IGCStats> {\n\t\t// Generate statistics from the current run. This is done before updating the current state because it\n\t\t// generates some of its data based on previous state of the system.\n\t\tconst gcStats = this.generateStats(gcResult);\n\n\t\t// Update the current mark state and update the runtime of all used routes or ids that used as per the GC run.\n\t\tconst sweepReadyNodes = this.updateMarkPhase(\n\t\t\tgcData,\n\t\t\tgcResult,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tlogger,\n\t\t);\n\t\tthis.runtime.updateUsedRoutes(gcResult.referencedNodeIds);\n\n\t\t// Log events for objects that are ready to be deleted by sweep. When we have sweep enabled, we will\n\t\t// delete these objects here instead.\n\t\tthis.logSweepEvents(logger, currentReferenceTimestampMs);\n\n\t\tlet updatedGCData: IGarbageCollectionData = gcData;\n\n\t\tif (this.configs.shouldRunSweep) {\n\t\t\tupdatedGCData = this.runSweepPhase(sweepReadyNodes, gcData);\n\t\t} else if (this.configs.testMode) {\n\t\t\t// If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n\t\t\t// involving access to deleted data.\n\t\t\tthis.runtime.updateUnusedRoutes(gcResult.deletedNodeIds);\n\t\t} else if (this.configs.tombstoneMode) {\n\t\t\tthis.tombstones = sweepReadyNodes;\n\t\t\t// If we are running in GC tombstone mode, update tombstoned routes. This enables testing scenarios\n\t\t\t// involving access to \"deleted\" data without actually deleting the data from summaries.\n\t\t\t// Note: we will not tombstone in test mode.\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\tthis.gcDataFromLastRun = cloneGCData(updatedGCData);\n\n\t\t// Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and\n\t\t// updates its state so that we don't send false positives based on intermediate state. For example, we may get\n\t\t// reference to an unreferenced node from another unreferenced node which means the node wasn't revived.\n\t\tawait this.logUnreferencedEvents(logger);\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * Summarizes the GC data and returns it as a summary tree.\n\t * We current write the entire GC state in a single blob. This can be modified later to write multiple\n\t * blobs. All the blob keys should start with `gcBlobPrefix`.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined {\n\t\tif (!this.configs.shouldRunGC || this.gcDataFromLastRun === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst gcState: IGarbageCollectionState = { gcNodes: {} };\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n\t\t\tgcState.gcNodes[nodeId] = {\n\t\t\t\toutboundRoutes,\n\t\t\t\tunreferencedTimestampMs:\n\t\t\t\t\tthis.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n\t\t\t};\n\t\t}\n\n\t\treturn this.summaryStateTracker.summarize(\n\t\t\tfullTree,\n\t\t\ttrackState,\n\t\t\tgcState,\n\t\t\tthis.deletedNodes,\n\t\t\tthis.tombstones,\n\t\t);\n\t}\n\n\tpublic getMetadata(): IGCMetadata {\n\t\treturn {\n\t\t\t/**\n\t\t\t * If GC is enabled, the GC data is written using the current GC version and that is the gcFeature that goes\n\t\t\t * into the metadata blob. If GC is disabled, the gcFeature is 0.\n\t\t\t */\n\t\t\tgcFeature: this.configs.gcEnabled ? this.summaryStateTracker.currentGCVersion : 0,\n\t\t\tgcFeatureMatrix: this.configs.persistedGcFeatureMatrix,\n\t\t\tsessionExpiryTimeoutMs: this.configs.sessionExpiryTimeoutMs,\n\t\t\tsweepEnabled: false, // DEPRECATED - to be removed\n\t\t\tsweepTimeoutMs: this.configs.sweepTimeoutMs,\n\t\t};\n\t}\n\n\t/**\n\t * Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes\n\t * in the container.\n\t */\n\tpublic async getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase> {\n\t\treturn this.baseGCDetailsP;\n\t}\n\n\t/**\n\t * Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot\n\t * is downloaded and should be used to update the state.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tresult: RefreshSummaryResult,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\tconst latestSnapshotData = await this.summaryStateTracker.refreshLatestSummary(\n\t\t\tproposalHandle,\n\t\t\tresult,\n\t\t\treadAndParseBlob,\n\t\t);\n\n\t\t// If the latest summary was updated but it was not tracked by this client, our state needs to be updated from\n\t\t// this snapshot data.\n\t\tif (this.shouldRunGC && result.latestSummaryUpdated && !result.wasSummaryTracked) {\n\t\t\t// The current reference timestamp should be available if we are refreshing state from a snapshot. There has\n\t\t\t// to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.\n\t\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\t\"No reference timestamp when updating GC state from snapshot\",\n\t\t\t\t\t\"refreshLatestSummary\",\n\t\t\t\t\tundefined,\n\t\t\t\t\t{\n\t\t\t\t\t\tproposalHandle,\n\t\t\t\t\t\tsummaryRefSeq: result.summaryRefSeq,\n\t\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.updateStateFromSnapshotData(latestSnapshotData, currentReferenceTimestampMs);\n\t\t}\n\t}\n\n\t/**\n\t * Called when a node with the given id is updated. If the node is inactive, log an error.\n\t * @param nodePath - The id of the node that changed.\n\t * @param reason - Whether the node was loaded or changed.\n\t * @param timestampMs - The timestamp when the node changed.\n\t * @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.\n\t * @param requestHeaders - If the node was loaded via request path, the headers in the request.\n\t */\n\tpublic nodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\n\t\t\t\treason,\n\t\t\t\tnodePath,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tundefined /* fromNodeId */,\n\t\t\t\tpackagePath,\n\t\t\t\ttimestampMs,\n\t\t\t\trequestHeaders,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n\t * referenced between summaries so that their unreferenced timestamp can be reset.\n\t *\n\t * @param fromNodePath - The node from which the reference is added.\n\t * @param toNodePath - The node to which the reference is added.\n\t */\n\tpublic addedOutboundReference(fromNodePath: string, toNodePath: string) {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];\n\t\toutboundRoutes.push(toNodePath);\n\t\tthis.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(toNodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\"Revived\", toNodePath, nodeStateTracker, fromNodePath);\n\t\t}\n\n\t\tif (this.tombstones.includes(toNodePath)) {\n\t\t\tconst nodeType = this.runtime.getNodeType(toNodePath);\n\n\t\t\tlet eventName = \"GC_Tombstone_SubDatastore_Revived\";\n\t\t\tif (nodeType === GCNodeType.DataStore) {\n\t\t\t\teventName = \"GC_Tombstone_Datastore_Revived\";\n\t\t\t} else if (nodeType === GCNodeType.Blob) {\n\t\t\t\teventName = \"GC_Tombstone_Blob_Revived\";\n\t\t\t}\n\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\turl: trimLeadingSlashes(toNodePath),\n\t\t\t\t\tnodeType,\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify\n\t * cases where objects are used after they are deleted and throw / log errors accordingly.\n\t */\n\tpublic isNodeDeleted(nodePath: string): boolean {\n\t\treturn this.deletedNodes.has(nodePath);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.sessionExpiryTimer?.clear();\n\t\tthis.sessionExpiryTimer = undefined;\n\t}\n\n\t/**\n\t * Updates the state of the system as per the current GC run. It does the following:\n\t * 1. Sets up the current GC state as per the gcData.\n\t * 2. Starts tracking for nodes that have become unreferenced in this run.\n\t * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n\t * @param gcData - The data representing the reference graph on which GC is run.\n\t * @param gcResult - The result of the GC run on the gcData.\n\t * @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.\n\t * @returns - A list of sweep ready nodes. (Nodes ready to be deleted)\n\t */\n\tprivate updateMarkPhase(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tlogger: ITelemetryLogger,\n\t) {\n\t\t// Get references from the current GC run + references between previous and current run and then update each\n\t\t// node's state\n\t\tconst allNodesReferencedBetweenGCs =\n\t\t\tthis.findAllNodesReferencedBetweenGCs(gcData, this.gcDataFromLastRun, logger) ??\n\t\t\tgcResult.referencedNodeIds;\n\t\tthis.newReferencesSinceLastRun.clear();\n\n\t\t// Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n\t\tfor (const nodeId of allNodesReferencedBetweenGCs) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * If a node became unreferenced in this run, start tracking it.\n\t\t * If a node was already unreferenced, update its tracking information. Since the current reference time is\n\t\t * from the ops seen, this will ensure that we keep updating the unreferenced state as time moves forward.\n\t\t *\n\t\t * If a node is sweep ready, store and then return it.\n\t\t */\n\t\tconst sweepReadyNodes: string[] = [];\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker === undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.configs.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tnodeStateTracker.updateTracking(currentReferenceTimestampMs);\n\t\t\t\tif (nodeStateTracker.state === UnreferencedState.SweepReady) {\n\t\t\t\t\tsweepReadyNodes.push(nodeId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn sweepReadyNodes;\n\t}\n\n\t/**\n\t * Deletes nodes from both the runtime and garbage collection\n\t * @param sweepReadyNodes - nodes that are ready to be deleted\n\t */\n\tprivate runSweepPhase(sweepReadyNodes: string[], gcData: IGarbageCollectionData) {\n\t\t// TODO: GC:Validation - validate that removed routes are not double deleted\n\t\t// TODO: GC:Validation - validate that the child routes of removed routes are deleted as well\n\t\tconst sweptRoutes = this.runtime.deleteSweepReadyNodes(sweepReadyNodes);\n\t\tconst updatedGCData = this.deleteSweptRoutes(sweptRoutes, gcData);\n\n\t\tfor (const nodeId of sweptRoutes) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\t// TODO: GC:Validation - assert that the nodeStateTracker is defined\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t\t// TODO: GC:Validation - assert that the deleted node is not a duplicate\n\t\t\tthis.deletedNodes.add(nodeId);\n\t\t}\n\n\t\treturn updatedGCData;\n\t}\n\n\t/**\n\t * @returns IGarbageCollectionData after deleting the sweptRoutes from the gcData\n\t */\n\tprivate deleteSweptRoutes(\n\t\tsweptRoutes: string[],\n\t\tgcData: IGarbageCollectionData,\n\t): IGarbageCollectionData {\n\t\tconst sweptRoutesSet = new Set<string>(sweptRoutes);\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\t\tif (!sweptRoutesSet.has(id)) {\n\t\t\t\tgcNodes[id] = Array.from(outboundRoutes);\n\t\t\t}\n\t\t}\n\n\t\t// TODO: GC:Validation - assert that the nodeId is in gcData\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n\n\t/**\n\t * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n\t * time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be\n\t * updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of\n\t * these objects while there can be in-memory referenced to it:\n\t * 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is\n\t * added, the object may have been accessed and in-memory reference to it added.\n\t * 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were\n\t * unreferenced, they could have been accessed and in-memory reference to them added.\n\t *\n\t * This function identifies nodes that were referenced since the last run.\n\t * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n\t *\n\t * @returns - a list of all nodes referenced from the last local summary until now.\n\t */\n\tprivate findAllNodesReferencedBetweenGCs(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData | undefined,\n\t\tlogger: ITelemetryLogger,\n\t): string[] | undefined {\n\t\t// If we haven't run GC before there is nothing to do.\n\t\t// No previousGCData, means nothing is unreferenced, and there are no reference state trackers to clear\n\t\tif (previousGCData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Find any references that haven't been identified correctly.\n\t\tconst missingExplicitReferences = this.findMissingExplicitReferences(\n\t\t\tcurrentGCData,\n\t\t\tpreviousGCData,\n\t\t\tthis.newReferencesSinceLastRun,\n\t\t);\n\n\t\tif (missingExplicitReferences.length > 0) {\n\t\t\tmissingExplicitReferences.forEach((missingExplicitReference) => {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\tgcNodeId: missingExplicitReference[0],\n\t\t\t\t\tgcRoutes: JSON.stringify(missingExplicitReference[1]),\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t// No references were added since the last run so we don't have to update reference states of any unreferenced\n\t\t// nodes. There is no in between state at this point.\n\t\tif (this.newReferencesSinceLastRun.size === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t/**\n\t\t * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n\t\t * edges that have been added since then. To do this, combine the GC data from the last run and the current\n\t\t * run, and then add the references since last run.\n\t\t *\n\t\t * Note on why we need to combine the data from previous run, current run and all references in between -\n\t\t * 1. We need data from last run because some of its references may have been deleted since then. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 3. We need data from the current run because currently we may not detect when DDSes are referenced:\n\t\t * - We don't require DDSes handles to be stored in a referenced DDS.\n\t\t * - A new data store may have \"root\" DDSes already created and we don't detect them today.\n\t\t */\n\t\tconst gcDataSuperSet = concatGarbageCollectionData(previousGCData, currentGCData);\n\t\tconst newOutboundRoutesSinceLastRun: string[] = [];\n\t\tthis.newReferencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n\t\t\tif (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n\t\t\t} else {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n\t\t\t}\n\t\t\tnewOutboundRoutesSinceLastRun.push(...outboundRoutes);\n\t\t});\n\n\t\t/**\n\t\t * Run GC on the above reference graph starting with root and all new outbound routes. This will generate a\n\t\t * list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,\n\t\t * unreferenced, stop tracking them and remove from unreferenced list.\n\t\t * Note that some of these nodes may be unreferenced now and if so, the current run will mark them as\n\t\t * unreferenced and add unreferenced state.\n\t\t */\n\t\tconst gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\n\t\t\t\"/\",\n\t\t\t...newOutboundRoutesSinceLastRun,\n\t\t]);\n\t\treturn gcResult.referencedNodeIds;\n\t}\n\n\t/**\n\t * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t * @returns - a list of missing explicit references\n\t */\n\tprivate findMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t): [string, string[]][] {\n\t\tassert(\n\t\t\tpreviousGCData !== undefined,\n\t\t\t0x2b7 /* \"Can't validate correctness without GC data from last run\" */,\n\t\t);\n\n\t\tconst currentGraph = Object.entries(currentGCData.gcNodes);\n\t\tconst missingExplicitReferences: [string, string[]][] = [];\n\t\tcurrentGraph.forEach(([nodeId, currentOutboundRoutes]) => {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tcurrentOutboundRoutes.forEach((route) => {\n\t\t\t\tconst nodeType = this.runtime.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tmissingExplicitReferences.push([nodeId, missingExplicitRoutes]);\n\t\t\t}\n\t\t});\n\n\t\t// Ideally missingExplicitReferences should always have a size 0\n\t\treturn missingExplicitReferences;\n\t}\n\n\t/**\n\t * Generates the stats of a garbage collection run from the given results of the run.\n\t * @param gcResult - The result of a GC run.\n\t * @returns the GC stats of the GC run.\n\t */\n\tprivate generateStats(gcResult: IGCResult): IGCStats {\n\t\tconst gcStats: IGCStats = {\n\t\t\tnodeCount: 0,\n\t\t\tdataStoreCount: 0,\n\t\t\tattachmentBlobCount: 0,\n\t\t\tunrefNodeCount: 0,\n\t\t\tunrefDataStoreCount: 0,\n\t\t\tunrefAttachmentBlobCount: 0,\n\t\t\tupdatedNodeCount: 0,\n\t\t\tupdatedDataStoreCount: 0,\n\t\t\tupdatedAttachmentBlobCount: 0,\n\t\t};\n\n\t\tconst updateNodeStats = (nodeId: string, referenced: boolean) => {\n\t\t\tgcStats.nodeCount++;\n\t\t\t// If there is no previous GC data, every node's state is generated and is considered as updated.\n\t\t\t// Otherwise, find out if any node went from referenced to unreferenced or vice-versa.\n\t\t\tconst stateUpdated =\n\t\t\t\tthis.gcDataFromLastRun === undefined ||\n\t\t\t\tthis.unreferencedNodesState.has(nodeId) === referenced;\n\t\t\tif (stateUpdated) {\n\t\t\t\tgcStats.updatedNodeCount++;\n\t\t\t}\n\t\t\tif (!referenced) {\n\t\t\t\tgcStats.unrefNodeCount++;\n\t\t\t}\n\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {\n\t\t\t\tgcStats.dataStoreCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedDataStoreCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefDataStoreCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {\n\t\t\t\tgcStats.attachmentBlobCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfor (const nodeId of gcResult.referencedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, true /* referenced */);\n\t\t}\n\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, false /* referenced */);\n\t\t}\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tprivate logSweepEvents(logger: ITelemetryLogger, currentReferenceTimestampMs: number) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unreferencedNodesState.forEach((nodeStateTracker, nodeId) => {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GCObjectDeleted\",\n\t\t\t\tid: nodeId,\n\t\t\t\ttype: nodeType,\n\t\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.\n\t */\n\tprivate inactiveNodeUsed(\n\t\tusageType: \"Changed\" | \"Loaded\" | \"Revived\",\n\t\tnodeId: string,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tfromNodeId?: string,\n\t\tpackagePath?: readonly string[],\n\t\tcurrentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(),\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is active, skip logging.\n\t\tif (\n\t\t\tcurrentReferenceTimestampMs === undefined ||\n\t\t\tnodeStateTracker.state === UnreferencedState.Active\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We only care about data stores and attachment blobs for this telemetry since GC only marks these objects\n\t\t// as unreferenced. Also, if an inactive DDS is used, the corresponding data store store will also be used.\n\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${nodeId}-${usageType}`;\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst propsToLog = {\n\t\t\tid: nodeId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t...this.createContainerMetadata,\n\t\t\tviaHandle: requestHeaders?.[RuntimeHeaders.viaHandle],\n\t\t\tfromId: fromNodeId,\n\t\t};\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({ ...propsToLog, usageType, state });\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: packagePathToTelemetryProperty(packagePath),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If SweepReady Usage Detection is enabled, the handler may close the interactive container.\n\t\t\t// Once Sweep is fully implemented, this will be removed since the objects will be gone\n\t\t\t// and errors will arise elsewhere in the runtime\n\t\t\tif (state === UnreferencedState.SweepReady) {\n\t\t\t\tthis.sweepReadyUsageHandler.usageDetectedInInteractiveClient({\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\tusageType,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async logUnreferencedEvents(logger: ITelemetryLogger) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(eventProps.id);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: pkg\n\t\t\t\t\t\t? { value: pkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tfromPkg: fromPkg\n\t\t\t\t\t\t? { value: fromPkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcConfigs.d.ts","sourceRoot":"","sources":["../../src/gc/gcConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"gcConfigs.d.ts","sourceRoot":"","sources":["../../src/gc/gcConfigs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAWN,wBAAwB,EACxB,iBAAiB,EAOjB,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAChC,EAAE,EAAE,iBAAiB,EACrB,YAAY,EAAE;IACb,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAChD,QAAQ,EAAE,OAAO,CAAC;CAClB,GACC,wBAAwB,CAmI1B"}
|
package/dist/gc/gcConfigs.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.generateGCConfigs = void 0;
|
|
8
|
-
const
|
|
8
|
+
const container_utils_1 = require("@fluidframework/container-utils");
|
|
9
9
|
const gcDefinitions_1 = require("./gcDefinitions");
|
|
10
10
|
const gcHelpers_1 = require("./gcHelpers");
|
|
11
11
|
/**
|
|
@@ -18,9 +18,8 @@ const gcHelpers_1 = require("./gcHelpers");
|
|
|
18
18
|
* @returns The garbage collector configurations.
|
|
19
19
|
*/
|
|
20
20
|
function generateGCConfigs(mc, createParams) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
21
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
22
22
|
let gcEnabled;
|
|
23
|
-
let sweepEnabled;
|
|
24
23
|
let sessionExpiryTimeoutMs;
|
|
25
24
|
let sweepTimeoutMs;
|
|
26
25
|
let persistedGcFeatureMatrix;
|
|
@@ -37,37 +36,38 @@ function generateGCConfigs(mc, createParams) {
|
|
|
37
36
|
// Existing documents which did not have createParams.metadata blob or had GC disabled have version as 0. For all
|
|
38
37
|
// other existing documents, GC is enabled.
|
|
39
38
|
gcEnabled = gcVersionInBaseSnapshot > 0;
|
|
40
|
-
|
|
41
|
-
sessionExpiryTimeoutMs = (_c = createParams.metadata) === null || _c === void 0 ? void 0 : _c.sessionExpiryTimeoutMs;
|
|
39
|
+
sessionExpiryTimeoutMs = (_a = createParams.metadata) === null || _a === void 0 ? void 0 : _a.sessionExpiryTimeoutMs;
|
|
42
40
|
sweepTimeoutMs =
|
|
43
|
-
(
|
|
44
|
-
persistedGcFeatureMatrix = (
|
|
41
|
+
(_c = (_b = createParams.metadata) === null || _b === void 0 ? void 0 : _b.sweepTimeoutMs) !== null && _c !== void 0 ? _c : computeSweepTimeout(sessionExpiryTimeoutMs); // Backfill old documents that didn't persist this
|
|
42
|
+
persistedGcFeatureMatrix = (_d = createParams.metadata) === null || _d === void 0 ? void 0 : _d.gcFeatureMatrix;
|
|
45
43
|
}
|
|
46
44
|
else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
const tombstoneGeneration = createParams.gcOptions[gcDefinitions_1.gcTombstoneGenerationOptionName];
|
|
46
|
+
const sweepGeneration = createParams.gcOptions[gcDefinitions_1.gcSweepGenerationOptionName];
|
|
47
|
+
// Sweep should not be enabled (via sweepGeneration value) without enabling GC mark phase.
|
|
48
|
+
if (sweepGeneration !== undefined && createParams.gcOptions.gcAllowed === false) {
|
|
49
|
+
throw new container_utils_1.UsageError("GC sweep phase cannot be enabled without enabling GC mark phase");
|
|
51
50
|
}
|
|
52
51
|
// This Test Override only applies for new containers
|
|
53
52
|
const testOverrideSweepTimeoutMs = mc.config.getNumber("Fluid.GarbageCollection.TestOverride.SweepTimeoutMs");
|
|
54
53
|
// For new documents, GC is enabled by default. It can be explicitly disabled by setting the gcAllowed
|
|
55
54
|
// flag in GC options to false.
|
|
56
55
|
gcEnabled = createParams.gcOptions.gcAllowed !== false;
|
|
57
|
-
// The sweep phase has to be explicitly enabled by setting the sweepAllowed flag in GC options to true.
|
|
58
|
-
sweepEnabled = createParams.gcOptions.sweepAllowed === true;
|
|
59
56
|
// Set the Session Expiry if GC is enabled and session expiry flag isn't explicitly set to false.
|
|
60
57
|
if (gcEnabled && mc.config.getBoolean(gcDefinitions_1.runSessionExpiryKey) !== false) {
|
|
61
58
|
sessionExpiryTimeoutMs =
|
|
62
|
-
(
|
|
59
|
+
(_e = createParams.gcOptions.sessionExpiryTimeoutMs) !== null && _e !== void 0 ? _e : gcDefinitions_1.defaultSessionExpiryDurationMs;
|
|
63
60
|
}
|
|
64
61
|
sweepTimeoutMs = testOverrideSweepTimeoutMs !== null && testOverrideSweepTimeoutMs !== void 0 ? testOverrideSweepTimeoutMs : computeSweepTimeout(sessionExpiryTimeoutMs);
|
|
65
|
-
if (
|
|
62
|
+
if (tombstoneGeneration !== undefined || sweepGeneration !== undefined) {
|
|
66
63
|
persistedGcFeatureMatrix = {
|
|
67
|
-
tombstoneGeneration
|
|
64
|
+
tombstoneGeneration,
|
|
65
|
+
sweepGeneration,
|
|
68
66
|
};
|
|
69
67
|
}
|
|
70
68
|
}
|
|
69
|
+
// Is sweepEnabled for this document?
|
|
70
|
+
const sweepEnabled = (0, gcHelpers_1.shouldAllowGcSweep)(persistedGcFeatureMatrix !== null && persistedGcFeatureMatrix !== void 0 ? persistedGcFeatureMatrix : {} /* persistedGenerations */, createParams.gcOptions[gcDefinitions_1.gcSweepGenerationOptionName] /* currentGeneration */);
|
|
71
71
|
/**
|
|
72
72
|
* Whether GC should run or not. The following conditions have to be met to run sweep:
|
|
73
73
|
*
|
|
@@ -77,7 +77,7 @@ function generateGCConfigs(mc, createParams) {
|
|
|
77
77
|
*
|
|
78
78
|
* These conditions can be overridden via runGCKey feature flag.
|
|
79
79
|
*/
|
|
80
|
-
const shouldRunGC = (
|
|
80
|
+
const shouldRunGC = (_f = mc.config.getBoolean(gcDefinitions_1.runGCKey)) !== null && _f !== void 0 ? _f :
|
|
81
81
|
// GC must be enabled for the document.
|
|
82
82
|
(gcEnabled &&
|
|
83
83
|
// GC must not be disabled via GC options.
|
|
@@ -89,24 +89,26 @@ function generateGCConfigs(mc, createParams) {
|
|
|
89
89
|
* 2. Sweep timeout should be available. Without this, we wouldn't know when an object should be deleted.
|
|
90
90
|
* 3. The driver must implement the policy limiting the age of snapshots used for loading. Otherwise
|
|
91
91
|
* the Sweep Timeout calculation is not valid. We use the persisted value to ensure consistency over time.
|
|
92
|
-
* 4. Sweep should be enabled for this container
|
|
92
|
+
* 4. Sweep should be enabled for this container. This can be overridden via runSweep
|
|
93
93
|
* feature flag.
|
|
94
94
|
*/
|
|
95
95
|
const shouldRunSweep = shouldRunGC &&
|
|
96
96
|
sweepTimeoutMs !== undefined &&
|
|
97
|
-
((
|
|
97
|
+
((_g = mc.config.getBoolean(gcDefinitions_1.runSweepKey)) !== null && _g !== void 0 ? _g : sweepEnabled);
|
|
98
98
|
// Override inactive timeout if test config or gc options to override it is set.
|
|
99
|
-
const inactiveTimeoutMs = (
|
|
99
|
+
const inactiveTimeoutMs = (_j = (_h = mc.config.getNumber("Fluid.GarbageCollection.TestOverride.InactiveTimeoutMs")) !== null && _h !== void 0 ? _h : createParams.gcOptions.inactiveTimeoutMs) !== null && _j !== void 0 ? _j : gcDefinitions_1.defaultInactiveTimeoutMs;
|
|
100
100
|
// Inactive timeout must be greater than sweep timeout since a node goes from active -> inactive -> sweep ready.
|
|
101
101
|
if (sweepTimeoutMs !== undefined && inactiveTimeoutMs > sweepTimeoutMs) {
|
|
102
|
-
throw new
|
|
102
|
+
throw new container_utils_1.UsageError("inactive timeout should not be greater than the sweep timeout");
|
|
103
103
|
}
|
|
104
104
|
// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
|
|
105
|
-
const testMode = (
|
|
105
|
+
const testMode = (_k = mc.config.getBoolean(gcDefinitions_1.gcTestModeKey)) !== null && _k !== void 0 ? _k : createParams.gcOptions.runGCInTestMode === true;
|
|
106
106
|
// Whether we are running in tombstone mode. This is enabled by default if sweep won't run. It can be disabled
|
|
107
107
|
// via feature flags.
|
|
108
108
|
const tombstoneMode = !shouldRunSweep && mc.config.getBoolean(gcDefinitions_1.disableTombstoneKey) !== true;
|
|
109
109
|
const runFullGC = createParams.gcOptions.runFullGC;
|
|
110
|
+
// If version upgrade is not enabled, fall back to the stable GC version.
|
|
111
|
+
const gcVersionInEffect = mc.config.getBoolean(gcDefinitions_1.gcVersionUpgradeToV2Key) === true ? gcDefinitions_1.currentGCVersion : gcDefinitions_1.stableGCVersion;
|
|
110
112
|
return {
|
|
111
113
|
gcEnabled,
|
|
112
114
|
sweepEnabled,
|
|
@@ -120,6 +122,7 @@ function generateGCConfigs(mc, createParams) {
|
|
|
120
122
|
inactiveTimeoutMs,
|
|
121
123
|
persistedGcFeatureMatrix,
|
|
122
124
|
gcVersionInBaseSnapshot,
|
|
125
|
+
gcVersionInEffect,
|
|
123
126
|
};
|
|
124
127
|
}
|
|
125
128
|
exports.generateGCConfigs = generateGCConfigs;
|