@fluidframework/container-runtime 0.56.8 → 0.56.11

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.
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAUhF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAEH,sBAAsB,EAEtB,6BAA6B,EAC7B,qBAAqB,EACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EAEvB,MAAM,+BAA+B,CAAC;AAQvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAGH,yBAAyB,EAI5B,MAAM,iBAAiB,CAAC;AAMzB,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B,eAAO,MAAM,YAAY,SAAS,CAAC;AAanC,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,yEAAyE;AACzE,MAAM,WAAW,QAAQ;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC7B;AAED,qFAAqF;AACrF,MAAM,WAAW,yBAAyB;IACtC,mFAAmF;IACnF,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,0DAA0D;IAC1D,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC7D,oFAAoF;IACpF,gBAAgB,CAAC,UA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MAAM,EAAE,6BAA6B,CAAC,CAAC;IAI7F;;;OAGG;IACU,2BAA2B,CACpC,MAAM,EAAE,oBAAoB,EAC5B,gBAAgB,EAAE,gBAAgB,GACnC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;OAEG;IACI,WAAW,CAAC,EAAE,EAAE,MAAM;IAYtB,OAAO,IAAI,IAAI;IAOtB;;;;;;OAMG;IACI,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAMlE;;OAEG;YACW,kCAAkC;IAQhD;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IAkDjC;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;CA6CvC"}
@@ -126,8 +126,12 @@ class GarbageCollector {
126
126
  }
127
127
  // If session expiry is enabled, we need to close the container when the timeout expires
128
128
  if (this.sessionExpiryTimeoutMs !== undefined) {
129
- const expiryMs = this.sessionExpiryTimeoutMs;
130
- this.sessionExpiryTimer = setTimeout(() => this.closeFn(new container_utils_1.ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);
129
+ const timeoutMs = this.sessionExpiryTimeoutMs;
130
+ setLongTimeout(timeoutMs, () => {
131
+ this.closeFn(new container_utils_1.ClientSessionExpiredError(`Client session expired.`, timeoutMs));
132
+ }, (timer) => {
133
+ this.sessionExpiryTimer = timer;
134
+ });
131
135
  }
132
136
  // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
133
137
  // latest tracked GC version. For new documents, we will be writing the first summary with the current version.
@@ -574,4 +578,23 @@ async function getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob) {
574
578
  }
575
579
  return rootGCState;
576
580
  }
581
+ /**
582
+ * setLongTimeout is used for timeouts longer than setTimeout's ~24.8 day max
583
+ * @param timeoutMs - the total time the timeout needs to last in ms
584
+ * @param timeoutFn - the function to execute when the timer ends
585
+ * @param setTimerFn - the function used to update your timer variable
586
+ */
587
+ function setLongTimeout(timeoutMs, timeoutFn, setTimerFn) {
588
+ // The setTimeout max is 24.8 days before looping occurs.
589
+ const maxTimeout = 2147483647;
590
+ let timer;
591
+ if (timeoutMs > maxTimeout) {
592
+ const newTimeoutMs = timeoutMs - maxTimeout;
593
+ timer = setTimeout(() => setLongTimeout(newTimeoutMs, timeoutFn, setTimerFn), maxTimeout);
594
+ }
595
+ else {
596
+ timer = setTimeout(() => timeoutFn(), timeoutMs);
597
+ }
598
+ setTimerFn(timer);
599
+ }
577
600
  //# sourceMappingURL=garbageCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0E;AAE1E,qEAA4E;AAC5E,yEAO2C;AAE3C,6EAM6C;AAC7C,iEAIuC;AACvC,qEAK0C;AAG1C,6CAAuD;AACvD,mDAOyB;AAEzB,yDAAyD;AACzD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,sCAAsC;AACzB,QAAA,SAAS,GAAG,IAAI,CAAC;AAC9B,sDAAsD;AACzC,QAAA,YAAY,GAAG,MAAM,CAAC;AAEnC,wCAAwC;AACxC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,kDAAkD;AAClD,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAC3D,8CAA8C;AAC9C,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qEAAqE;AACrE,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AA2DjE;;;GAGG;AACH,MAAM,wBAAwB;IAO1B,YACoB,uBAA+B,EAC/C,iBAAyB;QADT,4BAAuB,GAAvB,uBAAuB,CAAQ;QAP3C,aAAQ,GAAY,KAAK,CAAC;QAClC,mHAAmH;QACnH,2BAA2B;QACV,yB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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 { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ClientSessionExpiredError } from \"@fluidframework/container-utils\";\nimport {\n cloneGCData,\n concatGarbageCollectionStates,\n concatGarbageCollectionData,\n IGCResult,\n runGarbageCollection,\n unpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionState,\n IGarbageCollectionDetailsBase,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ReadAndParseBlob,\n RefreshSummaryResult,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n loggerToMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n } from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n metadataBlobName,\n ReadFluidDataStoreAttributes,\n dataStoreAttributesBlobName,\n} from \"./summaryFormat\";\n\n/** This is the current version of garbage collection. */\nconst GCVersion = 1;\n\n// The key for the GC tree in summary.\nexport const gcTreeKey = \"gc\";\n// They prefix for GC blobs in the GC tree in summary.\nexport const gcBlobPrefix = \"__gc\";\n\n// Feature gate key to turn GC on / off.\nconst runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC test mode on / off.\nconst gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to turn GC sweep on / off.\nconst runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to write GC data at the root of the summary tree.\nconst writeAtRootKey = \"Fluid.GarbageCollection.WriteDataAtRoot\";\n\nconst defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\n/** The used state statistics of a node. */\nexport interface IUsedStateStats {\n totalNodeCount: number;\n unusedNodeCount: number;\n}\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n totalNodes: number;\n deletedNodes: number;\n totalDataStores: number;\n deletedDataStores: number;\n}\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n /** Before GC runs, called to notify the runtime to update any pending GC state. */\n updateStateBeforeGC(): Promise<void>;\n /** Returns the garbage collection data of the runtime. */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n /** After GC has run, called to notify the runtime of routes that are used in it. */\n updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): IUsedStateStats;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n /** Tells whether GC should run or not. */\n readonly shouldRunGC: boolean;\n /** The time in ms to expire a session for a client for gc. */\n readonly sessionExpiryTimeoutMs: number | undefined;\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n readonly gcSummaryFeatureVersion: number;\n /** Tells whether the GC state in summary needs to be reset in the next summary. */\n readonly summaryStateNeedsReset: boolean;\n /** Tells whether GC data should be written to the root of the summary tree. */\n readonly writeDataAtRoot: boolean;\n /** Run garbage collection and update the reference / used state of the system. */\n collectGarbage(\n options: { logger?: ITelemetryLogger, runGC?: boolean, runSweep?: boolean, fullGC?: boolean },\n ): Promise<IGCStats>;\n /** Summarizes the GC data and returns it as a summary tree. */\n summarize(): ISummaryTreeWithStats | undefined;\n /** Returns a map of each data store id to its GC details in the base summary. */\n getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;\n /** Called when the latest summary of the system has been refreshed. */\n latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;\n /** Called when a node is changed. Used to detect and log when an inactive node is changed. */\n nodeChanged(id: string): void;\n /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n addedOutboundReference(fromNodeId: string, toNodeId: string): void;\n dispose(): void;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets\n * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).\n */\nclass UnreferencedStateTracker {\n private inactive: boolean = false;\n // Keeps track of all inactive events that are logged. This is used to limit the log generation for each event to 1\n // so that it is not noisy.\n private readonly inactiveEventsLogged: Set<string> = new Set();\n private readonly timer: Timer | undefined;\n\n constructor(\n public readonly unreferencedTimestampMs: number,\n inactiveTimeoutMs: number,\n ) {\n // If the timeout has already expired, the node should become inactive immediately. Otherwise, start a timer of\n // inactiveTimeoutMs after which the node will become inactive.\n if (inactiveTimeoutMs <= 0) {\n this.inactive = true;\n } else {\n this.timer = new Timer(inactiveTimeoutMs, () => { this.inactive = true; });\n this.timer.start();\n }\n }\n\n /** Stop tracking this node. Reset the unreferenced timer, if any, and reset inactive state. */\n public stopTracking() {\n this.timer?.clear();\n this.inactive = false;\n }\n\n /** Logs an error with the given properties if the node is inactive. */\n public logIfInactive(\n logger: ITelemetryLogger,\n eventName: string,\n currentTimestampMs: number,\n deleteTimeoutMs: number,\n inactiveNodeId: string,\n ) {\n if (this.inactive && !this.inactiveEventsLogged.has(eventName)) {\n logger.sendErrorEvent({\n eventName,\n age: currentTimestampMs - this.unreferencedTimestampMs,\n timeout: deleteTimeoutMs,\n id: inactiveNodeId,\n });\n this.inactiveEventsLogged.add(eventName);\n }\n }\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 */\nexport class GarbageCollector implements IGarbageCollector {\n public static create(\n provider: IGarbageCollectionRuntime,\n gcOptions: IGCRuntimeOptions,\n deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n getCurrentTimestampMs: () => number,\n closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ): IGarbageCollector {\n return new GarbageCollector(\n provider,\n gcOptions,\n deleteUnusedRoutes,\n getCurrentTimestampMs,\n closeFn,\n baseSnapshot,\n readAndParseBlob,\n baseLogger,\n existing,\n metadata,\n );\n }\n\n /**\n * Tells whether GC should be run based on the GC options and local storage flags.\n */\n public readonly shouldRunGC: boolean;\n\n /**\n * The time in ms to expire a session for a client for gc.\n */\n public readonly sessionExpiryTimeoutMs: number | undefined;\n\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n public get gcSummaryFeatureVersion(): number {\n return this.gcEnabled ? this.currentGCVersion : 0;\n }\n\n /**\n * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n * 3. The GC version in the latest summary is different from the current GC version. This can happen if:\n * 3.1. The summary this client loaded with has data from a different GC version.\n * 3.2. This client's latest summary was updated from a snapshot that has a different GC version.\n */\n public get summaryStateNeedsReset(): boolean {\n return this.initialStateNeedsReset ||\n (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);\n }\n\n /**\n * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly gcEnabled: boolean;\n private readonly shouldRunSweep: boolean;\n private readonly testMode: boolean;\n private readonly mc: MonitoringContext;\n\n /**\n * Tells whether the GC data should be written to the root of the summary tree.\n */\n private _writeDataAtRoot: boolean = false;\n public get writeDataAtRoot(): boolean {\n return this._writeDataAtRoot;\n }\n\n /**\n * Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:\n * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n * a document and the first time GC is enabled after is was disabled before.\n *\n * Note that the state needs reset only for the very first time summary is generated by this client. After that, the\n * state will be up-to-date and this flag will be reset.\n */\n private initialStateNeedsReset: boolean = false;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary being tracked.\n private latestSummaryGCVersion: GCVersion;\n\n // Keeps track of the GC state from the last run.\n private gcDataFromLastRun: IGarbageCollectionData | undefined;\n // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n // outbound routes from that node.\n private readonly referencesSinceLastRun: Map<string, string[]> = new Map();\n\n // Promise when resolved initializes the base state of the nodes from the base summary state.\n private readonly initializeBaseStateP: Promise<void>;\n // The map of data store ids to their GC details in the base summary returned in getDataStoreGCDetails().\n private readonly dataStoreGCDetailsP: Promise<Map<string, IGarbageCollectionDetailsBase>>;\n // The time after which an unreferenced node can be deleted. Currently, we only set the node's state to expired.\n private readonly deleteTimeoutMs: number;\n // Map of node ids to their unreferenced state tracker.\n private readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n // The timeout responsible for closing the container when the session has expired\n private sessionExpiryTimer?: ReturnType<typeof setTimeout>;\n\n protected constructor(\n private readonly provider: IGarbageCollectionRuntime,\n private readonly gcOptions: IGCRuntimeOptions,\n /** After GC has run, called to delete objects in the runtime whose routes are unused. */\n private readonly deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n /** Returns the current timestamp to be assigned to nodes that become unreferenced. */\n private readonly getCurrentTimestampMs: () => number,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ) {\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(baseLogger, \"GarbageCollector\"));\n\n this.deleteTimeoutMs = this.gcOptions.deleteTimeoutMs ?? defaultDeleteTimeoutMs;\n\n let prevSummaryGCVersion: number | undefined;\n\n // GC can only be enabled during creation. After that, it can never be enabled again. So, for existing\n // documents, we get this information from the metadata blob. Similarly the session timeout should be\n // consistent across all clients, thus we grab it as well from the metadata blob, and set it once on creation.\n if (existing) {\n prevSummaryGCVersion = getGCVersion(metadata);\n // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n // other exsiting documents, GC is enabled.\n this.gcEnabled = prevSummaryGCVersion > 0;\n this.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n } else {\n // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.\n this.gcEnabled = gcOptions.gcAllowed === true;\n this.sessionExpiryTimeoutMs = this.gcOptions.gcTestSessionTimeoutMs;\n }\n\n // If session expiry is enabled, we need to close the container when the timeout expires\n if (this.sessionExpiryTimeoutMs !== undefined) {\n const expiryMs = this.sessionExpiryTimeoutMs;\n this.sessionExpiryTimer = setTimeout(() => this.closeFn(\n new ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);\n }\n\n // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n // latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n this.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = this.mc.config.getBoolean(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // GC must not be disabled via GC options.\n && !gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (this.mc.config.getBoolean(runSweepKey) ?? gcOptions.runSweep === true)\n && this.sessionExpiryTimer !== undefined;\n\n // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? gcOptions.runGCInTestMode === true;\n\n /**\n * Enable resetting initial state once the following issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n * Currently, the GC tree is not written at root, so we don't know if the base snapshot contains GC tree or not.\n */\n // The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't contain\n // GC tree and GC is enabled.\n // const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;\n // this.initialStateNeedsReset = gcTreePresent ? !this.shouldRunGC : this.shouldRunGC;\n\n // If `writeDataAtRoot` setting is true, write the GC data into the root of the summary tree. We do this so that\n // the roll out can be staged. Once its rolled out everywhere, we will start writing at root by default.\n this._writeDataAtRoot = this.mc.config.getBoolean(writeAtRootKey) ?? this.gcOptions.writeDataAtRoot === true;\n\n // Get the GC state from the GC blob in the base snapshot. Use LazyPromise because we only want to do\n // this once since it involves fetching blobs from storage which is expensive.\n const baseSummaryStateP = new LazyPromise<IGarbageCollectionState | undefined>(async () => {\n if (baseSnapshot === undefined) {\n return undefined;\n }\n\n // For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If the GC tree is written at root, we should also do the same.\n this._writeDataAtRoot = true;\n return getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob);\n }\n\n // back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n // consolidate into IGarbageCollectionState format.\n // Add a node for the root node that is not present in older snapshot format.\n const gcState: IGarbageCollectionState = { gcNodes: { \"/\": { outboundRoutes: [] } } };\n const dataStoreSnaphotTree = getSummaryForDatastores(baseSnapshot, metadata);\n assert(dataStoreSnaphotTree !== undefined,\n 0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */);\n for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {\n const blobId = dsSnapshotTree.blobs[gcBlobKey];\n if (blobId === undefined) {\n continue;\n }\n\n const gcSummaryDetails = await readAndParseBlob<IGarbageCollectionDetailsBase>(blobId);\n // If there are no nodes for this data store, skip it.\n if (gcSummaryDetails.gcData?.gcNodes === undefined) {\n continue;\n }\n\n const dsRootId = `/${dsId}`;\n // Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n // Construct that entry by adding root data store ids to its outbound routes.\n const initialSnapshotDetails = await readAndParseBlob<ReadFluidDataStoreAttributes>(\n dsSnapshotTree.blobs[dataStoreAttributesBlobName],\n );\n if (initialSnapshotDetails.isRootDataStore) {\n gcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n }\n\n for (const [id, outboundRoutes] of Object.entries(gcSummaryDetails.gcData.gcNodes)) {\n // Prefix the data store id to the GC node ids to make them relative to the root from being\n // relative to the data store. Similar to how its done in DataStore::getGCData.\n const rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n gcState.gcNodes[rootId] = { outboundRoutes: Array.from(outboundRoutes) };\n }\n assert(gcState.gcNodes[dsRootId] !== undefined,\n 0x2a9 /* `GC nodes for data store ${dsId} not in GC blob` */);\n gcState.gcNodes[dsRootId].unreferencedTimestampMs = gcSummaryDetails.unrefTimestamp;\n }\n\n // If there is only one node (root node just added above), either GC is disabled or we are loading from the\n // very first summary generated by detached container. In both cases, GC was not run - return undefined.\n return Object.keys(gcState.gcNodes).length === 1 ? undefined : gcState;\n });\n\n // Set up the initializer which initializes the base GC state from the base snapshot. Use lazy promise because\n // we only do this once - the very first time we run GC.\n this.initializeBaseStateP = new LazyPromise<void>(async () => {\n const currentTimestampMs = this.getCurrentTimestampMs();\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return;\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n const unreferencedTimestampMs = nodeData.unreferencedTimestampMs;\n if (unreferencedTimestampMs !== undefined) {\n // Get how long it has been since the node was unreferenced. Start a timeout for the remaining time\n // left for it to be eligible for deletion.\n const unreferencedDurationMs = currentTimestampMs - unreferencedTimestampMs;\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n unreferencedTimestampMs,\n this.deleteTimeoutMs - unreferencedDurationMs,\n ),\n );\n }\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n this.gcDataFromLastRun = { gcNodes };\n });\n\n // Get the GC details for each data store from the GC state in the base summary. This is returned in\n // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.\n this.dataStoreGCDetailsP = new LazyPromise<Map<string, IGarbageCollectionDetailsBase>>(async () => {\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return new Map();\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the base summary to get the routes used in each node in the container.\n // This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n // each node in the summary.\n const usedRoutes = runGarbageCollection(\n gcNodes,\n [ \"/\" ],\n this.mc.logger,\n ).referencedNodeIds;\n\n const dataStoreGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });\n // Currently, the data stores write the GC data. So, we need to update it's base GC details with the\n // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));\n if (dataStoreGCDetails !== undefined) {\n dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;\n }\n }\n }\n return dataStoreGCDetailsMap;\n });\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(\n options: {\n /** Logger to use for logging GC events */\n logger?: ITelemetryLogger,\n /** True to run GC sweep phase after the mark phase */\n runSweep?: boolean,\n /** True to generate full GC data */\n fullGC?: boolean,\n },\n ): Promise<IGCStats> {\n const {\n logger = this.mc.logger,\n runSweep = this.shouldRunSweep,\n fullGC = this.gcOptions.runFullGC === true || this.summaryStateNeedsReset,\n } = options;\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n await this.initializeBaseStateP;\n\n // Let the runtime update its pending state before GC runs.\n await this.provider.updateStateBeforeGC();\n\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n\n // Get the runtime's GC data and run GC on the reference graph in it.\n const gcData = await this.provider.getGCData(fullGC);\n\n this.updateStateSinceLatestRun(gcData);\n\n const gcResult = runGarbageCollection(\n gcData.gcNodes,\n [ \"/\" ],\n logger,\n );\n\n const currentTimestampMs = this.getCurrentTimestampMs();\n // Update the current state of the system based on the GC run.\n this.updateCurrentState(gcData, gcResult, currentTimestampMs);\n\n const dataStoreUsedStateStats =\n this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentTimestampMs);\n\n if (runSweep) {\n // Placeholder for running sweep logic.\n }\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = gcResult.deletedNodeIds.length;\n gcStats.totalNodes = gcResult.referencedNodeIds.length + gcResult.deletedNodeIds.length;\n gcStats.deletedDataStores = dataStoreUsedStateStats.unusedNodeCount;\n gcStats.totalDataStores = dataStoreUsedStateStats.totalNodeCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.testMode) {\n this.deleteUnusedRoutes(gcResult.deletedNodeIds);\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n },\n { end: true, cancel: \"error\" });\n }\n\n /**\n * Summarizes the GC data and returns it as a summary tree.\n * We current write the entire GC state in a single blob. This can be modified later to write multiple\n * blobs. All the blob keys should start with `gcBlobPrefix`.\n */\n public summarize(): ISummaryTreeWithStats | undefined {\n if (!this.shouldRunGC || this.gcDataFromLastRun === undefined) {\n return;\n }\n\n const gcState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n gcState.gcNodes[nodeId] = {\n outboundRoutes,\n unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n };\n }\n\n const builder = new SummaryTreeBuilder();\n builder.addBlob(`${gcBlobPrefix}_root`, JSON.stringify(gcState));\n return builder.getSummaryTree();\n }\n\n /**\n * Returns a map of data store ids to their base GC details generated from the base summary.This is used to\n * initialize the GC state of data stores.\n */\n public async getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>> {\n return this.dataStoreGCDetailsP;\n }\n\n /**\n * Called when the latest summary of the system has been refreshed. This will be used to update the state of the\n * latest summary tracked.\n */\n public async latestSummaryStateRefreshed(\n result: RefreshSummaryResult,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // After a summary is successfully submitted and ack'd by this client, the GC state should have been reset in\n // the summary and doesn't need to be reset anymore.\n this.initialStateNeedsReset = false;\n\n if (!this.shouldRunGC || !result.latestSummaryUpdated) {\n return;\n }\n\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Basically, it was written in the current GC version.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update latest GC version from the snapshot in the result as\n // that is now the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot, readAndParseBlob);\n }\n\n /**\n * Called when a node with the given id is changed. If the node is inactive, log an error.\n */\n public nodeChanged(id: string) {\n // Prefix \"/\" if needed to make it relative to the root.\n const nodeId = id.startsWith(\"/\") ? id : `/${id}`;\n this.unreferencedNodesState.get(nodeId)?.logIfInactive(\n this.mc.logger,\n \"inactiveObjectChanged\",\n this.getCurrentTimestampMs(),\n this.deleteTimeoutMs,\n nodeId,\n );\n }\n\n public dispose(): void {\n if (this.sessionExpiryTimer !== undefined) {\n clearTimeout(this.sessionExpiryTimer);\n this.sessionExpiryTimer = undefined;\n }\n }\n\n /**\n * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n * referenced between summaries so that their unreferenced timestamp can be reset.\n *\n * @param fromNodeId - The node from which the reference is added.\n * @param toNodeId - The node to which the reference is added.\n */\n public addedOutboundReference(fromNodeId: string, toNodeId: string) {\n const outboundRoutes = this.referencesSinceLastRun.get(fromNodeId) ?? [];\n outboundRoutes.push(toNodeId);\n this.referencesSinceLastRun.set(fromNodeId, outboundRoutes);\n }\n\n /**\n * Update the latest summary GC version from the metadata blob in the given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob) {\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n /**\n * Updates the state of the system as per the current GC run. It does the following:\n * 1. Sets up the current GC state as per the gcData.\n * 2. Starts tracking for nodes that have become unreferenced in this run.\n * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n * @param gcData - The data representing the reference graph on which GC is run.\n * @param gcResult - The result of the GC run on the gcData.\n * @param currentTimestampMs - The current timestamp to be used for unreferenced nodes' timestamp.\n */\n private updateCurrentState(gcData: IGarbageCollectionData, gcResult: IGCResult, currentTimestampMs: number) {\n this.gcDataFromLastRun = cloneGCData(gcData);\n this.referencesSinceLastRun.clear();\n\n // Iterate through the deleted nodes and start tracking if they became unreferenced in this run.\n for (const nodeId of gcResult.deletedNodeIds) {\n // The time when the node became unreferenced. This is added to the current GC state.\n let unreferencedTimestampMs: number = currentTimestampMs;\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n unreferencedTimestampMs = nodeStateTracker.unreferencedTimestampMs;\n } else {\n // Start tracking this node as it became unreferenced in this run.\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(unreferencedTimestampMs, this.deleteTimeoutMs),\n );\n }\n }\n\n // Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // If this node has been unreferenced for longer than deleteTimeoutMs and is being referenced,\n // log an error as this may mean the deleteTimeoutMs is not long enough.\n nodeStateTracker.logIfInactive(\n this.mc.logger,\n \"inactiveObjectRevived\",\n currentTimestampMs,\n this.deleteTimeoutMs,\n nodeId,\n );\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n * time. It's possible that nodes transition from `unreferenced -> referenced -> unreferenced` between two runs. The\n * unreferenced timestamp of such nodes needs to be reset as they may have been accessed when they were referenced.\n *\n * This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.\n * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n */\n private updateStateSinceLatestRun(currentGCData: IGarbageCollectionData) {\n // If we haven't run GC before or no references were added since the last run, there is nothing to do.\n if (this.gcDataFromLastRun === undefined || this.referencesSinceLastRun.size === 0) {\n return;\n }\n\n // Validate that we have identified all references correctly.\n this.validateReferenceCorrectness(currentGCData);\n\n /**\n * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n * edges that have been added since then. To do this, combine the GC data from the last run and the current\n * run, and then add the references since last run.\n *\n * Note on why we need to combine the data from previous run, current run and all references in between -\n * 1. We need data from last run because some of its references may have been deleted since then. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 3. We need data from the current run because currently we may not detect when DDSs are referenced:\n * - We don't require DDSs handles to be stored in a referenced DDS. For this, we need GC at DDS level\n * which is tracked by https://github.com/microsoft/FluidFramework/issues/8470.\n * - A new data store may have \"root\" DDSs already created and we don't detect them today.\n */\n const gcDataSuperSet = concatGarbageCollectionData(this.gcDataFromLastRun, currentGCData);\n this.referencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n } else {\n gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n }\n });\n\n /**\n * Run GC on the above reference graph to find all nodes that are referenced. For each one, if they are\n * unreferenced, stop tracking them and remove from unreferenced list.\n * Some of these nodes may be unreferenced now and if so, the current run will add unreferenced state for them.\n */\n const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\"/\"], this.mc.logger);\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Validates that all new references are correctly identified and processed. The basic principle for validation is\n * that we should not have new references in the reference graph (GC data) that have not been notified to the\n * garbage collector via `referenceAdded`.\n * We validate that the references in the current reference graph should be a subset of the references in the last\n * run's reference graph + references since the last run.\n * @param currentGCData - The GC data (reference graph) from the current GC run.\n */\n private validateReferenceCorrectness(currentGCData: IGarbageCollectionData) {\n assert(this.gcDataFromLastRun !== undefined, 0x2b7\n /* \"Can't validate correctness without GC data from last run\" */);\n\n // Get a list of all the outbound routes (or references) in the current GC data.\n const currentReferences: string[] = [];\n for (const [nodeId, outboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n /**\n * Remove routes from a child node to its parent which is added implicitly by the runtime. For instance,\n * each adds its data store as an outbound route to mark it as referenced if the DDS is referenced.\n * We won't get any explicit notification for these references so they must be removed before validation.\n */\n const explicitRoutes = outboundRoutes.filter((route) => !nodeId.startsWith(route));\n currentReferences.push(...explicitRoutes);\n }\n\n // Get a list of outbound routes (or references) from the last run's GC data plus references added since the\n // last run that were notified via `referenceAdded`.\n const explicitReferences: string[] = [];\n for (const [, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n explicitReferences.push(...outboundRoutes);\n }\n this.referencesSinceLastRun.forEach((outboundRoutes: string[]) => {\n explicitReferences.push(...outboundRoutes);\n });\n\n // Validate that the current reference graph doesn't have references that we are not already aware of. If this\n // happens, it might indicate data corruption since we may delete objects prematurely.\n currentReferences.forEach((route: string) => {\n // Validate references for data stores only whose routes are of the format \"/dataStoreId\". Currently, layers\n // below data stores don't have GC implemented so there is no guarantee their references will be notified.\n if (route.split(\"/\").length === 2 && !explicitReferences.includes(route)) {\n /**\n * The following log will be enabled once this issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n */\n // We should ideally throw a data corruption error here. However, send an error for now until we have\n // implemented sweep and have reasonable confidence in the sweep process.\n // this.mc.logger.sendErrorEvent({\n // eventName: \"gcUnknownOutboundRoute\",\n // route,\n // });\n }\n });\n }\n}\n\n/**\n * Gets the garbage collection state from the given snapshot tree. The GC state may be written into multiple blobs.\n * Merge the GC state from all such blobs and return the merged GC state.\n*/\nasync function getGCStateFromSnapshot(\n gcSnapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<IGarbageCollectionState> {\n let rootGCState: IGarbageCollectionState = { gcNodes: {} };\n for (const key of Object.keys(gcSnapshotTree.blobs)) {\n // Skip blobs that do not stsart with the GC prefix.\n if (!key.startsWith(gcBlobPrefix)) {\n continue;\n }\n\n const blobId = gcSnapshotTree.blobs[key];\n if (blobId === undefined) {\n continue;\n }\n const gcState = await readAndParseBlob<IGarbageCollectionState>(blobId);\n assert(gcState !== undefined, 0x2ad /* \"GC blob missing from snapshot\" */);\n // Merge the GC state of this blob into the root GC state.\n rootGCState = concatGarbageCollectionStates(rootGCState, gcState);\n }\n return rootGCState;\n}\n"]}
1
+ {"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0E;AAE1E,qEAA4E;AAC5E,yEAO2C;AAE3C,6EAM6C;AAC7C,iEAIuC;AACvC,qEAK0C;AAG1C,6CAAuD;AACvD,mDAOyB;AAEzB,yDAAyD;AACzD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,sCAAsC;AACzB,QAAA,SAAS,GAAG,IAAI,CAAC;AAC9B,sDAAsD;AACzC,QAAA,YAAY,GAAG,MAAM,CAAC;AAEnC,wCAAwC;AACxC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,kDAAkD;AAClD,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAC3D,8CAA8C;AAC9C,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qEAAqE;AACrE,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AA2DjE;;;GAGG;AACH,MAAM,wBAAwB;IAO1B,YACoB,uBAA+B,EAC/C,iBAAyB;QADT,4BAAuB,GAAvB,uBAAuB,CAAQ;QAP3C,aAAQ,GAAY,KAAK,CAAC;QAClC,mHAAmH;QACnH,2BAA2B;QACV,yBAAoB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAO3D,+GAA+G;QAC/G,+DAA+D;QAC/D,IAAI,iBAAiB,IAAI,CAAC,EAAE;YACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;SACxB;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAK,CAAC,iBAAiB,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,IAAI,C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AAE,CAAC,cAAc,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;KAC7F;SAAM;QACH,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC;KACpD;IACD,UAAU,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC","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 { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ClientSessionExpiredError } from \"@fluidframework/container-utils\";\nimport {\n cloneGCData,\n concatGarbageCollectionStates,\n concatGarbageCollectionData,\n IGCResult,\n runGarbageCollection,\n unpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionState,\n IGarbageCollectionDetailsBase,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ReadAndParseBlob,\n RefreshSummaryResult,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n loggerToMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n } from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n metadataBlobName,\n ReadFluidDataStoreAttributes,\n dataStoreAttributesBlobName,\n} from \"./summaryFormat\";\n\n/** This is the current version of garbage collection. */\nconst GCVersion = 1;\n\n// The key for the GC tree in summary.\nexport const gcTreeKey = \"gc\";\n// They prefix for GC blobs in the GC tree in summary.\nexport const gcBlobPrefix = \"__gc\";\n\n// Feature gate key to turn GC on / off.\nconst runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC test mode on / off.\nconst gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to turn GC sweep on / off.\nconst runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to write GC data at the root of the summary tree.\nconst writeAtRootKey = \"Fluid.GarbageCollection.WriteDataAtRoot\";\n\nconst defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\n/** The used state statistics of a node. */\nexport interface IUsedStateStats {\n totalNodeCount: number;\n unusedNodeCount: number;\n}\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n totalNodes: number;\n deletedNodes: number;\n totalDataStores: number;\n deletedDataStores: number;\n}\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n /** Before GC runs, called to notify the runtime to update any pending GC state. */\n updateStateBeforeGC(): Promise<void>;\n /** Returns the garbage collection data of the runtime. */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n /** After GC has run, called to notify the runtime of routes that are used in it. */\n updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): IUsedStateStats;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n /** Tells whether GC should run or not. */\n readonly shouldRunGC: boolean;\n /** The time in ms to expire a session for a client for gc. */\n readonly sessionExpiryTimeoutMs: number | undefined;\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n readonly gcSummaryFeatureVersion: number;\n /** Tells whether the GC state in summary needs to be reset in the next summary. */\n readonly summaryStateNeedsReset: boolean;\n /** Tells whether GC data should be written to the root of the summary tree. */\n readonly writeDataAtRoot: boolean;\n /** Run garbage collection and update the reference / used state of the system. */\n collectGarbage(\n options: { logger?: ITelemetryLogger, runGC?: boolean, runSweep?: boolean, fullGC?: boolean },\n ): Promise<IGCStats>;\n /** Summarizes the GC data and returns it as a summary tree. */\n summarize(): ISummaryTreeWithStats | undefined;\n /** Returns a map of each data store id to its GC details in the base summary. */\n getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;\n /** Called when the latest summary of the system has been refreshed. */\n latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;\n /** Called when a node is changed. Used to detect and log when an inactive node is changed. */\n nodeChanged(id: string): void;\n /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n addedOutboundReference(fromNodeId: string, toNodeId: string): void;\n dispose(): void;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets\n * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).\n */\nclass UnreferencedStateTracker {\n private inactive: boolean = false;\n // Keeps track of all inactive events that are logged. This is used to limit the log generation for each event to 1\n // so that it is not noisy.\n private readonly inactiveEventsLogged: Set<string> = new Set();\n private readonly timer: Timer | undefined;\n\n constructor(\n public readonly unreferencedTimestampMs: number,\n inactiveTimeoutMs: number,\n ) {\n // If the timeout has already expired, the node should become inactive immediately. Otherwise, start a timer of\n // inactiveTimeoutMs after which the node will become inactive.\n if (inactiveTimeoutMs <= 0) {\n this.inactive = true;\n } else {\n this.timer = new Timer(inactiveTimeoutMs, () => { this.inactive = true; });\n this.timer.start();\n }\n }\n\n /** Stop tracking this node. Reset the unreferenced timer, if any, and reset inactive state. */\n public stopTracking() {\n this.timer?.clear();\n this.inactive = false;\n }\n\n /** Logs an error with the given properties if the node is inactive. */\n public logIfInactive(\n logger: ITelemetryLogger,\n eventName: string,\n currentTimestampMs: number,\n deleteTimeoutMs: number,\n inactiveNodeId: string,\n ) {\n if (this.inactive && !this.inactiveEventsLogged.has(eventName)) {\n logger.sendErrorEvent({\n eventName,\n age: currentTimestampMs - this.unreferencedTimestampMs,\n timeout: deleteTimeoutMs,\n id: inactiveNodeId,\n });\n this.inactiveEventsLogged.add(eventName);\n }\n }\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 */\nexport class GarbageCollector implements IGarbageCollector {\n public static create(\n provider: IGarbageCollectionRuntime,\n gcOptions: IGCRuntimeOptions,\n deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n getCurrentTimestampMs: () => number,\n closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ): IGarbageCollector {\n return new GarbageCollector(\n provider,\n gcOptions,\n deleteUnusedRoutes,\n getCurrentTimestampMs,\n closeFn,\n baseSnapshot,\n readAndParseBlob,\n baseLogger,\n existing,\n metadata,\n );\n }\n\n /**\n * Tells whether GC should be run based on the GC options and local storage flags.\n */\n public readonly shouldRunGC: boolean;\n\n /**\n * The time in ms to expire a session for a client for gc.\n */\n public readonly sessionExpiryTimeoutMs: number | undefined;\n\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n public get gcSummaryFeatureVersion(): number {\n return this.gcEnabled ? this.currentGCVersion : 0;\n }\n\n /**\n * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n * 3. The GC version in the latest summary is different from the current GC version. This can happen if:\n * 3.1. The summary this client loaded with has data from a different GC version.\n * 3.2. This client's latest summary was updated from a snapshot that has a different GC version.\n */\n public get summaryStateNeedsReset(): boolean {\n return this.initialStateNeedsReset ||\n (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);\n }\n\n /**\n * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly gcEnabled: boolean;\n private readonly shouldRunSweep: boolean;\n private readonly testMode: boolean;\n private readonly mc: MonitoringContext;\n\n /**\n * Tells whether the GC data should be written to the root of the summary tree.\n */\n private _writeDataAtRoot: boolean = false;\n public get writeDataAtRoot(): boolean {\n return this._writeDataAtRoot;\n }\n\n /**\n * Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:\n * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n * a document and the first time GC is enabled after is was disabled before.\n *\n * Note that the state needs reset only for the very first time summary is generated by this client. After that, the\n * state will be up-to-date and this flag will be reset.\n */\n private initialStateNeedsReset: boolean = false;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary being tracked.\n private latestSummaryGCVersion: GCVersion;\n\n // Keeps track of the GC state from the last run.\n private gcDataFromLastRun: IGarbageCollectionData | undefined;\n // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n // outbound routes from that node.\n private readonly referencesSinceLastRun: Map<string, string[]> = new Map();\n\n // Promise when resolved initializes the base state of the nodes from the base summary state.\n private readonly initializeBaseStateP: Promise<void>;\n // The map of data store ids to their GC details in the base summary returned in getDataStoreGCDetails().\n private readonly dataStoreGCDetailsP: Promise<Map<string, IGarbageCollectionDetailsBase>>;\n // The time after which an unreferenced node can be deleted. Currently, we only set the node's state to expired.\n private readonly deleteTimeoutMs: number;\n // Map of node ids to their unreferenced state tracker.\n private readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n // The timeout responsible for closing the container when the session has expired\n private sessionExpiryTimer?: ReturnType<typeof setTimeout>;\n\n protected constructor(\n private readonly provider: IGarbageCollectionRuntime,\n private readonly gcOptions: IGCRuntimeOptions,\n /** After GC has run, called to delete objects in the runtime whose routes are unused. */\n private readonly deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n /** Returns the current timestamp to be assigned to nodes that become unreferenced. */\n private readonly getCurrentTimestampMs: () => number,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ) {\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(baseLogger, \"GarbageCollector\"));\n\n this.deleteTimeoutMs = this.gcOptions.deleteTimeoutMs ?? defaultDeleteTimeoutMs;\n\n let prevSummaryGCVersion: number | undefined;\n\n // GC can only be enabled during creation. After that, it can never be enabled again. So, for existing\n // documents, we get this information from the metadata blob. Similarly the session timeout should be\n // consistent across all clients, thus we grab it as well from the metadata blob, and set it once on creation.\n if (existing) {\n prevSummaryGCVersion = getGCVersion(metadata);\n // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n // other exsiting documents, GC is enabled.\n this.gcEnabled = prevSummaryGCVersion > 0;\n this.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n } else {\n // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.\n this.gcEnabled = gcOptions.gcAllowed === true;\n this.sessionExpiryTimeoutMs = this.gcOptions.gcTestSessionTimeoutMs;\n }\n\n // If session expiry is enabled, we need to close the container when the timeout expires\n if (this.sessionExpiryTimeoutMs !== undefined) {\n const timeoutMs = this.sessionExpiryTimeoutMs;\n setLongTimeout(timeoutMs,\n () => {\n this.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));\n },\n (timer) => {\n this.sessionExpiryTimer = timer;\n });\n }\n\n // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n // latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n this.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = this.mc.config.getBoolean(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // GC must not be disabled via GC options.\n && !gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (this.mc.config.getBoolean(runSweepKey) ?? gcOptions.runSweep === true)\n && this.sessionExpiryTimer !== undefined;\n\n // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? gcOptions.runGCInTestMode === true;\n\n /**\n * Enable resetting initial state once the following issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n * Currently, the GC tree is not written at root, so we don't know if the base snapshot contains GC tree or not.\n */\n // The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't contain\n // GC tree and GC is enabled.\n // const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;\n // this.initialStateNeedsReset = gcTreePresent ? !this.shouldRunGC : this.shouldRunGC;\n\n // If `writeDataAtRoot` setting is true, write the GC data into the root of the summary tree. We do this so that\n // the roll out can be staged. Once its rolled out everywhere, we will start writing at root by default.\n this._writeDataAtRoot = this.mc.config.getBoolean(writeAtRootKey) ?? this.gcOptions.writeDataAtRoot === true;\n\n // Get the GC state from the GC blob in the base snapshot. Use LazyPromise because we only want to do\n // this once since it involves fetching blobs from storage which is expensive.\n const baseSummaryStateP = new LazyPromise<IGarbageCollectionState | undefined>(async () => {\n if (baseSnapshot === undefined) {\n return undefined;\n }\n\n // For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If the GC tree is written at root, we should also do the same.\n this._writeDataAtRoot = true;\n return getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob);\n }\n\n // back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n // consolidate into IGarbageCollectionState format.\n // Add a node for the root node that is not present in older snapshot format.\n const gcState: IGarbageCollectionState = { gcNodes: { \"/\": { outboundRoutes: [] } } };\n const dataStoreSnaphotTree = getSummaryForDatastores(baseSnapshot, metadata);\n assert(dataStoreSnaphotTree !== undefined,\n 0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */);\n for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {\n const blobId = dsSnapshotTree.blobs[gcBlobKey];\n if (blobId === undefined) {\n continue;\n }\n\n const gcSummaryDetails = await readAndParseBlob<IGarbageCollectionDetailsBase>(blobId);\n // If there are no nodes for this data store, skip it.\n if (gcSummaryDetails.gcData?.gcNodes === undefined) {\n continue;\n }\n\n const dsRootId = `/${dsId}`;\n // Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n // Construct that entry by adding root data store ids to its outbound routes.\n const initialSnapshotDetails = await readAndParseBlob<ReadFluidDataStoreAttributes>(\n dsSnapshotTree.blobs[dataStoreAttributesBlobName],\n );\n if (initialSnapshotDetails.isRootDataStore) {\n gcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n }\n\n for (const [id, outboundRoutes] of Object.entries(gcSummaryDetails.gcData.gcNodes)) {\n // Prefix the data store id to the GC node ids to make them relative to the root from being\n // relative to the data store. Similar to how its done in DataStore::getGCData.\n const rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n gcState.gcNodes[rootId] = { outboundRoutes: Array.from(outboundRoutes) };\n }\n assert(gcState.gcNodes[dsRootId] !== undefined,\n 0x2a9 /* `GC nodes for data store ${dsId} not in GC blob` */);\n gcState.gcNodes[dsRootId].unreferencedTimestampMs = gcSummaryDetails.unrefTimestamp;\n }\n\n // If there is only one node (root node just added above), either GC is disabled or we are loading from the\n // very first summary generated by detached container. In both cases, GC was not run - return undefined.\n return Object.keys(gcState.gcNodes).length === 1 ? undefined : gcState;\n });\n\n // Set up the initializer which initializes the base GC state from the base snapshot. Use lazy promise because\n // we only do this once - the very first time we run GC.\n this.initializeBaseStateP = new LazyPromise<void>(async () => {\n const currentTimestampMs = this.getCurrentTimestampMs();\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return;\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n const unreferencedTimestampMs = nodeData.unreferencedTimestampMs;\n if (unreferencedTimestampMs !== undefined) {\n // Get how long it has been since the node was unreferenced. Start a timeout for the remaining time\n // left for it to be eligible for deletion.\n const unreferencedDurationMs = currentTimestampMs - unreferencedTimestampMs;\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n unreferencedTimestampMs,\n this.deleteTimeoutMs - unreferencedDurationMs,\n ),\n );\n }\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n this.gcDataFromLastRun = { gcNodes };\n });\n\n // Get the GC details for each data store from the GC state in the base summary. This is returned in\n // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.\n this.dataStoreGCDetailsP = new LazyPromise<Map<string, IGarbageCollectionDetailsBase>>(async () => {\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return new Map();\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the base summary to get the routes used in each node in the container.\n // This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n // each node in the summary.\n const usedRoutes = runGarbageCollection(\n gcNodes,\n [ \"/\" ],\n this.mc.logger,\n ).referencedNodeIds;\n\n const dataStoreGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });\n // Currently, the data stores write the GC data. So, we need to update it's base GC details with the\n // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));\n if (dataStoreGCDetails !== undefined) {\n dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;\n }\n }\n }\n return dataStoreGCDetailsMap;\n });\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(\n options: {\n /** Logger to use for logging GC events */\n logger?: ITelemetryLogger,\n /** True to run GC sweep phase after the mark phase */\n runSweep?: boolean,\n /** True to generate full GC data */\n fullGC?: boolean,\n },\n ): Promise<IGCStats> {\n const {\n logger = this.mc.logger,\n runSweep = this.shouldRunSweep,\n fullGC = this.gcOptions.runFullGC === true || this.summaryStateNeedsReset,\n } = options;\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n await this.initializeBaseStateP;\n\n // Let the runtime update its pending state before GC runs.\n await this.provider.updateStateBeforeGC();\n\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n\n // Get the runtime's GC data and run GC on the reference graph in it.\n const gcData = await this.provider.getGCData(fullGC);\n\n this.updateStateSinceLatestRun(gcData);\n\n const gcResult = runGarbageCollection(\n gcData.gcNodes,\n [ \"/\" ],\n logger,\n );\n\n const currentTimestampMs = this.getCurrentTimestampMs();\n // Update the current state of the system based on the GC run.\n this.updateCurrentState(gcData, gcResult, currentTimestampMs);\n\n const dataStoreUsedStateStats =\n this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentTimestampMs);\n\n if (runSweep) {\n // Placeholder for running sweep logic.\n }\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = gcResult.deletedNodeIds.length;\n gcStats.totalNodes = gcResult.referencedNodeIds.length + gcResult.deletedNodeIds.length;\n gcStats.deletedDataStores = dataStoreUsedStateStats.unusedNodeCount;\n gcStats.totalDataStores = dataStoreUsedStateStats.totalNodeCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.testMode) {\n this.deleteUnusedRoutes(gcResult.deletedNodeIds);\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n },\n { end: true, cancel: \"error\" });\n }\n\n /**\n * Summarizes the GC data and returns it as a summary tree.\n * We current write the entire GC state in a single blob. This can be modified later to write multiple\n * blobs. All the blob keys should start with `gcBlobPrefix`.\n */\n public summarize(): ISummaryTreeWithStats | undefined {\n if (!this.shouldRunGC || this.gcDataFromLastRun === undefined) {\n return;\n }\n\n const gcState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n gcState.gcNodes[nodeId] = {\n outboundRoutes,\n unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n };\n }\n\n const builder = new SummaryTreeBuilder();\n builder.addBlob(`${gcBlobPrefix}_root`, JSON.stringify(gcState));\n return builder.getSummaryTree();\n }\n\n /**\n * Returns a map of data store ids to their base GC details generated from the base summary.This is used to\n * initialize the GC state of data stores.\n */\n public async getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>> {\n return this.dataStoreGCDetailsP;\n }\n\n /**\n * Called when the latest summary of the system has been refreshed. This will be used to update the state of the\n * latest summary tracked.\n */\n public async latestSummaryStateRefreshed(\n result: RefreshSummaryResult,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // After a summary is successfully submitted and ack'd by this client, the GC state should have been reset in\n // the summary and doesn't need to be reset anymore.\n this.initialStateNeedsReset = false;\n\n if (!this.shouldRunGC || !result.latestSummaryUpdated) {\n return;\n }\n\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Basically, it was written in the current GC version.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update latest GC version from the snapshot in the result as\n // that is now the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot, readAndParseBlob);\n }\n\n /**\n * Called when a node with the given id is changed. If the node is inactive, log an error.\n */\n public nodeChanged(id: string) {\n // Prefix \"/\" if needed to make it relative to the root.\n const nodeId = id.startsWith(\"/\") ? id : `/${id}`;\n this.unreferencedNodesState.get(nodeId)?.logIfInactive(\n this.mc.logger,\n \"inactiveObjectChanged\",\n this.getCurrentTimestampMs(),\n this.deleteTimeoutMs,\n nodeId,\n );\n }\n\n public dispose(): void {\n if (this.sessionExpiryTimer !== undefined) {\n clearTimeout(this.sessionExpiryTimer);\n this.sessionExpiryTimer = undefined;\n }\n }\n\n /**\n * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n * referenced between summaries so that their unreferenced timestamp can be reset.\n *\n * @param fromNodeId - The node from which the reference is added.\n * @param toNodeId - The node to which the reference is added.\n */\n public addedOutboundReference(fromNodeId: string, toNodeId: string) {\n const outboundRoutes = this.referencesSinceLastRun.get(fromNodeId) ?? [];\n outboundRoutes.push(toNodeId);\n this.referencesSinceLastRun.set(fromNodeId, outboundRoutes);\n }\n\n /**\n * Update the latest summary GC version from the metadata blob in the given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob) {\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n /**\n * Updates the state of the system as per the current GC run. It does the following:\n * 1. Sets up the current GC state as per the gcData.\n * 2. Starts tracking for nodes that have become unreferenced in this run.\n * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n * @param gcData - The data representing the reference graph on which GC is run.\n * @param gcResult - The result of the GC run on the gcData.\n * @param currentTimestampMs - The current timestamp to be used for unreferenced nodes' timestamp.\n */\n private updateCurrentState(gcData: IGarbageCollectionData, gcResult: IGCResult, currentTimestampMs: number) {\n this.gcDataFromLastRun = cloneGCData(gcData);\n this.referencesSinceLastRun.clear();\n\n // Iterate through the deleted nodes and start tracking if they became unreferenced in this run.\n for (const nodeId of gcResult.deletedNodeIds) {\n // The time when the node became unreferenced. This is added to the current GC state.\n let unreferencedTimestampMs: number = currentTimestampMs;\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n unreferencedTimestampMs = nodeStateTracker.unreferencedTimestampMs;\n } else {\n // Start tracking this node as it became unreferenced in this run.\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(unreferencedTimestampMs, this.deleteTimeoutMs),\n );\n }\n }\n\n // Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // If this node has been unreferenced for longer than deleteTimeoutMs and is being referenced,\n // log an error as this may mean the deleteTimeoutMs is not long enough.\n nodeStateTracker.logIfInactive(\n this.mc.logger,\n \"inactiveObjectRevived\",\n currentTimestampMs,\n this.deleteTimeoutMs,\n nodeId,\n );\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n * time. It's possible that nodes transition from `unreferenced -> referenced -> unreferenced` between two runs. The\n * unreferenced timestamp of such nodes needs to be reset as they may have been accessed when they were referenced.\n *\n * This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.\n * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n */\n private updateStateSinceLatestRun(currentGCData: IGarbageCollectionData) {\n // If we haven't run GC before or no references were added since the last run, there is nothing to do.\n if (this.gcDataFromLastRun === undefined || this.referencesSinceLastRun.size === 0) {\n return;\n }\n\n // Validate that we have identified all references correctly.\n this.validateReferenceCorrectness(currentGCData);\n\n /**\n * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n * edges that have been added since then. To do this, combine the GC data from the last run and the current\n * run, and then add the references since last run.\n *\n * Note on why we need to combine the data from previous run, current run and all references in between -\n * 1. We need data from last run because some of its references may have been deleted since then. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 3. We need data from the current run because currently we may not detect when DDSs are referenced:\n * - We don't require DDSs handles to be stored in a referenced DDS. For this, we need GC at DDS level\n * which is tracked by https://github.com/microsoft/FluidFramework/issues/8470.\n * - A new data store may have \"root\" DDSs already created and we don't detect them today.\n */\n const gcDataSuperSet = concatGarbageCollectionData(this.gcDataFromLastRun, currentGCData);\n this.referencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n } else {\n gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n }\n });\n\n /**\n * Run GC on the above reference graph to find all nodes that are referenced. For each one, if they are\n * unreferenced, stop tracking them and remove from unreferenced list.\n * Some of these nodes may be unreferenced now and if so, the current run will add unreferenced state for them.\n */\n const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\"/\"], this.mc.logger);\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Validates that all new references are correctly identified and processed. The basic principle for validation is\n * that we should not have new references in the reference graph (GC data) that have not been notified to the\n * garbage collector via `referenceAdded`.\n * We validate that the references in the current reference graph should be a subset of the references in the last\n * run's reference graph + references since the last run.\n * @param currentGCData - The GC data (reference graph) from the current GC run.\n */\n private validateReferenceCorrectness(currentGCData: IGarbageCollectionData) {\n assert(this.gcDataFromLastRun !== undefined, 0x2b7\n /* \"Can't validate correctness without GC data from last run\" */);\n\n // Get a list of all the outbound routes (or references) in the current GC data.\n const currentReferences: string[] = [];\n for (const [nodeId, outboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n /**\n * Remove routes from a child node to its parent which is added implicitly by the runtime. For instance,\n * each adds its data store as an outbound route to mark it as referenced if the DDS is referenced.\n * We won't get any explicit notification for these references so they must be removed before validation.\n */\n const explicitRoutes = outboundRoutes.filter((route) => !nodeId.startsWith(route));\n currentReferences.push(...explicitRoutes);\n }\n\n // Get a list of outbound routes (or references) from the last run's GC data plus references added since the\n // last run that were notified via `referenceAdded`.\n const explicitReferences: string[] = [];\n for (const [, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n explicitReferences.push(...outboundRoutes);\n }\n this.referencesSinceLastRun.forEach((outboundRoutes: string[]) => {\n explicitReferences.push(...outboundRoutes);\n });\n\n // Validate that the current reference graph doesn't have references that we are not already aware of. If this\n // happens, it might indicate data corruption since we may delete objects prematurely.\n currentReferences.forEach((route: string) => {\n // Validate references for data stores only whose routes are of the format \"/dataStoreId\". Currently, layers\n // below data stores don't have GC implemented so there is no guarantee their references will be notified.\n if (route.split(\"/\").length === 2 && !explicitReferences.includes(route)) {\n /**\n * The following log will be enabled once this issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n */\n // We should ideally throw a data corruption error here. However, send an error for now until we have\n // implemented sweep and have reasonable confidence in the sweep process.\n // this.mc.logger.sendErrorEvent({\n // eventName: \"gcUnknownOutboundRoute\",\n // route,\n // });\n }\n });\n }\n}\n\n/**\n * Gets the garbage collection state from the given snapshot tree. The GC state may be written into multiple blobs.\n * Merge the GC state from all such blobs and return the merged GC state.\n*/\nasync function getGCStateFromSnapshot(\n gcSnapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<IGarbageCollectionState> {\n let rootGCState: IGarbageCollectionState = { gcNodes: {} };\n for (const key of Object.keys(gcSnapshotTree.blobs)) {\n // Skip blobs that do not stsart with the GC prefix.\n if (!key.startsWith(gcBlobPrefix)) {\n continue;\n }\n\n const blobId = gcSnapshotTree.blobs[key];\n if (blobId === undefined) {\n continue;\n }\n const gcState = await readAndParseBlob<IGarbageCollectionState>(blobId);\n assert(gcState !== undefined, 0x2ad /* \"GC blob missing from snapshot\" */);\n // Merge the GC state of this blob into the root GC state.\n rootGCState = concatGarbageCollectionStates(rootGCState, gcState);\n }\n return rootGCState;\n}\n\n/**\n * setLongTimeout is used for timeouts longer than setTimeout's ~24.8 day max\n * @param timeoutMs - the total time the timeout needs to last in ms\n * @param timeoutFn - the function to execute when the timer ends\n * @param setTimerFn - the function used to update your timer variable\n */\nfunction setLongTimeout(\n timeoutMs: number,\n timeoutFn: () => void,\n setTimerFn: (timer: ReturnType<typeof setTimeout>) => void,\n) {\n // The setTimeout max is 24.8 days before looping occurs.\n const maxTimeout = 2147483647;\n let timer: ReturnType<typeof setTimeout>;\n if (timeoutMs > maxTimeout) {\n const newTimeoutMs = timeoutMs - maxTimeout;\n timer = setTimeout(() => setLongTimeout(newTimeoutMs, timeoutFn, setTimerFn), maxTimeout);\n } else {\n timer = setTimeout(() => timeoutFn(), timeoutMs);\n }\n setTimerFn(timer);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "0.56.8";
8
+ export declare const pkgVersion = "0.56.11";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,WAAW,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,YAAY,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/container-runtime";
11
- exports.pkgVersion = "0.56.8";
11
+ exports.pkgVersion = "0.56.11";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"0.56.8\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"0.56.11\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,o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C,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAMlE;;OAEG;YACW,kCAAkC;IAQhD;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAyC1B;;;;;;;OAOG;IACH,OAAO,CAAC,yBAAyB;IAkDjC;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;CA6CvC"}
@@ -123,8 +123,12 @@ export class GarbageCollector {
123
123
  }
124
124
  // If session expiry is enabled, we need to close the container when the timeout expires
125
125
  if (this.sessionExpiryTimeoutMs !== undefined) {
126
- const expiryMs = this.sessionExpiryTimeoutMs;
127
- this.sessionExpiryTimer = setTimeout(() => this.closeFn(new ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);
126
+ const timeoutMs = this.sessionExpiryTimeoutMs;
127
+ setLongTimeout(timeoutMs, () => {
128
+ this.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));
129
+ }, (timer) => {
130
+ this.sessionExpiryTimer = timer;
131
+ });
128
132
  }
129
133
  // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
130
134
  // latest tracked GC version. For new documents, we will be writing the first summary with the current version.
@@ -570,4 +574,23 @@ async function getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob) {
570
574
  }
571
575
  return rootGCState;
572
576
  }
577
+ /**
578
+ * setLongTimeout is used for timeouts longer than setTimeout's ~24.8 day max
579
+ * @param timeoutMs - the total time the timeout needs to last in ms
580
+ * @param timeoutFn - the function to execute when the timer ends
581
+ * @param setTimerFn - the function used to update your timer variable
582
+ */
583
+ function setLongTimeout(timeoutMs, timeoutFn, setTimerFn) {
584
+ // The setTimeout max is 24.8 days before looping occurs.
585
+ const maxTimeout = 2147483647;
586
+ let timer;
587
+ if (timeoutMs > maxTimeout) {
588
+ const newTimeoutMs = timeoutMs - maxTimeout;
589
+ timer = setTimeout(() => setLongTimeout(newTimeoutMs, timeoutFn, setTimerFn), maxTimeout);
590
+ }
591
+ else {
592
+ timer = setTimeout(() => timeoutFn(), timeoutMs);
593
+ }
594
+ setTimerFn(timer);
595
+ }
573
596
  //# sourceMappingURL=garbageCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACH,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAE3B,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACH,SAAS,GAKZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGH,kBAAkB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,WAAW,EACX,yBAAyB,EAEzB,gBAAgB,GAClB,MAAM,iCAAiC,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACH,YAAY,EAGZ,gBAAgB,EAEhB,2BAA2B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,yDAAyD;AACzD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,sCAAsC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AAEnC,wCAAwC;AACxC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,kDAAkD;AAClD,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAC3D,8CAA8C;AAC9C,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qEAAqE;AACrE,MAAM,cAAc,GAAG,yCAAyC,CAAC;AAEjE,MAAM,sBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SA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AAC;QAC3E,0DAA0D;QAC1D,WAAW,GAAG,6BAA6B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;KACrE;IACD,OAAO,WAAW,CAAC;AACvB,CAAC","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 { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ClientSessionExpiredError } from \"@fluidframework/container-utils\";\nimport {\n cloneGCData,\n concatGarbageCollectionStates,\n concatGarbageCollectionData,\n IGCResult,\n runGarbageCollection,\n unpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionState,\n IGarbageCollectionDetailsBase,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ReadAndParseBlob,\n RefreshSummaryResult,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n loggerToMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n } from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n metadataBlobName,\n ReadFluidDataStoreAttributes,\n dataStoreAttributesBlobName,\n} from \"./summaryFormat\";\n\n/** This is the current version of garbage collection. */\nconst GCVersion = 1;\n\n// The key for the GC tree in summary.\nexport const gcTreeKey = \"gc\";\n// They prefix for GC blobs in the GC tree in summary.\nexport const gcBlobPrefix = \"__gc\";\n\n// Feature gate key to turn GC on / off.\nconst runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC test mode on / off.\nconst gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to turn GC sweep on / off.\nconst runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to write GC data at the root of the summary tree.\nconst writeAtRootKey = \"Fluid.GarbageCollection.WriteDataAtRoot\";\n\nconst defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\n/** The used state statistics of a node. */\nexport interface IUsedStateStats {\n totalNodeCount: number;\n unusedNodeCount: number;\n}\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n totalNodes: number;\n deletedNodes: number;\n totalDataStores: number;\n deletedDataStores: number;\n}\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n /** Before GC runs, called to notify the runtime to update any pending GC state. */\n updateStateBeforeGC(): Promise<void>;\n /** Returns the garbage collection data of the runtime. */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n /** After GC has run, called to notify the runtime of routes that are used in it. */\n updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): IUsedStateStats;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n /** Tells whether GC should run or not. */\n readonly shouldRunGC: boolean;\n /** The time in ms to expire a session for a client for gc. */\n readonly sessionExpiryTimeoutMs: number | undefined;\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n readonly gcSummaryFeatureVersion: number;\n /** Tells whether the GC state in summary needs to be reset in the next summary. */\n readonly summaryStateNeedsReset: boolean;\n /** Tells whether GC data should be written to the root of the summary tree. */\n readonly writeDataAtRoot: boolean;\n /** Run garbage collection and update the reference / used state of the system. */\n collectGarbage(\n options: { logger?: ITelemetryLogger, runGC?: boolean, runSweep?: boolean, fullGC?: boolean },\n ): Promise<IGCStats>;\n /** Summarizes the GC data and returns it as a summary tree. */\n summarize(): ISummaryTreeWithStats | undefined;\n /** Returns a map of each data store id to its GC details in the base summary. */\n getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;\n /** Called when the latest summary of the system has been refreshed. */\n latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;\n /** Called when a node is changed. Used to detect and log when an inactive node is changed. */\n nodeChanged(id: string): void;\n /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n addedOutboundReference(fromNodeId: string, toNodeId: string): void;\n dispose(): void;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets\n * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).\n */\nclass UnreferencedStateTracker {\n private inactive: boolean = false;\n // Keeps track of all inactive events that are logged. This is used to limit the log generation for each event to 1\n // so that it is not noisy.\n private readonly inactiveEventsLogged: Set<string> = new Set();\n private readonly timer: Timer | undefined;\n\n constructor(\n public readonly unreferencedTimestampMs: number,\n inactiveTimeoutMs: number,\n ) {\n // If the timeout has already expired, the node should become inactive immediately. Otherwise, start a timer of\n // inactiveTimeoutMs after which the node will become inactive.\n if (inactiveTimeoutMs <= 0) {\n this.inactive = true;\n } else {\n this.timer = new Timer(inactiveTimeoutMs, () => { this.inactive = true; });\n this.timer.start();\n }\n }\n\n /** Stop tracking this node. Reset the unreferenced timer, if any, and reset inactive state. */\n public stopTracking() {\n this.timer?.clear();\n this.inactive = false;\n }\n\n /** Logs an error with the given properties if the node is inactive. */\n public logIfInactive(\n logger: ITelemetryLogger,\n eventName: string,\n currentTimestampMs: number,\n deleteTimeoutMs: number,\n inactiveNodeId: string,\n ) {\n if (this.inactive && !this.inactiveEventsLogged.has(eventName)) {\n logger.sendErrorEvent({\n eventName,\n age: currentTimestampMs - this.unreferencedTimestampMs,\n timeout: deleteTimeoutMs,\n id: inactiveNodeId,\n });\n this.inactiveEventsLogged.add(eventName);\n }\n }\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 */\nexport class GarbageCollector implements IGarbageCollector {\n public static create(\n provider: IGarbageCollectionRuntime,\n gcOptions: IGCRuntimeOptions,\n deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n getCurrentTimestampMs: () => number,\n closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ): IGarbageCollector {\n return new GarbageCollector(\n provider,\n gcOptions,\n deleteUnusedRoutes,\n getCurrentTimestampMs,\n closeFn,\n baseSnapshot,\n readAndParseBlob,\n baseLogger,\n existing,\n metadata,\n );\n }\n\n /**\n * Tells whether GC should be run based on the GC options and local storage flags.\n */\n public readonly shouldRunGC: boolean;\n\n /**\n * The time in ms to expire a session for a client for gc.\n */\n public readonly sessionExpiryTimeoutMs: number | undefined;\n\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n public get gcSummaryFeatureVersion(): number {\n return this.gcEnabled ? this.currentGCVersion : 0;\n }\n\n /**\n * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n * 3. The GC version in the latest summary is different from the current GC version. This can happen if:\n * 3.1. The summary this client loaded with has data from a different GC version.\n * 3.2. This client's latest summary was updated from a snapshot that has a different GC version.\n */\n public get summaryStateNeedsReset(): boolean {\n return this.initialStateNeedsReset ||\n (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);\n }\n\n /**\n * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly gcEnabled: boolean;\n private readonly shouldRunSweep: boolean;\n private readonly testMode: boolean;\n private readonly mc: MonitoringContext;\n\n /**\n * Tells whether the GC data should be written to the root of the summary tree.\n */\n private _writeDataAtRoot: boolean = false;\n public get writeDataAtRoot(): boolean {\n return this._writeDataAtRoot;\n }\n\n /**\n * Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:\n * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n * a document and the first time GC is enabled after is was disabled before.\n *\n * Note that the state needs reset only for the very first time summary is generated by this client. After that, the\n * state will be up-to-date and this flag will be reset.\n */\n private initialStateNeedsReset: boolean = false;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary being tracked.\n private latestSummaryGCVersion: GCVersion;\n\n // Keeps track of the GC state from the last run.\n private gcDataFromLastRun: IGarbageCollectionData | undefined;\n // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n // outbound routes from that node.\n private readonly referencesSinceLastRun: Map<string, string[]> = new Map();\n\n // Promise when resolved initializes the base state of the nodes from the base summary state.\n private readonly initializeBaseStateP: Promise<void>;\n // The map of data store ids to their GC details in the base summary returned in getDataStoreGCDetails().\n private readonly dataStoreGCDetailsP: Promise<Map<string, IGarbageCollectionDetailsBase>>;\n // The time after which an unreferenced node can be deleted. Currently, we only set the node's state to expired.\n private readonly deleteTimeoutMs: number;\n // Map of node ids to their unreferenced state tracker.\n private readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n // The timeout responsible for closing the container when the session has expired\n private sessionExpiryTimer?: ReturnType<typeof setTimeout>;\n\n protected constructor(\n private readonly provider: IGarbageCollectionRuntime,\n private readonly gcOptions: IGCRuntimeOptions,\n /** After GC has run, called to delete objects in the runtime whose routes are unused. */\n private readonly deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n /** Returns the current timestamp to be assigned to nodes that become unreferenced. */\n private readonly getCurrentTimestampMs: () => number,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ) {\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(baseLogger, \"GarbageCollector\"));\n\n this.deleteTimeoutMs = this.gcOptions.deleteTimeoutMs ?? defaultDeleteTimeoutMs;\n\n let prevSummaryGCVersion: number | undefined;\n\n // GC can only be enabled during creation. After that, it can never be enabled again. So, for existing\n // documents, we get this information from the metadata blob. Similarly the session timeout should be\n // consistent across all clients, thus we grab it as well from the metadata blob, and set it once on creation.\n if (existing) {\n prevSummaryGCVersion = getGCVersion(metadata);\n // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n // other exsiting documents, GC is enabled.\n this.gcEnabled = prevSummaryGCVersion > 0;\n this.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n } else {\n // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.\n this.gcEnabled = gcOptions.gcAllowed === true;\n this.sessionExpiryTimeoutMs = this.gcOptions.gcTestSessionTimeoutMs;\n }\n\n // If session expiry is enabled, we need to close the container when the timeout expires\n if (this.sessionExpiryTimeoutMs !== undefined) {\n const expiryMs = this.sessionExpiryTimeoutMs;\n this.sessionExpiryTimer = setTimeout(() => this.closeFn(\n new ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);\n }\n\n // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n // latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n this.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = this.mc.config.getBoolean(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // GC must not be disabled via GC options.\n && !gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (this.mc.config.getBoolean(runSweepKey) ?? gcOptions.runSweep === true)\n && this.sessionExpiryTimer !== undefined;\n\n // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? gcOptions.runGCInTestMode === true;\n\n /**\n * Enable resetting initial state once the following issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n * Currently, the GC tree is not written at root, so we don't know if the base snapshot contains GC tree or not.\n */\n // The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't contain\n // GC tree and GC is enabled.\n // const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;\n // this.initialStateNeedsReset = gcTreePresent ? !this.shouldRunGC : this.shouldRunGC;\n\n // If `writeDataAtRoot` setting is true, write the GC data into the root of the summary tree. We do this so that\n // the roll out can be staged. Once its rolled out everywhere, we will start writing at root by default.\n this._writeDataAtRoot = this.mc.config.getBoolean(writeAtRootKey) ?? this.gcOptions.writeDataAtRoot === true;\n\n // Get the GC state from the GC blob in the base snapshot. Use LazyPromise because we only want to do\n // this once since it involves fetching blobs from storage which is expensive.\n const baseSummaryStateP = new LazyPromise<IGarbageCollectionState | undefined>(async () => {\n if (baseSnapshot === undefined) {\n return undefined;\n }\n\n // For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If the GC tree is written at root, we should also do the same.\n this._writeDataAtRoot = true;\n return getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob);\n }\n\n // back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n // consolidate into IGarbageCollectionState format.\n // Add a node for the root node that is not present in older snapshot format.\n const gcState: IGarbageCollectionState = { gcNodes: { \"/\": { outboundRoutes: [] } } };\n const dataStoreSnaphotTree = getSummaryForDatastores(baseSnapshot, metadata);\n assert(dataStoreSnaphotTree !== undefined,\n 0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */);\n for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {\n const blobId = dsSnapshotTree.blobs[gcBlobKey];\n if (blobId === undefined) {\n continue;\n }\n\n const gcSummaryDetails = await readAndParseBlob<IGarbageCollectionDetailsBase>(blobId);\n // If there are no nodes for this data store, skip it.\n if (gcSummaryDetails.gcData?.gcNodes === undefined) {\n continue;\n }\n\n const dsRootId = `/${dsId}`;\n // Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n // Construct that entry by adding root data store ids to its outbound routes.\n const initialSnapshotDetails = await readAndParseBlob<ReadFluidDataStoreAttributes>(\n dsSnapshotTree.blobs[dataStoreAttributesBlobName],\n );\n if (initialSnapshotDetails.isRootDataStore) {\n gcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n }\n\n for (const [id, outboundRoutes] of Object.entries(gcSummaryDetails.gcData.gcNodes)) {\n // Prefix the data store id to the GC node ids to make them relative to the root from being\n // relative to the data store. Similar to how its done in DataStore::getGCData.\n const rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n gcState.gcNodes[rootId] = { outboundRoutes: Array.from(outboundRoutes) };\n }\n assert(gcState.gcNodes[dsRootId] !== undefined,\n 0x2a9 /* `GC nodes for data store ${dsId} not in GC blob` */);\n gcState.gcNodes[dsRootId].unreferencedTimestampMs = gcSummaryDetails.unrefTimestamp;\n }\n\n // If there is only one node (root node just added above), either GC is disabled or we are loading from the\n // very first summary generated by detached container. In both cases, GC was not run - return undefined.\n return Object.keys(gcState.gcNodes).length === 1 ? undefined : gcState;\n });\n\n // Set up the initializer which initializes the base GC state from the base snapshot. Use lazy promise because\n // we only do this once - the very first time we run GC.\n this.initializeBaseStateP = new LazyPromise<void>(async () => {\n const currentTimestampMs = this.getCurrentTimestampMs();\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return;\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n const unreferencedTimestampMs = nodeData.unreferencedTimestampMs;\n if (unreferencedTimestampMs !== undefined) {\n // Get how long it has been since the node was unreferenced. Start a timeout for the remaining time\n // left for it to be eligible for deletion.\n const unreferencedDurationMs = currentTimestampMs - unreferencedTimestampMs;\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n unreferencedTimestampMs,\n this.deleteTimeoutMs - unreferencedDurationMs,\n ),\n );\n }\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n this.gcDataFromLastRun = { gcNodes };\n });\n\n // Get the GC details for each data store from the GC state in the base summary. This is returned in\n // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.\n this.dataStoreGCDetailsP = new LazyPromise<Map<string, IGarbageCollectionDetailsBase>>(async () => {\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return new Map();\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the base summary to get the routes used in each node in the container.\n // This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n // each node in the summary.\n const usedRoutes = runGarbageCollection(\n gcNodes,\n [ \"/\" ],\n this.mc.logger,\n ).referencedNodeIds;\n\n const dataStoreGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });\n // Currently, the data stores write the GC data. So, we need to update it's base GC details with the\n // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));\n if (dataStoreGCDetails !== undefined) {\n dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;\n }\n }\n }\n return dataStoreGCDetailsMap;\n });\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(\n options: {\n /** Logger to use for logging GC events */\n logger?: ITelemetryLogger,\n /** True to run GC sweep phase after the mark phase */\n runSweep?: boolean,\n /** True to generate full GC data */\n fullGC?: boolean,\n },\n ): Promise<IGCStats> {\n const {\n logger = this.mc.logger,\n runSweep = this.shouldRunSweep,\n fullGC = this.gcOptions.runFullGC === true || this.summaryStateNeedsReset,\n } = options;\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n await this.initializeBaseStateP;\n\n // Let the runtime update its pending state before GC runs.\n await this.provider.updateStateBeforeGC();\n\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n\n // Get the runtime's GC data and run GC on the reference graph in it.\n const gcData = await this.provider.getGCData(fullGC);\n\n this.updateStateSinceLatestRun(gcData);\n\n const gcResult = runGarbageCollection(\n gcData.gcNodes,\n [ \"/\" ],\n logger,\n );\n\n const currentTimestampMs = this.getCurrentTimestampMs();\n // Update the current state of the system based on the GC run.\n this.updateCurrentState(gcData, gcResult, currentTimestampMs);\n\n const dataStoreUsedStateStats =\n this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentTimestampMs);\n\n if (runSweep) {\n // Placeholder for running sweep logic.\n }\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = gcResult.deletedNodeIds.length;\n gcStats.totalNodes = gcResult.referencedNodeIds.length + gcResult.deletedNodeIds.length;\n gcStats.deletedDataStores = dataStoreUsedStateStats.unusedNodeCount;\n gcStats.totalDataStores = dataStoreUsedStateStats.totalNodeCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.testMode) {\n this.deleteUnusedRoutes(gcResult.deletedNodeIds);\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n },\n { end: true, cancel: \"error\" });\n }\n\n /**\n * Summarizes the GC data and returns it as a summary tree.\n * We current write the entire GC state in a single blob. This can be modified later to write multiple\n * blobs. All the blob keys should start with `gcBlobPrefix`.\n */\n public summarize(): ISummaryTreeWithStats | undefined {\n if (!this.shouldRunGC || this.gcDataFromLastRun === undefined) {\n return;\n }\n\n const gcState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n gcState.gcNodes[nodeId] = {\n outboundRoutes,\n unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n };\n }\n\n const builder = new SummaryTreeBuilder();\n builder.addBlob(`${gcBlobPrefix}_root`, JSON.stringify(gcState));\n return builder.getSummaryTree();\n }\n\n /**\n * Returns a map of data store ids to their base GC details generated from the base summary.This is used to\n * initialize the GC state of data stores.\n */\n public async getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>> {\n return this.dataStoreGCDetailsP;\n }\n\n /**\n * Called when the latest summary of the system has been refreshed. This will be used to update the state of the\n * latest summary tracked.\n */\n public async latestSummaryStateRefreshed(\n result: RefreshSummaryResult,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // After a summary is successfully submitted and ack'd by this client, the GC state should have been reset in\n // the summary and doesn't need to be reset anymore.\n this.initialStateNeedsReset = false;\n\n if (!this.shouldRunGC || !result.latestSummaryUpdated) {\n return;\n }\n\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Basically, it was written in the current GC version.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update latest GC version from the snapshot in the result as\n // that is now the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot, readAndParseBlob);\n }\n\n /**\n * Called when a node with the given id is changed. If the node is inactive, log an error.\n */\n public nodeChanged(id: string) {\n // Prefix \"/\" if needed to make it relative to the root.\n const nodeId = id.startsWith(\"/\") ? id : `/${id}`;\n this.unreferencedNodesState.get(nodeId)?.logIfInactive(\n this.mc.logger,\n \"inactiveObjectChanged\",\n this.getCurrentTimestampMs(),\n this.deleteTimeoutMs,\n nodeId,\n );\n }\n\n public dispose(): void {\n if (this.sessionExpiryTimer !== undefined) {\n clearTimeout(this.sessionExpiryTimer);\n this.sessionExpiryTimer = undefined;\n }\n }\n\n /**\n * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n * referenced between summaries so that their unreferenced timestamp can be reset.\n *\n * @param fromNodeId - The node from which the reference is added.\n * @param toNodeId - The node to which the reference is added.\n */\n public addedOutboundReference(fromNodeId: string, toNodeId: string) {\n const outboundRoutes = this.referencesSinceLastRun.get(fromNodeId) ?? [];\n outboundRoutes.push(toNodeId);\n this.referencesSinceLastRun.set(fromNodeId, outboundRoutes);\n }\n\n /**\n * Update the latest summary GC version from the metadata blob in the given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob) {\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n /**\n * Updates the state of the system as per the current GC run. It does the following:\n * 1. Sets up the current GC state as per the gcData.\n * 2. Starts tracking for nodes that have become unreferenced in this run.\n * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n * @param gcData - The data representing the reference graph on which GC is run.\n * @param gcResult - The result of the GC run on the gcData.\n * @param currentTimestampMs - The current timestamp to be used for unreferenced nodes' timestamp.\n */\n private updateCurrentState(gcData: IGarbageCollectionData, gcResult: IGCResult, currentTimestampMs: number) {\n this.gcDataFromLastRun = cloneGCData(gcData);\n this.referencesSinceLastRun.clear();\n\n // Iterate through the deleted nodes and start tracking if they became unreferenced in this run.\n for (const nodeId of gcResult.deletedNodeIds) {\n // The time when the node became unreferenced. This is added to the current GC state.\n let unreferencedTimestampMs: number = currentTimestampMs;\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n unreferencedTimestampMs = nodeStateTracker.unreferencedTimestampMs;\n } else {\n // Start tracking this node as it became unreferenced in this run.\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(unreferencedTimestampMs, this.deleteTimeoutMs),\n );\n }\n }\n\n // Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // If this node has been unreferenced for longer than deleteTimeoutMs and is being referenced,\n // log an error as this may mean the deleteTimeoutMs is not long enough.\n nodeStateTracker.logIfInactive(\n this.mc.logger,\n \"inactiveObjectRevived\",\n currentTimestampMs,\n this.deleteTimeoutMs,\n nodeId,\n );\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n * time. It's possible that nodes transition from `unreferenced -> referenced -> unreferenced` between two runs. The\n * unreferenced timestamp of such nodes needs to be reset as they may have been accessed when they were referenced.\n *\n * This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.\n * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n */\n private updateStateSinceLatestRun(currentGCData: IGarbageCollectionData) {\n // If we haven't run GC before or no references were added since the last run, there is nothing to do.\n if (this.gcDataFromLastRun === undefined || this.referencesSinceLastRun.size === 0) {\n return;\n }\n\n // Validate that we have identified all references correctly.\n this.validateReferenceCorrectness(currentGCData);\n\n /**\n * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n * edges that have been added since then. To do this, combine the GC data from the last run and the current\n * run, and then add the references since last run.\n *\n * Note on why we need to combine the data from previous run, current run and all references in between -\n * 1. We need data from last run because some of its references may have been deleted since then. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 3. We need data from the current run because currently we may not detect when DDSs are referenced:\n * - We don't require DDSs handles to be stored in a referenced DDS. For this, we need GC at DDS level\n * which is tracked by https://github.com/microsoft/FluidFramework/issues/8470.\n * - A new data store may have \"root\" DDSs already created and we don't detect them today.\n */\n const gcDataSuperSet = concatGarbageCollectionData(this.gcDataFromLastRun, currentGCData);\n this.referencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n } else {\n gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n }\n });\n\n /**\n * Run GC on the above reference graph to find all nodes that are referenced. For each one, if they are\n * unreferenced, stop tracking them and remove from unreferenced list.\n * Some of these nodes may be unreferenced now and if so, the current run will add unreferenced state for them.\n */\n const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\"/\"], this.mc.logger);\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Validates that all new references are correctly identified and processed. The basic principle for validation is\n * that we should not have new references in the reference graph (GC data) that have not been notified to the\n * garbage collector via `referenceAdded`.\n * We validate that the references in the current reference graph should be a subset of the references in the last\n * run's reference graph + references since the last run.\n * @param currentGCData - The GC data (reference graph) from the current GC run.\n */\n private validateReferenceCorrectness(currentGCData: IGarbageCollectionData) {\n assert(this.gcDataFromLastRun !== undefined, 0x2b7\n /* \"Can't validate correctness without GC data from last run\" */);\n\n // Get a list of all the outbound routes (or references) in the current GC data.\n const currentReferences: string[] = [];\n for (const [nodeId, outboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n /**\n * Remove routes from a child node to its parent which is added implicitly by the runtime. For instance,\n * each adds its data store as an outbound route to mark it as referenced if the DDS is referenced.\n * We won't get any explicit notification for these references so they must be removed before validation.\n */\n const explicitRoutes = outboundRoutes.filter((route) => !nodeId.startsWith(route));\n currentReferences.push(...explicitRoutes);\n }\n\n // Get a list of outbound routes (or references) from the last run's GC data plus references added since the\n // last run that were notified via `referenceAdded`.\n const explicitReferences: string[] = [];\n for (const [, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n explicitReferences.push(...outboundRoutes);\n }\n this.referencesSinceLastRun.forEach((outboundRoutes: string[]) => {\n explicitReferences.push(...outboundRoutes);\n });\n\n // Validate that the current reference graph doesn't have references that we are not already aware of. If this\n // happens, it might indicate data corruption since we may delete objects prematurely.\n currentReferences.forEach((route: string) => {\n // Validate references for data stores only whose routes are of the format \"/dataStoreId\". Currently, layers\n // below data stores don't have GC implemented so there is no guarantee their references will be notified.\n if (route.split(\"/\").length === 2 && !explicitReferences.includes(route)) {\n /**\n * The following log will be enabled once this issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n */\n // We should ideally throw a data corruption error here. However, send an error for now until we have\n // implemented sweep and have reasonable confidence in the sweep process.\n // this.mc.logger.sendErrorEvent({\n // eventName: \"gcUnknownOutboundRoute\",\n // route,\n // });\n }\n });\n }\n}\n\n/**\n * Gets the garbage collection state from the given snapshot tree. The GC state may be written into multiple blobs.\n * Merge the GC state from all such blobs and return the merged GC state.\n*/\nasync function getGCStateFromSnapshot(\n gcSnapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<IGarbageCollectionState> {\n let rootGCState: IGarbageCollectionState = { gcNodes: {} };\n for (const key of Object.keys(gcSnapshotTree.blobs)) {\n // Skip blobs that do not stsart with the GC prefix.\n if (!key.startsWith(gcBlobPrefix)) {\n continue;\n }\n\n const blobId = gcSnapshotTree.blobs[key];\n if (blobId === undefined) {\n continue;\n }\n const gcState = await readAndParseBlob<IGarbageCollectionState>(blobId);\n assert(gcState !== undefined, 0x2ad /* \"GC blob missing from snapshot\" */);\n // Merge the GC state of this blob into the root GC state.\n rootGCState = concatGarbageCollectionStates(rootGCState, gcState);\n }\n return rootGCState;\n}\n"]}
1
+ {"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACH,WAAW,EACX,6BAA6B,EAC7B,2BAA2B,EAE3B,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACH,SAAS,GAKZ,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGH,kBAAkB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACH,WAAW,EACX,yBAAyB,EAEzB,gBAAgB,GAClB,MAAM,iCAAiC,CAAC;AAG1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACH,YAAY,EAGZ,gBAAgB,EAEhB,2BAA2B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,yDAAyD;AACzD,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB,sCAAsC;AACtC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC;AAC9B,sDAAsD;AACtD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AAEnC,wCAAwC;AACxC,MAAM,QAAQ,GAAG,+BAA+B,CAAC;AACjD,kDAAkD;AAClD,MAAM,aAAa,GAAG,oCAAoC,CAAC;AAC3D,8CAA8C;AAC9C,MAAM,WAAW,GAAG,kCAAkC,CAAC;AACvD,qEAAqE;AACrE,MAAM,cAAc,GAAG,yCAA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AI,MAAM,KAAK,SAAS,EAAE;YACtB,SAAS;SACZ;QACD,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAA0B,MAAM,CAAC,CAAC;QACxE,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;QAC3E,0DAA0D;QAC1D,WAAW,GAAG,6BAA6B,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;KACrE;IACD,OAAO,WAAW,CAAC;AACvB,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CACnB,SAAiB,EACjB,SAAqB,EACrB,UAA0D;IAE1D,yDAAyD;IACzD,MAAM,UAAU,GAAG,UAAU,CAAC;IAC9B,IAAI,KAAoC,CAAC;IACzC,IAAI,SAAS,GAAG,UAAU,EAAE;QACxB,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC;QAC5C,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,YAAY,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;KAC7F;SAAM;QACH,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,CAAC,CAAC;KACpD;IACD,UAAU,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC","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 { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ClientSessionExpiredError } from \"@fluidframework/container-utils\";\nimport {\n cloneGCData,\n concatGarbageCollectionStates,\n concatGarbageCollectionData,\n IGCResult,\n runGarbageCollection,\n unpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionState,\n IGarbageCollectionDetailsBase,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n ReadAndParseBlob,\n RefreshSummaryResult,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n loggerToMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n } from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n metadataBlobName,\n ReadFluidDataStoreAttributes,\n dataStoreAttributesBlobName,\n} from \"./summaryFormat\";\n\n/** This is the current version of garbage collection. */\nconst GCVersion = 1;\n\n// The key for the GC tree in summary.\nexport const gcTreeKey = \"gc\";\n// They prefix for GC blobs in the GC tree in summary.\nexport const gcBlobPrefix = \"__gc\";\n\n// Feature gate key to turn GC on / off.\nconst runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC test mode on / off.\nconst gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to turn GC sweep on / off.\nconst runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to write GC data at the root of the summary tree.\nconst writeAtRootKey = \"Fluid.GarbageCollection.WriteDataAtRoot\";\n\nconst defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\n/** The used state statistics of a node. */\nexport interface IUsedStateStats {\n totalNodeCount: number;\n unusedNodeCount: number;\n}\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n totalNodes: number;\n deletedNodes: number;\n totalDataStores: number;\n deletedDataStores: number;\n}\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n /** Before GC runs, called to notify the runtime to update any pending GC state. */\n updateStateBeforeGC(): Promise<void>;\n /** Returns the garbage collection data of the runtime. */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n /** After GC has run, called to notify the runtime of routes that are used in it. */\n updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): IUsedStateStats;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n /** Tells whether GC should run or not. */\n readonly shouldRunGC: boolean;\n /** The time in ms to expire a session for a client for gc. */\n readonly sessionExpiryTimeoutMs: number | undefined;\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n readonly gcSummaryFeatureVersion: number;\n /** Tells whether the GC state in summary needs to be reset in the next summary. */\n readonly summaryStateNeedsReset: boolean;\n /** Tells whether GC data should be written to the root of the summary tree. */\n readonly writeDataAtRoot: boolean;\n /** Run garbage collection and update the reference / used state of the system. */\n collectGarbage(\n options: { logger?: ITelemetryLogger, runGC?: boolean, runSweep?: boolean, fullGC?: boolean },\n ): Promise<IGCStats>;\n /** Summarizes the GC data and returns it as a summary tree. */\n summarize(): ISummaryTreeWithStats | undefined;\n /** Returns a map of each data store id to its GC details in the base summary. */\n getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;\n /** Called when the latest summary of the system has been refreshed. */\n latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;\n /** Called when a node is changed. Used to detect and log when an inactive node is changed. */\n nodeChanged(id: string): void;\n /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n addedOutboundReference(fromNodeId: string, toNodeId: string): void;\n dispose(): void;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets\n * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).\n */\nclass UnreferencedStateTracker {\n private inactive: boolean = false;\n // Keeps track of all inactive events that are logged. This is used to limit the log generation for each event to 1\n // so that it is not noisy.\n private readonly inactiveEventsLogged: Set<string> = new Set();\n private readonly timer: Timer | undefined;\n\n constructor(\n public readonly unreferencedTimestampMs: number,\n inactiveTimeoutMs: number,\n ) {\n // If the timeout has already expired, the node should become inactive immediately. Otherwise, start a timer of\n // inactiveTimeoutMs after which the node will become inactive.\n if (inactiveTimeoutMs <= 0) {\n this.inactive = true;\n } else {\n this.timer = new Timer(inactiveTimeoutMs, () => { this.inactive = true; });\n this.timer.start();\n }\n }\n\n /** Stop tracking this node. Reset the unreferenced timer, if any, and reset inactive state. */\n public stopTracking() {\n this.timer?.clear();\n this.inactive = false;\n }\n\n /** Logs an error with the given properties if the node is inactive. */\n public logIfInactive(\n logger: ITelemetryLogger,\n eventName: string,\n currentTimestampMs: number,\n deleteTimeoutMs: number,\n inactiveNodeId: string,\n ) {\n if (this.inactive && !this.inactiveEventsLogged.has(eventName)) {\n logger.sendErrorEvent({\n eventName,\n age: currentTimestampMs - this.unreferencedTimestampMs,\n timeout: deleteTimeoutMs,\n id: inactiveNodeId,\n });\n this.inactiveEventsLogged.add(eventName);\n }\n }\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 */\nexport class GarbageCollector implements IGarbageCollector {\n public static create(\n provider: IGarbageCollectionRuntime,\n gcOptions: IGCRuntimeOptions,\n deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n getCurrentTimestampMs: () => number,\n closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ): IGarbageCollector {\n return new GarbageCollector(\n provider,\n gcOptions,\n deleteUnusedRoutes,\n getCurrentTimestampMs,\n closeFn,\n baseSnapshot,\n readAndParseBlob,\n baseLogger,\n existing,\n metadata,\n );\n }\n\n /**\n * Tells whether GC should be run based on the GC options and local storage flags.\n */\n public readonly shouldRunGC: boolean;\n\n /**\n * The time in ms to expire a session for a client for gc.\n */\n public readonly sessionExpiryTimeoutMs: number | undefined;\n\n /**\n * This tracks two things:\n * 1. Whether GC is enabled - If this is 0, GC is disabled. If this is greater than 0, GC is enabled.\n * 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.\n */\n public get gcSummaryFeatureVersion(): number {\n return this.gcEnabled ? this.currentGCVersion : 0;\n }\n\n /**\n * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n * 3. The GC version in the latest summary is different from the current GC version. This can happen if:\n * 3.1. The summary this client loaded with has data from a different GC version.\n * 3.2. This client's latest summary was updated from a snapshot that has a different GC version.\n */\n public get summaryStateNeedsReset(): boolean {\n return this.initialStateNeedsReset ||\n (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);\n }\n\n /**\n * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly gcEnabled: boolean;\n private readonly shouldRunSweep: boolean;\n private readonly testMode: boolean;\n private readonly mc: MonitoringContext;\n\n /**\n * Tells whether the GC data should be written to the root of the summary tree.\n */\n private _writeDataAtRoot: boolean = false;\n public get writeDataAtRoot(): boolean {\n return this._writeDataAtRoot;\n }\n\n /**\n * Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:\n * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n * a document and the first time GC is enabled after is was disabled before.\n *\n * Note that the state needs reset only for the very first time summary is generated by this client. After that, the\n * state will be up-to-date and this flag will be reset.\n */\n private initialStateNeedsReset: boolean = false;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary being tracked.\n private latestSummaryGCVersion: GCVersion;\n\n // Keeps track of the GC state from the last run.\n private gcDataFromLastRun: IGarbageCollectionData | undefined;\n // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n // outbound routes from that node.\n private readonly referencesSinceLastRun: Map<string, string[]> = new Map();\n\n // Promise when resolved initializes the base state of the nodes from the base summary state.\n private readonly initializeBaseStateP: Promise<void>;\n // The map of data store ids to their GC details in the base summary returned in getDataStoreGCDetails().\n private readonly dataStoreGCDetailsP: Promise<Map<string, IGarbageCollectionDetailsBase>>;\n // The time after which an unreferenced node can be deleted. Currently, we only set the node's state to expired.\n private readonly deleteTimeoutMs: number;\n // Map of node ids to their unreferenced state tracker.\n private readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n // The timeout responsible for closing the container when the session has expired\n private sessionExpiryTimer?: ReturnType<typeof setTimeout>;\n\n protected constructor(\n private readonly provider: IGarbageCollectionRuntime,\n private readonly gcOptions: IGCRuntimeOptions,\n /** After GC has run, called to delete objects in the runtime whose routes are unused. */\n private readonly deleteUnusedRoutes: (unusedRoutes: string[]) => void,\n /** Returns the current timestamp to be assigned to nodes that become unreferenced. */\n private readonly getCurrentTimestampMs: () => number,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n baseSnapshot: ISnapshotTree | undefined,\n readAndParseBlob: ReadAndParseBlob,\n baseLogger: ITelemetryLogger,\n existing: boolean,\n metadata?: IContainerRuntimeMetadata,\n ) {\n this.mc = loggerToMonitoringContext(\n ChildLogger.create(baseLogger, \"GarbageCollector\"));\n\n this.deleteTimeoutMs = this.gcOptions.deleteTimeoutMs ?? defaultDeleteTimeoutMs;\n\n let prevSummaryGCVersion: number | undefined;\n\n // GC can only be enabled during creation. After that, it can never be enabled again. So, for existing\n // documents, we get this information from the metadata blob. Similarly the session timeout should be\n // consistent across all clients, thus we grab it as well from the metadata blob, and set it once on creation.\n if (existing) {\n prevSummaryGCVersion = getGCVersion(metadata);\n // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n // other exsiting documents, GC is enabled.\n this.gcEnabled = prevSummaryGCVersion > 0;\n this.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n } else {\n // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.\n this.gcEnabled = gcOptions.gcAllowed === true;\n this.sessionExpiryTimeoutMs = this.gcOptions.gcTestSessionTimeoutMs;\n }\n\n // If session expiry is enabled, we need to close the container when the timeout expires\n if (this.sessionExpiryTimeoutMs !== undefined) {\n const timeoutMs = this.sessionExpiryTimeoutMs;\n setLongTimeout(timeoutMs,\n () => {\n this.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));\n },\n (timer) => {\n this.sessionExpiryTimer = timer;\n });\n }\n\n // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n // latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n this.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = this.mc.config.getBoolean(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // GC must not be disabled via GC options.\n && !gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (this.mc.config.getBoolean(runSweepKey) ?? gcOptions.runSweep === true)\n && this.sessionExpiryTimer !== undefined;\n\n // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? gcOptions.runGCInTestMode === true;\n\n /**\n * Enable resetting initial state once the following issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n * Currently, the GC tree is not written at root, so we don't know if the base snapshot contains GC tree or not.\n */\n // The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't contain\n // GC tree and GC is enabled.\n // const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;\n // this.initialStateNeedsReset = gcTreePresent ? !this.shouldRunGC : this.shouldRunGC;\n\n // If `writeDataAtRoot` setting is true, write the GC data into the root of the summary tree. We do this so that\n // the roll out can be staged. Once its rolled out everywhere, we will start writing at root by default.\n this._writeDataAtRoot = this.mc.config.getBoolean(writeAtRootKey) ?? this.gcOptions.writeDataAtRoot === true;\n\n // Get the GC state from the GC blob in the base snapshot. Use LazyPromise because we only want to do\n // this once since it involves fetching blobs from storage which is expensive.\n const baseSummaryStateP = new LazyPromise<IGarbageCollectionState | undefined>(async () => {\n if (baseSnapshot === undefined) {\n return undefined;\n }\n\n // For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n // If the GC tree is written at root, we should also do the same.\n this._writeDataAtRoot = true;\n return getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob);\n }\n\n // back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n // consolidate into IGarbageCollectionState format.\n // Add a node for the root node that is not present in older snapshot format.\n const gcState: IGarbageCollectionState = { gcNodes: { \"/\": { outboundRoutes: [] } } };\n const dataStoreSnaphotTree = getSummaryForDatastores(baseSnapshot, metadata);\n assert(dataStoreSnaphotTree !== undefined,\n 0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */);\n for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {\n const blobId = dsSnapshotTree.blobs[gcBlobKey];\n if (blobId === undefined) {\n continue;\n }\n\n const gcSummaryDetails = await readAndParseBlob<IGarbageCollectionDetailsBase>(blobId);\n // If there are no nodes for this data store, skip it.\n if (gcSummaryDetails.gcData?.gcNodes === undefined) {\n continue;\n }\n\n const dsRootId = `/${dsId}`;\n // Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n // Construct that entry by adding root data store ids to its outbound routes.\n const initialSnapshotDetails = await readAndParseBlob<ReadFluidDataStoreAttributes>(\n dsSnapshotTree.blobs[dataStoreAttributesBlobName],\n );\n if (initialSnapshotDetails.isRootDataStore) {\n gcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n }\n\n for (const [id, outboundRoutes] of Object.entries(gcSummaryDetails.gcData.gcNodes)) {\n // Prefix the data store id to the GC node ids to make them relative to the root from being\n // relative to the data store. Similar to how its done in DataStore::getGCData.\n const rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n gcState.gcNodes[rootId] = { outboundRoutes: Array.from(outboundRoutes) };\n }\n assert(gcState.gcNodes[dsRootId] !== undefined,\n 0x2a9 /* `GC nodes for data store ${dsId} not in GC blob` */);\n gcState.gcNodes[dsRootId].unreferencedTimestampMs = gcSummaryDetails.unrefTimestamp;\n }\n\n // If there is only one node (root node just added above), either GC is disabled or we are loading from the\n // very first summary generated by detached container. In both cases, GC was not run - return undefined.\n return Object.keys(gcState.gcNodes).length === 1 ? undefined : gcState;\n });\n\n // Set up the initializer which initializes the base GC state from the base snapshot. Use lazy promise because\n // we only do this once - the very first time we run GC.\n this.initializeBaseStateP = new LazyPromise<void>(async () => {\n const currentTimestampMs = this.getCurrentTimestampMs();\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return;\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n const unreferencedTimestampMs = nodeData.unreferencedTimestampMs;\n if (unreferencedTimestampMs !== undefined) {\n // Get how long it has been since the node was unreferenced. Start a timeout for the remaining time\n // left for it to be eligible for deletion.\n const unreferencedDurationMs = currentTimestampMs - unreferencedTimestampMs;\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n unreferencedTimestampMs,\n this.deleteTimeoutMs - unreferencedDurationMs,\n ),\n );\n }\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n this.gcDataFromLastRun = { gcNodes };\n });\n\n // Get the GC details for each data store from the GC state in the base summary. This is returned in\n // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.\n this.dataStoreGCDetailsP = new LazyPromise<Map<string, IGarbageCollectionDetailsBase>>(async () => {\n const baseState = await baseSummaryStateP;\n if (baseState === undefined) {\n return new Map();\n }\n\n const gcNodes: { [ id: string ]: string[] } = {};\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the base summary to get the routes used in each node in the container.\n // This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n // each node in the summary.\n const usedRoutes = runGarbageCollection(\n gcNodes,\n [ \"/\" ],\n this.mc.logger,\n ).referencedNodeIds;\n\n const dataStoreGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });\n // Currently, the data stores write the GC data. So, we need to update it's base GC details with the\n // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.\n for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));\n if (dataStoreGCDetails !== undefined) {\n dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;\n }\n }\n }\n return dataStoreGCDetailsMap;\n });\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(\n options: {\n /** Logger to use for logging GC events */\n logger?: ITelemetryLogger,\n /** True to run GC sweep phase after the mark phase */\n runSweep?: boolean,\n /** True to generate full GC data */\n fullGC?: boolean,\n },\n ): Promise<IGCStats> {\n const {\n logger = this.mc.logger,\n runSweep = this.shouldRunSweep,\n fullGC = this.gcOptions.runFullGC === true || this.summaryStateNeedsReset,\n } = options;\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n await this.initializeBaseStateP;\n\n // Let the runtime update its pending state before GC runs.\n await this.provider.updateStateBeforeGC();\n\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n\n // Get the runtime's GC data and run GC on the reference graph in it.\n const gcData = await this.provider.getGCData(fullGC);\n\n this.updateStateSinceLatestRun(gcData);\n\n const gcResult = runGarbageCollection(\n gcData.gcNodes,\n [ \"/\" ],\n logger,\n );\n\n const currentTimestampMs = this.getCurrentTimestampMs();\n // Update the current state of the system based on the GC run.\n this.updateCurrentState(gcData, gcResult, currentTimestampMs);\n\n const dataStoreUsedStateStats =\n this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentTimestampMs);\n\n if (runSweep) {\n // Placeholder for running sweep logic.\n }\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = gcResult.deletedNodeIds.length;\n gcStats.totalNodes = gcResult.referencedNodeIds.length + gcResult.deletedNodeIds.length;\n gcStats.deletedDataStores = dataStoreUsedStateStats.unusedNodeCount;\n gcStats.totalDataStores = dataStoreUsedStateStats.totalNodeCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.testMode) {\n this.deleteUnusedRoutes(gcResult.deletedNodeIds);\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n },\n { end: true, cancel: \"error\" });\n }\n\n /**\n * Summarizes the GC data and returns it as a summary tree.\n * We current write the entire GC state in a single blob. This can be modified later to write multiple\n * blobs. All the blob keys should start with `gcBlobPrefix`.\n */\n public summarize(): ISummaryTreeWithStats | undefined {\n if (!this.shouldRunGC || this.gcDataFromLastRun === undefined) {\n return;\n }\n\n const gcState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n gcState.gcNodes[nodeId] = {\n outboundRoutes,\n unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n };\n }\n\n const builder = new SummaryTreeBuilder();\n builder.addBlob(`${gcBlobPrefix}_root`, JSON.stringify(gcState));\n return builder.getSummaryTree();\n }\n\n /**\n * Returns a map of data store ids to their base GC details generated from the base summary.This is used to\n * initialize the GC state of data stores.\n */\n public async getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>> {\n return this.dataStoreGCDetailsP;\n }\n\n /**\n * Called when the latest summary of the system has been refreshed. This will be used to update the state of the\n * latest summary tracked.\n */\n public async latestSummaryStateRefreshed(\n result: RefreshSummaryResult,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // After a summary is successfully submitted and ack'd by this client, the GC state should have been reset in\n // the summary and doesn't need to be reset anymore.\n this.initialStateNeedsReset = false;\n\n if (!this.shouldRunGC || !result.latestSummaryUpdated) {\n return;\n }\n\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Basically, it was written in the current GC version.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update latest GC version from the snapshot in the result as\n // that is now the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot, readAndParseBlob);\n }\n\n /**\n * Called when a node with the given id is changed. If the node is inactive, log an error.\n */\n public nodeChanged(id: string) {\n // Prefix \"/\" if needed to make it relative to the root.\n const nodeId = id.startsWith(\"/\") ? id : `/${id}`;\n this.unreferencedNodesState.get(nodeId)?.logIfInactive(\n this.mc.logger,\n \"inactiveObjectChanged\",\n this.getCurrentTimestampMs(),\n this.deleteTimeoutMs,\n nodeId,\n );\n }\n\n public dispose(): void {\n if (this.sessionExpiryTimer !== undefined) {\n clearTimeout(this.sessionExpiryTimer);\n this.sessionExpiryTimer = undefined;\n }\n }\n\n /**\n * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n * referenced between summaries so that their unreferenced timestamp can be reset.\n *\n * @param fromNodeId - The node from which the reference is added.\n * @param toNodeId - The node to which the reference is added.\n */\n public addedOutboundReference(fromNodeId: string, toNodeId: string) {\n const outboundRoutes = this.referencesSinceLastRun.get(fromNodeId) ?? [];\n outboundRoutes.push(toNodeId);\n this.referencesSinceLastRun.set(fromNodeId, outboundRoutes);\n }\n\n /**\n * Update the latest summary GC version from the metadata blob in the given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree, readAndParseBlob: ReadAndParseBlob) {\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n /**\n * Updates the state of the system as per the current GC run. It does the following:\n * 1. Sets up the current GC state as per the gcData.\n * 2. Starts tracking for nodes that have become unreferenced in this run.\n * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n * @param gcData - The data representing the reference graph on which GC is run.\n * @param gcResult - The result of the GC run on the gcData.\n * @param currentTimestampMs - The current timestamp to be used for unreferenced nodes' timestamp.\n */\n private updateCurrentState(gcData: IGarbageCollectionData, gcResult: IGCResult, currentTimestampMs: number) {\n this.gcDataFromLastRun = cloneGCData(gcData);\n this.referencesSinceLastRun.clear();\n\n // Iterate through the deleted nodes and start tracking if they became unreferenced in this run.\n for (const nodeId of gcResult.deletedNodeIds) {\n // The time when the node became unreferenced. This is added to the current GC state.\n let unreferencedTimestampMs: number = currentTimestampMs;\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n unreferencedTimestampMs = nodeStateTracker.unreferencedTimestampMs;\n } else {\n // Start tracking this node as it became unreferenced in this run.\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(unreferencedTimestampMs, this.deleteTimeoutMs),\n );\n }\n }\n\n // Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // If this node has been unreferenced for longer than deleteTimeoutMs and is being referenced,\n // log an error as this may mean the deleteTimeoutMs is not long enough.\n nodeStateTracker.logIfInactive(\n this.mc.logger,\n \"inactiveObjectRevived\",\n currentTimestampMs,\n this.deleteTimeoutMs,\n nodeId,\n );\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n * time. It's possible that nodes transition from `unreferenced -> referenced -> unreferenced` between two runs. The\n * unreferenced timestamp of such nodes needs to be reset as they may have been accessed when they were referenced.\n *\n * This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.\n * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n */\n private updateStateSinceLatestRun(currentGCData: IGarbageCollectionData) {\n // If we haven't run GC before or no references were added since the last run, there is nothing to do.\n if (this.gcDataFromLastRun === undefined || this.referencesSinceLastRun.size === 0) {\n return;\n }\n\n // Validate that we have identified all references correctly.\n this.validateReferenceCorrectness(currentGCData);\n\n /**\n * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n * edges that have been added since then. To do this, combine the GC data from the last run and the current\n * run, and then add the references since last run.\n *\n * Note on why we need to combine the data from previous run, current run and all references in between -\n * 1. We need data from last run because some of its references may have been deleted since then. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n * references added new outbound references before getting deleted, we need to detect them.\n * 3. We need data from the current run because currently we may not detect when DDSs are referenced:\n * - We don't require DDSs handles to be stored in a referenced DDS. For this, we need GC at DDS level\n * which is tracked by https://github.com/microsoft/FluidFramework/issues/8470.\n * - A new data store may have \"root\" DDSs already created and we don't detect them today.\n */\n const gcDataSuperSet = concatGarbageCollectionData(this.gcDataFromLastRun, currentGCData);\n this.referencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n } else {\n gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n }\n });\n\n /**\n * Run GC on the above reference graph to find all nodes that are referenced. For each one, if they are\n * unreferenced, stop tracking them and remove from unreferenced list.\n * Some of these nodes may be unreferenced now and if so, the current run will add unreferenced state for them.\n */\n const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\"/\"], this.mc.logger);\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Validates that all new references are correctly identified and processed. The basic principle for validation is\n * that we should not have new references in the reference graph (GC data) that have not been notified to the\n * garbage collector via `referenceAdded`.\n * We validate that the references in the current reference graph should be a subset of the references in the last\n * run's reference graph + references since the last run.\n * @param currentGCData - The GC data (reference graph) from the current GC run.\n */\n private validateReferenceCorrectness(currentGCData: IGarbageCollectionData) {\n assert(this.gcDataFromLastRun !== undefined, 0x2b7\n /* \"Can't validate correctness without GC data from last run\" */);\n\n // Get a list of all the outbound routes (or references) in the current GC data.\n const currentReferences: string[] = [];\n for (const [nodeId, outboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n /**\n * Remove routes from a child node to its parent which is added implicitly by the runtime. For instance,\n * each adds its data store as an outbound route to mark it as referenced if the DDS is referenced.\n * We won't get any explicit notification for these references so they must be removed before validation.\n */\n const explicitRoutes = outboundRoutes.filter((route) => !nodeId.startsWith(route));\n currentReferences.push(...explicitRoutes);\n }\n\n // Get a list of outbound routes (or references) from the last run's GC data plus references added since the\n // last run that were notified via `referenceAdded`.\n const explicitReferences: string[] = [];\n for (const [, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n explicitReferences.push(...outboundRoutes);\n }\n this.referencesSinceLastRun.forEach((outboundRoutes: string[]) => {\n explicitReferences.push(...outboundRoutes);\n });\n\n // Validate that the current reference graph doesn't have references that we are not already aware of. If this\n // happens, it might indicate data corruption since we may delete objects prematurely.\n currentReferences.forEach((route: string) => {\n // Validate references for data stores only whose routes are of the format \"/dataStoreId\". Currently, layers\n // below data stores don't have GC implemented so there is no guarantee their references will be notified.\n if (route.split(\"/\").length === 2 && !explicitReferences.includes(route)) {\n /**\n * The following log will be enabled once this issue is resolved:\n * https://github.com/microsoft/FluidFramework/issues/8878.\n */\n // We should ideally throw a data corruption error here. However, send an error for now until we have\n // implemented sweep and have reasonable confidence in the sweep process.\n // this.mc.logger.sendErrorEvent({\n // eventName: \"gcUnknownOutboundRoute\",\n // route,\n // });\n }\n });\n }\n}\n\n/**\n * Gets the garbage collection state from the given snapshot tree. The GC state may be written into multiple blobs.\n * Merge the GC state from all such blobs and return the merged GC state.\n*/\nasync function getGCStateFromSnapshot(\n gcSnapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<IGarbageCollectionState> {\n let rootGCState: IGarbageCollectionState = { gcNodes: {} };\n for (const key of Object.keys(gcSnapshotTree.blobs)) {\n // Skip blobs that do not stsart with the GC prefix.\n if (!key.startsWith(gcBlobPrefix)) {\n continue;\n }\n\n const blobId = gcSnapshotTree.blobs[key];\n if (blobId === undefined) {\n continue;\n }\n const gcState = await readAndParseBlob<IGarbageCollectionState>(blobId);\n assert(gcState !== undefined, 0x2ad /* \"GC blob missing from snapshot\" */);\n // Merge the GC state of this blob into the root GC state.\n rootGCState = concatGarbageCollectionStates(rootGCState, gcState);\n }\n return rootGCState;\n}\n\n/**\n * setLongTimeout is used for timeouts longer than setTimeout's ~24.8 day max\n * @param timeoutMs - the total time the timeout needs to last in ms\n * @param timeoutFn - the function to execute when the timer ends\n * @param setTimerFn - the function used to update your timer variable\n */\nfunction setLongTimeout(\n timeoutMs: number,\n timeoutFn: () => void,\n setTimerFn: (timer: ReturnType<typeof setTimeout>) => void,\n) {\n // The setTimeout max is 24.8 days before looping occurs.\n const maxTimeout = 2147483647;\n let timer: ReturnType<typeof setTimeout>;\n if (timeoutMs > maxTimeout) {\n const newTimeoutMs = timeoutMs - maxTimeout;\n timer = setTimeout(() => setLongTimeout(newTimeoutMs, timeoutFn, setTimerFn), maxTimeout);\n } else {\n timer = setTimeout(() => timeoutFn(), timeoutMs);\n }\n setTimerFn(timer);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "0.56.8";
8
+ export declare const pkgVersion = "0.56.11";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,WAAW,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,sCAAsC,CAAC;AAC3D,eAAO,MAAM,UAAU,YAAY,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-runtime";
8
- export const pkgVersion = "0.56.8";
8
+ export const pkgVersion = "0.56.11";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"0.56.8\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"0.56.11\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-runtime",
3
- "version": "0.56.8",
3
+ "version": "0.56.11",
4
4
  "description": "Fluid container runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -59,26 +59,26 @@
59
59
  "@fluidframework/common-definitions": "^0.20.1",
60
60
  "@fluidframework/common-utils": "^0.32.1",
61
61
  "@fluidframework/container-definitions": "^0.45.0",
62
- "@fluidframework/container-runtime-definitions": "^0.56.8",
63
- "@fluidframework/container-utils": "^0.56.8",
62
+ "@fluidframework/container-runtime-definitions": "^0.56.11",
63
+ "@fluidframework/container-utils": "^0.56.11",
64
64
  "@fluidframework/core-interfaces": "^0.42.0",
65
- "@fluidframework/datastore": "^0.56.8",
65
+ "@fluidframework/datastore": "^0.56.11",
66
66
  "@fluidframework/driver-definitions": "^0.44.0",
67
- "@fluidframework/driver-utils": "^0.56.8",
68
- "@fluidframework/garbage-collector": "^0.56.8",
67
+ "@fluidframework/driver-utils": "^0.56.11",
68
+ "@fluidframework/garbage-collector": "^0.56.11",
69
69
  "@fluidframework/protocol-base": "^0.1034.0",
70
70
  "@fluidframework/protocol-definitions": "^0.1026.0",
71
- "@fluidframework/runtime-definitions": "^0.56.8",
72
- "@fluidframework/runtime-utils": "^0.56.8",
73
- "@fluidframework/telemetry-utils": "^0.56.8",
71
+ "@fluidframework/runtime-definitions": "^0.56.11",
72
+ "@fluidframework/runtime-utils": "^0.56.11",
73
+ "@fluidframework/telemetry-utils": "^0.56.11",
74
74
  "double-ended-queue": "^2.1.0-0",
75
75
  "uuid": "^8.3.1"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@fluidframework/build-common": "^0.23.0",
79
79
  "@fluidframework/eslint-config-fluid": "^0.25.0",
80
- "@fluidframework/mocha-test-setup": "^0.56.8",
81
- "@fluidframework/test-runtime-utils": "^0.56.8",
80
+ "@fluidframework/mocha-test-setup": "^0.56.11",
81
+ "@fluidframework/test-runtime-utils": "^0.56.11",
82
82
  "@microsoft/api-extractor": "^7.16.1",
83
83
  "@rushstack/eslint-config": "^2.5.1",
84
84
  "@types/double-ended-queue": "^2.1.0",
@@ -325,9 +325,14 @@ export class GarbageCollector implements IGarbageCollector {
325
325
 
326
326
  // If session expiry is enabled, we need to close the container when the timeout expires
327
327
  if (this.sessionExpiryTimeoutMs !== undefined) {
328
- const expiryMs = this.sessionExpiryTimeoutMs;
329
- this.sessionExpiryTimer = setTimeout(() => this.closeFn(
330
- new ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);
328
+ const timeoutMs = this.sessionExpiryTimeoutMs;
329
+ setLongTimeout(timeoutMs,
330
+ () => {
331
+ this.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));
332
+ },
333
+ (timer) => {
334
+ this.sessionExpiryTimer = timer;
335
+ });
331
336
  }
332
337
 
333
338
  // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
@@ -855,3 +860,26 @@ async function getGCStateFromSnapshot(
855
860
  }
856
861
  return rootGCState;
857
862
  }
863
+
864
+ /**
865
+ * setLongTimeout is used for timeouts longer than setTimeout's ~24.8 day max
866
+ * @param timeoutMs - the total time the timeout needs to last in ms
867
+ * @param timeoutFn - the function to execute when the timer ends
868
+ * @param setTimerFn - the function used to update your timer variable
869
+ */
870
+ function setLongTimeout(
871
+ timeoutMs: number,
872
+ timeoutFn: () => void,
873
+ setTimerFn: (timer: ReturnType<typeof setTimeout>) => void,
874
+ ) {
875
+ // The setTimeout max is 24.8 days before looping occurs.
876
+ const maxTimeout = 2147483647;
877
+ let timer: ReturnType<typeof setTimeout>;
878
+ if (timeoutMs > maxTimeout) {
879
+ const newTimeoutMs = timeoutMs - maxTimeout;
880
+ timer = setTimeout(() => setLongTimeout(newTimeoutMs, timeoutFn, setTimerFn), maxTimeout);
881
+ } else {
882
+ timer = setTimeout(() => timeoutFn(), timeoutMs);
883
+ }
884
+ setTimerFn(timer);
885
+ }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-runtime";
9
- export const pkgVersion = "0.56.8";
9
+ export const pkgVersion = "0.56.11";