@fluidframework/container-runtime 2.0.0-internal.3.1.0 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blobManager.d.ts +6 -0
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +31 -6
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +17 -15
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +158 -121
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +21 -12
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +76 -50
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +9 -10
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +42 -49
- package/dist/dataStores.js.map +1 -1
- package/dist/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +5 -200
- package/dist/gc/garbageCollection.d.ts.map +1 -0
- package/dist/{garbageCollection.js → gc/garbageCollection.js} +77 -353
- package/dist/gc/garbageCollection.js.map +1 -0
- package/dist/gc/gcDefinitions.d.ts +189 -0
- package/dist/gc/gcDefinitions.d.ts.map +1 -0
- package/dist/{garbageCollectionConstants.js → gc/gcDefinitions.js} +24 -2
- package/dist/gc/gcDefinitions.js.map +1 -0
- package/{lib/garbageCollectionHelpers.d.ts → dist/gc/gcHelpers.d.ts} +5 -1
- package/dist/gc/gcHelpers.d.ts.map +1 -0
- package/dist/{garbageCollectionHelpers.js → gc/gcHelpers.js} +27 -7
- package/dist/gc/gcHelpers.js.map +1 -0
- package/dist/gc/gcSummaryStateTracker.d.ts +86 -0
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/dist/gc/gcSummaryStateTracker.js +246 -0
- package/dist/gc/gcSummaryStateTracker.js.map +1 -0
- package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +2 -2
- package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.js +94 -0
- package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
- package/dist/gc/index.d.ts +11 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/gc/index.js +40 -0
- package/dist/gc/index.js.map +1 -0
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -9
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +2 -13
- package/dist/opLifecycle/batchManager.d.ts.map +1 -1
- package/dist/opLifecycle/batchManager.js +7 -36
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +4 -0
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js +1 -0
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts +1 -1
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +20 -12
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +19 -3
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +59 -28
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +1 -2
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +14 -9
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/summary/index.d.ts +17 -0
- package/dist/summary/index.d.ts.map +1 -0
- package/dist/summary/index.js +47 -0
- package/dist/summary/index.js.map +1 -0
- package/dist/summary/orderedClientElection.d.ts.map +1 -0
- package/dist/summary/orderedClientElection.js.map +1 -0
- package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
- package/{lib → dist/summary}/runningSummarizer.d.ts +19 -18
- package/dist/summary/runningSummarizer.d.ts.map +1 -0
- package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +158 -56
- package/dist/summary/runningSummarizer.js.map +1 -0
- package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +2 -4
- package/dist/summary/summarizer.d.ts.map +1 -0
- package/dist/{summarizer.js → summary/summarizer.js} +1 -61
- package/dist/summary/summarizer.js.map +1 -0
- package/dist/summary/summarizerClientElection.d.ts.map +1 -0
- package/dist/summary/summarizerClientElection.js.map +1 -0
- package/dist/summary/summarizerHandle.d.ts.map +1 -0
- package/dist/summary/summarizerHandle.js.map +1 -0
- package/dist/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
- package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
- package/dist/summary/summarizerHeuristics.js.map +1 -0
- package/{lib → dist/summary}/summarizerTypes.d.ts +1 -1
- package/dist/summary/summarizerTypes.d.ts.map +1 -0
- package/dist/summary/summarizerTypes.js.map +1 -0
- package/dist/summary/summaryCollection.d.ts.map +1 -0
- package/dist/summary/summaryCollection.js.map +1 -0
- package/{lib → dist/summary}/summaryFormat.d.ts +1 -43
- package/dist/summary/summaryFormat.d.ts.map +1 -0
- package/dist/{summaryFormat.js → summary/summaryFormat.js} +1 -10
- package/dist/summary/summaryFormat.js.map +1 -0
- package/dist/summary/summaryGenerator.d.ts.map +1 -0
- package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +1 -2
- package/dist/summary/summaryGenerator.js.map +1 -0
- package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
- package/dist/summary/summaryManager.d.ts.map +1 -0
- package/dist/summary/summaryManager.js.map +1 -0
- package/lib/blobManager.d.ts +6 -0
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +28 -3
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +17 -15
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +127 -90
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +21 -12
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +64 -38
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +9 -10
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +33 -40
- package/lib/dataStores.js.map +1 -1
- package/lib/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +5 -200
- package/lib/gc/garbageCollection.d.ts.map +1 -0
- package/lib/{garbageCollection.js → gc/garbageCollection.js} +44 -319
- package/lib/gc/garbageCollection.js.map +1 -0
- package/lib/gc/gcDefinitions.d.ts +189 -0
- package/lib/gc/gcDefinitions.d.ts.map +1 -0
- package/lib/{garbageCollectionConstants.js → gc/gcDefinitions.js} +23 -1
- package/lib/gc/gcDefinitions.js.map +1 -0
- package/{dist/garbageCollectionHelpers.d.ts → lib/gc/gcHelpers.d.ts} +5 -1
- package/lib/gc/gcHelpers.d.ts.map +1 -0
- package/lib/{garbageCollectionHelpers.js → gc/gcHelpers.js} +20 -2
- package/lib/gc/gcHelpers.js.map +1 -0
- package/lib/gc/gcSummaryStateTracker.d.ts +86 -0
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/lib/gc/gcSummaryStateTracker.js +242 -0
- package/lib/gc/gcSummaryStateTracker.js.map +1 -0
- package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
- package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +1 -1
- package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
- package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.js +90 -0
- package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
- package/lib/gc/index.d.ts +11 -0
- package/lib/gc/index.d.ts.map +1 -0
- package/lib/gc/index.js +11 -0
- package/lib/gc/index.js.map +1 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -4
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +2 -13
- package/lib/opLifecycle/batchManager.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +7 -36
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +4 -0
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js +1 -0
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts +1 -1
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +20 -12
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +19 -3
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +60 -29
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +1 -2
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +14 -9
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/summary/index.d.ts +17 -0
- package/lib/summary/index.d.ts.map +1 -0
- package/lib/summary/index.js +16 -0
- package/lib/summary/index.js.map +1 -0
- package/lib/summary/orderedClientElection.d.ts.map +1 -0
- package/lib/summary/orderedClientElection.js.map +1 -0
- package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
- package/{dist → lib/summary}/runningSummarizer.d.ts +19 -18
- package/lib/summary/runningSummarizer.d.ts.map +1 -0
- package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +159 -57
- package/lib/summary/runningSummarizer.js.map +1 -0
- package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +2 -4
- package/lib/summary/summarizer.d.ts.map +1 -0
- package/lib/{summarizer.js → summary/summarizer.js} +3 -63
- package/lib/summary/summarizer.js.map +1 -0
- package/lib/summary/summarizerClientElection.d.ts.map +1 -0
- package/lib/summary/summarizerClientElection.js.map +1 -0
- package/lib/summary/summarizerHandle.d.ts.map +1 -0
- package/lib/summary/summarizerHandle.js.map +1 -0
- package/lib/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
- package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
- package/lib/summary/summarizerHeuristics.js.map +1 -0
- package/{dist → lib/summary}/summarizerTypes.d.ts +1 -1
- package/lib/summary/summarizerTypes.d.ts.map +1 -0
- package/lib/summary/summarizerTypes.js.map +1 -0
- package/lib/summary/summaryCollection.d.ts.map +1 -0
- package/lib/summary/summaryCollection.js.map +1 -0
- package/{dist → lib/summary}/summaryFormat.d.ts +1 -43
- package/lib/summary/summaryFormat.d.ts.map +1 -0
- package/lib/{summaryFormat.js → summary/summaryFormat.js} +0 -8
- package/lib/summary/summaryFormat.js.map +1 -0
- package/lib/summary/summaryGenerator.d.ts.map +1 -0
- package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +1 -2
- package/lib/summary/summaryGenerator.js.map +1 -0
- package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
- package/lib/summary/summaryManager.d.ts.map +1 -0
- package/lib/summary/summaryManager.js.map +1 -0
- package/package.json +125 -122
- package/src/blobManager.ts +33 -3
- package/src/containerRuntime.ts +178 -106
- package/src/dataStoreContext.ts +90 -49
- package/src/dataStores.ts +44 -51
- package/{garbageCollection.md → src/gc/garbageCollection.md} +2 -2
- package/src/{garbageCollection.ts → gc/garbageCollection.ts} +90 -560
- package/src/gc/gcDefinitions.ts +244 -0
- package/src/{garbageCollectionHelpers.ts → gc/gcHelpers.ts} +26 -1
- package/src/gc/gcSummaryStateTracker.ts +339 -0
- package/src/{gcSweepReadyUsageDetection.ts → gc/gcSweepReadyUsageDetection.ts} +1 -1
- package/src/gc/gcUnreferencedStateTracker.ts +114 -0
- package/src/gc/index.ts +40 -0
- package/src/index.ts +10 -14
- package/src/opLifecycle/batchManager.ts +7 -54
- package/src/opLifecycle/definitions.ts +4 -0
- package/src/opLifecycle/opCompressor.ts +1 -0
- package/src/opLifecycle/opSplitter.ts +33 -14
- package/src/opLifecycle/outbox.ts +84 -38
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +26 -14
- package/src/summary/index.ts +99 -0
- package/src/{runningSummarizer.ts → summary/runningSummarizer.ts} +279 -139
- package/src/{summarizer.ts → summary/summarizer.ts} +5 -76
- package/src/{summarizerHeuristics.ts → summary/summarizerHeuristics.ts} +1 -1
- package/src/{summarizerTypes.ts → summary/summarizerTypes.ts} +1 -1
- package/src/{summaryFormat.ts → summary/summaryFormat.ts} +1 -53
- package/src/{summaryGenerator.ts → summary/summaryGenerator.ts} +9 -9
- package/src/{summaryManager.ts → summary/summaryManager.ts} +1 -1
- package/dist/garbageCollection.d.ts.map +0 -1
- package/dist/garbageCollection.js.map +0 -1
- package/dist/garbageCollectionConstants.d.ts +0 -26
- package/dist/garbageCollectionConstants.d.ts.map +0 -1
- package/dist/garbageCollectionConstants.js.map +0 -1
- package/dist/garbageCollectionHelpers.d.ts.map +0 -1
- package/dist/garbageCollectionHelpers.js.map +0 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
- package/dist/gcSweepReadyUsageDetection.js.map +0 -1
- package/dist/orderedClientElection.d.ts.map +0 -1
- package/dist/orderedClientElection.js.map +0 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/dist/runWhileConnectedCoordinator.js.map +0 -1
- package/dist/runningSummarizer.d.ts.map +0 -1
- package/dist/runningSummarizer.js.map +0 -1
- package/dist/summarizer.d.ts.map +0 -1
- package/dist/summarizer.js.map +0 -1
- package/dist/summarizerClientElection.d.ts.map +0 -1
- package/dist/summarizerClientElection.js.map +0 -1
- package/dist/summarizerHandle.d.ts.map +0 -1
- package/dist/summarizerHandle.js.map +0 -1
- package/dist/summarizerHeuristics.d.ts.map +0 -1
- package/dist/summarizerHeuristics.js.map +0 -1
- package/dist/summarizerTypes.d.ts.map +0 -1
- package/dist/summarizerTypes.js.map +0 -1
- package/dist/summaryCollection.d.ts.map +0 -1
- package/dist/summaryCollection.js.map +0 -1
- package/dist/summaryFormat.d.ts.map +0 -1
- package/dist/summaryFormat.js.map +0 -1
- package/dist/summaryGenerator.d.ts.map +0 -1
- package/dist/summaryGenerator.js.map +0 -1
- package/dist/summaryManager.d.ts.map +0 -1
- package/dist/summaryManager.js.map +0 -1
- package/lib/garbageCollection.d.ts.map +0 -1
- package/lib/garbageCollection.js.map +0 -1
- package/lib/garbageCollectionConstants.d.ts +0 -26
- package/lib/garbageCollectionConstants.d.ts.map +0 -1
- package/lib/garbageCollectionConstants.js.map +0 -1
- package/lib/garbageCollectionHelpers.d.ts.map +0 -1
- package/lib/garbageCollectionHelpers.js.map +0 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
- package/lib/gcSweepReadyUsageDetection.js.map +0 -1
- package/lib/orderedClientElection.d.ts.map +0 -1
- package/lib/orderedClientElection.js.map +0 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/lib/runWhileConnectedCoordinator.js.map +0 -1
- package/lib/runningSummarizer.d.ts.map +0 -1
- package/lib/runningSummarizer.js.map +0 -1
- package/lib/summarizer.d.ts.map +0 -1
- package/lib/summarizer.js.map +0 -1
- package/lib/summarizerClientElection.d.ts.map +0 -1
- package/lib/summarizerClientElection.js.map +0 -1
- package/lib/summarizerHandle.d.ts.map +0 -1
- package/lib/summarizerHandle.js.map +0 -1
- package/lib/summarizerHeuristics.d.ts.map +0 -1
- package/lib/summarizerHeuristics.js.map +0 -1
- package/lib/summarizerTypes.d.ts.map +0 -1
- package/lib/summarizerTypes.js.map +0 -1
- package/lib/summaryCollection.d.ts.map +0 -1
- package/lib/summaryCollection.js.map +0 -1
- package/lib/summaryFormat.d.ts.map +0 -1
- package/lib/summaryFormat.js.map +0 -1
- package/lib/summaryGenerator.d.ts.map +0 -1
- package/lib/summaryGenerator.js.map +0 -1
- package/lib/summaryManager.d.ts.map +0 -1
- package/lib/summaryManager.js.map +0 -1
- package/src/garbageCollectionConstants.ts +0 -44
- /package/dist/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
- /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
- /package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
- /package/dist/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
- /package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
- /package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
- /package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
- /package/dist/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
- /package/dist/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
- /package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +0 -0
- /package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
- /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
- /package/dist/{summaryCollection.js → summary/summaryCollection.js} +0 -0
- /package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
- /package/dist/{summaryManager.js → summary/summaryManager.js} +0 -0
- /package/lib/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
- /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
- /package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
- /package/lib/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
- /package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
- /package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
- /package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
- /package/lib/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
- /package/lib/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
- /package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +0 -0
- /package/lib/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
- /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
- /package/lib/{summaryCollection.js → summary/summaryCollection.js} +0 -0
- /package/lib/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
- /package/lib/{summaryManager.js → summary/summaryManager.js} +0 -0
- /package/src/{orderedClientElection.ts → summary/orderedClientElection.ts} +0 -0
- /package/src/{runWhileConnectedCoordinator.ts → summary/runWhileConnectedCoordinator.ts} +0 -0
- /package/src/{summarizerClientElection.ts → summary/summarizerClientElection.ts} +0 -0
- /package/src/{summarizerHandle.ts → summary/summarizerHandle.ts} +0 -0
- /package/src/{summaryCollection.ts → summary/summaryCollection.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summaryFormat.js","sourceRoot":"","sources":["../src/summaryFormat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAEtD,+DAA4D;AAC5D,+EA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C;AACnB,CAAC;AAfD,kEAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { readAndParse } from \"@fluidframework/driver-utils\";\nimport {\n\tISequencedDocumentMessage,\n\tISnapshotTree,\n\tSummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tchannelsTreeName,\n\tgcTreeKey,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\n\ntype OmitAttributesVersions<T> = Omit<T, \"snapshotFormatVersion\" | \"summaryFormatVersion\">;\ninterface IFluidDataStoreAttributes0 {\n\treadonly snapshotFormatVersion?: undefined;\n\treadonly summaryFormatVersion?: undefined;\n\tpkg: string;\n\t/**\n\t * This tells whether a data store is root. Root data stores are never collected.\n\t * Non-root data stores may be collected if they are not used. If this is not present, default it to\n\t * true. This will ensure that older data stores are incorrectly collected.\n\t */\n\treadonly isRootDataStore?: boolean;\n}\ninterface IFluidDataStoreAttributes1 extends OmitAttributesVersions<IFluidDataStoreAttributes0> {\n\treadonly snapshotFormatVersion: \"0.1\";\n\treadonly summaryFormatVersion?: undefined;\n}\ninterface IFluidDataStoreAttributes2 extends OmitAttributesVersions<IFluidDataStoreAttributes1> {\n\t/** Switch from snapshotFormatVersion to summaryFormatVersion */\n\treadonly snapshotFormatVersion?: undefined;\n\treadonly summaryFormatVersion: 2;\n\t/**\n\t * True if channels are not isolated in .channels subtrees, otherwise isolated.\n\t * This is required in both datastore attributes as well as the root container,\n\t * because reused summary handles may cause different format versions in each\n\t * datastore subtree within the summary.\n\t */\n\treadonly disableIsolatedChannels?: true;\n}\n/**\n * Added IFluidDataStoreAttributes similar to IChannelAttributes which will tell the attributes of a\n * store like the package, snapshotFormatVersion to take different decisions based on a particular\n * snapshotFormatVersion.\n */\nexport type ReadFluidDataStoreAttributes =\n\t| IFluidDataStoreAttributes0\n\t| IFluidDataStoreAttributes1\n\t| IFluidDataStoreAttributes2;\nexport type WriteFluidDataStoreAttributes = IFluidDataStoreAttributes1 | IFluidDataStoreAttributes2;\n\nexport function getAttributesFormatVersion(attributes: ReadFluidDataStoreAttributes): number {\n\tif (attributes.summaryFormatVersion) {\n\t\t/**\n\t\t * Version 2+: Introduces .channels trees for isolation of\n\t\t * channel trees from data store objects.\n\t\t */\n\t\treturn attributes.summaryFormatVersion;\n\t} else if (attributes.snapshotFormatVersion === \"0.1\") {\n\t\t/**\n\t\t * Version 1: from this version the pkg within the data store\n\t\t * attributes blob is a JSON array rather than a string.\n\t\t */\n\t\treturn 1;\n\t}\n\t/**\n\t * Version 0: format version is missing from summary.\n\t * This indicates it is an older version.\n\t */\n\treturn 0;\n}\n\nexport function hasIsolatedChannels(attributes: ReadFluidDataStoreAttributes): boolean {\n\treturn !!attributes.summaryFormatVersion && !attributes.disableIsolatedChannels;\n}\nexport interface IContainerRuntimeMetadata extends ICreateContainerMetadata, IGCMetadata {\n\treadonly summaryFormatVersion: 1;\n\t/** The last message processed at the time of summary. Only primitive property types are added to the summary. */\n\treadonly message: ISummaryMetadataMessage | undefined;\n\t/** True if channels are not isolated in .channels subtrees, otherwise isolated. */\n\treadonly disableIsolatedChannels?: true;\n\t/** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */\n\treadonly summaryNumber?: number;\n}\n\nexport interface ICreateContainerMetadata {\n\t/** Runtime version of the container when it was first created */\n\tcreateContainerRuntimeVersion?: string;\n\t/** Timestamp of the container when it was first created */\n\tcreateContainerTimestamp?: number;\n}\n\n/** @see IGCMetadata.gcFeatureMatrix */\nexport interface GCFeatureMatrix {\n\t/**\n\t * The Tombstone Generation value in effect when this file was created.\n\t * Gives a way for an app to disqualify old files from GC Tombstone enforcement\n\t * Provided via Container Runtime Options\n\t */\n\ttombstoneGeneration?: number;\n}\n\nexport type GCVersion = number;\nexport interface IGCMetadata {\n\t/**\n\t * The version of the GC code that was run to generate the GC data that is written in the summary.\n\t * If the persisted value doesn't match the current value in the code, saved GC data will be discarded and regenerated from scratch.\n\t * Also, used to determine whether GC is enabled for this container or not:\n\t * - A value of 0 or undefined means GC is disabled.\n\t * - A value greater than 0 means GC is enabled.\n\t */\n\treadonly gcFeature?: GCVersion;\n\n\t/**\n\t * A collection of different numerical \"Generations\" for different features,\n\t * used to determine feature availability over time.\n\t * This info may come from multiple sources (FF code, config service, app via Container Runtime Options),\n\t * and pertains to aspects of the document that may be fixed for its lifetime.\n\t *\n\t * For each dimension, if the persisted value doesn't match the currently provided value,\n\t * then this file does not support the corresponding feature as currently implemented.\n\t *\n\t * Guidance is that if no value is provided at runtime, it should result in the current default behavior.\n\t */\n\treadonly gcFeatureMatrix?: GCFeatureMatrix;\n\t/**\n\t * Tells whether the GC sweep phase is enabled for this container.\n\t * - True means sweep phase is enabled.\n\t * - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.\n\t */\n\treadonly sweepEnabled?: boolean;\n\t/** If this is present, the session for this container will expire after this time and the container will close */\n\treadonly sessionExpiryTimeoutMs?: number;\n\t/** How long to wait after an object is unreferenced before deleting it via GC Sweep */\n\treadonly sweepTimeoutMs?: number;\n}\n\n/** The properties of an ISequencedDocumentMessage to be stored in the metadata blob in summary. */\nexport type ISummaryMetadataMessage = Pick<\n\tISequencedDocumentMessage,\n\t| \"clientId\"\n\t| \"clientSequenceNumber\"\n\t| \"minimumSequenceNumber\"\n\t| \"referenceSequenceNumber\"\n\t| \"sequenceNumber\"\n\t| \"timestamp\"\n\t| \"type\"\n>;\n\n/**\n * Extracts the properties from an ISequencedDocumentMessage as defined by ISummaryMetadataMessage. This message is\n * added to the metadata blob in summary.\n */\nexport const extractSummaryMetadataMessage = (\n\tmessage?: ISequencedDocumentMessage,\n): ISummaryMetadataMessage | undefined =>\n\tmessage === undefined\n\t\t? undefined\n\t\t: {\n\t\t\t\tclientId: message.clientId,\n\t\t\t\tclientSequenceNumber: message.clientSequenceNumber,\n\t\t\t\tminimumSequenceNumber: message.minimumSequenceNumber,\n\t\t\t\treferenceSequenceNumber: message.referenceSequenceNumber,\n\t\t\t\tsequenceNumber: message.sequenceNumber,\n\t\t\t\ttimestamp: message.timestamp,\n\t\t\t\ttype: message.type,\n\t\t };\n\nexport function getMetadataFormatVersion(metadata?: IContainerRuntimeMetadata): number {\n\t/**\n\t * Version 2+: Introduces runtime sequence number for data verification.\n\t *\n\t * Version 1+: Introduces .metadata blob and .channels trees for isolation of\n\t * data store trees from container-level objects.\n\t * Also introduces enableGC option stored in the summary.\n\t *\n\t * Version 0: metadata blob missing; format version is missing from summary.\n\t * This indicates it is an older version.\n\t */\n\treturn metadata?.summaryFormatVersion ?? 0;\n}\n\nexport const aliasBlobName = \".aliases\";\nexport const metadataBlobName = \".metadata\";\nexport const chunksBlobName = \".chunks\";\nexport const electedSummarizerBlobName = \".electedSummarizer\";\nexport const blobsTreeName = \".blobs\";\n\nexport function rootHasIsolatedChannels(metadata?: IContainerRuntimeMetadata): boolean {\n\treturn !!metadata && !metadata.disableIsolatedChannels;\n}\n\nexport function getGCVersion(metadata?: IGCMetadata): GCVersion {\n\tif (!metadata) {\n\t\t// Force to 0/disallowed in prior versions\n\t\treturn 0;\n\t}\n\treturn metadata.gcFeature ?? 0;\n}\n\nexport const protocolTreeName = \".protocol\";\n\n/**\n * List of tree IDs at the container level which are reserved.\n * This is for older versions of summaries that do not yet have an\n * isolated data stores namespace. Without the namespace, this must\n * be used to prevent name collisions with data store IDs.\n */\nexport const nonDataStorePaths = [\n\tprotocolTreeName,\n\t\".logTail\",\n\t\".serviceProtocol\",\n\tblobsTreeName,\n\tgcTreeKey,\n];\n\nexport const dataStoreAttributesBlobName = \".component\";\n\n/**\n * Modifies summary tree and stats to put tree under .channels tree.\n *\n * @param summarizeResult - Summary tree and stats to modify\n *\n * @example\n * Converts from:\n * ```typescript\n * {\n * type: SummaryType.Tree,\n * tree: { a: {...}, b: {...}, c: {...} },\n * }\n * ```\n *\n * to:\n *\n * ```typescript\n * {\n * type: SummaryType.Tree,\n * tree: {\n * \".channels\": {\n * type: SummaryType.Tree,\n * tree: { a: {...}, b: {...}, c: {...} }\n * },\n * },\n * }\n * ```\n * And adds +1 to treeNodeCount in stats.\n */\nexport function wrapSummaryInChannelsTree(summarizeResult: ISummaryTreeWithStats): void {\n\tsummarizeResult.summary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { [channelsTreeName]: summarizeResult.summary },\n\t};\n\tsummarizeResult.stats.treeNodeCount++;\n}\n\nexport async function getFluidDataStoreAttributes(\n\tstorage: IDocumentStorageService,\n\tsnapshot: ISnapshotTree,\n): Promise<ReadFluidDataStoreAttributes> {\n\tconst attributes = await readAndParse<ReadFluidDataStoreAttributes>(\n\t\tstorage,\n\t\tsnapshot.blobs[dataStoreAttributesBlobName],\n\t);\n\t// Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.\n\t// For snapshotFormatVersion = \"0.1\" (1) or above, pkg is jsonified, otherwise it is just a string.\n\t// However the feature of loading a detached container from snapshot, is added when the\n\t// snapshotFormatVersion is at least \"0.1\" (1), so we don't expect it to be anything else.\n\tconst formatVersion = getAttributesFormatVersion(attributes);\n\tassert(formatVersion > 0, 0x1d5 /* Invalid snapshot format version */);\n\treturn attributes;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summaryGenerator.d.ts","sourceRoot":"","sources":["../src/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAEN,QAAQ,EACR,aAAa,EACb,mBAAmB,EAEnB,MAAM,8BAA8B,CAAC;AAKtC,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EAE7B,MA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IAAA,qBAAM,EAAC,IAAI,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACpD;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;IAEO,qBAAqB,CAAC,IAAY,EAAE,KAAa;QACxD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS,EAAE,kBAAkB;YAC7B,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACnB,CAAC,CAAC;QACH,IAAI,KAAK,GAAG,wBAAwB,EAAE;YACrC,+BAA+B;YAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC;YAC1B,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,CACxC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAC/C,CAAC;SACF;IACF,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACD;AAnVD,4CAmVC","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 {\n\tassert,\n\tDeferred,\n\tIPromiseTimer,\n\tIPromiseTimerResult,\n\tTimer,\n} from \"@fluidframework/common-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { PerformanceEvent, LoggingError, ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { getRetryDelaySecondsFromError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIAckSummaryResult,\n\tINackSummaryResult,\n\tISummarizeOptions,\n\tIBroadcastSummaryResult,\n\tISummarizeResults,\n\tISummarizeHeuristicData,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tSummarizeResultPart,\n\tISummaryCancellationToken,\n\tISummarizeTelemetryProperties,\n\tSummaryGeneratorTelemetry,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher } from \"./summaryCollection\";\n\nexport type raceTimerResult<T> =\n\t| { result: \"done\"; value: T }\n\t| { result: IPromiseTimerResult[\"timerResult\"] }\n\t| { result: \"cancelled\" };\n\n/** Helper function to wait for a promise or PromiseTimer to elapse. */\nexport async function raceTimer<T>(\n\tpromise: Promise<T>,\n\ttimer: Promise<IPromiseTimerResult>,\n\tcancellationToken?: ISummaryCancellationToken,\n): Promise<raceTimerResult<T>> {\n\tconst promises: Promise<raceTimerResult<T>>[] = [\n\t\tpromise.then((value) => ({ result: \"done\", value } as const)),\n\t\ttimer.then(({ timerResult: result }) => ({ result } as const)),\n\t];\n\tif (cancellationToken !== undefined) {\n\t\tpromises.push(\n\t\t\tcancellationToken.waitCancelled.then(() => ({ result: \"cancelled\" } as const)),\n\t\t);\n\t}\n\treturn Promise.race(promises);\n}\n\n// Send some telemetry if generate summary takes too long\nconst maxSummarizeTimeoutTime = 20000; // 20 sec\nconst maxSummarizeTimeoutCount = 5; // Double and resend 5 times\n\nexport type SummarizeReason =\n\t/**\n\t * Attempt to summarize after idle timeout has elapsed.\n\t * Idle timer restarts whenever an op is received. So this\n\t * triggers only after some amount of time has passed with\n\t * no ops being received.\n\t */\n\t| \"idle\"\n\t/**\n\t * Attempt to summarize after a maximum time since last\n\t * successful summary has passed. This measures time since\n\t * last summary ack op was processed.\n\t */\n\t| \"maxTime\"\n\t/**\n\t * Attempt to summarize after a maximum number of ops have\n\t * passed since the last successful summary. This compares\n\t * op sequence numbers with the reference sequence number\n\t * of the summarize op corresponding to the last summary\n\t * ack op.\n\t */\n\t| \"maxOps\"\n\t/**\n\t * Special case to attempt to summarize one last time before the\n\t * summarizer client closes itself. This is to prevent cases where\n\t * the summarizer client never gets a chance to summarize, because\n\t * there are too many outstanding ops and/or parent client cannot\n\t * stay connected long enough for summarizer client to catch up.\n\t */\n\t| \"lastSummary\"\n\t/** On-demand summary requested with specified reason. */\n\t| `onDemand;${string}`\n\t/** Enqueue summarize attempt with specified reason. */\n\t| `enqueue;${string}`;\n\nconst summarizeErrors = {\n\t/**\n\t * Error encountered while generating the summary tree, uploading\n\t * it to storage, or submitting the op. It could be a result of\n\t * the client becoming disconnected while generating or an actual error.\n\t */\n\tsubmitSummaryFailure: \"Error while generating, uploading, or submitting summary\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving the summarize op\n\t * sent by this summarize attempt. It is expected to be broadcast quickly.\n\t */\n\tsummaryOpWaitTimeout: \"Timeout while waiting for summarize op broadcast\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving either a\n\t * summaryAck or summaryNack op from the server in response to this\n\t * summarize attempt. It is expected that the server should respond.\n\t */\n\tsummaryAckWaitTimeout: \"Timeout while waiting for summaryAck/summaryNack op\",\n\t/**\n\t * The server responded with a summaryNack op, thus rejecting this\n\t * summarize attempt.\n\t */\n\tsummaryNack: \"Server rejected summary via summaryNack op\",\n\n\tdisconnect: \"Summary cancelled due to summarizer or main client disconnect\",\n} as const;\n\nexport class SummarizeResultBuilder {\n\tpublic readonly summarySubmitted = new Deferred<SummarizeResultPart<SubmitSummaryResult>>();\n\tpublic readonly summaryOpBroadcasted = new Deferred<\n\t\tSummarizeResultPart<IBroadcastSummaryResult>\n\t>();\n\tpublic readonly receivedSummaryAckOrNack = new Deferred<\n\t\tSummarizeResultPart<IAckSummaryResult, INackSummaryResult>\n\t>();\n\n\tpublic fail(\n\t\tmessage: string,\n\t\terror: any,\n\t\tnackSummaryResult?: INackSummaryResult,\n\t\tretryAfterSeconds?: number,\n\t) {\n\t\tassert(\n\t\t\t!this.receivedSummaryAckOrNack.isCompleted,\n\t\t\t0x25e /* \"no reason to call fail if all promises have been completed\" */,\n\t\t);\n\n\t\tconst result: SummarizeResultPart<undefined> = {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t\tdata: undefined,\n\t\t\terror,\n\t\t\tretryAfterSeconds,\n\t\t} as const;\n\t\tthis.summarySubmitted.resolve(result);\n\t\tthis.summaryOpBroadcasted.resolve(result);\n\t\tthis.receivedSummaryAckOrNack.resolve({ ...result, data: nackSummaryResult });\n\t}\n\tpublic build(): ISummarizeResults {\n\t\treturn {\n\t\t\tsummarySubmitted: this.summarySubmitted.promise,\n\t\t\tsummaryOpBroadcasted: this.summaryOpBroadcasted.promise,\n\t\t\treceivedSummaryAckOrNack: this.receivedSummaryAckOrNack.promise,\n\t\t} as const;\n\t}\n}\n\n/**\n * This class generates and tracks a summary attempt.\n */\nexport class SummaryGenerator {\n\tprivate readonly summarizeTimer: Timer;\n\tconstructor(\n\t\tprivate readonly pendingAckTimer: IPromiseTimer,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly raiseSummarizingError: (errorMessage: string) => void,\n\t\tprivate readonly successfulSummaryCallback: () => void,\n\t\tprivate readonly summaryWatcher: Pick<IClientSummaryWatcher, \"watchSummary\">,\n\t\tprivate readonly logger: ITelemetryLogger,\n\t) {\n\t\tthis.summarizeTimer = new Timer(maxSummarizeTimeoutTime, () =>\n\t\t\tthis.summarizeTimerHandler(maxSummarizeTimeoutTime, 1),\n\t\t);\n\t}\n\n\t/**\n\t * Generates summary and listens for broadcast and ack/nack.\n\t * Returns true for ack, false for nack, and undefined for failure or timeout.\n\t * @param reason - reason for summarizing\n\t * @param options - refreshLatestAck to fetch summary ack info from server,\n\t * fullTree to generate tree without any summary handles even if unchanged\n\t */\n\tpublic summarize(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"Summarize_start\",\n\t\t\t...summarizeProps,\n\t\t});\n\t\tthis.summarizeCore(summarizeProps, options, resultsBuilder, cancellationToken).catch(\n\t\t\t(error) => {\n\t\t\t\tconst message = \"UnexpectedSummarizeError\";\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: message, ...summarizeProps }, error);\n\t\t\t\tresultsBuilder.fail(message, error);\n\t\t\t},\n\t\t);\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\tprivate async summarizeCore(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t): Promise<void> {\n\t\tconst { refreshLatestAck, fullTree } = options;\n\t\tconst logger = ChildLogger.create(this.logger, undefined, { all: summarizeProps });\n\n\t\t// Note: timeSinceLastAttempt and timeSinceLastSummary for the\n\t\t// first summary are basically the time since the summarizer was loaded.\n\t\tconst timeSinceLastAttempt = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\tconst timeSinceLastSummary =\n\t\t\tDate.now() - this.heuristicData.lastSuccessfulSummary.summaryTime;\n\t\tlet summarizeTelemetryProps: SummaryGeneratorTelemetry = {\n\t\t\tfullTree,\n\t\t\ttimeSinceLastAttempt,\n\t\t\ttimeSinceLastSummary,\n\t\t};\n\n\t\tconst summarizeEvent = PerformanceEvent.start(logger, {\n\t\t\teventName: \"Summarize\",\n\t\t\trefreshLatestAck,\n\t\t\t...summarizeTelemetryProps,\n\t\t});\n\n\t\t// Helper functions to report failures and return.\n\t\tconst getFailMessage = (errorCode: keyof typeof summarizeErrors) =>\n\t\t\t`${errorCode}: ${summarizeErrors[errorCode]}`;\n\t\tconst fail = (\n\t\t\terrorCode: keyof typeof summarizeErrors,\n\t\t\terror?: any,\n\t\t\tproperties?: SummaryGeneratorTelemetry,\n\t\t\tnackSummaryResult?: INackSummaryResult,\n\t\t) => {\n\t\t\tthis.raiseSummarizingError(summarizeErrors[errorCode]);\n\t\t\t// UploadSummary may fail with 429 and retryAfter - respect that\n\t\t\t// Summary Nack also can have retryAfter, it's parsed below and comes as a property.\n\t\t\tconst retryAfterSeconds = getRetryDelaySecondsFromError(error);\n\n\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t// If failure happened on upload, we may not yet realized that socket disconnected, so check\n\t\t\t// offlineError too.\n\t\t\tconst category =\n\t\t\t\tcancellationToken.cancelled || error?.errorType === DriverErrorType.offlineError\n\t\t\t\t\t? \"generic\"\n\t\t\t\t\t: \"error\";\n\n\t\t\tconst message = getFailMessage(errorCode);\n\t\t\tsummarizeEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\t...properties,\n\t\t\t\t\treason: errorCode,\n\t\t\t\t\tcategory,\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t},\n\t\t\t\terror ?? message,\n\t\t\t); // disconnect & summaryAckTimeout do not have proper error.\n\t\t\tresultsBuilder.fail(message, error, nackSummaryResult, retryAfterSeconds);\n\t\t};\n\n\t\t// Wait to generate and send summary\n\t\tthis.summarizeTimer.start();\n\n\t\t// Use record type to prevent unexpected value types\n\t\tlet summaryData: SubmitSummaryResult | undefined;\n\t\ttry {\n\t\t\tsummaryData = await this.submitSummaryCallback({\n\t\t\t\tfullTree,\n\t\t\t\trefreshLatestAck,\n\t\t\t\tsummaryLogger: logger,\n\t\t\t\tcancellationToken,\n\t\t\t});\n\n\t\t\t// Cumulatively add telemetry properties based on how far generateSummary went.\n\t\t\tconst referenceSequenceNumber = summaryData.referenceSequenceNumber;\n\t\t\tconst opsSinceLastSummary =\n\t\t\t\treferenceSequenceNumber -\n\t\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\treferenceSequenceNumber,\n\t\t\t\tminimumSequenceNumber: summaryData.minimumSequenceNumber,\n\t\t\t\topsSinceLastAttempt:\n\t\t\t\t\treferenceSequenceNumber - this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\topsSinceLastSummary,\n\t\t\t};\n\t\t\tsummarizeTelemetryProps = this.addSummaryDataToTelemetryProps(\n\t\t\t\tsummaryData,\n\t\t\t\tsummarizeTelemetryProps,\n\t\t\t);\n\n\t\t\tif (summaryData.stage !== \"submit\") {\n\t\t\t\treturn fail(\"submitSummaryFailure\", summaryData.error, summarizeTelemetryProps);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * With incremental summaries, if the full tree was not summarized, only data stores that changed should\n\t\t\t * be summarized. A data store is considered changed if either or both of the following is true:\n\t\t\t * - It has received an op.\n\t\t\t * - Its reference state changed, i.e., it went from referenced to unreferenced or vice-versa.\n\t\t\t *\n\t\t\t * In the extreme case, every op can be for a different data store and each op can result in the reference\n\t\t\t * state change of multiple data stores. So, the total number of data stores that are summarized should not\n\t\t\t * exceed the number of ops since last summary + number of data store whose reference state changed.\n\t\t\t */\n\t\t\tif (!fullTree && !summaryData.forcedFullTree) {\n\t\t\t\tconst { summarizedDataStoreCount, gcStateUpdatedDataStoreCount = 0 } =\n\t\t\t\t\tsummaryData.summaryStats;\n\t\t\t\tif (summarizedDataStoreCount > gcStateUpdatedDataStoreCount + opsSinceLastSummary) {\n\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"IncrementalSummaryViolation\",\n\t\t\t\t\t\tsummarizedDataStoreCount,\n\t\t\t\t\t\tgcStateUpdatedDataStoreCount,\n\t\t\t\t\t\topsSinceLastSummary,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Log event here on summary success only, as Summarize_cancel duplicates failure logging.\n\t\t\tsummarizeEvent.reportEvent(\"generate\", { ...summarizeTelemetryProps });\n\t\t\tresultsBuilder.summarySubmitted.resolve({ success: true, data: summaryData });\n\t\t} catch (error) {\n\t\t\treturn fail(\"submitSummaryFailure\", error);\n\t\t} finally {\n\t\t\tthis.heuristicData.recordAttempt(summaryData?.referenceSequenceNumber);\n\t\t\tthis.summarizeTimer.clear();\n\t\t}\n\n\t\ttry {\n\t\t\tconst pendingTimeoutP = this.pendingAckTimer.start();\n\t\t\tconst summary = this.summaryWatcher.watchSummary(summaryData.clientSequenceNumber);\n\n\t\t\t// Wait for broadcast\n\t\t\tconst waitBroadcastResult = await raceTimer(\n\t\t\t\tsummary.waitBroadcast(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitBroadcastResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\");\n\t\t\t}\n\t\t\tif (waitBroadcastResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryOpWaitTimeout\");\n\t\t\t}\n\t\t\tconst summarizeOp = waitBroadcastResult.value;\n\n\t\t\tconst broadcastDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\t\tresultsBuilder.summaryOpBroadcasted.resolve({\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: { summarizeOp, broadcastDuration },\n\t\t\t});\n\n\t\t\tthis.heuristicData.lastAttempt.summarySequenceNumber = summarizeOp.sequenceNumber;\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"Summarize_Op\",\n\t\t\t\tduration: broadcastDuration,\n\t\t\t\treferenceSequenceNumber: summarizeOp.referenceSequenceNumber,\n\t\t\t\tsummarySequenceNumber: summarizeOp.sequenceNumber,\n\t\t\t\thandle: summarizeOp.contents.handle,\n\t\t\t});\n\n\t\t\t// Wait for ack/nack\n\t\t\tconst waitAckNackResult = await raceTimer(\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitAckNackResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\");\n\t\t\t}\n\t\t\tif (waitAckNackResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryAckWaitTimeout\");\n\t\t\t}\n\t\t\tconst ackNackOp = waitAckNackResult.value;\n\t\t\tthis.pendingAckTimer.clear();\n\n\t\t\t// Update for success/failure\n\t\t\tconst ackNackDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\n\t\t\t// adding new properties\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\tackWaitDuration: ackNackDuration,\n\t\t\t\tackNackSequenceNumber: ackNackOp.sequenceNumber,\n\t\t\t\tsummarySequenceNumber: ackNackOp.contents.summaryProposal.summarySequenceNumber,\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t};\n\t\t\tif (ackNackOp.type === MessageType.SummaryAck) {\n\t\t\t\tthis.heuristicData.markLastAttemptAsSuccessful();\n\t\t\t\tthis.successfulSummaryCallback();\n\t\t\t\tsummarizeEvent.end({\n\t\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\t\thandle: ackNackOp.contents.handle,\n\t\t\t\t});\n\t\t\t\tresultsBuilder.receivedSummaryAckOrNack.resolve({\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsummaryAckOp: ackNackOp,\n\t\t\t\t\t\tackNackDuration,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Check for retryDelay in summaryNack response.\n\t\t\t\tassert(ackNackOp.type === MessageType.SummaryNack, 0x274 /* \"type check\" */);\n\t\t\t\tconst summaryNack = ackNackOp.contents;\n\t\t\t\tconst errorMessage = summaryNack?.message;\n\t\t\t\tconst retryAfterSeconds = summaryNack?.retryAfter;\n\n\t\t\t\t// pre-0.58 error message prefix: summaryNack\n\t\t\t\tconst error = new LoggingError(`Received summaryNack`, {\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t\terrorMessage,\n\t\t\t\t});\n\n\t\t\t\tassert(\n\t\t\t\t\tgetRetryDelaySecondsFromError(error) === retryAfterSeconds,\n\t\t\t\t\t0x25f /* \"retryAfterSeconds\" */,\n\t\t\t\t);\n\t\t\t\t// This will only set resultsBuilder.receivedSummaryAckOrNack, as other promises are already set.\n\t\t\t\treturn fail(\n\t\t\t\t\t\"summaryNack\",\n\t\t\t\t\terror,\n\t\t\t\t\t{ ...summarizeTelemetryProps, nackRetryAfter: retryAfterSeconds },\n\t\t\t\t\t{ summaryNackOp: ackNackOp, ackNackDuration },\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.pendingAckTimer.clear();\n\t\t}\n\t}\n\n\tprivate addSummaryDataToTelemetryProps(\n\t\tsummaryData: SubmitSummaryResult,\n\t\tinitialProps: SummaryGeneratorTelemetry,\n\t): SummaryGeneratorTelemetry {\n\t\tswitch (summaryData.stage) {\n\t\t\tcase \"base\":\n\t\t\t\treturn initialProps;\n\n\t\t\tcase \"generate\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t};\n\n\t\t\tcase \"upload\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t};\n\n\t\t\tcase \"submit\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t\tclientSequenceNumber: summaryData.clientSequenceNumber,\n\t\t\t\t\thasMissingOpData: this.heuristicData.hasMissingOpData,\n\t\t\t\t\topsSizesSinceLastSummary: this.heuristicData.totalOpsSize,\n\t\t\t\t\tnonRuntimeOpsSinceLastSummary: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t};\n\n\t\t\tdefault:\n\t\t\t\tassert(true, 0x397 /* Unexpected summary stage */);\n\t\t}\n\n\t\treturn initialProps;\n\t}\n\n\tprivate summarizeTimerHandler(time: number, count: number) {\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName: \"SummarizeTimeout\",\n\t\t\ttimeoutTime: time,\n\t\t\ttimeoutCount: count,\n\t\t});\n\t\tif (count < maxSummarizeTimeoutCount) {\n\t\t\t// Double and start a new timer\n\t\t\tconst nextTime = time * 2;\n\t\t\tthis.summarizeTimer.start(nextTime, () =>\n\t\t\t\tthis.summarizeTimerHandler(nextTime, count + 1),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic dispose() {\n\t\tthis.summarizeTimer.clear();\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summaryManager.d.ts","sourceRoot":"","sources":["../src/summaryManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,MAAM,oCAAoC,CAAC;AAI5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAMxD,oBAAY,mBAAmB;IAC9B,GAAG,IAAI;IACP,QAAQ,IAAI;IACZ,OAAO,IAAI;IACX,QAAQ,IAAI;CACZ;AAaD,MAAM,WAAW,gBAAiB,SAAQ,MAAM;IAC/C,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,OAAE;IAC3D,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,IAAI,OAAE;CAC9C;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IACxE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;;;OAMG;IACH,QAAQ,CAAC,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,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;QAC3D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACjE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;;AA1VF,wCA2VC;AAvRwB,kCAAmB,GAAG,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,KAAK,mBAAmB,CAAC,QAAQ,IAAI,KAAK,KAAK,mBAAmB,CAAC,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDisposable,\n\tIEvent,\n\tIEventProvider,\n\tITelemetryLogger,\n} from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ISummarizerClientElection } from \"./summarizerClientElection\";\nimport { IThrottler } from \"./throttler\";\nimport { ISummarizer, SummarizerStopReason } from \"./summarizerTypes\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { Summarizer } from \"./summarizer\";\n\nconst defaultInitialDelayMs = 5000;\nconst defaultOpsToBypassInitialDelay = 4000;\n\nexport enum SummaryManagerState {\n\tOff = 0,\n\tStarting = 1,\n\tRunning = 2,\n\tStopping = 3,\n}\n\n// Please note that all reasons in this list are not errors,\n// and thus they are not raised today to parent container as error.\n// If this needs to be changed in future, we should re-evaluate what and how we raise to summarizer\ntype StopReason = Extract<\n\tSummarizerStopReason,\n\t\"parentNotConnected\" | \"notElectedParent\" | \"notElectedClient\"\n>;\ntype ShouldSummarizeState =\n\t| { shouldSummarize: true }\n\t| { shouldSummarize: false; stopReason: StopReason };\n\nexport interface IConnectedEvents extends IEvent {\n\t(event: \"connected\", listener: (clientId: string) => void);\n\t(event: \"disconnected\", listener: () => void);\n}\n\n/**\n * IConnectedState describes an object that SummaryManager can watch to observe connection/disconnection.\n *\n * Under current implementation, its role will be fulfilled by the ContainerRuntime, but this could be replaced\n * with anything else that fulfills the contract if we want to shift the layer that the SummaryManager lives at.\n */\nexport interface IConnectedState extends IEventProvider<IConnectedEvents> {\n\treadonly connected: boolean;\n\n\t/**\n\t * Under current implementation this is undefined if we've never connected, otherwise it's the clientId from our\n\t * latest connection (even if we've since disconnected!). Although this happens to be the behavior we want in\n\t * SummaryManager, I suspect that globally we may eventually want to modify this behavior (e.g. make clientId\n\t * undefined while disconnected). To protect against this, let's assume this field can't be trusted while\n\t * disconnected and instead separately track \"latest clientId\" in SummaryManager.\n\t */\n\treadonly clientId: string | undefined;\n}\n\nexport interface ISummaryManagerConfig {\n\tinitialDelayMs: number;\n\topsToBypassInitialDelay: number;\n}\n\n/**\n * SummaryManager is created by parent container (i.e. interactive container with clientType !== \"summarizer\") only.\n * It observes changes in calculated summarizer and reacts to changes by either creating summarizer client or\n * stopping existing summarizer client.\n */\nexport class SummaryManager implements IDisposable {\n\tprivate readonly logger: ITelemetryLogger;\n\tprivate readonly opsToBypassInitialDelay: number;\n\tprivate readonly initialDelayMs: number;\n\tprivate latestClientId: string | undefined;\n\tprivate state = SummaryManagerState.Off;\n\tprivate summarizer?: ISummarizer;\n\tprivate _disposed = false;\n\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\n\tpublic get currentState() {\n\t\treturn this.state;\n\t}\n\n\tconstructor(\n\t\tprivate readonly clientElection: ISummarizerClientElection,\n\t\tprivate readonly connectedState: IConnectedState,\n\t\tprivate readonly summaryCollection: Pick<\n\t\t\tSummaryCollection,\n\t\t\t\"opsSinceLastAck\" | \"addOpListener\" | \"removeOpListener\"\n\t\t>,\n\t\tparentLogger: ITelemetryLogger,\n\t\t/** Creates summarizer by asking interactive container to spawn summarizing container and\n\t\t * get back its Summarizer instance. */\n\t\tprivate readonly requestSummarizerFn: () => Promise<ISummarizer>,\n\t\tprivate readonly startThrottler: IThrottler,\n\t\t{\n\t\t\tinitialDelayMs = defaultInitialDelayMs,\n\t\t\topsToBypassInitialDelay = defaultOpsToBypassInitialDelay,\n\t\t}: Readonly<Partial<ISummaryManagerConfig>> = {},\n\t\tprivate readonly disableHeuristics?: boolean,\n\t) {\n\t\tthis.logger = ChildLogger.create(parentLogger, \"SummaryManager\", {\n\t\t\tall: { clientId: () => this.latestClientId },\n\t\t});\n\n\t\tthis.connectedState.on(\"connected\", this.handleConnected);\n\t\tthis.connectedState.on(\"disconnected\", this.handleDisconnected);\n\t\tthis.latestClientId = this.connectedState.clientId;\n\n\t\tthis.opsToBypassInitialDelay = opsToBypassInitialDelay;\n\t\tthis.initialDelayMs = initialDelayMs;\n\t}\n\n\t/**\n\t * Until start is called, the SummaryManager won't begin attempting to start summarization. This ensures there's\n\t * a window between construction and starting where the caller can attach listeners.\n\t */\n\tpublic start(): void {\n\t\tthis.clientElection.on(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.refreshSummarizer();\n\t}\n\n\tprivate readonly handleConnected = (clientId: string) => {\n\t\tthis.latestClientId = clientId;\n\t\t// If we have a summarizer, it should have been either cancelled on disconnected by now.\n\t\t// But because of lastSummary process, it can still hang around, so there is not much we can\n\t\t// check or assert.\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate readonly handleDisconnected = () => {\n\t\tthis.refreshSummarizer();\n\t};\n\n\tprivate static readonly isStartingOrRunning = (state: SummaryManagerState) =>\n\t\tstate === SummaryManagerState.Starting || state === SummaryManagerState.Running;\n\n\tprivate getShouldSummarizeState(): ShouldSummarizeState {\n\t\t// Note that if we're in the Running state, the electedClient may be a summarizer client, so we can't\n\t\t// enforce connectedState.clientId === clientElection.electedClientId. But once we're Running, we should\n\t\t// only transition to Stopping when the electedParentId changes. Stopping the summarizer without\n\t\t// changing the electedParent will just cause us to transition to Starting again.\n\n\t\t// New Parent has been elected and it is not the current client, or\n\t\tif (this.connectedState.clientId !== this.clientElection.electedParentId) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedParent\" };\n\t\t}\n\n\t\t// We are not already running the summarizer and we are not the current elected client id.\n\t\tif (\n\t\t\tthis.state !== SummaryManagerState.Running &&\n\t\t\tthis.connectedState.clientId !== this.clientElection.electedClientId\n\t\t) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"notElectedClient\" };\n\t\t}\n\n\t\tif (!this.connectedState.connected) {\n\t\t\treturn { shouldSummarize: false, stopReason: \"parentNotConnected\" };\n\t\t}\n\n\t\tif (this.disposed) {\n\t\t\tassert(false, 0x260 /* \"Disposed should mean disconnected!\" */);\n\t\t} else {\n\t\t\treturn { shouldSummarize: true };\n\t\t}\n\t}\n\n\tprivate readonly refreshSummarizer = () => {\n\t\t// Transition states depending on shouldSummarize, which is a calculated property\n\t\t// that is only true if this client is connected and is the elected summarizer.\n\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\tswitch (this.state) {\n\t\t\tcase SummaryManagerState.Off: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Starting: {\n\t\t\t\t// Cannot take any action until summarizer is created\n\t\t\t\t// state transition will occur after creation\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Running: {\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\tthis.stop(shouldSummarizeState.stopReason);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase SummaryManagerState.Stopping: {\n\t\t\t\t// Cannot take any action until running summarizer finishes\n\t\t\t\t// state transition will occur after it stops\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate startSummarization() {\n\t\tassert(this.state === SummaryManagerState.Off, 0x261 /* \"Expected: off\" */);\n\t\tthis.state = SummaryManagerState.Starting;\n\n\t\tassert(this.summarizer === undefined, 0x262 /* \"Old summarizer is still working!\" */);\n\n\t\tthis.delayBeforeCreatingSummarizer()\n\t\t\t.then(async (startWithInitialDelay: boolean) => {\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// but only if creation was delayed. If it was not, then we want to ensure we always create\n\t\t\t\t// a summarizer to kick off lastSummary. Without that, we would not be able to summarize and get\n\t\t\t\t// document out of broken state if it has too many ops and ordering service keeps nacking main\n\t\t\t\t// container (and thus it goes into cycle of reconnects)\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeStateEarlyStage = this.getShouldSummarizeState();\n\t\t\t\tif (\n\t\t\t\t\tstartWithInitialDelay &&\n\t\t\t\t\tshouldSummarizeStateEarlyStage.shouldSummarize === false\n\t\t\t\t) {\n\t\t\t\t\treturn `early exit ${shouldSummarizeStateEarlyStage.stopReason}`;\n\t\t\t\t}\n\n\t\t\t\t// We transition to Running before requesting the summarizer, because after requesting we can't predict\n\t\t\t\t// when the electedClient will be replaced with the new summarizer client.\n\t\t\t\t// The alternative would be to let connectedState.clientId !== clientElection.electedClientId when\n\t\t\t\t// state === Starting || state === Running.\n\t\t\t\tassert(\n\t\t\t\t\tthis.state === SummaryManagerState.Starting,\n\t\t\t\t\t0x263 /* \"Expected: starting\" */,\n\t\t\t\t);\n\t\t\t\tthis.state = SummaryManagerState.Running;\n\n\t\t\t\tconst summarizer = await this.requestSummarizerFn();\n\t\t\t\tthis.summarizer = summarizer;\n\n\t\t\t\t// Re-validate that it need to be running. Due to asynchrony, it may be not the case anymore\n\t\t\t\t// If we can't run the LastSummary, simply return as to avoid paying the cost of launching\n\t\t\t\t// the summarizer at all.\n\t\t\t\tconst shouldSummarizeState = this.getShouldSummarizeState();\n\t\t\t\tif (shouldSummarizeState.shouldSummarize === false) {\n\t\t\t\t\t// In order to allow the last summary to run, we not only need a stop reason that would\n\t\t\t\t\t// allow it but also, startWithInitialDelay to be false (start the summarization immediately),\n\t\t\t\t\t// which would happen when we have a high enough number of unsummarized ops.\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartWithInitialDelay ||\n\t\t\t\t\t\t!Summarizer.stopReasonCanRunLastSummary(shouldSummarizeState.stopReason)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.state = SummaryManagerState.Starting;\n\t\t\t\t\t\tsummarizer.stop(shouldSummarizeState.stopReason);\n\t\t\t\t\t\treturn `early exit after starting summarizer ${shouldSummarizeState.stopReason}`;\n\t\t\t\t\t}\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"LastAttemptToSummarize\",\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst clientId = this.latestClientId!;\n\n\t\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{ eventName: \"RunningSummarizer\", attempt: this.startThrottler.numAttempts },\n\t\t\t\t\tasync () => summarizer.run(clientId, this.disableHeuristics),\n\t\t\t\t);\n\t\t\t})\n\t\t\t.then((reason: string) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\treason,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"EndingSummarizer\",\n\t\t\t\t\t\treason: \"exception\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\t// Most of exceptions happen due to container being closed while loading it, due to\n\t\t\t\t// summarizer container loosing connection while load.\n\t\t\t\t// Not worth reporting such errors as errors. That said, we might miss some real errors if\n\t\t\t\t// we ignore blindly, so try to narrow signature we are looking for - skip logging\n\t\t\t\t// error only if this client should no longer be a summarizer (which in practice\n\t\t\t\t// means it also lost connection), and error happened on load (we do not have summarizer).\n\t\t\t\t// We could annotate the error raised in Container.load where the container closed during load with no error\n\t\t\t\t// and check for that case here, but that does not seem to be necessary.\n\t\t\t\tif (\n\t\t\t\t\tthis.getShouldSummarizeState().shouldSummarize ||\n\t\t\t\t\tthis.summarizer !== undefined\n\t\t\t\t) {\n\t\t\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t\t\t// If failure happened on container load, we may not yet realized that socket disconnected, so check\n\t\t\t\t\t// offlineError.\n\t\t\t\t\tconst category =\n\t\t\t\t\t\terror?.errorType === DriverErrorType.offlineError ? \"generic\" : \"error\";\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizerException\",\n\t\t\t\t\t\t\tcategory,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tassert(this.state !== SummaryManagerState.Off, 0x264 /* \"Expected: Not Off\" */);\n\t\t\t\tthis.state = SummaryManagerState.Off;\n\n\t\t\t\tthis.summarizer?.close();\n\t\t\t\tthis.summarizer = undefined;\n\n\t\t\t\tif (this.getShouldSummarizeState().shouldSummarize) {\n\t\t\t\t\tthis.startSummarization();\n\t\t\t\t}\n\t\t\t});\n\t}\n\n\tprivate stop(reason: SummarizerStopReason) {\n\t\tif (!SummaryManager.isStartingOrRunning(this.state)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.state = SummaryManagerState.Stopping;\n\n\t\t// Stopping the running summarizer client should trigger a change\n\t\t// in states when the running summarizer closes\n\t\tthis.summarizer?.stop(reason);\n\t}\n\n\t/**\n\t * Implements initial delay before creating summarizer\n\t * @returns `true`, if creation is delayed due to heuristics (not many ops to summarize).\n\t * `false` if summarizer should start immediately due to too many unsummarized ops.\n\t */\n\tprivate async delayBeforeCreatingSummarizer(): Promise<boolean> {\n\t\t// throttle creation of new summarizer containers to prevent spamming the server with websocket connections\n\t\tlet delayMs = this.startThrottler.getDelay();\n\n\t\t// We have been elected the summarizer. Some day we may be able to summarize with a live document but for\n\t\t// now we play it safe and launch a second copy.\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"CreatingSummarizer\",\n\t\t\tthrottlerDelay: delayMs,\n\t\t\tinitialDelay: this.initialDelayMs,\n\t\t\tstartThrottlerMaxDelayMs: this.startThrottler.maxDelayMs,\n\t\t\topsSinceLastAck: this.summaryCollection.opsSinceLastAck,\n\t\t\topsToBypassInitialDelay: this.opsToBypassInitialDelay,\n\t\t});\n\n\t\t// This delay helps ensure that last summarizer that might be left from previous client\n\t\t// has enough time to complete its last summary and thus new summarizer not conflict with previous one.\n\t\t// If, however, there are too many unsummarized ops, try to resolve it as quickly as possible, with\n\t\t// understanding that we may see nacks because of such quick action.\n\t\t// A better design would be for summarizer election logic to always select current summarizer as\n\t\t// summarizing client (i.e. clientType === \"summarizer\" can be elected) to ensure that nobody else can\n\t\t// summarizer while it finishes its work and moves to exit.\n\t\t// It also helps with pure boot scenario (single client) to offset expensive work a bit out from\n\t\t// critical boot sequence.\n\t\tlet startWithInitialDelay = false;\n\t\tif (this.summaryCollection.opsSinceLastAck < this.opsToBypassInitialDelay) {\n\t\t\tstartWithInitialDelay = true;\n\t\t\tdelayMs = Math.max(delayMs, this.initialDelayMs);\n\t\t}\n\n\t\tif (delayMs > 0) {\n\t\t\tlet timer;\n\t\t\tlet resolveOpPromiseFn;\n\t\t\t// Create a listener that will break the delay if we've exceeded the initial delay ops count.\n\t\t\tconst opsListenerFn = () => {\n\t\t\t\tif (this.summaryCollection.opsSinceLastAck >= this.opsToBypassInitialDelay) {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolveOpPromiseFn();\n\t\t\t\t}\n\t\t\t};\n\t\t\t// Create a Promise that will resolve when the delay expires.\n\t\t\tconst delayPromise = new Promise<void>((resolve) => {\n\t\t\t\ttimer = setTimeout(() => resolve(), delayMs);\n\t\t\t});\n\t\t\t// Create a Promise that will resolve if the ops count passes the threshold.\n\t\t\tconst opPromise = new Promise<void>((resolve) => {\n\t\t\t\tresolveOpPromiseFn = resolve;\n\t\t\t});\n\t\t\tthis.summaryCollection.addOpListener(opsListenerFn);\n\t\t\tawait Promise.race([delayPromise, opPromise]);\n\t\t\tthis.summaryCollection.removeOpListener(opsListenerFn);\n\t\t}\n\t\treturn startWithInitialDelay;\n\t}\n\n\tpublic readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.summarizeOnDemand(...args);\n\t};\n\n\tpublic readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n\t\tif (this.summarizer === undefined) {\n\t\t\tthrow Error(\"No running summarizer client\");\n\t\t\t// TODO: could spawn a summarizer client temporarily.\n\t\t}\n\t\treturn this.summarizer.enqueueSummarize(...args);\n\t};\n\n\tpublic dispose() {\n\t\tthis.clientElection.off(\"electedSummarizerChanged\", this.refreshSummarizer);\n\t\tthis.connectedState.off(\"connected\", this.handleConnected);\n\t\tthis.connectedState.off(\"disconnected\", this.handleDisconnected);\n\t\tthis._disposed = true;\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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;AAMhF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAAE,aAAa,EAAe,MAAM,sCAAsC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aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACrD,MAAM,aAAa,GAA4B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC/D,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,aAAa,EAAE;QAC/C,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QAC/B,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC;KACzC;IACD,OAAO,aAAa,CAAC;AACtB,CAAC;AAED,+FAA+F;AAC/F,MAAM,yBAA0B,SAAQ,KAAK;IAC5C,YAA6B,QAAoB;QAChD,2FAA2F;QAC3F,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QAJyB,aAAQ,GAAR,QAAQ,CAAY;IAKjD,CAAC;IAED,KAAK,CAAC,SAAiB;QACtB,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,SAAiB;QACxB,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;CACD","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 {\n\tClientSessionExpiredError,\n\tDataProcessingError,\n\tUsageError,\n} from \"@fluidframework/container-utils\";\nimport { IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport {\n\tcloneGCData,\n\tconcatGarbageCollectionData,\n\tgetGCDataFromSnapshot,\n\tIGCResult,\n\trunGarbageCollection,\n\ttrimLeadingSlashes,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgcTreeKey,\n\tgcBlobPrefix,\n\tgcTombstoneBlobKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tISummarizeResult,\n\tITelemetryContext,\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSummaryDetailsLegacy,\n\tISummaryTreeWithStats,\n\tgcDeletedBlobKey,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tmergeStats,\n\tpackagePathToTelemetryProperty,\n\tReadAndParseBlob,\n\tRefreshSummaryResult,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n\tChildLogger,\n\tgenerateStack,\n\tloggerToMonitoringContext,\n\tMonitoringContext,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions, RuntimeHeaders } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n\tcurrentGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSessionExpiryDurationMs,\n\tdisableSweepLogKey,\n\tdisableTombstoneKey,\n\tgcVersionUpgradeToV2Key,\n\tgcTestModeKey,\n\toneDayMs,\n\trunGCKey,\n\trunSessionExpiryKey,\n\trunSweepKey,\n\tstableGCVersion,\n\ttrackGCStateKey,\n\tgcTombstoneGenerationOptionName,\n} from \"./garbageCollectionConstants\";\nimport { sendGCUnexpectedUsageEvent } from \"./garbageCollectionHelpers\";\nimport { SweepReadyUsageDetectionHandler } from \"./gcSweepReadyUsageDetection\";\nimport {\n\tgetGCVersion,\n\tGCVersion,\n\tIContainerRuntimeMetadata,\n\tmetadataBlobName,\n\tReadFluidDataStoreAttributes,\n\tdataStoreAttributesBlobName,\n\tIGCMetadata,\n\tICreateContainerMetadata,\n\tGCFeatureMatrix,\n} from \"./summaryFormat\";\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n\t/** The number of nodes in the container. */\n\tnodeCount: number;\n\t/** The number of data stores in the container. */\n\tdataStoreCount: number;\n\t/** The number of attachment blobs in the container. */\n\tattachmentBlobCount: number;\n\t/** The number of unreferenced nodes in the container. */\n\tunrefNodeCount: number;\n\t/** The number of unreferenced data stores in the container. */\n\tunrefDataStoreCount: number;\n\t/** The number of unreferenced attachment blobs in the container. */\n\tunrefAttachmentBlobCount: number;\n\t/** The number of nodes whose reference state updated since last GC run. */\n\tupdatedNodeCount: number;\n\t/** The number of data stores whose reference state updated since last GC run. */\n\tupdatedDataStoreCount: number;\n\t/** The number of attachment blobs whose reference state updated since last GC run. */\n\tupdatedAttachmentBlobCount: number;\n}\n\n/** The types of GC nodes in the GC reference graph. */\nexport const GCNodeType = {\n\t// Nodes that are for data stores.\n\tDataStore: \"DataStore\",\n\t// Nodes that are within a data store. For example, DDS nodes.\n\tSubDataStore: \"SubDataStore\",\n\t// Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.\n\tBlob: \"Blob\",\n\t// Nodes that are neither of the above. For example, root node.\n\tOther: \"Other\",\n};\nexport type GCNodeType = typeof GCNodeType[keyof typeof GCNodeType];\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n\t/** Before GC runs, called to notify the runtime to update any pending GC state. */\n\tupdateStateBeforeGC(): Promise<void>;\n\t/** Returns the garbage collection data of the runtime. */\n\tgetGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n\t/** After GC has run, called to notify the runtime of routes that are used in it. */\n\tupdateUsedRoutes(usedRoutes: string[]): void;\n\t/** After GC has run, called to notify the runtime of routes that are unused in it. */\n\tupdateUnusedRoutes(unusedRoutes: string[]): void;\n\t/**\n\t * After GC has run, called to notify the runtime of deletable routes. The runtime is responsible\n\t * for telling the garbage collector the routes of the objects it has deleted\n\t */\n\tdeleteUnusedNodes(unusedNodes: string[]): string[];\n\t/** Called to notify the runtime of routes that are tombstones. */\n\tupdateTombstonedRoutes(tombstoneRoutes: string[]): void;\n\t/** Returns a referenced timestamp to be used to track unreferenced nodes. */\n\tgetCurrentReferenceTimestampMs(): number | undefined;\n\t/** Returns the type of the GC node. */\n\tgetNodeType(nodePath: string): GCNodeType;\n\t/** Called when the runtime should close because of an error. */\n\tcloseFn: (error?: ICriticalContainerError) => void;\n\t/** If false, loading or using a Tombstoned object should merely log, not fail */\n\tgcTombstoneEnforcementAllowed: boolean;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n\t/** Tells whether GC should run or not. */\n\treadonly shouldRunGC: boolean;\n\t/** Tells whether the GC state in summary needs to be reset in the next summary. */\n\treadonly summaryStateNeedsReset: boolean;\n\treadonly trackGCState: boolean;\n\t/** Initialize the state from the base snapshot after its creation. */\n\tinitializeBaseState(): Promise<void>;\n\t/** Run garbage collection and update the reference / used state of the system. */\n\tcollectGarbage(options: {\n\t\tlogger?: ITelemetryLogger;\n\t\trunSweep?: boolean;\n\t\tfullGC?: boolean;\n\t}): Promise<IGCStats | undefined>;\n\t/** Summarizes the GC data and returns it as a summary tree. */\n\tsummarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined;\n\t/** Returns the garbage collector specific metadata to be written into the summary. */\n\tgetMetadata(): IGCMetadata;\n\t/** Returns the GC details generated from the base snapshot. */\n\tgetBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;\n\t/** Called when the latest summary of the system has been refreshed. */\n\trefreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tresult: RefreshSummaryResult,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void>;\n\t/** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */\n\tnodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequestHeaders?: IRequestHeader,\n\t): void;\n\t/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n\taddedOutboundReference(fromNodePath: string, toNodePath: string): void;\n\t/** Returns true if this node has been deleted by GC during sweep phase. */\n\tisNodeDeleted(nodePath: string): boolean;\n\tsetConnectionState(connected: boolean, clientId?: string): void;\n\tdispose(): void;\n}\n\n/** Parameters necessary for creating a GarbageCollector. */\nexport interface IGarbageCollectorCreateParams {\n\treadonly runtime: IGarbageCollectionRuntime;\n\treadonly gcOptions: IGCRuntimeOptions;\n\treadonly baseLogger: ITelemetryLogger;\n\treadonly existing: boolean;\n\treadonly metadata: IContainerRuntimeMetadata | undefined;\n\treadonly createContainerMetadata: ICreateContainerMetadata;\n\treadonly baseSnapshot: ISnapshotTree | undefined;\n\treadonly isSummarizerClient: boolean;\n\treadonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;\n\treadonly getLastSummaryTimestampMs: () => number | undefined;\n\treadonly readAndParseBlob: ReadAndParseBlob;\n\treadonly activeConnection: () => boolean;\n\treadonly getContainerDiagnosticId: () => string;\n}\n\n/** The state of node that is unreferenced. */\nexport const UnreferencedState = {\n\t/** The node is active, i.e., it can become referenced again. */\n\tActive: \"Active\",\n\t/** The node is inactive, i.e., it should not become referenced. */\n\tInactive: \"Inactive\",\n\t/** The node is ready to be deleted by the sweep phase. */\n\tSweepReady: \"SweepReady\",\n} as const;\nexport type UnreferencedState = typeof UnreferencedState[keyof typeof UnreferencedState];\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps {\n\tusageType: \"Changed\" | \"Loaded\" | \"Revived\";\n\tstate: UnreferencedState;\n\tid: string;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\tcompletedGCRuns: number;\n\tfromId?: string;\n\ttimeout?: number;\n\tlastSummaryTime?: number;\n\texternalRequest?: boolean;\n\tviaHandle?: boolean;\n}\n\n/**\n * The GC data that is tracked for a summary that is submitted.\n */\ninterface IGCSummaryTrackingData {\n\tserializedGCState: string | undefined;\n\tserializedTombstones: string | undefined;\n\tserializedDeletedNodes: string | undefined;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced and if it can\n * be deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n\tprivate _state: UnreferencedState = UnreferencedState.Active;\n\tpublic get state(): UnreferencedState {\n\t\treturn this._state;\n\t}\n\n\t/** Timer to indicate when an unreferenced object is considered Inactive */\n\tprivate readonly inactiveTimer: TimerWithNoDefaultTimeout;\n\t/** Timer to indicate when an unreferenced object is Sweep-Ready */\n\tprivate readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n\tconstructor(\n\t\tpublic readonly unreferencedTimestampMs: number,\n\t\t/** The time after which node transitions to Inactive state. */\n\t\tprivate readonly inactiveTimeoutMs: number,\n\t\t/** The current reference timestamp used to track how long this node has been unreferenced for. */\n\t\tcurrentReferenceTimestampMs: number,\n\t\t/** The time after which node transitions to SweepReady state; undefined if session expiry is disabled. */\n\t\tprivate readonly sweepTimeoutMs: number | undefined,\n\t) {\n\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\tassert(\n\t\t\t\tthis.inactiveTimeoutMs <= this.sweepTimeoutMs,\n\t\t\t\t0x3b0 /* inactive timeout must not be greater than the sweep timeout */,\n\t\t\t);\n\t\t}\n\n\t\tthis.sweepTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer,\n\t\t\t\t0x3b1 /* inactiveTimer still running after sweepTimer fired! */,\n\t\t\t);\n\t\t});\n\n\t\tthis.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\t// After the node becomes inactive, start the sweep timer after which the node will be ready for sweep.\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - this.inactiveTimeoutMs);\n\t\t\t}\n\t\t});\n\t\tthis.updateTracking(currentReferenceTimestampMs);\n\t}\n\n\t/* Updates the unreferenced state based on the provided timestamp. */\n\tpublic updateTracking(currentReferenceTimestampMs: number) {\n\t\tconst unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n\t\t// If the node has been unreferenced for sweep timeout amount of time, update the state to SweepReady.\n\t\tif (this.sweepTimeoutMs !== undefined && unreferencedDurationMs >= this.sweepTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tthis.clearTimers();\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced for inactive timeoutMs amount of time, update the state to inactive.\n\t\t// Also, start a timer for the sweep timeout.\n\t\tif (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\t\t\tthis.inactiveTimer.clear();\n\n\t\t\tif (this.sweepTimeoutMs !== undefined) {\n\t\t\t\tthis.sweepTimer.restart(this.sweepTimeoutMs - unreferencedDurationMs);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n\t\tthis.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n\t}\n\n\tprivate clearTimers() {\n\t\tthis.inactiveTimer.clear();\n\t\tthis.sweepTimer.clear();\n\t}\n\n\t/** Stop tracking this node. Reset the unreferenced timers and state, if any. */\n\tpublic stopTracking() {\n\t\tthis.clearTimers();\n\t\tthis._state = UnreferencedState.Active;\n\t}\n}\n\n/**\n * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains\n * its state across summaries.\n *\n * Node - represented as nodeId, it's a node on the GC graph\n *\n * Outbound Route - a path from one node to another node, think `nodeA` -\\> `nodeB`\n *\n * Graph - all nodes with their respective routes\n *\n * ```\n *\t\t\t GC Graph\n *\n *\t\t\t Node\n *\t\tNodeId = \"datastore1\"\n *\t\t /\t\t\t \\\\\n *\tOutboundRoute OutboundRoute\n *\t\t /\t\t\t\t \\\\\n *\t Node\t\t\t Node\n * NodeId = \"dds1\"\t NodeId = \"dds2\"\n * ```\n */\nexport class GarbageCollector implements IGarbageCollector {\n\tpublic static create(createParams: IGarbageCollectorCreateParams): IGarbageCollector {\n\t\treturn new GarbageCollector(createParams);\n\t}\n\n\t/**\n\t * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n\t *\n\t * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n\t *\n\t * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * 4. The GC version in the latest summary is different from the current GC version. This can happen if:\n\t *\n\t * 4.1. The summary this client loaded with has data from a different GC version.\n\t *\n\t * 4.2. This client's latest summary was updated from a snapshot that has a different GC version.\n\t */\n\tpublic get summaryStateNeedsReset(): boolean {\n\t\treturn (\n\t\t\tthis.gcStateNeedsReset ||\n\t\t\t(this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion)\n\t\t);\n\t}\n\n\t/**\n\t * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\tprivate readonly gcEnabled: boolean;\n\t/**\n\t * Tracks if sweep phase is enabled for this document. This is specified during document creation and doesn't change\n\t * throughout its lifetime.\n\t */\n\tprivate readonly sweepEnabled: boolean;\n\n\t/**\n\t * Tracks if GC should run or not. Even if GC is enabled for a document (see gcEnabled), it can be explicitly\n\t * disabled via runtime options or feature flags.\n\t */\n\tpublic readonly shouldRunGC: boolean;\n\t/**\n\t * Tracks if sweep phase should run or not. Even if the sweep phase is enabled for a document (see sweepEnabled), it\n\t * can be explicitly disabled via feature flags. It also won't run if session expiry is not enabled.\n\t */\n\tprivate readonly shouldRunSweep: boolean;\n\n\tpublic readonly trackGCState: boolean;\n\n\tprivate readonly testMode: boolean;\n\tprivate readonly tombstoneMode: boolean;\n\tprivate readonly mc: MonitoringContext;\n\n\t/**\n\t * Tells whether the GC state needs to be reset. This can happen under 3 conditions:\n\t *\n\t * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n\t * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n\t *\n\t * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n\t * a document and the first time GC is enabled after is was disabled before.\n\t *\n\t * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.\n\t *\n\t * Note that the state will be reset only once for the first summary generated after this returns true. After that,\n\t * this will return false.\n\t */\n\tprivate get gcStateNeedsReset(): boolean {\n\t\treturn this.wasGCRunInLatestSummary !== this.shouldRunGC;\n\t}\n\t// Tracks whether there was GC was run in latest summary being tracked.\n\tprivate wasGCRunInLatestSummary: boolean;\n\n\t// The current GC version that this container is running.\n\tprivate readonly currentGCVersion: GCVersion;\n\t// This is the version of GC data in the latest summary being tracked.\n\tprivate latestSummaryGCVersion: GCVersion;\n\n\t// Feature Support info persisted to this container's summary\n\tprivate readonly persistedGcFeatureMatrix: GCFeatureMatrix | undefined;\n\n\t// Keeps track of the GC state from the last run.\n\tprivate gcDataFromLastRun: IGarbageCollectionData | undefined;\n\t// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n\t// outbound routes from that node.\n\tprivate readonly newReferencesSinceLastRun: Map<string, string[]> = new Map();\n\t// A list of nodes that have been tombstoned.\n\tprivate tombstones: string[] = [];\n\t// A list of nodes that have been deleted during sweep phase.\n\tprivate deletedNodes: Set<string> = new Set();\n\n\t/**\n\t * Keeps track of the GC data from the latest summary successfully submitted to and acked from the server.\n\t */\n\tprivate latestSummaryData: IGCSummaryTrackingData | undefined;\n\t/**\n\t * Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n\t */\n\tprivate pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n\t// Promise when resolved returns the GC data data in the base snapshot.\n\tprivate readonly baseSnapshotDataP: Promise<IGarbageCollectionSnapshotData | undefined>;\n\t// Promise when resolved initializes the GC state from the data in the base snapshot.\n\tprivate readonly initializeGCStateFromBaseSnapshotP: Promise<void>;\n\t// The GC details generated from the base snapshot.\n\tprivate readonly baseGCDetailsP: Promise<IGarbageCollectionDetailsBase>;\n\t// Map of node ids to their unreferenced state tracker.\n\tprivate readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n\t// The Timer responsible for closing the container when the session has expired\n\tprivate sessionExpiryTimer: Timer | undefined;\n\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\t// The number of times GC has successfully completed on this instance of GarbageCollector.\n\tprivate completedRuns = 0;\n\n\tprivate readonly runtime: IGarbageCollectionRuntime;\n\tprivate readonly createContainerMetadata: ICreateContainerMetadata;\n\tprivate readonly gcOptions: IGCRuntimeOptions;\n\tprivate readonly isSummarizerClient: boolean;\n\n\t/** The time in ms to expire a session for a client for gc. */\n\tprivate readonly sessionExpiryTimeoutMs: number | undefined;\n\t/** The time after which an unreferenced node is inactive. */\n\tprivate readonly inactiveTimeoutMs: number;\n\t/** The time after which an unreferenced node is ready to be swept. */\n\tprivate readonly sweepTimeoutMs: number | undefined;\n\n\t/** For a given node path, returns the node's package path. */\n\tprivate readonly getNodePackagePath: (\n\t\tnodePath: string,\n\t) => Promise<readonly string[] | undefined>;\n\t/** Returns the timestamp of the last summary generated for this container. */\n\tprivate readonly getLastSummaryTimestampMs: () => number | undefined;\n\t/** Returns true if connection is active, i.e. it's \"write\" connection and the runtime is connected. */\n\tprivate readonly activeConnection: () => boolean;\n\n\t/** Returns a list of all the configurations for garbage collection. */\n\tprivate get configs() {\n\t\treturn {\n\t\t\tgcEnabled: this.gcEnabled,\n\t\t\tsweepEnabled: this.sweepEnabled,\n\t\t\trunGC: this.shouldRunGC,\n\t\t\trunSweep: this.shouldRunSweep,\n\t\t\ttestMode: this.testMode,\n\t\t\ttombstoneMode: this.tombstoneMode,\n\t\t\tsessionExpiry: this.sessionExpiryTimeoutMs,\n\t\t\tsweepTimeout: this.sweepTimeoutMs,\n\t\t\tinactiveTimeout: this.inactiveTimeoutMs,\n\t\t\ttrackGCState: this.trackGCState,\n\t\t\t...this.gcOptions,\n\t\t};\n\t}\n\n\t/** Handler to respond to when a SweepReady object is used */\n\tprivate readonly sweepReadyUsageHandler: SweepReadyUsageDetectionHandler;\n\n\tprotected constructor(createParams: IGarbageCollectorCreateParams) {\n\t\tthis.runtime = createParams.runtime;\n\t\tthis.isSummarizerClient = createParams.isSummarizerClient;\n\t\tthis.gcOptions = createParams.gcOptions;\n\t\tthis.createContainerMetadata = createParams.createContainerMetadata;\n\t\tthis.getNodePackagePath = createParams.getNodePackagePath;\n\t\tthis.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;\n\t\tthis.activeConnection = createParams.activeConnection;\n\n\t\tconst baseSnapshot = createParams.baseSnapshot;\n\t\tconst metadata = createParams.metadata;\n\t\tconst readAndParseBlob = createParams.readAndParseBlob;\n\n\t\tthis.mc = loggerToMonitoringContext(\n\t\t\tChildLogger.create(createParams.baseLogger, \"GarbageCollector\", {\n\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t}),\n\t\t);\n\n\t\t// If version upgrade is not enabled, fall back to the stable GC version.\n\t\tthis.currentGCVersion =\n\t\t\tthis.mc.config.getBoolean(gcVersionUpgradeToV2Key) === true\n\t\t\t\t? currentGCVersion\n\t\t\t\t: stableGCVersion;\n\n\t\tthis.sweepReadyUsageHandler = new SweepReadyUsageDetectionHandler(\n\t\t\tcreateParams.getContainerDiagnosticId(),\n\t\t\tthis.mc,\n\t\t\tthis.runtime.closeFn,\n\t\t);\n\n\t\tlet prevSummaryGCVersion: number | undefined;\n\n\t\t/**\n\t\t * Sweep timeout is the time after which unreferenced content can be swept.\n\t\t * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + one day buffer.\n\t\t *\n\t\t * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days.\n\t\t * The buffer is added to account for any clock skew or other edge cases.\n\t\t * We use server timestamps throughout so the skew should be minimal but make it 1 day to be safe.\n\t\t */\n\t\tfunction computeSweepTimeout(sessionExpiryTimeoutMs: number | undefined) {\n\t\t\tconst maxSnapshotCacheExpiryMs = 5 * oneDayMs;\n\t\t\tconst bufferMs = oneDayMs;\n\t\t\treturn (\n\t\t\t\tsessionExpiryTimeoutMs &&\n\t\t\t\tsessionExpiryTimeoutMs + maxSnapshotCacheExpiryMs + bufferMs\n\t\t\t);\n\t\t}\n\n\t\t/**\n\t\t * The following GC state is enabled during container creation and cannot be changed throughout its lifetime:\n\t\t * 1. Whether running GC mark phase is allowed or not.\n\t\t * 2. Whether running GC sweep phase is allowed or not.\n\t\t * 3. Whether GC session expiry is enabled or not.\n\t\t * For existing containers, we get this information from the metadata blob of its summary.\n\t\t */\n\t\tif (createParams.existing) {\n\t\t\tprevSummaryGCVersion = getGCVersion(metadata);\n\t\t\t// Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n\t\t\t// other existing documents, GC is enabled.\n\t\t\tthis.gcEnabled = prevSummaryGCVersion > 0;\n\t\t\tthis.sweepEnabled = metadata?.sweepEnabled ?? false;\n\t\t\tthis.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n\t\t\tthis.sweepTimeoutMs =\n\t\t\t\tmetadata?.sweepTimeoutMs ?? computeSweepTimeout(this.sessionExpiryTimeoutMs); // Backfill old documents that didn't persist this\n\t\t\tthis.persistedGcFeatureMatrix = metadata?.gcFeatureMatrix;\n\t\t} else {\n\t\t\t// Sweep should not be enabled without enabling GC mark phase. We could silently disable sweep in this\n\t\t\t// scenario but explicitly failing makes it clearer and promotes correct usage.\n\t\t\tif (this.gcOptions.sweepAllowed && this.gcOptions.gcAllowed === false) {\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"GC sweep phase cannot be enabled without enabling GC mark phase\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// This Test Override only applies for new containers\n\t\t\tconst testOverrideSweepTimeoutMs = this.mc.config.getNumber(\n\t\t\t\t\"Fluid.GarbageCollection.TestOverride.SweepTimeoutMs\",\n\t\t\t);\n\n\t\t\t// For new documents, GC is enabled by default. It can be explicitly disabled by setting the gcAllowed\n\t\t\t// flag in GC options to false.\n\t\t\tthis.gcEnabled = this.gcOptions.gcAllowed !== false;\n\t\t\t// The sweep phase has to be explicitly enabled by setting the sweepAllowed flag in GC options to true.\n\t\t\tthis.sweepEnabled = this.gcOptions.sweepAllowed === true;\n\n\t\t\t// Set the Session Expiry only if the flag is enabled and GC is enabled.\n\t\t\tif (this.mc.config.getBoolean(runSessionExpiryKey) && this.gcEnabled) {\n\t\t\t\tthis.sessionExpiryTimeoutMs =\n\t\t\t\t\tthis.gcOptions.sessionExpiryTimeoutMs ?? defaultSessionExpiryDurationMs;\n\t\t\t}\n\t\t\tthis.sweepTimeoutMs =\n\t\t\t\ttestOverrideSweepTimeoutMs ?? computeSweepTimeout(this.sessionExpiryTimeoutMs);\n\t\t\tif (this.gcOptions[gcTombstoneGenerationOptionName] !== undefined) {\n\t\t\t\tthis.persistedGcFeatureMatrix = {\n\t\t\t\t\ttombstoneGeneration: this.gcOptions[gcTombstoneGenerationOptionName],\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\t// If session expiry is enabled, we need to close the container when the session expiry timeout expires.\n\t\tif (this.sessionExpiryTimeoutMs !== undefined) {\n\t\t\t// If Test Override config is set, override Session Expiry timeout.\n\t\t\tconst overrideSessionExpiryTimeoutMs = this.mc.config.getNumber(\n\t\t\t\t\"Fluid.GarbageCollection.TestOverride.SessionExpiryMs\",\n\t\t\t);\n\t\t\tconst timeoutMs = overrideSessionExpiryTimeoutMs ?? this.sessionExpiryTimeoutMs;\n\n\t\t\tthis.sessionExpiryTimer = new Timer(timeoutMs, () => {\n\t\t\t\tthis.runtime.closeFn(\n\t\t\t\t\tnew ClientSessionExpiredError(`Client session expired.`, timeoutMs),\n\t\t\t\t);\n\t\t\t});\n\t\t\tthis.sessionExpiryTimer.start();\n\t\t}\n\n\t\t// For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n\t\t// latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n\t\tthis.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n\t\t/**\n\t\t * Whether GC should run or not. The following conditions have to be met to run sweep:\n\t\t *\n\t\t * 1. GC should be enabled for this container.\n\t\t *\n\t\t * 2. GC should not be disabled via disableGC GC option.\n\t\t *\n\t\t * These conditions can be overridden via runGCKey feature flag.\n\t\t */\n\t\tthis.shouldRunGC =\n\t\t\tthis.mc.config.getBoolean(runGCKey) ??\n\t\t\t// GC must be enabled for the document.\n\t\t\t(this.gcEnabled &&\n\t\t\t\t// GC must not be disabled via GC options.\n\t\t\t\t!this.gcOptions.disableGC);\n\n\t\t/**\n\t\t * Whether sweep should run or not. The following conditions have to be met to run sweep:\n\t\t *\n\t\t * 1. Overall GC or mark phase must be enabled (this.shouldRunGC).\n\t\t * 2. Sweep timeout should be available. Without this, we wouldn't know when an object should be deleted.\n\t\t * 3. The driver must implement the policy limiting the age of snapshots used for loading. Otherwise\n\t\t * the Sweep Timeout calculation is not valid. We use the persisted value to ensure consistency over time.\n\t\t * 4. Sweep should be enabled for this container (this.sweepEnabled). This can be overridden via runSweep\n\t\t * feature flag.\n\t\t */\n\t\tthis.shouldRunSweep =\n\t\t\tthis.shouldRunGC &&\n\t\t\tthis.sweepTimeoutMs !== undefined &&\n\t\t\t(this.mc.config.getBoolean(runSweepKey) ?? this.sweepEnabled);\n\n\t\tthis.trackGCState = this.mc.config.getBoolean(trackGCStateKey) === true;\n\n\t\t// Override inactive timeout if test config or gc options to override it is set.\n\t\tthis.inactiveTimeoutMs =\n\t\t\tthis.mc.config.getNumber(\"Fluid.GarbageCollection.TestOverride.InactiveTimeoutMs\") ??\n\t\t\tthis.gcOptions.inactiveTimeoutMs ??\n\t\t\tdefaultInactiveTimeoutMs;\n\n\t\t// Inactive timeout must be greater than sweep timeout since a node goes from active -> inactive -> sweep ready.\n\t\tif (this.sweepTimeoutMs !== undefined && this.inactiveTimeoutMs > this.sweepTimeoutMs) {\n\t\t\tthrow new UsageError(\"inactive timeout should not be greater than the sweep timeout\");\n\t\t}\n\n\t\t// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n\t\tthis.testMode =\n\t\t\tthis.mc.config.getBoolean(gcTestModeKey) ?? this.gcOptions.runGCInTestMode === true;\n\t\t// Whether we are running in tombstone mode. This is enabled by default if sweep won't run. It can be disabled\n\t\t// via feature flags.\n\t\tthis.tombstoneMode =\n\t\t\t!this.shouldRunSweep && this.mc.config.getBoolean(disableTombstoneKey) !== true;\n\n\t\t// If GC ran in the container that generated the base snapshot, it will have a GC tree.\n\t\tthis.wasGCRunInLatestSummary = baseSnapshot?.trees[gcTreeKey] !== undefined;\n\n\t\t// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it\n\t\t// it involves fetching blobs from storage which is expensive.\n\t\tthis.baseSnapshotDataP = new LazyPromise<IGarbageCollectionSnapshotData | undefined>(\n\t\t\tasync () => {\n\t\t\t\tif (baseSnapshot === undefined) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\t// For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n\t\t\t\t\tconst gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n\t\t\t\t\tif (gcSnapshotTree !== undefined) {\n\t\t\t\t\t\treturn getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\t\t\t\t\t}\n\n\t\t\t\t\t// back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n\t\t\t\t\t// consolidate into IGarbageCollectionState format.\n\t\t\t\t\t// Add a node for the root node that is not present in older snapshot format.\n\t\t\t\t\tconst gcState: IGarbageCollectionState = {\n\t\t\t\t\t\tgcNodes: { \"/\": { outboundRoutes: [] } },\n\t\t\t\t\t};\n\t\t\t\t\tconst dataStoreSnapshotTree = getSummaryForDatastores(baseSnapshot, metadata);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tdataStoreSnapshotTree !== undefined,\n\t\t\t\t\t\t0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */,\n\t\t\t\t\t);\n\t\t\t\t\tfor (const [dsId, dsSnapshotTree] of Object.entries(\n\t\t\t\t\t\tdataStoreSnapshotTree.trees,\n\t\t\t\t\t)) {\n\t\t\t\t\t\tconst blobId = dsSnapshotTree.blobs[gcTreeKey];\n\t\t\t\t\t\tif (blobId === undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst gcSummaryDetails =\n\t\t\t\t\t\t\tawait readAndParseBlob<IGarbageCollectionSummaryDetailsLegacy>(blobId);\n\t\t\t\t\t\t// If there are no nodes for this data store, skip it.\n\t\t\t\t\t\tif (gcSummaryDetails.gcData?.gcNodes === undefined) {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst dsRootId = `/${dsId}`;\n\t\t\t\t\t\t// Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n\t\t\t\t\t\t// Construct that entry by adding root data store ids to its outbound routes.\n\t\t\t\t\t\tconst initialSnapshotDetails =\n\t\t\t\t\t\t\tawait readAndParseBlob<ReadFluidDataStoreAttributes>(\n\t\t\t\t\t\t\t\tdsSnapshotTree.blobs[dataStoreAttributesBlobName],\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tif (initialSnapshotDetails.isRootDataStore) {\n\t\t\t\t\t\t\tgcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (const [id, outboundRoutes] of Object.entries(\n\t\t\t\t\t\t\tgcSummaryDetails.gcData.gcNodes,\n\t\t\t\t\t\t)) {\n\t\t\t\t\t\t\t// Prefix the data store id to the GC node ids to make them relative to the root from being\n\t\t\t\t\t\t\t// relative to the data store. Similar to how its done in DataStore::getGCData.\n\t\t\t\t\t\t\tconst rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n\t\t\t\t\t\t\tgcState.gcNodes[rootId] = {\n\t\t\t\t\t\t\t\toutboundRoutes: Array.from(outboundRoutes),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tassert(\n\t\t\t\t\t\t\tgcState.gcNodes[dsRootId] !== undefined,\n\t\t\t\t\t\t\t0x2a9 /* GC nodes for data store not in GC blob */,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tgcState.gcNodes[dsRootId].unreferencedTimestampMs =\n\t\t\t\t\t\t\tgcSummaryDetails.unrefTimestamp;\n\t\t\t\t\t}\n\t\t\t\t\t// If there is only one node (root node just added above), either GC is disabled or we are loading from\n\t\t\t\t\t// the first summary generated by detached container. In both cases, GC was not run - return undefined.\n\t\t\t\t\treturn Object.keys(gcState.gcNodes).length === 1\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: { gcState, tombstones: undefined, deletedNodes: undefined };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst dpe = DataProcessingError.wrapIfUnrecognized(\n\t\t\t\t\t\terror,\n\t\t\t\t\t\t\"FailedToInitializeGC\",\n\t\t\t\t\t);\n\t\t\t\t\tdpe.addTelemetryProperties({ gcConfigs: JSON.stringify(this.configs) });\n\t\t\t\t\tthrow dpe;\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\t/**\n\t\t * Set up the initializer which initializes the GC state from the data in base snapshot. This is done when\n\t\t * connected in write mode or when GC runs the first time. It sets up all unreferenced nodes from the base\n\t\t * GC state and updates their inactive or sweep ready state.\n\t\t */\n\t\tthis.initializeGCStateFromBaseSnapshotP = new LazyPromise<void>(async () => {\n\t\t\t/**\n\t\t\t * If there is no current reference timestamp, skip initialization. We need the current timestamp to track\n\t\t\t * how long objects have been unreferenced and if they can be deleted.\n\t\t\t *\n\t\t\t * Note that the only scenario where there is no reference timestamp is when no ops have ever been processed\n\t\t\t * for this container and it is in read mode. In this scenario, there is no point in running GC anyway\n\t\t\t * because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t\t */\n\t\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"GarbageCollectorInitializedWithoutTimestamp\",\n\t\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t/**\n\t\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t\t * 1. The first summary created by the detached container.\n\t\t\t * 2. A summary that was generated with GC disabled.\n\t\t\t * 3. A summary that was generated before GC even existed.\n\t\t\t */\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.updateStateFromSnapshotData(baseSnapshotData, currentReferenceTimestampMs);\n\t\t});\n\n\t\t// Get the GC details from the GC state in the base summary. This is returned in getBaseGCDetails which is\n\t\t// used to initialize the GC state of all the nodes in the container.\n\t\tthis.baseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {\n\t\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t\tif (baseSnapshotData === undefined) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\t\tfor (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n\t\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t\t}\n\t\t\t// Run GC on the nodes in the base summary to get the routes used in each node in the container.\n\t\t\t// This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n\t\t\t// each node in the summary.\n\t\t\tconst usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n\n\t\t\treturn { gcData: { gcNodes }, usedRoutes };\n\t\t});\n\n\t\t// Log all the GC options and the state determined by the garbage collector. This is interesting only for the\n\t\t// summarizer client since it is the only one that runs GC. It also helps keep the telemetry less noisy.\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"GarbageCollectorLoaded\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done\n\t * during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.\n\t */\n\tpublic async initializeBaseState(): Promise<void> {\n\t\tconst baseSnapshotData = await this.baseSnapshotDataP;\n\t\t/**\n\t\t * The base snapshot data will not be present if the container is loaded from:\n\t\t * 1. The first summary created by the detached container.\n\t\t * 2. A summary that was generated with GC disabled.\n\t\t * 3. A summary that was generated before GC even existed.\n\t\t */\n\t\tif (baseSnapshotData === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not\n\t\t// to identify deleted nodes' usage.\n\t\tif (baseSnapshotData.deletedNodes !== undefined) {\n\t\t\tthis.deletedNodes = new Set(baseSnapshotData.deletedNodes);\n\t\t}\n\n\t\t// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of\n\t\t// tombstone routes.\n\t\tif (this.tombstoneMode && baseSnapshotData.tombstones !== undefined) {\n\t\t\t// Create a copy since we are writing from a source we don't control\n\t\t\tthis.tombstones = Array.from(baseSnapshotData.tombstones);\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\t}\n\n\t/**\n\t * Update state from the given snapshot data. This is done during load and during refreshing state from a snapshot.\n\t * All current tracking is reset and updated from the data in the snapshot.\n\t * @param snapshotData - The snapshot data to update state from. If this is undefined, all GC state and tracking\n\t * is reset.\n\t * @param currentReferenceTimestampMs - The current reference timestamp for marking unreferenced nodes' unreferenced\n\t * timestamp.\n\t */\n\tprivate updateStateFromSnapshotData(\n\t\tsnapshotData: IGarbageCollectionSnapshotData | undefined,\n\t\tcurrentReferenceTimestampMs: number,\n\t) {\n\t\t/**\n\t\t * Note: \"newReferencesSinceLastRun\" is not reset here. This is done because there may be references since the\n\t\t * snapshot that we are updating state from. For example, this client may have processed ops till seq#1000 and\n\t\t * its refreshing state from a summary that happened at seq#900. In this case, there may be references between\n\t\t * seq#901 and seq#1000 that we don't want to reset.\n\t\t * Unfortunately, there is no way to track the seq# of ops that add references, so we choose to not reset any\n\t\t * references here. This should be fine because, in the worst case, we may end up updating the unreferenced\n\t\t * timestamp of a node which will delay its deletion. Although not ideal, this will only happen in rare\n\t\t * scenarios, so it should be okay.\n\t\t */\n\n\t\t// Clear all existing unreferenced state tracking.\n\t\tfor (const [, nodeStateTracker] of this.unreferencedNodesState) {\n\t\t\tnodeStateTracker.stopTracking();\n\t\t}\n\t\tthis.unreferencedNodesState.clear();\n\n\t\t// If running sweep, the tombstone state represents the list of nodes that have been deleted during sweep.\n\t\t// If running in tombstone mode, the tombstone state represents the list of nodes that have been marked as\n\t\t// tombstones.\n\t\t// If this call is because we are refreshing from a snapshot due to an ack, it is likely that the GC state\n\t\t// in the snapshot is newer than this client's. And so, the deleted / tombstone nodes need to be updated.\n\t\tif (this.shouldRunSweep) {\n\t\t\tconst snapshotDeletedNodes = snapshotData?.deletedNodes\n\t\t\t\t? new Set(snapshotData.deletedNodes)\n\t\t\t\t: undefined;\n\t\t\t// If the snapshot contains deleted nodes that are not yet deleted by this client, ask the runtime to\n\t\t\t// delete them.\n\t\t\tif (snapshotDeletedNodes !== undefined) {\n\t\t\t\tconst newDeletedNodes: string[] = [];\n\t\t\t\tfor (const nodeId of snapshotDeletedNodes) {\n\t\t\t\t\tif (!this.deletedNodes.has(nodeId)) {\n\t\t\t\t\t\tnewDeletedNodes.push(nodeId);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (newDeletedNodes.length > 0) {\n\t\t\t\t\t// Call container runtime to delete these nodes and add deleted nodes to this.deletedNodes.\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (this.tombstoneMode) {\n\t\t\t// The snapshot may contain more or fewer tombstone nodes than this client. Update tombstone state and\n\t\t\t// notify the runtime to update its state as well.\n\t\t\tthis.tombstones = snapshotData?.tombstones ? Array.from(snapshotData.tombstones) : [];\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\t// If there is no snapshot data, it means this snapshot was generated with GC disabled. Unset all GC state.\n\t\tif (snapshotData === undefined) {\n\t\t\tthis.gcDataFromLastRun = undefined;\n\t\t\tthis.latestSummaryData = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\t// Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun\n\t\t// to the GC data from the snapshot data.\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [nodeId, nodeData] of Object.entries(snapshotData.gcState.gcNodes)) {\n\t\t\tif (nodeData.unreferencedTimestampMs !== undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tnodeData.unreferencedTimestampMs,\n\t\t\t\t\t\tthis.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\tgcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n\t\t}\n\t\tthis.gcDataFromLastRun = { gcNodes };\n\n\t\t// If tracking state across summaries, update latest summary data from the snapshot's GC data.\n\t\tif (this.trackGCState) {\n\t\t\tthis.latestSummaryData = {\n\t\t\t\tserializedGCState: JSON.stringify(generateSortedGCState(snapshotData.gcState)),\n\t\t\t\tserializedTombstones: JSON.stringify(snapshotData.tombstones),\n\t\t\t\tserializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this\n\t * to initialize the base state for non-summarizer clients so that they can track inactive / sweep ready nodes.\n\t * @param connected - Whether the runtime connected / disconnected.\n\t * @param clientId - The clientId of this runtime.\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string | undefined): void {\n\t\t/**\n\t\t * For all clients, initialize the base state when the container becomes active, i.e., it transitions\n\t\t * to \"write\" mode. This will ensure that the container's own join op is processed and there is a recent\n\t\t * reference timestamp that will be used to update the state of unreferenced nodes. Also, all trailing ops which\n\t\t * could affect the GC state will have been processed.\n\t\t *\n\t\t * If GC is up-to-date for the client and the summarizing client, there will be an doubling of both\n\t\t * InactiveObject_Loaded and SweepReady_Loaded errors, as there will be one from the sending client and one from\n\t\t * the receiving summarizer client.\n\t\t *\n\t\t * Ideally, this initialization should only be done for summarizer client. However, we are currently rolling out\n\t\t * sweep in phases and we want to track when inactive and sweep ready objects are used in any client.\n\t\t */\n\t\tif (this.activeConnection() && this.shouldRunGC) {\n\t\t\tthis.initializeGCStateFromBaseSnapshotP.catch((error) => {});\n\t\t}\n\t}\n\n\t/**\n\t * Runs garbage collection and updates the reference / used state of the nodes in the container.\n\t * @returns stats of the GC run or undefined if GC did not run.\n\t */\n\tpublic async collectGarbage(options: {\n\t\t/** Logger to use for logging GC events */\n\t\tlogger?: ITelemetryLogger;\n\t\t/** True to run GC sweep phase after the mark phase */\n\t\trunSweep?: boolean;\n\t\t/** True to generate full GC data */\n\t\tfullGC?: boolean;\n\t}): Promise<IGCStats | undefined> {\n\t\tconst fullGC =\n\t\t\toptions.fullGC ?? (this.gcOptions.runFullGC === true || this.summaryStateNeedsReset);\n\t\tconst logger = options.logger\n\t\t\t? ChildLogger.create(options.logger, undefined, {\n\t\t\t\t\tall: { completedGCRuns: () => this.completedRuns },\n\t\t\t })\n\t\t\t: this.mc.logger;\n\n\t\t/**\n\t\t * If there is no current reference timestamp, skip running GC. We need the current timestamp to track\n\t\t * how long objects have been unreferenced and if they should be deleted.\n\t\t *\n\t\t * Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever\n\t\t * been processed for this container and it is in read mode. In this scenario, there is no point in running GC\n\t\t * anyway because references in the container do not change without any ops, i.e., there is nothing to collect.\n\t\t */\n\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\t// Log an event so we can evaluate how often we run into this scenario.\n\t\t\tlogger.sendErrorEvent({\n\t\t\t\teventName: \"CollectGarbageCalledWithoutTimestamp\",\n\t\t\t\tgcConfigs: JSON.stringify(this.configs),\n\t\t\t});\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"GarbageCollection\" },\n\t\t\tasync (event) => {\n\t\t\t\tawait this.runPreGCSteps();\n\n\t\t\t\t// Get the runtime's GC data and run GC on the reference graph in it.\n\t\t\t\tconst gcData = await this.runtime.getGCData(fullGC);\n\t\t\t\tconst gcResult = runGarbageCollection(gcData.gcNodes, [\"/\"]);\n\n\t\t\t\tconst gcStats = await this.runPostGCSteps(\n\t\t\t\t\tgcData,\n\t\t\t\t\tgcResult,\n\t\t\t\t\tlogger,\n\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t);\n\t\t\t\tevent.end({ ...gcStats, timestamp: currentReferenceTimestampMs });\n\t\t\t\tthis.completedRuns++;\n\t\t\t\treturn gcStats;\n\t\t\t},\n\t\t\t{ end: true, cancel: \"error\" },\n\t\t);\n\t}\n\n\tprivate async runPreGCSteps() {\n\t\t// Ensure that state has been initialized from the base snapshot data.\n\t\tawait this.initializeGCStateFromBaseSnapshotP;\n\t\t// Let the runtime update its pending state before GC runs.\n\t\tawait this.runtime.updateStateBeforeGC();\n\t}\n\n\tprivate async runPostGCSteps(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tlogger: ITelemetryLogger,\n\t\tcurrentReferenceTimestampMs: number,\n\t): Promise<IGCStats> {\n\t\t// Generate statistics from the current run. This is done before updating the current state because it\n\t\t// generates some of its data based on previous state of the system.\n\t\tconst gcStats = this.generateStats(gcResult);\n\n\t\t// Update the current mark state and update the runtime of all used routes or ids that used as per the GC run.\n\t\tconst sweepReadyNodes = this.updateMarkPhase(\n\t\t\tgcData,\n\t\t\tgcResult,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tlogger,\n\t\t);\n\t\tthis.runtime.updateUsedRoutes(gcResult.referencedNodeIds);\n\n\t\t// Log events for objects that are ready to be deleted by sweep. When we have sweep enabled, we will\n\t\t// delete these objects here instead.\n\t\tthis.logSweepEvents(logger, currentReferenceTimestampMs);\n\n\t\tlet updatedGCData: IGarbageCollectionData = gcData;\n\n\t\tif (this.shouldRunSweep) {\n\t\t\tupdatedGCData = this.runSweepPhase(sweepReadyNodes, gcData);\n\t\t} else if (this.testMode) {\n\t\t\t// If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n\t\t\t// involving access to deleted data.\n\t\t\tthis.runtime.updateUnusedRoutes(gcResult.deletedNodeIds);\n\t\t} else if (this.tombstoneMode) {\n\t\t\tthis.tombstones = sweepReadyNodes;\n\t\t\t// If we are running in GC tombstone mode, update tombstoned routes. This enables testing scenarios\n\t\t\t// involving access to \"deleted\" data without actually deleting the data from summaries.\n\t\t\t// Note: we will not tombstone in test mode.\n\t\t\tthis.runtime.updateTombstonedRoutes(this.tombstones);\n\t\t}\n\n\t\tthis.gcDataFromLastRun = cloneGCData(updatedGCData);\n\n\t\t// Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and\n\t\t// updates its state so that we don't send false positives based on intermediate state. For example, we may get\n\t\t// reference to an unreferenced node from another unreferenced node which means the node wasn't revived.\n\t\tawait this.logUnreferencedEvents(logger);\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * Summarizes the GC data and returns it as a summary tree.\n\t * We current write the entire GC state in a single blob. This can be modified later to write multiple\n\t * blobs. All the blob keys should start with `gcBlobPrefix`.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): ISummarizeResult | undefined {\n\t\tif (!this.shouldRunGC || this.gcDataFromLastRun === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst gcState: IGarbageCollectionState = { gcNodes: {} };\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {\n\t\t\tgcState.gcNodes[nodeId] = {\n\t\t\t\toutboundRoutes,\n\t\t\t\tunreferencedTimestampMs:\n\t\t\t\t\tthis.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n\t\t\t};\n\t\t}\n\n\t\tconst serializedGCState = JSON.stringify(generateSortedGCState(gcState));\n\t\t// Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so\n\t\t// to identify deleted nodes' usage.\n\t\tconst serializedDeletedNodes =\n\t\t\tthis.deletedNodes.size > 0\n\t\t\t\t? JSON.stringify(Array.from(this.deletedNodes).sort())\n\t\t\t\t: undefined;\n\t\t// If running in tombstone mode, serialize and write tombstones, if any.\n\t\tconst serializedTombstones = this.tombstoneMode\n\t\t\t? this.tombstones.length > 0\n\t\t\t\t? JSON.stringify(this.tombstones.sort())\n\t\t\t\t: undefined\n\t\t\t: undefined;\n\n\t\t/**\n\t\t * Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,\n\t\t * write summary handle instead of summary tree for GC.\n\t\t * Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and\n\t\t * for each of these that did not change, write a summary handle.\n\t\t */\n\t\tif (this.trackGCState) {\n\t\t\tthis.pendingSummaryData = {\n\t\t\t\tserializedGCState,\n\t\t\t\tserializedTombstones,\n\t\t\t\tserializedDeletedNodes,\n\t\t\t};\n\t\t\tif (trackState && !fullTree && this.latestSummaryData !== undefined) {\n\t\t\t\t// If nothing changed since last summary, send a summary handle for the entire GC data.\n\t\t\t\tif (\n\t\t\t\t\tthis.latestSummaryData.serializedGCState === serializedGCState &&\n\t\t\t\t\tthis.latestSummaryData.serializedTombstones === serializedTombstones\n\t\t\t\t) {\n\t\t\t\t\tconst stats = mergeStats();\n\t\t\t\t\tstats.handleNodeCount++;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tsummary: {\n\t\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\t\thandle: `/${gcTreeKey}`,\n\t\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstats,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\t// If some state changed, build a GC summary tree.\n\t\t\t\treturn this.buildGCSummaryTree(\n\t\t\t\t\tserializedGCState,\n\t\t\t\t\tserializedTombstones,\n\t\t\t\t\tserializedDeletedNodes,\n\t\t\t\t\ttrue /* trackState */,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// If not tracking GC state, build a GC summary tree without any summary handles.\n\t\treturn this.buildGCSummaryTree(\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t\tfalse /* trackState */,\n\t\t);\n\t}\n\n\t/**\n\t * Builds the GC summary tree which contains GC state, deleted nodes and tombstones.\n\t * If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.\n\t * If trackState is true, only states that changed are written. Rest are written as handles.\n\t * @param serializedGCState - The GC state serialized as string.\n\t * @param serializedTombstones - The tombstone state serialized as string.\n\t * @param serializedDeletedNodes - Deleted nodes serialized as string.\n\t * @param trackState - Whether we are tracking GC state across summaries.\n\t * @returns the GC summary tree.\n\t */\n\tprivate buildGCSummaryTree(\n\t\tserializedGCState: string,\n\t\tserializedTombstones: string | undefined,\n\t\tserializedDeletedNodes: string | undefined,\n\t\ttrackState: boolean,\n\t): ISummaryTreeWithStats {\n\t\tconst gcStateBlobKey = `${gcBlobPrefix}_root`;\n\t\tconst builder = new SummaryTreeBuilder();\n\n\t\t// If the GC state hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (this.latestSummaryData?.serializedGCState === serializedGCState && trackState) {\n\t\t\tbuilder.addHandle(gcStateBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcStateBlobKey}`);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcStateBlobKey, serializedGCState);\n\t\t}\n\n\t\t// If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a\n\t\t// summary blob.\n\t\tif (serializedTombstones !== undefined) {\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData?.serializedTombstones === serializedTombstones &&\n\t\t\t\ttrackState\n\t\t\t) {\n\t\t\t\tbuilder.addHandle(\n\t\t\t\t\tgcTombstoneBlobKey,\n\t\t\t\t\tSummaryType.Blob,\n\t\t\t\t\t`/${gcTreeKey}/${gcTombstoneBlobKey}`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tbuilder.addBlob(gcTombstoneBlobKey, serializedTombstones);\n\t\t\t}\n\t\t}\n\n\t\t// If there are no deleted nodes, return the summary tree.\n\t\tif (serializedDeletedNodes === undefined) {\n\t\t\treturn builder.getSummaryTree();\n\t\t}\n\n\t\t// If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.\n\t\tif (\n\t\t\tthis.latestSummaryData?.serializedDeletedNodes === serializedDeletedNodes &&\n\t\t\ttrackState\n\t\t) {\n\t\t\tbuilder.addHandle(\n\t\t\t\tgcDeletedBlobKey,\n\t\t\t\tSummaryType.Blob,\n\t\t\t\t`/${gcTreeKey}/${gcDeletedBlobKey}`,\n\t\t\t);\n\t\t} else {\n\t\t\tbuilder.addBlob(gcDeletedBlobKey, serializedDeletedNodes);\n\t\t}\n\t\treturn builder.getSummaryTree();\n\t}\n\n\tpublic getMetadata(): IGCMetadata {\n\t\treturn {\n\t\t\t/**\n\t\t\t * If GC is enabled, the GC data is written using the current GC version and that is the gcFeature that goes\n\t\t\t * into the metadata blob. If GC is disabled, the gcFeature is 0.\n\t\t\t */\n\t\t\tgcFeature: this.gcEnabled ? this.currentGCVersion : 0,\n\t\t\tgcFeatureMatrix: this.persistedGcFeatureMatrix,\n\t\t\tsessionExpiryTimeoutMs: this.sessionExpiryTimeoutMs,\n\t\t\tsweepEnabled: this.sweepEnabled,\n\t\t\tsweepTimeoutMs: this.sweepTimeoutMs,\n\t\t};\n\t}\n\n\t/**\n\t * Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes\n\t * in the container.\n\t */\n\tpublic async getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase> {\n\t\treturn this.baseGCDetailsP;\n\t}\n\n\t/**\n\t * Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot\n\t * is downloaded and should be used to update the state.\n\t */\n\tpublic async refreshLatestSummary(\n\t\tproposalHandle: string | undefined,\n\t\tresult: RefreshSummaryResult,\n\t\treadAndParseBlob: ReadAndParseBlob,\n\t): Promise<void> {\n\t\t// If the latest summary was updated and the summary was tracked, this client is the one that generated this\n\t\t// summary. So, update wasGCRunInLatestSummary.\n\t\t// Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return\n\t\t// true in scenarios where GC is disabled but enabled in the snapshot we loaded from.\n\t\tif (result.latestSummaryUpdated && result.wasSummaryTracked) {\n\t\t\tthis.wasGCRunInLatestSummary = this.shouldRunGC;\n\t\t}\n\n\t\tif (!result.latestSummaryUpdated || !this.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the summary was tracked by this client, it was the one that generated the summary in the first place.\n\t\t// Update latest state from pending.\n\t\tif (result.wasSummaryTracked) {\n\t\t\tthis.latestSummaryGCVersion = this.currentGCVersion;\n\t\t\tif (this.trackGCState) {\n\t\t\t\tthis.latestSummaryData = this.pendingSummaryData;\n\t\t\t\tthis.pendingSummaryData = undefined;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// If the summary was not tracked by this client, the state should be updated from the downloaded snapshot.\n\t\tconst snapshotTree = result.snapshotTree;\n\t\tconst metadataBlobId = snapshotTree.blobs[metadataBlobName];\n\t\tif (metadataBlobId) {\n\t\t\tconst metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n\t\t\tthis.latestSummaryGCVersion = getGCVersion(metadata);\n\t\t}\n\n\t\t// The current reference timestamp should be available if we are refreshing state from a snapshot. There has\n\t\t// to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.\n\t\tconst currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n\t\tif (currentReferenceTimestampMs === undefined) {\n\t\t\tthrow DataProcessingError.create(\n\t\t\t\t\"No reference timestamp when updating GC state from snapshot\",\n\t\t\t\t\"refreshLatestSummary\",\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tproposalHandle,\n\t\t\t\t\tsummaryRefSeq: result.summaryRefSeq,\n\t\t\t\t\tdetails: JSON.stringify(this.configs),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst gcSnapshotTree = snapshotTree.trees[gcTreeKey];\n\t\t// If GC ran in the container that generated this snapshot, it will have a GC tree.\n\t\tthis.wasGCRunInLatestSummary = gcSnapshotTree !== undefined;\n\t\tlet latestGCData: IGarbageCollectionSnapshotData | undefined;\n\t\tif (gcSnapshotTree !== undefined) {\n\t\t\tlatestGCData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);\n\t\t}\n\t\tthis.updateStateFromSnapshotData(latestGCData, currentReferenceTimestampMs);\n\t\tthis.pendingSummaryData = undefined;\n\t}\n\n\t/**\n\t * Called when a node with the given id is updated. If the node is inactive, log an error.\n\t * @param nodePath - The id of the node that changed.\n\t * @param reason - Whether the node was loaded or changed.\n\t * @param timestampMs - The timestamp when the node changed.\n\t * @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.\n\t * @param requestHeaders - If the node was loaded via request path, the headers in the request.\n\t */\n\tpublic nodeUpdated(\n\t\tnodePath: string,\n\t\treason: \"Loaded\" | \"Changed\",\n\t\ttimestampMs?: number,\n\t\tpackagePath?: readonly string[],\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\tif (!this.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\n\t\t\t\treason,\n\t\t\t\tnodePath,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tundefined /* fromNodeId */,\n\t\t\t\tpackagePath,\n\t\t\t\ttimestampMs,\n\t\t\t\trequestHeaders,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n\t * referenced between summaries so that their unreferenced timestamp can be reset.\n\t *\n\t * @param fromNodePath - The node from which the reference is added.\n\t * @param toNodePath - The node to which the reference is added.\n\t */\n\tpublic addedOutboundReference(fromNodePath: string, toNodePath: string) {\n\t\tif (!this.shouldRunGC) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];\n\t\toutboundRoutes.push(toNodePath);\n\t\tthis.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);\n\n\t\tconst nodeStateTracker = this.unreferencedNodesState.get(toNodePath);\n\t\tif (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n\t\t\tthis.inactiveNodeUsed(\"Revived\", toNodePath, nodeStateTracker, fromNodePath);\n\t\t}\n\n\t\tif (this.tombstones.includes(toNodePath)) {\n\t\t\tconst nodeType = this.runtime.getNodeType(toNodePath);\n\n\t\t\tlet eventName = \"GC_Tombstone_SubDatastore_Revived\";\n\t\t\tif (nodeType === GCNodeType.DataStore) {\n\t\t\t\teventName = \"GC_Tombstone_Datastore_Revived\";\n\t\t\t} else if (nodeType === GCNodeType.Blob) {\n\t\t\t\teventName = \"GC_Tombstone_Blob_Revived\";\n\t\t\t}\n\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\turl: trimLeadingSlashes(toNodePath),\n\t\t\t\t\tnodeType,\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify\n\t * cases where objects are used after they are deleted and throw / log errors accordingly.\n\t */\n\tpublic isNodeDeleted(nodePath: string): boolean {\n\t\treturn this.deletedNodes.has(nodePath);\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.sessionExpiryTimer?.clear();\n\t\tthis.sessionExpiryTimer = undefined;\n\t}\n\n\t/**\n\t * Updates the state of the system as per the current GC run. It does the following:\n\t * 1. Sets up the current GC state as per the gcData.\n\t * 2. Starts tracking for nodes that have become unreferenced in this run.\n\t * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n\t * @param gcData - The data representing the reference graph on which GC is run.\n\t * @param gcResult - The result of the GC run on the gcData.\n\t * @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.\n\t * @returns - A list of sweep ready nodes. (Nodes ready to be deleted)\n\t */\n\tprivate updateMarkPhase(\n\t\tgcData: IGarbageCollectionData,\n\t\tgcResult: IGCResult,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tlogger: ITelemetryLogger,\n\t) {\n\t\t// Get references from the current GC run + references between previous and current run and then update each\n\t\t// node's state\n\t\tconst allNodesReferencedBetweenGCs =\n\t\t\tthis.findAllNodesReferencedBetweenGCs(gcData, this.gcDataFromLastRun, logger) ??\n\t\t\tgcResult.referencedNodeIds;\n\t\tthis.newReferencesSinceLastRun.clear();\n\n\t\t// Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n\t\tfor (const nodeId of allNodesReferencedBetweenGCs) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * If a node became unreferenced in this run, start tracking it.\n\t\t * If a node was already unreferenced, update its tracking information. Since the current reference time is\n\t\t * from the ops seen, this will ensure that we keep updating the unreferenced state as time moves forward.\n\t\t *\n\t\t * If a node is sweep ready, store and then return it.\n\t\t */\n\t\tconst sweepReadyNodes: string[] = [];\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\tif (nodeStateTracker === undefined) {\n\t\t\t\tthis.unreferencedNodesState.set(\n\t\t\t\t\tnodeId,\n\t\t\t\t\tnew UnreferencedStateTracker(\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.inactiveTimeoutMs,\n\t\t\t\t\t\tcurrentReferenceTimestampMs,\n\t\t\t\t\t\tthis.sweepTimeoutMs,\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tnodeStateTracker.updateTracking(currentReferenceTimestampMs);\n\t\t\t\tif (nodeStateTracker.state === UnreferencedState.SweepReady) {\n\t\t\t\t\tsweepReadyNodes.push(nodeId);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn sweepReadyNodes;\n\t}\n\n\t/**\n\t * Deletes nodes from both the runtime and garbage collection\n\t * @param sweepReadyNodes - nodes that are ready to be deleted\n\t */\n\tprivate runSweepPhase(sweepReadyNodes: string[], gcData: IGarbageCollectionData) {\n\t\t// TODO: GC:Validation - validate that removed routes are not double deleted\n\t\t// TODO: GC:Validation - validate that the child routes of removed routes are deleted as well\n\t\tconst sweptRoutes = this.runtime.deleteUnusedNodes(sweepReadyNodes);\n\t\tconst updatedGCData = this.deleteSweptRoutes(sweptRoutes, gcData);\n\n\t\tfor (const nodeId of sweptRoutes) {\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n\t\t\t// TODO: GC:Validation - assert that the nodeStateTracker is defined\n\t\t\tif (nodeStateTracker !== undefined) {\n\t\t\t\t// Stop tracking so as to clear out any running timers.\n\t\t\t\tnodeStateTracker.stopTracking();\n\t\t\t\t// Delete the node as we don't need to track it any more.\n\t\t\t\tthis.unreferencedNodesState.delete(nodeId);\n\t\t\t}\n\t\t\t// TODO: GC:Validation - assert that the deleted node is not a duplicate\n\t\t\tthis.deletedNodes.add(nodeId);\n\t\t}\n\n\t\treturn updatedGCData;\n\t}\n\n\t/**\n\t * @returns IGarbageCollectionData after deleting the sweptRoutes from the gcData\n\t */\n\tprivate deleteSweptRoutes(\n\t\tsweptRoutes: string[],\n\t\tgcData: IGarbageCollectionData,\n\t): IGarbageCollectionData {\n\t\tconst sweptRoutesSet = new Set<string>(sweptRoutes);\n\t\tconst gcNodes: { [id: string]: string[] } = {};\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\t\tif (!sweptRoutesSet.has(id)) {\n\t\t\t\tgcNodes[id] = Array.from(outboundRoutes);\n\t\t\t}\n\t\t}\n\n\t\t// TODO: GC:Validation - assert that the nodeId is in gcData\n\n\t\treturn {\n\t\t\tgcNodes,\n\t\t};\n\t}\n\n\t/**\n\t * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n\t * time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be\n\t * updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of\n\t * these objects while there can be in-memory referenced to it:\n\t * 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is\n\t * added, the object may have been accessed and in-memory reference to it added.\n\t * 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were\n\t * unreferenced, they could have been accessed and in-memory reference to them added.\n\t *\n\t * This function identifies nodes that were referenced since the last run.\n\t * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n\t *\n\t * @returns - a list of all nodes referenced from the last local summary until now.\n\t */\n\tprivate findAllNodesReferencedBetweenGCs(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData | undefined,\n\t\tlogger: ITelemetryLogger,\n\t): string[] | undefined {\n\t\t// If we haven't run GC before there is nothing to do.\n\t\t// No previousGCData, means nothing is unreferenced, and there are no reference state trackers to clear\n\t\tif (previousGCData === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Find any references that haven't been identified correctly.\n\t\tconst missingExplicitReferences = this.findMissingExplicitReferences(\n\t\t\tcurrentGCData,\n\t\t\tpreviousGCData,\n\t\t\tthis.newReferencesSinceLastRun,\n\t\t);\n\n\t\tif (missingExplicitReferences.length > 0) {\n\t\t\tmissingExplicitReferences.forEach((missingExplicitReference) => {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\tgcNodeId: missingExplicitReference[0],\n\t\t\t\t\tgcRoutes: JSON.stringify(missingExplicitReference[1]),\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\n\t\t// No references were added since the last run so we don't have to update reference states of any unreferenced\n\t\t// nodes. There is no in between state at this point.\n\t\tif (this.newReferencesSinceLastRun.size === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t/**\n\t\t * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n\t\t * edges that have been added since then. To do this, combine the GC data from the last run and the current\n\t\t * run, and then add the references since last run.\n\t\t *\n\t\t * Note on why we need to combine the data from previous run, current run and all references in between -\n\t\t * 1. We need data from last run because some of its references may have been deleted since then. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n\t\t * references added new outbound references before they were deleted, we need to detect them.\n\t\t *\n\t\t * 3. We need data from the current run because currently we may not detect when DDSes are referenced:\n\t\t * - We don't require DDSes handles to be stored in a referenced DDS.\n\t\t * - A new data store may have \"root\" DDSes already created and we don't detect them today.\n\t\t */\n\t\tconst gcDataSuperSet = concatGarbageCollectionData(previousGCData, currentGCData);\n\t\tconst newOutboundRoutesSinceLastRun: string[] = [];\n\t\tthis.newReferencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n\t\t\tif (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n\t\t\t} else {\n\t\t\t\tgcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n\t\t\t}\n\t\t\tnewOutboundRoutesSinceLastRun.push(...outboundRoutes);\n\t\t});\n\n\t\t/**\n\t\t * Run GC on the above reference graph starting with root and all new outbound routes. This will generate a\n\t\t * list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,\n\t\t * unreferenced, stop tracking them and remove from unreferenced list.\n\t\t * Note that some of these nodes may be unreferenced now and if so, the current run will mark them as\n\t\t * unreferenced and add unreferenced state.\n\t\t */\n\t\tconst gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\n\t\t\t\"/\",\n\t\t\t...newOutboundRoutesSinceLastRun,\n\t\t]);\n\t\treturn gcResult.referencedNodeIds;\n\t}\n\n\t/**\n\t * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t * @returns - a list of missing explicit references\n\t */\n\tprivate findMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t): [string, string[]][] {\n\t\tassert(\n\t\t\tpreviousGCData !== undefined,\n\t\t\t0x2b7 /* \"Can't validate correctness without GC data from last run\" */,\n\t\t);\n\n\t\tconst currentGraph = Object.entries(currentGCData.gcNodes);\n\t\tconst missingExplicitReferences: [string, string[]][] = [];\n\t\tcurrentGraph.forEach(([nodeId, currentOutboundRoutes]) => {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tcurrentOutboundRoutes.forEach((route) => {\n\t\t\t\tconst nodeType = this.runtime.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tmissingExplicitReferences.push([nodeId, missingExplicitRoutes]);\n\t\t\t}\n\t\t});\n\n\t\t// Ideally missingExplicitReferences should always have a size 0\n\t\treturn missingExplicitReferences;\n\t}\n\n\t/**\n\t * Generates the stats of a garbage collection run from the given results of the run.\n\t * @param gcResult - The result of a GC run.\n\t * @returns the GC stats of the GC run.\n\t */\n\tprivate generateStats(gcResult: IGCResult): IGCStats {\n\t\tconst gcStats: IGCStats = {\n\t\t\tnodeCount: 0,\n\t\t\tdataStoreCount: 0,\n\t\t\tattachmentBlobCount: 0,\n\t\t\tunrefNodeCount: 0,\n\t\t\tunrefDataStoreCount: 0,\n\t\t\tunrefAttachmentBlobCount: 0,\n\t\t\tupdatedNodeCount: 0,\n\t\t\tupdatedDataStoreCount: 0,\n\t\t\tupdatedAttachmentBlobCount: 0,\n\t\t};\n\n\t\tconst updateNodeStats = (nodeId: string, referenced: boolean) => {\n\t\t\tgcStats.nodeCount++;\n\t\t\t// If there is no previous GC data, every node's state is generated and is considered as updated.\n\t\t\t// Otherwise, find out if any node went from referenced to unreferenced or vice-versa.\n\t\t\tconst stateUpdated =\n\t\t\t\tthis.gcDataFromLastRun === undefined ||\n\t\t\t\tthis.unreferencedNodesState.has(nodeId) === referenced;\n\t\t\tif (stateUpdated) {\n\t\t\t\tgcStats.updatedNodeCount++;\n\t\t\t}\n\t\t\tif (!referenced) {\n\t\t\t\tgcStats.unrefNodeCount++;\n\t\t\t}\n\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {\n\t\t\t\tgcStats.dataStoreCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedDataStoreCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefDataStoreCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {\n\t\t\t\tgcStats.attachmentBlobCount++;\n\t\t\t\tif (stateUpdated) {\n\t\t\t\t\tgcStats.updatedAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t\tif (!referenced) {\n\t\t\t\t\tgcStats.unrefAttachmentBlobCount++;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tfor (const nodeId of gcResult.referencedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, true /* referenced */);\n\t\t}\n\n\t\tfor (const nodeId of gcResult.deletedNodeIds) {\n\t\t\tupdateNodeStats(nodeId, false /* referenced */);\n\t\t}\n\n\t\treturn gcStats;\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tprivate logSweepEvents(logger: ITelemetryLogger, currentReferenceTimestampMs: number) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.unreferencedNodesState.forEach((nodeStateTracker, nodeId) => {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GCObjectDeleted\",\n\t\t\t\tid: nodeId,\n\t\t\t\ttype: nodeType,\n\t\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\t\ttimeout: this.sweepTimeoutMs,\n\t\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.\n\t */\n\tprivate inactiveNodeUsed(\n\t\tusageType: \"Changed\" | \"Loaded\" | \"Revived\",\n\t\tnodeId: string,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tfromNodeId?: string,\n\t\tpackagePath?: readonly string[],\n\t\tcurrentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(),\n\t\trequestHeaders?: IRequestHeader,\n\t) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is active, skip logging.\n\t\tif (\n\t\t\tcurrentReferenceTimestampMs === undefined ||\n\t\t\tnodeStateTracker.state === UnreferencedState.Active\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We only care about data stores and attachment blobs for this telemetry since GC only marks these objects\n\t\t// as unreferenced. Also, if an inactive DDS is used, the corresponding data store store will also be used.\n\t\tconst nodeType = this.runtime.getNodeType(nodeId);\n\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${nodeId}-${usageType}`;\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst propsToLog = {\n\t\t\tid: nodeId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Inactive\n\t\t\t\t\t? this.inactiveTimeoutMs\n\t\t\t\t\t: this.sweepTimeoutMs,\n\t\t\tcompletedGCRuns: this.completedRuns,\n\t\t\tlastSummaryTime: this.getLastSummaryTimestampMs(),\n\t\t\t...this.createContainerMetadata,\n\t\t\texternalRequest: requestHeaders?.[RuntimeHeaders.externalRequest],\n\t\t\tviaHandle: requestHeaders?.[RuntimeHeaders.viaHandle],\n\t\t\tfromId: fromNodeId,\n\t\t};\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({ ...propsToLog, usageType, state });\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: packagePathToTelemetryProperty(packagePath),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If SweepReady Usage Detection is enabled, the handler may close the interactive container.\n\t\t\t// Once Sweep is fully implemented, this will be removed since the objects will be gone\n\t\t\t// and errors will arise elsewhere in the runtime\n\t\t\tif (state === UnreferencedState.SweepReady) {\n\t\t\t\tthis.sweepReadyUsageHandler.usageDetectedInInteractiveClient({\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\tusageType,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async logUnreferencedEvents(logger: ITelemetryLogger) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.unreferencedNodesState.get(eventProps.id);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\t...propsToLog,\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tpkg: pkg\n\t\t\t\t\t\t? { value: pkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tfromPkg: fromPkg\n\t\t\t\t\t\t? { value: fromPkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n\nfunction generateSortedGCState(gcState: IGarbageCollectionState): IGarbageCollectionState {\n\tconst sortableArray: [string, IGarbageCollectionNodeData][] = Object.entries(gcState.gcNodes);\n\tsortableArray.sort(([a], [b]) => a.localeCompare(b));\n\tconst sortedGCState: IGarbageCollectionState = { gcNodes: {} };\n\tfor (const [nodeId, nodeData] of sortableArray) {\n\t\tnodeData.outboundRoutes.sort();\n\t\tsortedGCState.gcNodes[nodeId] = nodeData;\n\t}\n\treturn sortedGCState;\n}\n\n/** A wrapper around common-utils Timer that requires the timeout when calling start/restart */\nclass TimerWithNoDefaultTimeout extends Timer {\n\tconstructor(private readonly callback: () => void) {\n\t\t// The default timeout/handlers will never be used since start/restart pass overrides below\n\t\tsuper(0, () => {\n\t\t\tthrow new Error(\"DefaultHandler should not be used\");\n\t\t});\n\t}\n\n\tstart(timeoutMs: number) {\n\t\tsuper.start(timeoutMs, this.callback);\n\t}\n\n\trestart(timeoutMs: number): void {\n\t\tsuper.restart(timeoutMs, this.callback);\n\t}\n}\n"]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { GCVersion } from "./summaryFormat";
|
|
6
|
-
/** The stable version of garbage collection in production. */
|
|
7
|
-
export declare const stableGCVersion: GCVersion;
|
|
8
|
-
/** The current version of garbage collection. */
|
|
9
|
-
export declare const currentGCVersion: GCVersion;
|
|
10
|
-
/** This undocumented GC Option (on ContainerRuntime Options) allows an app to disable enforcing GC on old documents by incrementing this value */
|
|
11
|
-
export declare const gcTombstoneGenerationOptionName = "gcTombstoneGeneration";
|
|
12
|
-
export declare const runGCKey = "Fluid.GarbageCollection.RunGC";
|
|
13
|
-
export declare const runSweepKey = "Fluid.GarbageCollection.RunSweep";
|
|
14
|
-
export declare const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
|
|
15
|
-
export declare const runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
|
|
16
|
-
export declare const trackGCStateKey = "Fluid.GarbageCollection.TrackGCState";
|
|
17
|
-
export declare const disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
|
|
18
|
-
export declare const disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
|
|
19
|
-
export declare const throwOnTombstoneLoadKey = "Fluid.GarbageCollection.ThrowOnTombstoneLoad";
|
|
20
|
-
export declare const throwOnTombstoneUsageKey = "Fluid.GarbageCollection.ThrowOnTombstoneUsage";
|
|
21
|
-
export declare const gcVersionUpgradeToV2Key = "Fluid.GarbageCollection.GCVersionUpgradeToV2";
|
|
22
|
-
export declare const sweepDatastoresKey = "Fluid.GarbageCollection.Test.SweepDataStores";
|
|
23
|
-
export declare const oneDayMs: number;
|
|
24
|
-
export declare const defaultInactiveTimeoutMs: number;
|
|
25
|
-
export declare const defaultSessionExpiryDurationMs: number;
|
|
26
|
-
//# sourceMappingURL=garbageCollectionConstants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollectionConstants.d.ts","sourceRoot":"","sources":["../src/garbageCollectionConstants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,8DAA8D;AAC9D,eAAO,MAAM,eAAe,EAAE,SAAa,CAAC;AAC5C,iDAAiD;AACjD,eAAO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,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,sCAAsC,CAAC;AACtE,6CAA6C;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,yCAAyC,CAAC;AAC5E,qHAAqH;AACrH,MAAM,CAAC,MAAM,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,wFAAwF;AACxF,MAAM,CAAC,MAAM,uBAAuB,GAAG,8CAA8C,CAAC;AACtF,0GAA0G;AAC1G,MAAM,CAAC,MAAM,wBAAwB,GAAG,+CAA+C,CAAC;AACxF,6CAA6C;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,8CAA8C,CAAC;AACtF,kDAAkD;AAClD,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAEjF,2BAA2B;AAC3B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,SAAS;AAC/D,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,UAAU","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { GCVersion } from \"./summaryFormat\";\n\n/** The stable version of garbage collection in production. */\nexport const stableGCVersion: GCVersion = 1;\n/** The current version of garbage collection. */\nexport const currentGCVersion: GCVersion = 2;\n\n/** This undocumented GC Option (on ContainerRuntime Options) allows an app to disable enforcing GC on old documents by incrementing this value */\nexport const gcTombstoneGenerationOptionName = \"gcTombstoneGeneration\";\n\n// Feature gate key to turn GC on / off.\nexport const runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC sweep on / off.\nexport const runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to turn GC test mode on / off.\nexport const gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to expire a session after a set period of time.\nexport const runSessionExpiryKey = \"Fluid.GarbageCollection.RunSessionExpiry\";\n// Feature gate key to write the gc blob as a handle if the data is the same.\nexport const trackGCStateKey = \"Fluid.GarbageCollection.TrackGCState\";\n// Feature gate key to turn GC sweep log off.\nexport const disableSweepLogKey = \"Fluid.GarbageCollection.DisableSweepLog\";\n// Feature gate key to disable the tombstone feature, i.e., tombstone information is not read / written into summary.\nexport const disableTombstoneKey = \"Fluid.GarbageCollection.DisableTombstone\";\n// Feature gate to enable throwing an error when tombstone object is loaded (requested).\nexport const throwOnTombstoneLoadKey = \"Fluid.GarbageCollection.ThrowOnTombstoneLoad\";\n// Feature gate to enable throwing an error when tombstone object is used (e.g. outgoing or incoming ops).\nexport const throwOnTombstoneUsageKey = \"Fluid.GarbageCollection.ThrowOnTombstoneUsage\";\n// Feature gate to enable GC version upgrade.\nexport const gcVersionUpgradeToV2Key = \"Fluid.GarbageCollection.GCVersionUpgradeToV2\";\n// Feature gate to enable GC sweep for datastores.\n// TODO: Remove Test from the flag when we are confident to turn on sweep\nexport const sweepDatastoresKey = \"Fluid.GarbageCollection.Test.SweepDataStores\";\n\n// One day in milliseconds.\nexport const oneDayMs = 1 * 24 * 60 * 60 * 1000;\n\nexport const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days\nexport const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollectionHelpers.d.ts","sourceRoot":"","sources":["../src/garbageCollectionHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAQpE;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,EAAE,EAAE,iB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AM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,iCAAiC,CAChD,mBAAuC,EACvC,iBAAqC;IAErC,+HAA+H;IAC/H,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACpC,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,mBAAmB,KAAK,iBAAiB,CAAC;AAClD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryGenericEvent } from \"@fluidframework/common-definitions\";\nimport { packagePathToTelemetryProperty } from \"@fluidframework/runtime-utils\";\nimport { MonitoringContext } from \"@fluidframework/telemetry-utils\";\nimport {\n\tdisableTombstoneKey,\n\trunSweepKey,\n\tthrowOnTombstoneLoadKey,\n\tthrowOnTombstoneUsageKey,\n} from \"./garbageCollectionConstants\";\n\n/**\n * Consolidates info / logic for logging when we encounter unexpected usage of GC'd objects. For example, when a\n * tombstoned or deleted object is loaded.\n */\nexport function sendGCUnexpectedUsageEvent(\n\tmc: MonitoringContext,\n\tevent: ITelemetryGenericEvent & {\n\t\tcategory: \"error\" | \"generic\";\n\t\tgcTombstoneEnforcementAllowed: boolean | undefined;\n\t},\n\tpackagePath: readonly string[] | undefined,\n\terror?: unknown,\n) {\n\tevent.pkg = packagePathToTelemetryProperty(packagePath);\n\tevent.tombstoneFlags = JSON.stringify({\n\t\tDisableTombstone: mc.config.getBoolean(disableTombstoneKey),\n\t\tThrowOnTombstoneUsage: mc.config.getBoolean(throwOnTombstoneUsageKey),\n\t\tThrowOnTombstoneLoad: mc.config.getBoolean(throwOnTombstoneLoadKey),\n\t});\n\tevent.sweepFlags = JSON.stringify({\n\t\tEnableSweepFlag: mc.config.getBoolean(runSweepKey),\n\t});\n\n\tmc.logger.sendTelemetryEvent(event, error);\n}\n\n/**\n * In order to protect old documents that were created at a time when known bugs exist that violate GC's invariants\n * such that enforcing GC (Fail on Tombstone load/usage, GC Sweep) would cause legitimate data loss,\n * the container author may increment the generation value for Tombstone such that containers created\n * with a different value will not be subjected to GC enforcement.\n * If no generation is provided at runtime, this defaults to return true to maintain expected default behavior\n * @param persistedGeneration - The persisted feature support value\n * @param currentGeneration - The current app-provided feature support value\n * @returns true if GC Enforcement (Fail on Tombstone load/usage) should be allowed\n */\nexport function shouldAllowGcTombstoneEnforcement(\n\tpersistedGeneration: number | undefined,\n\tcurrentGeneration: number | undefined,\n): boolean {\n\t// If no Generation value is provided for this session, then we should default to letting Tombstone feature behave as intended.\n\tif (currentGeneration === undefined) {\n\t\treturn true;\n\t}\n\treturn persistedGeneration === currentGeneration;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gcSweepReadyUsageDetection.d.ts","sourceRoot":"","sources":["../src/gcSweepReadyUsageDetection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAEN,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,MAAM,iCAAiC,CAAC;AAGzC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iFAC4C,CAAC;AAEhF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,sEAC6B,CAAC;AAqBrE;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,YAAa,YAAW,eAAe;IAChF,oHAAoH;IAC7G,SAAS,EAAE,MAAM,CAAiD;CACzE;AAED;;;;;;;GAOG;AACH,qBAAa,+BAA+B;IAI1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IALzB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;gBAGlD,kBAAkB,EAAE,MAAM,EAC1B,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,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAClE,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;oBACpC,eAAe,GAAG,WAAW,CAAC;iBAC9B;aACD;YAAC,OAAO,CAAC,EAAE,GAAE;YACd,aAAa,GAAG,MAAA,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,0CAAE,aAAa,CAAC;YAExE,+DAA+D;YAC/D,IACC,aAAa,KAAK,SAAS;gBAC3B,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,GAAG,mBAAmB,GAAG,QAAQ,EAC1D;gBACD,WAAW,GAAG,KAAK,CAAC;aACpB;SACD;QAED,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,iDAAiD,EAAE;YACzF,YAAY,EAAE,IAAI,CAAC,SAAS,iCAAM,UAAU,KAAE,aAAa,EAAE,mBAAmB,IAAG;SACnF,CAAC,CAAC;QACH,IAAI,WAAW,EAAE;YAChB,qDAAqD;YACrD,8FAA8F;YAC9F,mGAAmG;YACnG,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACzE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,0BAA0B,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;YAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACpB;aAAM;YACN,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,+BAA+B,EAAE,EAAE,KAAK,CAAC,CAAC;SACrF;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n\tIConfigProvider,\n\tIFluidErrorBase,\n\tLoggingError,\n\tMonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { oneDayMs } from \"./garbageCollectionConstants\";\n\n/**\n * Feature Gate Key -\n * How many days between closing the container from this error (avoids locking user out of their file altogether)\n */\nexport const skipClosureForXDaysKey =\n\t\"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.SkipClosureForXDays\";\n\n/**\n * LocalStorage key (NOT via feature gate / monitoring context)\n * A map from docId to info about the last time we closed due to this error\n */\nexport const closuresMapLocalStorageKey =\n\t\"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.Closures\";\n\n/**\n * Feature gate key to enable closing the container if SweepReady objects are used.\n * Value should contain keywords \"interactiveClient\" and/or \"summarizer\" to enable detection in each container type\n */\nconst sweepReadyUsageDetectionSetting = {\n\tread(config: IConfigProvider) {\n\t\tconst sweepReadyUsageDetectionKey =\n\t\t\t\"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection\";\n\t\tconst value = config.getString(sweepReadyUsageDetectionKey);\n\t\tif (value === undefined) {\n\t\t\treturn { interactiveClient: false, summarizer: false };\n\t\t}\n\t\treturn {\n\t\t\tinteractiveClient: value.includes(\"interactiveClient\"),\n\t\t\tsummarizer: value.includes(\"summarizer\"),\n\t\t};\n\t},\n};\n\n/**\n * Error class raised when a SweepReady object is used, indicating a bug in how\n * references are managed in the container by the application, or a bug in how\n * GC tracks those references.\n *\n * There's a chance for false positives when this error is raised by an Interactive Container,\n * since only the Summarizer has the latest truth about unreferenced node tracking\n */\nexport class SweepReadyUsageError extends LoggingError implements IFluidErrorBase {\n\t/** This errorType will be in temporary use (until Sweep is fully implemented) so don't add to any errorType type */\n\tpublic errorType: string = \"unreferencedObjectUsedAfterGarbageCollected\";\n}\n\n/**\n * This class encapsulates the logic around what to do when a SweepReady object is used.\n * There are several tactics we plan to use in Dogfood environments to aid diagnosis of these cases:\n * - Closing the interactive container when either the interactive or summarizer client detects this kind of violation\n * (via sweepReadyUsageDetectionSetting above)\n * - Throttling the frequency of these crashes via a \"Skip Closure Period\" per container per device\n * (via skipClosureForXDaysKey above. Uses localStorage and closuresMapLocalStorageKey to implement this behavior)\n */\nexport class SweepReadyUsageDetectionHandler {\n\tprivate readonly localStorage: Pick<Storage, \"getItem\" | \"setItem\">;\n\n\tconstructor(\n\t\tprivate readonly uniqueContainerKey: string,\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly closeFn: (error?: ICriticalContainerError) => void,\n\t\tlocalStorageOverride?: Pick<Storage, \"getItem\" | \"setItem\">,\n\t) {\n\t\tconst noopStorage = { getItem: () => null, setItem: () => {} };\n\t\t// localStorage is not defined in Node environment, so fall back to noopStorage if needed.\n\t\tthis.localStorage = localStorageOverride ?? globalThis.localStorage ?? noopStorage;\n\n\t\tif (this.localStorage === noopStorage) {\n\t\t\t// This means the Skip Closure Period logic will not work.\n\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"SweepReadyUsageDetectionHandlerNoopStorage\",\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * If SweepReady Usage Detection is enabled, close the interactive container.\n\t * If the SkipClosureForXDays setting is set, don't close the container more than once in that period.\n\t *\n\t * Once Sweep is fully implemented, this will be removed since the objects will be gone\n\t * and errors will arise elsewhere in the runtime\n\t */\n\tpublic usageDetectedInInteractiveClient(errorProps: ITelemetryProperties) {\n\t\tif (!sweepReadyUsageDetectionSetting.read(this.mc.config).interactiveClient) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Default stance is we close every time - this reflects the severity of SweepReady Object Usage.\n\t\t// However, we may choose to \"throttle\" the closures by setting the SkipClosureForXDays setting,\n\t\t// which will only allow the container to close once during that period, to avoid locking users out.\n\t\tlet shouldClose: boolean = true;\n\t\tlet pastClosuresMap: Record<string, { lastCloseTime: number } | undefined> = {};\n\t\tlet lastCloseTime: number | undefined;\n\t\tconst skipClosureForXDays = this.mc.config.getNumber(skipClosureForXDaysKey);\n\t\tif (skipClosureForXDays !== undefined) {\n\t\t\t// Read pastClosuresMap from localStorage then extract the lastCloseTime from the map\n\t\t\ttry {\n\t\t\t\tconst rawValue = this.localStorage.getItem(closuresMapLocalStorageKey);\n\t\t\t\tconst parsedValue = rawValue === null ? {} : JSON.parse(rawValue);\n\t\t\t\tif (typeof parsedValue === \"object\") {\n\t\t\t\t\tpastClosuresMap = parsedValue;\n\t\t\t\t}\n\t\t\t} catch (e) {}\n\t\t\tlastCloseTime = pastClosuresMap[this.uniqueContainerKey]?.lastCloseTime;\n\n\t\t\t// Don't close if we did already within the Skip Closure Period\n\t\t\tif (\n\t\t\t\tlastCloseTime !== undefined &&\n\t\t\t\tDate.now() < lastCloseTime + skipClosureForXDays * oneDayMs\n\t\t\t) {\n\t\t\t\tshouldClose = false;\n\t\t\t}\n\t\t}\n\n\t\tconst error = new SweepReadyUsageError(\"SweepReady object used in Non-Summarizer Client\", {\n\t\t\terrorDetails: JSON.stringify({ ...errorProps, lastCloseTime, skipClosureForXDays }),\n\t\t});\n\t\tif (shouldClose) {\n\t\t\t// Update closures map in localStorage before closing\n\t\t\t// Note there is a race condition between different tabs updating localStorage and overwriting\n\t\t\t// each others' updates. If so, some tab will crash again. Just reload one at a time to get unstuck\n\t\t\tpastClosuresMap[this.uniqueContainerKey] = { lastCloseTime: Date.now() };\n\t\t\tthis.localStorage.setItem(closuresMapLocalStorageKey, JSON.stringify(pastClosuresMap));\n\n\t\t\tthis.closeFn(error);\n\t\t} else {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SweepReadyObject_UsageAllowed\" }, error);\n\t\t}\n\t}\n}\n"]}
|