@fluidframework/container-runtime 2.0.0-internal.3.3.1 → 2.0.0-internal.3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/blobManager.d.ts +17 -11
  2. package/dist/blobManager.d.ts.map +1 -1
  3. package/dist/blobManager.js +89 -58
  4. package/dist/blobManager.js.map +1 -1
  5. package/dist/containerRuntime.d.ts +5 -0
  6. package/dist/containerRuntime.d.ts.map +1 -1
  7. package/dist/containerRuntime.js +11 -10
  8. package/dist/containerRuntime.js.map +1 -1
  9. package/dist/gc/garbageCollection.d.ts.map +1 -1
  10. package/dist/gc/garbageCollection.js +4 -5
  11. package/dist/gc/garbageCollection.js.map +1 -1
  12. package/dist/gc/gcConfigs.d.ts.map +1 -1
  13. package/dist/gc/gcConfigs.js +25 -22
  14. package/dist/gc/gcConfigs.js.map +1 -1
  15. package/dist/gc/gcDefinitions.d.ts +28 -3
  16. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  17. package/dist/gc/gcDefinitions.js +15 -2
  18. package/dist/gc/gcDefinitions.js.map +1 -1
  19. package/dist/gc/gcHelpers.d.ts +25 -5
  20. package/dist/gc/gcHelpers.d.ts.map +1 -1
  21. package/dist/gc/gcHelpers.js +38 -5
  22. package/dist/gc/gcHelpers.js.map +1 -1
  23. package/dist/gc/gcSummaryStateTracker.d.ts +5 -7
  24. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  25. package/dist/gc/gcSummaryStateTracker.js +16 -25
  26. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  27. package/dist/gc/index.d.ts +2 -2
  28. package/dist/gc/index.d.ts.map +1 -1
  29. package/dist/gc/index.js +3 -1
  30. package/dist/gc/index.js.map +1 -1
  31. package/dist/packageVersion.d.ts +1 -1
  32. package/dist/packageVersion.js +1 -1
  33. package/dist/packageVersion.js.map +1 -1
  34. package/dist/summary/summaryFormat.d.ts +2 -0
  35. package/dist/summary/summaryFormat.d.ts.map +1 -1
  36. package/dist/summary/summaryFormat.js.map +1 -1
  37. package/lib/blobManager.d.ts +17 -11
  38. package/lib/blobManager.d.ts.map +1 -1
  39. package/lib/blobManager.js +89 -58
  40. package/lib/blobManager.js.map +1 -1
  41. package/lib/containerRuntime.d.ts +5 -0
  42. package/lib/containerRuntime.d.ts.map +1 -1
  43. package/lib/containerRuntime.js +11 -10
  44. package/lib/containerRuntime.js.map +1 -1
  45. package/lib/gc/garbageCollection.d.ts.map +1 -1
  46. package/lib/gc/garbageCollection.js +4 -5
  47. package/lib/gc/garbageCollection.js.map +1 -1
  48. package/lib/gc/gcConfigs.d.ts.map +1 -1
  49. package/lib/gc/gcConfigs.js +25 -22
  50. package/lib/gc/gcConfigs.js.map +1 -1
  51. package/lib/gc/gcDefinitions.d.ts +28 -3
  52. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  53. package/lib/gc/gcDefinitions.js +14 -1
  54. package/lib/gc/gcDefinitions.js.map +1 -1
  55. package/lib/gc/gcHelpers.d.ts +25 -5
  56. package/lib/gc/gcHelpers.d.ts.map +1 -1
  57. package/lib/gc/gcHelpers.js +36 -4
  58. package/lib/gc/gcHelpers.js.map +1 -1
  59. package/lib/gc/gcSummaryStateTracker.d.ts +5 -7
  60. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  61. package/lib/gc/gcSummaryStateTracker.js +16 -25
  62. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  63. package/lib/gc/index.d.ts +2 -2
  64. package/lib/gc/index.d.ts.map +1 -1
  65. package/lib/gc/index.js +2 -2
  66. package/lib/gc/index.js.map +1 -1
  67. package/lib/packageVersion.d.ts +1 -1
  68. package/lib/packageVersion.js +1 -1
  69. package/lib/packageVersion.js.map +1 -1
  70. package/lib/summary/summaryFormat.d.ts +2 -0
  71. package/lib/summary/summaryFormat.d.ts.map +1 -1
  72. package/lib/summary/summaryFormat.js.map +1 -1
  73. package/package.json +23 -24
  74. package/src/blobManager.ts +108 -77
  75. package/src/containerRuntime.ts +12 -4
  76. package/src/gc/garbageCollection.ts +4 -8
  77. package/src/gc/gcConfigs.ts +26 -12
  78. package/src/gc/gcDefinitions.ts +28 -3
  79. package/src/gc/gcHelpers.ts +45 -4
  80. package/src/gc/gcSummaryStateTracker.ts +17 -29
  81. package/src/gc/index.ts +3 -0
  82. package/src/packageVersion.ts +1 -1
  83. package/src/summary/summaryFormat.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"gcSummaryStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,GAKT,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,UAAU,EAGV,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAA6B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACN,gBAAgB,EAEhB,uBAAuB,EACvB,eAAe,GACf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWlE;;;;;GAKG;AACH,MAAM,OAAO,qBAAqB;IAcjC;IACC,sCAAsC;IACrB,WAAoB;IACrC,kDAAkD;IACjC,aAAsB,EACtB,EAAqB;IACtC,4EAA4E;IAC5E,sBAA+B;IAC/B,kEAAkE;IAClE,uBAA8C;QAP7B,gBAAW,GAAX,WAAW,CAAS;QAEpB,kBAAa,GAAb,aAAa,CAAS;QACtB,OAAE,GAAF,EAAE,CAAmB;QAMtC,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;QACtD,yEAAyE;QACzE,IAAI,CAAC,gBAAgB;YACpB,IAAI,CAAC,EAAE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AAiB,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAChF,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC;YAC/D,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,CAAC;SACnE,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { getGCDataFromSnapshot } from \"@fluidframework/garbage-collector\";\nimport { SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tmergeStats,\n\tReadAndParseBlob,\n\tRefreshSummaryResult,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport { MonitoringContext } from \"@fluidframework/telemetry-utils\";\nimport { IContainerRuntimeMetadata, metadataBlobName } from \"../summary\";\nimport {\n\tcurrentGCVersion,\n\tGCVersion,\n\tgcVersionUpgradeToV2Key,\n\tstableGCVersion,\n} from \"./gcDefinitions\";\nimport { generateSortedGCState, getGCVersion } from \"./gcHelpers\";\n\n/**\n * The GC data that is tracked for a summary.\n */\ninterface IGCSummaryTrackingData {\n\tserializedGCState: string | undefined;\n\tserializedTombstones: string | undefined;\n\tserializedDeletedNodes: string | undefined;\n}\n\n/**\n * Encapsulates the garbage collection state that is tracked across summaries.\n * It maintains the GC state as per the latest summary in by the server. It updates state when a summary tracked by this\n * client is acked by the server or from a snapshot is downloaded from the server.\n * On summarize, it decides whether to write new state or re-use previous summary's state.\n */\nexport class GCSummaryStateTracker {\n\t// The current version of GC running.\n\tpublic 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// Keeps track of the GC data from the latest summary successfully acked by the server.\n\tprivate latestSummaryData: IGCSummaryTrackingData | undefined;\n\t// Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n\tprivate pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n\t// Tracks whether there was GC was run in latest summary being tracked.\n\tprivate wasGCRunInLatestSummary: boolean;\n\n\tconstructor(\n\t\t// Tells whether GC should run or not.\n\t\tprivate readonly shouldRunGC: boolean,\n\t\t// Tells whether tombstone mode is enabled or not.\n\t\tprivate readonly tombstoneMode: boolean,\n\t\tprivate readonly mc: MonitoringContext,\n\t\t// Tells whether GC was run in the base snapshot this container loaded from.\n\t\twasGCRunInBaseSnapshot: boolean,\n\t\t// The GC version in the base snapshot this container loaded from.\n\t\tgcVersionInBaseSnapshot: GCVersion | undefined,\n\t) {\n\t\tthis.wasGCRunInLatestSummary = wasGCRunInBaseSnapshot;\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\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 = gcVersionInBaseSnapshot ?? this.currentGCVersion;\n\t}\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\tpublic doesGCStateNeedReset(): boolean {\n\t\treturn this.wasGCRunInLatestSummary !== this.shouldRunGC;\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 doesSummaryStateNeedReset(): boolean {\n\t\treturn (\n\t\t\tthis.doesGCStateNeedReset() ||\n\t\t\t(this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion)\n\t\t);\n\t}\n\n\t/**\n\t * Summarizes three component of the GC data - GC state, tombstones and deleted nodes.\n\t * It does incremental summary, i.e., it writes summary tree / summary blob only for the component that changed.\n\t * For components that did not change, a summary handle is returned that points to the previous successful summary.\n\t * If none of the components changed, it returns a summary handle for the entire GC data.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\tgcState: IGarbageCollectionState,\n\t\tdeletedNodes: Set<string>,\n\t\ttombstones: string[],\n\t): ISummarizeResult | undefined {\n\t\tif (!this.shouldRunGC) {\n\t\t\treturn;\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\tdeletedNodes.size > 0 ? JSON.stringify(Array.from(deletedNodes).sort()) : 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? tombstones.length > 0\n\t\t\t\t? JSON.stringify(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\tthis.pendingSummaryData = {\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t};\n\n\t\tif (trackState && !fullTree && this.latestSummaryData !== undefined) {\n\t\t\t// If nothing changed since last summary, send a summary handle for the entire GC data.\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData.serializedGCState === serializedGCState &&\n\t\t\t\tthis.latestSummaryData.serializedTombstones === serializedTombstones\n\t\t\t) {\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: `/${gcTreeKey}`,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If some state changed, build a GC summary tree.\n\t\t\treturn this.buildGCSummaryTree(\n\t\t\t\tserializedGCState,\n\t\t\t\tserializedTombstones,\n\t\t\t\tserializedDeletedNodes,\n\t\t\t\ttrue /* trackState */,\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\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<IGarbageCollectionSnapshotData | undefined> {\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 undefined;\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\tthis.latestSummaryData = this.pendingSummaryData;\n\t\t\tthis.pendingSummaryData = undefined;\n\t\t\treturn undefined;\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\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.pendingSummaryData = undefined;\n\t\treturn latestGCData;\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 * @param gcSnapshotData - The GC snapshot data to update state from.\n\t */\n\tpublic updateStateFromSnapshotData(gcSnapshotData: IGarbageCollectionSnapshotData | undefined) {\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 (gcSnapshotData === undefined) {\n\t\t\tthis.latestSummaryData = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\t// If tracking state across summaries, update latest summary data from the snapshot's GC data.\n\t\tthis.latestSummaryData = {\n\t\t\tserializedGCState: JSON.stringify(generateSortedGCState(gcSnapshotData.gcState)),\n\t\t\tserializedTombstones: JSON.stringify(gcSnapshotData.tombstones),\n\t\t\tserializedDeletedNodes: JSON.stringify(gcSnapshotData.deletedNodes),\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcSummaryStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,GAKT,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACN,UAAU,EAGV,kBAAkB,GAClB,MAAM,+BAA+B,CAAC;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CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;SAC7E;QACD,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAC;QACpC,OAAO,YAAY,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,2BAA2B,CAAC,cAA0D;QAC5F,2GAA2G;QAC3G,IAAI,cAAc,KAAK,SAAS,EAAE;YACjC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;YACnC,OAAO;SACP;QAED,8FAA8F;QAC9F,IAAI,CAAC,iBAAiB,GAAG;YACxB,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,qBAAqB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAChF,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,UAAU,CAAC;YAC/D,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,YAAY,CAAC;SACnE,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { getGCDataFromSnapshot } from \"@fluidframework/garbage-collector\";\nimport { SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tmergeStats,\n\tReadAndParseBlob,\n\tRefreshSummaryResult,\n\tSummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport { IContainerRuntimeMetadata, metadataBlobName } from \"../summary\";\nimport { GCVersion } from \"./gcDefinitions\";\nimport { generateSortedGCState, getGCVersion } from \"./gcHelpers\";\nimport { IGarbageCollectorConfigs } from \".\";\n\n/**\n * The GC data that is tracked for a summary.\n */\ninterface IGCSummaryTrackingData {\n\tserializedGCState: string | undefined;\n\tserializedTombstones: string | undefined;\n\tserializedDeletedNodes: string | undefined;\n}\n\n/**\n * Encapsulates the garbage collection state that is tracked across summaries.\n * It maintains the GC state as per the latest summary in by the server. It updates state when a summary tracked by this\n * client is acked by the server or from a snapshot is downloaded from the server.\n * On summarize, it decides whether to write new state or re-use previous summary's state.\n */\nexport class GCSummaryStateTracker {\n\t// The current version of GC running.\n\tpublic readonly currentGCVersion: GCVersion = this.configs.gcVersionInEffect;\n\t// This is the version of GC data in the latest summary being tracked.\n\tprivate latestSummaryGCVersion: GCVersion;\n\n\t// Keeps track of the GC data from the latest summary successfully acked by the server.\n\tprivate latestSummaryData: IGCSummaryTrackingData | undefined;\n\t// Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n\tprivate pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n\t// Tracks whether there was GC was run in latest summary being tracked.\n\tprivate wasGCRunInLatestSummary: boolean;\n\n\tconstructor(\n\t\t// Tells whether GC should run or not.\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"shouldRunGC\" | \"tombstoneMode\" | \"gcVersionInBaseSnapshot\" | \"gcVersionInEffect\"\n\t\t>,\n\t\t// Tells whether GC was run in the base snapshot this container loaded from.\n\t\twasGCRunInBaseSnapshot: boolean,\n\t) {\n\t\tthis.wasGCRunInLatestSummary = wasGCRunInBaseSnapshot;\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 = this.configs.gcVersionInBaseSnapshot ?? this.currentGCVersion;\n\t}\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\tpublic get doesGCStateNeedReset(): boolean {\n\t\treturn this.wasGCRunInLatestSummary !== this.configs.shouldRunGC;\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 doesSummaryStateNeedReset(): boolean {\n\t\treturn (\n\t\t\tthis.doesGCStateNeedReset ||\n\t\t\t(this.configs.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion)\n\t\t);\n\t}\n\n\t/**\n\t * Summarizes three component of the GC data - GC state, tombstones and deleted nodes.\n\t * It does incremental summary, i.e., it writes summary tree / summary blob only for the component that changed.\n\t * For components that did not change, a summary handle is returned that points to the previous successful summary.\n\t * If none of the components changed, it returns a summary handle for the entire GC data.\n\t */\n\tpublic summarize(\n\t\tfullTree: boolean,\n\t\ttrackState: boolean,\n\t\tgcState: IGarbageCollectionState,\n\t\tdeletedNodes: Set<string>,\n\t\ttombstones: string[],\n\t): ISummarizeResult | undefined {\n\t\tif (!this.configs.shouldRunGC) {\n\t\t\treturn;\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\tdeletedNodes.size > 0 ? JSON.stringify(Array.from(deletedNodes).sort()) : undefined;\n\t\t// If running in tombstone mode, serialize and write tombstones, if any.\n\t\tconst serializedTombstones = this.configs.tombstoneMode\n\t\t\t? tombstones.length > 0\n\t\t\t\t? JSON.stringify(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\tthis.pendingSummaryData = {\n\t\t\tserializedGCState,\n\t\t\tserializedTombstones,\n\t\t\tserializedDeletedNodes,\n\t\t};\n\n\t\tif (trackState && !fullTree && this.latestSummaryData !== undefined) {\n\t\t\t// If nothing changed since last summary, send a summary handle for the entire GC data.\n\t\t\tif (\n\t\t\t\tthis.latestSummaryData.serializedGCState === serializedGCState &&\n\t\t\t\tthis.latestSummaryData.serializedTombstones === serializedTombstones\n\t\t\t) {\n\t\t\t\tconst stats = mergeStats();\n\t\t\t\tstats.handleNodeCount++;\n\t\t\t\treturn {\n\t\t\t\t\tsummary: {\n\t\t\t\t\t\ttype: SummaryType.Handle,\n\t\t\t\t\t\thandle: `/${gcTreeKey}`,\n\t\t\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\t\t},\n\t\t\t\t\tstats,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// If some state changed, build a GC summary tree.\n\t\t\treturn this.buildGCSummaryTree(\n\t\t\t\tserializedGCState,\n\t\t\t\tserializedTombstones,\n\t\t\t\tserializedDeletedNodes,\n\t\t\t\ttrue /* trackState */,\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\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<IGarbageCollectionSnapshotData | undefined> {\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.configs.shouldRunGC;\n\t\t}\n\n\t\tif (!result.latestSummaryUpdated || !this.configs.shouldRunGC) {\n\t\t\treturn undefined;\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\tthis.latestSummaryData = this.pendingSummaryData;\n\t\t\tthis.pendingSummaryData = undefined;\n\t\t\treturn undefined;\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\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.pendingSummaryData = undefined;\n\t\treturn latestGCData;\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 * @param gcSnapshotData - The GC snapshot data to update state from.\n\t */\n\tpublic updateStateFromSnapshotData(gcSnapshotData: IGarbageCollectionSnapshotData | undefined) {\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 (gcSnapshotData === undefined) {\n\t\t\tthis.latestSummaryData = undefined;\n\t\t\treturn;\n\t\t}\n\n\t\t// If tracking state across summaries, update latest summary data from the snapshot's GC data.\n\t\tthis.latestSummaryData = {\n\t\t\tserializedGCState: JSON.stringify(generateSortedGCState(gcSnapshotData.gcState)),\n\t\t\tserializedTombstones: JSON.stringify(gcSnapshotData.tombstones),\n\t\t\tserializedDeletedNodes: JSON.stringify(gcSnapshotData.deletedNodes),\n\t\t};\n\t}\n}\n"]}
package/lib/gc/index.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection";
6
- export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, GCVersion, gcVersionUpgradeToV2Key, IGarbageCollectionRuntime, // Deprecated
6
+ export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, gcSweepGenerationOptionName, GCFeatureMatrix, GCVersion, gcVersionUpgradeToV2Key, IGarbageCollectionRuntime, // Deprecated
7
7
  IGarbageCollector, IGarbageCollectorConfigs, IGarbageCollectorCreateParams, IGCMetadata, IGCRuntimeOptions, IGCStats, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, sweepAttachmentBlobsKey, sweepDatastoresKey, throwOnTombstoneLoadKey, throwOnTombstoneUsageKey, UnreferencedState, } from "./gcDefinitions";
8
- export { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent, shouldAllowGcTombstoneEnforcement, } from "./gcHelpers";
8
+ export { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, } from "./gcHelpers";
9
9
  export { GCSummaryStateTracker } from "./gcSummaryStateTracker";
10
10
  export { skipClosureForXDaysKey, closuresMapLocalStorageKey, SweepReadyUsageDetectionHandler, } from "./gcSweepReadyUsageDetection";
11
11
  export { UnreferencedStateTracker } from "./gcUnreferencedStateTracker";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EAAE,aAAa;AACxC,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,oCAAoC,EACpC,0BAA0B,EAC1B,iCAAiC,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAC3B,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EAAE,aAAa;AACxC,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,oCAAoC,EACpC,0BAA0B,EAC1B,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC"}
package/lib/gc/index.js CHANGED
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection";
6
- export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, gcVersionUpgradeToV2Key, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, sweepAttachmentBlobsKey, sweepDatastoresKey, throwOnTombstoneLoadKey, throwOnTombstoneUsageKey, UnreferencedState, } from "./gcDefinitions";
7
- export { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent, shouldAllowGcTombstoneEnforcement, } from "./gcHelpers";
6
+ export { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, GCNodeType, gcTestModeKey, gcTombstoneGenerationOptionName, gcSweepGenerationOptionName, gcVersionUpgradeToV2Key, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, sweepAttachmentBlobsKey, sweepDatastoresKey, throwOnTombstoneLoadKey, throwOnTombstoneUsageKey, UnreferencedState, } from "./gcDefinitions";
7
+ export { getSnapshotDataFromOldSnapshotFormat, sendGCUnexpectedUsageEvent, shouldAllowGcTombstoneEnforcement, shouldAllowGcSweep, } from "./gcHelpers";
8
8
  export { GCSummaryStateTracker } from "./gcSummaryStateTracker";
9
9
  export { skipClosureForXDaysKey, closuresMapLocalStorageKey, SweepReadyUsageDetectionHandler, } from "./gcSweepReadyUsageDetection";
10
10
  export { UnreferencedStateTracker } from "./gcUnreferencedStateTracker";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAE/B,uBAAuB,EAQvB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,oCAAoC,EACpC,0BAA0B,EAC1B,iCAAiC,GACjC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection\";\nexport {\n\tcurrentGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSessionExpiryDurationMs,\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcTombstoneGenerationOptionName,\n\tGCVersion,\n\tgcVersionUpgradeToV2Key,\n\tIGarbageCollectionRuntime, // Deprecated\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCRuntimeOptions,\n\tIGCStats,\n\toneDayMs,\n\trunGCKey,\n\trunSessionExpiryKey,\n\trunSweepKey,\n\tstableGCVersion,\n\tsweepAttachmentBlobsKey,\n\tsweepDatastoresKey,\n\tthrowOnTombstoneLoadKey,\n\tthrowOnTombstoneUsageKey,\n\tUnreferencedState,\n} from \"./gcDefinitions\";\nexport {\n\tgetSnapshotDataFromOldSnapshotFormat,\n\tsendGCUnexpectedUsageEvent,\n\tshouldAllowGcTombstoneEnforcement,\n} from \"./gcHelpers\";\nexport { GCSummaryStateTracker } from \"./gcSummaryStateTracker\";\nexport {\n\tskipClosureForXDaysKey,\n\tclosuresMapLocalStorageKey,\n\tSweepReadyUsageDetectionHandler,\n} from \"./gcSweepReadyUsageDetection\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACN,gBAAgB,EAChB,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,2BAA2B,EAG3B,uBAAuB,EAQvB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,oCAAoC,EACpC,0BAA0B,EAC1B,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,sBAAsB,EACtB,0BAA0B,EAC1B,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection\";\nexport {\n\tcurrentGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSessionExpiryDurationMs,\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcTombstoneGenerationOptionName,\n\tgcSweepGenerationOptionName,\n\tGCFeatureMatrix,\n\tGCVersion,\n\tgcVersionUpgradeToV2Key,\n\tIGarbageCollectionRuntime, // Deprecated\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCRuntimeOptions,\n\tIGCStats,\n\toneDayMs,\n\trunGCKey,\n\trunSessionExpiryKey,\n\trunSweepKey,\n\tstableGCVersion,\n\tsweepAttachmentBlobsKey,\n\tsweepDatastoresKey,\n\tthrowOnTombstoneLoadKey,\n\tthrowOnTombstoneUsageKey,\n\tUnreferencedState,\n} from \"./gcDefinitions\";\nexport {\n\tgetSnapshotDataFromOldSnapshotFormat,\n\tsendGCUnexpectedUsageEvent,\n\tshouldAllowGcTombstoneEnforcement,\n\tshouldAllowGcSweep,\n} from \"./gcHelpers\";\nexport { GCSummaryStateTracker } from \"./gcSummaryStateTracker\";\nexport {\n\tskipClosureForXDaysKey,\n\tclosuresMapLocalStorageKey,\n\tSweepReadyUsageDetectionHandler,\n} from \"./gcSweepReadyUsageDetection\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "2.0.0-internal.3.3.1";
8
+ export declare const pkgVersion = "2.0.0-internal.3.4.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-runtime";
8
- export const pkgVersion = "2.0.0-internal.3.3.1";
8
+ export const pkgVersion = "2.0.0-internal.3.4.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.3.3.1\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.3.4.0\";\n"]}
@@ -51,6 +51,8 @@ export interface IContainerRuntimeMetadata extends ICreateContainerMetadata, IGC
51
51
  readonly disableIsolatedChannels?: true;
52
52
  /** The summary number for a container's summary. Incremented on summaries throughout its lifetime. */
53
53
  readonly summaryNumber?: number;
54
+ /** GUID to identify a document in telemetry */
55
+ readonly telemetryDocumentId?: string;
54
56
  }
55
57
  export interface ICreateContainerMetadata {
56
58
  /** Runtime version of the container when it was first created */
@@ -1 +1 @@
1
- {"version":3,"file":"summaryFormat.d.ts","sourceRoot":"","sources":["../../src/summary/summaryFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EACN,yBAAyB,EACzB,aAAa,EAEb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAGN,qBAAqB,EACrB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,aAAK,sB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,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAChD,OAAgC,EAChC,QAAuB;IAEvB,MAAM,UAAU,GAAG,MAAM,YAAY,CACpC,OAAO,EACP,QAAQ,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAC3C,CAAC;IACF,qFAAqF;IACrF,mGAAmG;IACnG,uFAAuF;IACvF,0FAA0F;IAC1F,MAAM,aAAa,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACnB,CAAC","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\";\nimport { IGCMetadata } from \"../gc\";\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/** 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 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
+ {"version":3,"file":"summaryFormat.js","sourceRoot":"","sources":["../../src/summary/summaryFormat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAGN,WAAW,GACX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACN,gBAAgB,EAChB,SAAS,GAET,MAAM,qCAAqC,CAAC;AA0C7C,MAAM,UAAU,0BAA0B,CAAC,UAAwC;IAClF,IAAI,UAAU,CAAC,oBAAoB,EAAE;QACpC;;;WAGG;QACH,OAAO,UAAU,CAAC,oBAAoB,CAAC;KACvC;SAAM,IAAI,UAAU,CAAC,qBAAqB,KAAK,KAAK,EAAE;QACtD;;;WAGG;QACH,OAAO,CAAC,CAAC;KACT;IACD;;;OAGG;IACH,OAAO,CAAC,CAAC;AACV,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,UAAwC;IAC3E,OAAO,CAAC,CAAC,UAAU,CAAC,oBAAoB,IAAI,CAAC,UAAU,CAAC,uBAAuB,CAAC;AACjF,CAAC;AAgCD;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC5C,OAAmC,EACG,EAAE,CACxC,OAAO,KAAK,SAAS;IACpB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC;QACA,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;QAClD,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;QACpD,uBAAuB,EAAE,OAAO,CAAC,uBAAuB;QACxD,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;KACjB,CAAC;AAEN,MAAM,UAA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ACrF,mGAAmG;IACnG,uFAAuF;IACvF,0FAA0F;IAC1F,MAAM,aAAa,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAC7D,MAAM,CAAC,aAAa,GAAG,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACnB,CAAC","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\";\nimport { IGCMetadata } from \"../gc\";\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\t/** GUID to identify a document in telemetry */\n\treadonly telemetryDocumentId?: string;\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/** 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 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-runtime",
3
- "version": "2.0.0-internal.3.3.1",
3
+ "version": "2.0.0-internal.3.4.0",
4
4
  "description": "Fluid container runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,47 +37,46 @@
37
37
  "dependencies": {
38
38
  "@fluidframework/common-definitions": "^0.20.1",
39
39
  "@fluidframework/common-utils": "^1.1.1",
40
- "@fluidframework/container-definitions": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
41
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
42
- "@fluidframework/container-utils": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
43
- "@fluidframework/core-interfaces": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
44
- "@fluidframework/datastore": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
45
- "@fluidframework/driver-definitions": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
46
- "@fluidframework/driver-utils": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
47
- "@fluidframework/garbage-collector": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
48
- "@fluidframework/protocol-base": "^0.1038.3000",
40
+ "@fluidframework/container-definitions": "^2.0.0-internal.3.4.0",
41
+ "@fluidframework/container-runtime-definitions": "^2.0.0-internal.3.4.0",
42
+ "@fluidframework/container-utils": "^2.0.0-internal.3.4.0",
43
+ "@fluidframework/core-interfaces": "^2.0.0-internal.3.4.0",
44
+ "@fluidframework/datastore": "^2.0.0-internal.3.4.0",
45
+ "@fluidframework/driver-definitions": "^2.0.0-internal.3.4.0",
46
+ "@fluidframework/driver-utils": "^2.0.0-internal.3.4.0",
47
+ "@fluidframework/garbage-collector": "^2.0.0-internal.3.4.0",
48
+ "@fluidframework/protocol-base": "^0.1038.4000",
49
49
  "@fluidframework/protocol-definitions": "^1.1.0",
50
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
51
- "@fluidframework/runtime-utils": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
52
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
50
+ "@fluidframework/runtime-definitions": "^2.0.0-internal.3.4.0",
51
+ "@fluidframework/runtime-utils": "^2.0.0-internal.3.4.0",
52
+ "@fluidframework/telemetry-utils": "^2.0.0-internal.3.4.0",
53
53
  "double-ended-queue": "^2.1.0-0",
54
54
  "events": "^3.1.0",
55
55
  "lz4js": "^0.2.0",
56
56
  "uuid": "^8.3.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@fluid-tools/build-cli": "^0.12.0",
59
+ "@fluid-tools/build-cli": "^0.13.0",
60
60
  "@fluidframework/build-common": "^1.1.0",
61
- "@fluidframework/build-tools": "^0.12.0",
61
+ "@fluidframework/build-tools": "^0.13.0",
62
62
  "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.3.2.0",
63
63
  "@fluidframework/eslint-config-fluid": "^2.0.0",
64
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
65
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.3.3.1 <2.0.0-internal.4.0.0",
66
- "@microsoft/api-extractor": "^7.22.2",
67
- "@rushstack/eslint-config": "^2.5.1",
64
+ "@fluidframework/mocha-test-setup": "^2.0.0-internal.3.4.0",
65
+ "@fluidframework/test-runtime-utils": "^2.0.0-internal.3.4.0",
66
+ "@microsoft/api-extractor": "^7.34.4",
68
67
  "@types/double-ended-queue": "^2.1.0",
69
68
  "@types/events": "^3.0.0",
70
69
  "@types/mocha": "^9.1.1",
71
70
  "@types/sinon": "^7.0.13",
72
71
  "@types/uuid": "^8.3.0",
73
- "concurrently": "^6.2.0",
72
+ "concurrently": "^7.6.0",
74
73
  "copyfiles": "^2.4.1",
75
- "cross-env": "^7.0.2",
74
+ "cross-env": "^7.0.3",
76
75
  "eslint": "~8.6.0",
77
- "mocha": "^10.0.0",
78
- "nyc": "^15.0.0",
76
+ "mocha": "^10.2.0",
77
+ "nyc": "^15.1.0",
79
78
  "prettier": "~2.6.2",
80
- "rimraf": "^2.6.2",
79
+ "rimraf": "^4.4.0",
81
80
  "sinon": "^7.4.2",
82
81
  "typescript": "~4.5.5"
83
82
  },
@@ -209,10 +209,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
209
209
  // Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.
210
210
  // blobPath's format - `/<BlobManager.basePath>/<blobId>`.
211
211
  private readonly blobRequested: (blobPath: string) => void,
212
- // Called when a reference is added to a blob. For instance, when creating a localId / storageId to storageId
213
- // mapping in the redirect table.
214
- // Node path formats - `/<BlobManager.basePath>/<blobId>`.
215
- private readonly addedBlobReference: (fromNodePath: string, toNodePath: string) => void,
216
212
  // Called to check if a blob has been deleted by GC.
217
213
  // blobPath's format - `/<BlobManager.basePath>/<blobId>`.
218
214
  private readonly isBlobDeleted: (blobPath: string) => boolean,
@@ -291,15 +287,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
291
287
  }
292
288
  }
293
289
 
294
- /**
295
- * For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`
296
- * This path must match the path of the blob handle returned by the createBlob API because blobs are marked
297
- * referenced by storing these handles in a referenced DDS.
298
- */
299
- private getBlobGCNodePath(blobId: string) {
300
- return `/${BlobManager.basePath}/${blobId}`;
301
- }
302
-
303
290
  /**
304
291
  * Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
305
292
  * detached or there are no (non-pending) attachment blobs in the document
@@ -344,7 +331,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
344
331
  }
345
332
 
346
333
  // Let runtime know that the corresponding GC node was requested.
347
- this.blobRequested(this.getBlobGCNodePath(blobId));
334
+ this.blobRequested(getGCNodePathFromBlobId(blobId));
348
335
 
349
336
  return PerformanceEvent.timedExecAsync(
350
337
  this.mc.logger,
@@ -422,11 +409,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
422
409
  */
423
410
  private setRedirection(fromId: string, toId: string | undefined) {
424
411
  this.redirectTable.set(fromId, toId);
425
- // Notify runtime of a reference added if toId is not undefined. It can be undefined when a blob is uploaded in
426
- // detached mode. In this case, the entry will be updated when the blob is updated.
427
- if (toId !== undefined) {
428
- this.addedBlobReference(this.getBlobGCNodePath(fromId), this.getBlobGCNodePath(toId));
429
- }
430
412
  }
431
413
 
432
414
  private deleteAndEmitsIfEmpty(id: string) {
@@ -679,6 +661,33 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
679
661
  return table;
680
662
  }
681
663
 
664
+ public summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
665
+ // if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
666
+ const blobIds =
667
+ this.storageIds.size > 0
668
+ ? Array.from(this.storageIds)
669
+ : Array.from(this.redirectTable.keys());
670
+ const builder = new SummaryTreeBuilder();
671
+ blobIds.forEach((blobId) => {
672
+ builder.addAttachment(blobId);
673
+ });
674
+
675
+ // Any non-identity entries in the table need to be saved in the summary
676
+ if (this.redirectTable.size > blobIds.length) {
677
+ builder.addBlob(
678
+ BlobManager.redirectTableBlobName,
679
+ // filter out identity entries
680
+ JSON.stringify(
681
+ Array.from(this.redirectTable.entries()).filter(
682
+ ([localId, storageId]) => localId !== storageId,
683
+ ),
684
+ ),
685
+ );
686
+ }
687
+
688
+ return builder.getSummaryTree();
689
+ }
690
+
682
691
  /**
683
692
  * Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
684
693
  * individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
@@ -689,32 +698,29 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
689
698
  const gcData: IGarbageCollectionData = { gcNodes: {} };
690
699
  for (const [localId, storageId] of this.redirectTable) {
691
700
  assert(!!storageId, 0x390 /* Must be attached to get GC data */);
692
- gcData.gcNodes[this.getBlobGCNodePath(localId)] = [this.getBlobGCNodePath(storageId)];
701
+ // Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage
702
+ // id entries have the same key and value, ignore them.
703
+ // The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced
704
+ // by adding its handle to a referenced DDS.
705
+ if (localId !== storageId) {
706
+ gcData.gcNodes[getGCNodePathFromBlobId(localId)] = [];
707
+ }
693
708
  }
694
709
  return gcData;
695
710
  }
696
711
 
697
712
  /**
698
713
  * This is called to update blobs whose routes are unused. The unused blobs are deleted.
699
- * @param unusedRoutes - The routes of the blob nodes that are unused.
714
+ * @param unusedRoutes - The routes of the blob nodes that are unused. These routes will be based off of local ids.
700
715
  */
701
716
  public updateUnusedRoutes(unusedRoutes: string[]): void {
702
- // The routes or blob node paths are in the same format as returned in getGCData -
703
- // `/<BlobManager.basePath>/<blobId>`.
704
- for (const route of unusedRoutes) {
705
- const pathParts = route.split("/");
706
- assert(
707
- pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
708
- 0x2d5 /* "Invalid blob node id in unused routes." */,
709
- );
710
- const blobId = pathParts[2];
711
- this.redirectTable.delete(blobId);
712
- }
717
+ this.deleteBlobsFromRedirectTable(unusedRoutes);
713
718
  }
714
719
 
715
720
  /**
716
721
  * Delete attachment blobs that are sweep ready.
717
- * @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted.
722
+ * @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will
723
+ * be based off of local ids.
718
724
  * @returns - The routes of blobs that were deleted.
719
725
  */
720
726
  public deleteSweepReadyNodes(sweepReadyBlobRoutes: string[]): string[] {
@@ -723,24 +729,59 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
723
729
  return [];
724
730
  }
725
731
 
726
- // The routes or blob node paths are in the same format as returned in getGCData -
727
- // `/<BlobManager.basePath>/<blobId>`.
728
- for (const route of sweepReadyBlobRoutes) {
729
- const pathParts = route.split("/");
730
- assert(
731
- pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
732
- 0x586 /* Invalid blob node id in deleted routes. */,
733
- );
734
- const blobId = pathParts[2];
732
+ this.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);
733
+ return Array.from(sweepReadyBlobRoutes);
734
+ }
735
+
736
+ /**
737
+ * Delete blobs with the given routes from the redirect table.
738
+ * The routes are GC nodes paths of format -`/<BlobManager.basePath>/<blobId>`. The blob ids are all local ids.
739
+ * Deleting the blobs involves 2 steps:
740
+ * 1. The redirect table entry for the local ids are deleted.
741
+ * 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries
742
+ * for the storage ids are deleted as well.
743
+ *
744
+ * Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table
745
+ * will remove them the next summary. The service would them delete them some time in the future.
746
+ */
747
+ private deleteBlobsFromRedirectTable(blobRoutes: string[]) {
748
+ if (blobRoutes.length === 0) {
749
+ return;
750
+ }
751
+
752
+ // This tracks the storage ids of local ids that are deleted. After the local ids have been deleted, if any of
753
+ // these storage ids are unused, they will be deleted as well.
754
+ const maybeUnusedStorageIds: Set<string> = new Set();
755
+ for (const route of blobRoutes) {
756
+ const blobId = getBlobIdFromGCNodePath(route);
735
757
  if (!this.redirectTable.has(blobId)) {
736
758
  this.mc.logger.sendErrorEvent({
737
759
  eventName: "DeletedAttachmentBlobNotFound",
738
760
  blobId,
739
761
  });
762
+ continue;
740
763
  }
764
+ const storageId = this.redirectTable.get(blobId);
765
+ assert(!!storageId, 0x5bb /* Must be attached to run GC */);
766
+ maybeUnusedStorageIds.add(storageId);
741
767
  this.redirectTable.delete(blobId);
742
768
  }
743
- return Array.from(sweepReadyBlobRoutes);
769
+
770
+ // Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if
771
+ // the redirect table has a local id -> storage id entry for it.
772
+ for (const [localId, storageId] of this.redirectTable.entries()) {
773
+ assert(!!storageId, 0x5bc /* Must be attached to run GC */);
774
+ // For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.
775
+ if (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {
776
+ maybeUnusedStorageIds.delete(storageId);
777
+ }
778
+ }
779
+
780
+ // For unused storage ids, delete their id -> id entries from the redirect table.
781
+ // This way they'll be absent from the next summary, and the service is free to delete them from storage.
782
+ for (const storageId of maybeUnusedStorageIds) {
783
+ this.redirectTable.delete(storageId);
784
+ }
744
785
  }
745
786
 
746
787
  /**
@@ -753,12 +794,8 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
753
794
  // The routes or blob node paths are in the same format as returned in getGCData -
754
795
  // `/<BlobManager.basePath>/<blobId>`.
755
796
  for (const route of tombstonedRoutes) {
756
- const pathParts = route.split("/");
757
- assert(
758
- pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
759
- 0x50f /* Invalid blob node id in tombstoned routes. */,
760
- );
761
- tombstonedBlobsSet.add(pathParts[2]);
797
+ const blobId = getBlobIdFromGCNodePath(route);
798
+ tombstonedBlobsSet.add(blobId);
762
799
  }
763
800
 
764
801
  // Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
@@ -786,7 +823,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
786
823
  * 3. "valid" - It has not been deleted or tombstoned.
787
824
  */
788
825
  let state: "valid" | "tombstoned" | "deleted" = "valid";
789
- if (this.isBlobDeleted(this.getBlobGCNodePath(blobId))) {
826
+ if (this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {
790
827
  state = "deleted";
791
828
  } else if (this.tombstonedBlobs.has(blobId)) {
792
829
  state = "tombstoned";
@@ -827,33 +864,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
827
864
  }
828
865
  }
829
866
 
830
- public summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {
831
- // if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
832
- const blobIds =
833
- this.storageIds.size > 0
834
- ? Array.from(this.storageIds)
835
- : Array.from(this.redirectTable.keys());
836
- const builder = new SummaryTreeBuilder();
837
- blobIds.forEach((blobId) => {
838
- builder.addAttachment(blobId);
839
- });
840
-
841
- // Any non-identity entries in the table need to be saved in the summary
842
- if (this.redirectTable.size > blobIds.length) {
843
- builder.addBlob(
844
- BlobManager.redirectTableBlobName,
845
- // filter out identity entries
846
- JSON.stringify(
847
- Array.from(this.redirectTable.entries()).filter(
848
- ([localId, storageId]) => localId !== storageId,
849
- ),
850
- ),
851
- );
852
- }
853
-
854
- return builder.getSummaryTree();
855
- }
856
-
857
867
  public setRedirectTable(table: Map<string, string>) {
858
868
  assert(
859
869
  this.runtime.attachState === AttachState.Detached,
@@ -882,3 +892,24 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
882
892
  return blobs;
883
893
  }
884
894
  }
895
+
896
+ /**
897
+ * For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
898
+ * This path must match the path of the blob handle returned by the createBlob API because blobs are marked
899
+ * referenced by storing these handles in a referenced DDS.
900
+ */
901
+ function getGCNodePathFromBlobId(blobId: string) {
902
+ return `/${BlobManager.basePath}/${blobId}`;
903
+ }
904
+
905
+ /**
906
+ * For a given GC node path, return the blobId. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
907
+ */
908
+ function getBlobIdFromGCNodePath(nodePath: string) {
909
+ const pathParts = nodePath.split("/");
910
+ assert(
911
+ pathParts.length === 3 && pathParts[1] === BlobManager.basePath,
912
+ 0x5bd /* Invalid blob node path */,
913
+ );
914
+ return pathParts[2];
915
+ }