@fluidframework/container-runtime 2.0.0-internal.3.3.1 → 2.0.0-internal.3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blobManager.d.ts +17 -11
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +89 -58
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +5 -0
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +11 -10
- package/dist/containerRuntime.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +4 -5
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcConfigs.d.ts.map +1 -1
- package/dist/gc/gcConfigs.js +25 -22
- package/dist/gc/gcConfigs.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +28 -3
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js +15 -2
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/gc/gcHelpers.d.ts +25 -5
- package/dist/gc/gcHelpers.d.ts.map +1 -1
- package/dist/gc/gcHelpers.js +38 -5
- package/dist/gc/gcHelpers.js.map +1 -1
- package/dist/gc/gcSummaryStateTracker.d.ts +5 -7
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/dist/gc/gcSummaryStateTracker.js +16 -25
- package/dist/gc/gcSummaryStateTracker.js.map +1 -1
- package/dist/gc/index.d.ts +2 -2
- package/dist/gc/index.d.ts.map +1 -1
- package/dist/gc/index.js +3 -1
- package/dist/gc/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/summary/summaryFormat.d.ts +2 -0
- package/dist/summary/summaryFormat.d.ts.map +1 -1
- package/dist/summary/summaryFormat.js.map +1 -1
- package/lib/blobManager.d.ts +17 -11
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +89 -58
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +5 -0
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +11 -10
- package/lib/containerRuntime.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +4 -5
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcConfigs.d.ts.map +1 -1
- package/lib/gc/gcConfigs.js +25 -22
- package/lib/gc/gcConfigs.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +28 -3
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js +14 -1
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/gc/gcHelpers.d.ts +25 -5
- package/lib/gc/gcHelpers.d.ts.map +1 -1
- package/lib/gc/gcHelpers.js +36 -4
- package/lib/gc/gcHelpers.js.map +1 -1
- package/lib/gc/gcSummaryStateTracker.d.ts +5 -7
- package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
- package/lib/gc/gcSummaryStateTracker.js +16 -25
- package/lib/gc/gcSummaryStateTracker.js.map +1 -1
- package/lib/gc/index.d.ts +2 -2
- package/lib/gc/index.d.ts.map +1 -1
- package/lib/gc/index.js +2 -2
- package/lib/gc/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/summary/summaryFormat.d.ts +2 -0
- package/lib/summary/summaryFormat.d.ts.map +1 -1
- package/lib/summary/summaryFormat.js.map +1 -1
- package/package.json +23 -24
- package/src/blobManager.ts +108 -77
- package/src/containerRuntime.ts +12 -4
- package/src/gc/garbageCollection.ts +4 -8
- package/src/gc/gcConfigs.ts +26 -12
- package/src/gc/gcDefinitions.ts +28 -3
- package/src/gc/gcHelpers.ts +45 -4
- package/src/gc/gcSummaryStateTracker.ts +17 -29
- package/src/gc/index.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/src/summary/summaryFormat.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcSummaryStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcSummaryStateTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yEAA0E;AAC1E,+EAAmE;AACnE,6EAS6C;AAC7C,iEAKuC;AAEvC,wCAAyE;AACzE,mDAKyB;AACzB,2CAAkE;AAWlE;;;;;GAKG;AACH,MAAa,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,CAAC,MAAM,CAAC,UAAU,CAAC,uCAAuB,CAAC,KAAK,IAAI;gBAC1D,CAAC,CAAC,gCAAgB;gBAClB,CAAC,CAAC,+BAAe,CAAC;QACpB,0GAA0G;QAC1G,+GAA+G;QAC/G,IAAI,CAAC,sBAAsB,GAAG,uBAAuB,aAAvB,uBAAuB,cAAvB,uBAAuB,GAAI,IAAI,CAAC,gBAAgB,CAAC;IAChF,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,oBAAoB;QAC1B,OAAO,IAAI,CAAC,uBAAuB,KAAK,IAAI,CAAC,WAAW,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,yBAAyB;QAC/B,OAAO,CACN,IAAI,CAAC,oBAAoB,EAAE;YAC3B,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC,gBAAgB,C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AAE;YACnB,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAA4B,cAAc,CAAC,CAAC;YACnF,IAAI,CAAC,sBAAsB,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAC;SACrD;QAED,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,+BAAS,CAAC,CAAC;QACrD,mFAAmF;QACnF,IAAI,CAAC,uBAAuB,GAAG,cAAc,KAAK,SAAS,CAAC;QAC5D,IAAI,YAAwD,CAAC;QAC7D,IAAI,cAAc,KAAK,SAAS,EAAE;YACjC,YAAY,GAAG,MAAM,IAAA,yCAAqB,EAAC,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,IAAA,iCAAqB,EAAC,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;AA3RD,sDA2RC","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,yEAA0E;AAC1E,+EAAmE;AACnE,6EAS6C;AAC7C,iEAKuC;AACvC,wCAAyE;AAEzE,2CAAkE;AAYlE;;;;;GAKG;AACH,MAAa,qBAAqB;IAcjC;IACC,sCAAsC;IACrB,OAGhB;IACD,4EAA4E;IAC5E,sBAA+B;;QALd,YAAO,GAAP,OAAO,CAGvB;QAlBF,qCAAqC;QACrB,qBAAgB,GAAc,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAqB5E,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC;QACtD,0GAA0G;QAC1G,+GAA+G;QAC/G,IAAI,CAAC,sBAAsB,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,uBAAuB,mCAAI,IAAI,CAAC,gBAAgB,CAAC;IAC7F,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,uBAAuB,KAAK,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,IAAW,yBAAyB;QACnC,OAAO,CACN,IAAI,CAAC,oBAAoB;YACzB,CAAC,IAAI,CAAC,OAAO,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,MAAM,CAAC,YAAY,CAAC;QACzC,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,0BAAgB,CAAC,CAAC;QAC5D,IAAI,cAAc,EAAE;YACnB,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAA4B,cAAc,CAAC,CAAC;YACnF,IAAI,CAAC,sBAAsB,GAAG,IAAA,wBAAY,EAAC,QAAQ,CAAC,CAAC;SACrD;QAED,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,+BAAS,CAAC,CAAC;QACrD,mFAAmF;QACnF,IAAI,CAAC,uBAAuB,GAAG,cAAc,KAAK,SAAS,CAAC;QAC5D,IAAI,YAAwD,CAAC;QAC7D,IAAI,cAAc,KAAK,SAAS,EAAE;YACjC,YAAY,GAAG,MAAM,IAAA,yCAAqB,EAAC,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,IAAA,iCAAqB,EAAC,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;AApRD,sDAoRC","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/dist/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";
|
package/dist/gc/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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/dist/gc/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.UnreferencedStateTracker = exports.SweepReadyUsageDetectionHandler = exports.closuresMapLocalStorageKey = exports.skipClosureForXDaysKey = exports.GCSummaryStateTracker = exports.shouldAllowGcTombstoneEnforcement = exports.sendGCUnexpectedUsageEvent = exports.getSnapshotDataFromOldSnapshotFormat = exports.UnreferencedState = exports.throwOnTombstoneUsageKey = exports.throwOnTombstoneLoadKey = exports.sweepDatastoresKey = exports.sweepAttachmentBlobsKey = exports.stableGCVersion = exports.runSweepKey = exports.runSessionExpiryKey = exports.runGCKey = exports.oneDayMs = exports.gcVersionUpgradeToV2Key = exports.gcTombstoneGenerationOptionName = exports.gcTestModeKey = exports.GCNodeType = exports.disableSweepLogKey = exports.defaultSessionExpiryDurationMs = exports.defaultInactiveTimeoutMs = exports.currentGCVersion = exports.GarbageCollector = void 0;
|
|
7
|
+
exports.UnreferencedStateTracker = exports.SweepReadyUsageDetectionHandler = exports.closuresMapLocalStorageKey = exports.skipClosureForXDaysKey = exports.GCSummaryStateTracker = exports.shouldAllowGcSweep = exports.shouldAllowGcTombstoneEnforcement = exports.sendGCUnexpectedUsageEvent = exports.getSnapshotDataFromOldSnapshotFormat = exports.UnreferencedState = exports.throwOnTombstoneUsageKey = exports.throwOnTombstoneLoadKey = exports.sweepDatastoresKey = exports.sweepAttachmentBlobsKey = exports.stableGCVersion = exports.runSweepKey = exports.runSessionExpiryKey = exports.runGCKey = exports.oneDayMs = exports.gcVersionUpgradeToV2Key = exports.gcSweepGenerationOptionName = exports.gcTombstoneGenerationOptionName = exports.gcTestModeKey = exports.GCNodeType = exports.disableSweepLogKey = exports.defaultSessionExpiryDurationMs = exports.defaultInactiveTimeoutMs = exports.currentGCVersion = exports.GarbageCollector = void 0;
|
|
8
8
|
var garbageCollection_1 = require("./garbageCollection");
|
|
9
9
|
Object.defineProperty(exports, "GarbageCollector", { enumerable: true, get: function () { return garbageCollection_1.GarbageCollector; } });
|
|
10
10
|
var gcDefinitions_1 = require("./gcDefinitions");
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "disableSweepLogKey", { enumerable: true, get: fu
|
|
|
15
15
|
Object.defineProperty(exports, "GCNodeType", { enumerable: true, get: function () { return gcDefinitions_1.GCNodeType; } });
|
|
16
16
|
Object.defineProperty(exports, "gcTestModeKey", { enumerable: true, get: function () { return gcDefinitions_1.gcTestModeKey; } });
|
|
17
17
|
Object.defineProperty(exports, "gcTombstoneGenerationOptionName", { enumerable: true, get: function () { return gcDefinitions_1.gcTombstoneGenerationOptionName; } });
|
|
18
|
+
Object.defineProperty(exports, "gcSweepGenerationOptionName", { enumerable: true, get: function () { return gcDefinitions_1.gcSweepGenerationOptionName; } });
|
|
18
19
|
Object.defineProperty(exports, "gcVersionUpgradeToV2Key", { enumerable: true, get: function () { return gcDefinitions_1.gcVersionUpgradeToV2Key; } });
|
|
19
20
|
Object.defineProperty(exports, "oneDayMs", { enumerable: true, get: function () { return gcDefinitions_1.oneDayMs; } });
|
|
20
21
|
Object.defineProperty(exports, "runGCKey", { enumerable: true, get: function () { return gcDefinitions_1.runGCKey; } });
|
|
@@ -30,6 +31,7 @@ var gcHelpers_1 = require("./gcHelpers");
|
|
|
30
31
|
Object.defineProperty(exports, "getSnapshotDataFromOldSnapshotFormat", { enumerable: true, get: function () { return gcHelpers_1.getSnapshotDataFromOldSnapshotFormat; } });
|
|
31
32
|
Object.defineProperty(exports, "sendGCUnexpectedUsageEvent", { enumerable: true, get: function () { return gcHelpers_1.sendGCUnexpectedUsageEvent; } });
|
|
32
33
|
Object.defineProperty(exports, "shouldAllowGcTombstoneEnforcement", { enumerable: true, get: function () { return gcHelpers_1.shouldAllowGcTombstoneEnforcement; } });
|
|
34
|
+
Object.defineProperty(exports, "shouldAllowGcSweep", { enumerable: true, get: function () { return gcHelpers_1.shouldAllowGcSweep; } });
|
|
33
35
|
var gcSummaryStateTracker_1 = require("./gcSummaryStateTracker");
|
|
34
36
|
Object.defineProperty(exports, "GCSummaryStateTracker", { enumerable: true, get: function () { return gcSummaryStateTracker_1.GCSummaryStateTracker; } });
|
|
35
37
|
var gcSweepReadyUsageDetection_1 = require("./gcSweepReadyUsageDetection");
|
package/dist/gc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,iDA6ByB;AA5BxB,iHAAA,gBAAgB,OAAA;AAChB,yHAAA,wBAAwB,OAAA;AACxB,+HAAA,8BAA8B,OAAA;AAC9B,mHAAA,kBAAkB,OAAA;AAClB,2GAAA,UAAU,OAAA;AACV,8GAAA,aAAa,OAAA;AACb,gIAAA,+BAA+B,OAAA;AAC/B,4HAAA,2BAA2B,OAAA;AAG3B,wHAAA,uBAAuB,OAAA;AAQvB,yGAAA,QAAQ,OAAA;AACR,yGAAA,QAAQ,OAAA;AACR,oHAAA,mBAAmB,OAAA;AACnB,4GAAA,WAAW,OAAA;AACX,gHAAA,eAAe,OAAA;AACf,wHAAA,uBAAuB,OAAA;AACvB,mHAAA,kBAAkB,OAAA;AAClB,wHAAA,uBAAuB,OAAA;AACvB,yHAAA,wBAAwB,OAAA;AACxB,kHAAA,iBAAiB,OAAA;AAElB,yCAKqB;AAJpB,iIAAA,oCAAoC,OAAA;AACpC,uHAAA,0BAA0B,OAAA;AAC1B,8HAAA,iCAAiC,OAAA;AACjC,+GAAA,kBAAkB,OAAA;AAEnB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2EAIsC;AAHrC,oIAAA,sBAAsB,OAAA;AACtB,wIAAA,0BAA0B,OAAA;AAC1B,6IAAA,+BAA+B,OAAA;AAEhC,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA","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"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -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.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.3.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/container-runtime";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.3.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.3.4.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,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.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,mCAAmC,CAAC;AAC9C,QAAA,UAAU,GAAG,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,sBAAsB,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,uBAAuB,GAAG,sBAAsB,CAAC,CAAC;AAC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,OAAO,EACP,QAAQ,CAAC,KAAK,CAAC,mCAA2B,CAAC,CAC3C,CAAC;IACF,qFAAqF;IACrF,mGAAmG;IACnG,uFAAuF;IACvF,0FAA0F;IAC1F,MAAM,aAAa,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;IAC7D,IAAA,qBAAM,EAAC,aAAa,GAAG,CAAC,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;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\";\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
|
+
{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oft 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/lib/blobManager.d.ts
CHANGED
|
@@ -59,7 +59,6 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
59
59
|
*/
|
|
60
60
|
private readonly sendBlobAttachOp;
|
|
61
61
|
private readonly blobRequested;
|
|
62
|
-
private readonly addedBlobReference;
|
|
63
62
|
private readonly isBlobDeleted;
|
|
64
63
|
private readonly runtime;
|
|
65
64
|
private readonly getCurrentReferenceTimestampMs;
|
|
@@ -105,7 +104,7 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
105
104
|
* knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
|
|
106
105
|
* before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
|
|
107
106
|
*/
|
|
108
|
-
sendBlobAttachOp: (localId: string, storageId?: string) => void, blobRequested: (blobPath: string) => void,
|
|
107
|
+
sendBlobAttachOp: (localId: string, storageId?: string) => void, blobRequested: (blobPath: string) => void, isBlobDeleted: (blobPath: string) => boolean, runtime: IBlobManagerRuntime, stashedBlobs: IPendingBlobs | undefined, getCurrentReferenceTimestampMs: () => number | undefined);
|
|
109
108
|
private get pendingOfflineUploads();
|
|
110
109
|
get hasPendingOfflineUploads(): boolean;
|
|
111
110
|
get hasPendingBlobs(): boolean;
|
|
@@ -118,12 +117,6 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
118
117
|
* again
|
|
119
118
|
*/
|
|
120
119
|
private onDisconnected;
|
|
121
|
-
/**
|
|
122
|
-
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`
|
|
123
|
-
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
124
|
-
* referenced by storing these handles in a referenced DDS.
|
|
125
|
-
*/
|
|
126
|
-
private getBlobGCNodePath;
|
|
127
120
|
/**
|
|
128
121
|
* Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
|
|
129
122
|
* detached or there are no (non-pending) attachment blobs in the document
|
|
@@ -162,6 +155,7 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
162
155
|
* Load a set of previously attached blob IDs and redirect table from a previous snapshot.
|
|
163
156
|
*/
|
|
164
157
|
private load;
|
|
158
|
+
summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
165
159
|
/**
|
|
166
160
|
* Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
|
|
167
161
|
* individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
|
|
@@ -171,15 +165,28 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
171
165
|
getGCData(fullGC?: boolean): IGarbageCollectionData;
|
|
172
166
|
/**
|
|
173
167
|
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
174
|
-
* @param unusedRoutes - The routes of the blob nodes that are unused.
|
|
168
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused. These routes will be based off of local ids.
|
|
175
169
|
*/
|
|
176
170
|
updateUnusedRoutes(unusedRoutes: string[]): void;
|
|
177
171
|
/**
|
|
178
172
|
* Delete attachment blobs that are sweep ready.
|
|
179
|
-
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted.
|
|
173
|
+
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will
|
|
174
|
+
* be based off of local ids.
|
|
180
175
|
* @returns - The routes of blobs that were deleted.
|
|
181
176
|
*/
|
|
182
177
|
deleteSweepReadyNodes(sweepReadyBlobRoutes: string[]): string[];
|
|
178
|
+
/**
|
|
179
|
+
* Delete blobs with the given routes from the redirect table.
|
|
180
|
+
* The routes are GC nodes paths of format -`/<BlobManager.basePath>/<blobId>`. The blob ids are all local ids.
|
|
181
|
+
* Deleting the blobs involves 2 steps:
|
|
182
|
+
* 1. The redirect table entry for the local ids are deleted.
|
|
183
|
+
* 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries
|
|
184
|
+
* for the storage ids are deleted as well.
|
|
185
|
+
*
|
|
186
|
+
* Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table
|
|
187
|
+
* will remove them the next summary. The service would them delete them some time in the future.
|
|
188
|
+
*/
|
|
189
|
+
private deleteBlobsFromRedirectTable;
|
|
183
190
|
/**
|
|
184
191
|
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
185
192
|
* accessing deleted content without actually deleting content from summaries.
|
|
@@ -191,7 +198,6 @@ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
191
198
|
* log an error and throw if necessary.
|
|
192
199
|
*/
|
|
193
200
|
private verifyBlobValidity;
|
|
194
|
-
summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
|
|
195
201
|
setRedirectTable(table: Map<string, string>): void;
|
|
196
202
|
getPendingBlobs(): IPendingBlobs;
|
|
197
203
|
}
|
package/lib/blobManager.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blobManager.d.ts","sourceRoot":"","sources":["../src/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAEN,yBAAyB,EACzB,aAAa,EACb,MAAM,sCAAsC,CAAC;AAO9C,OAAO,EAKN,iBAAiB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,+CAA+C,CAAC;AAQvD,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAA8B,MAAM,oBAAoB,CAAC;AAKlF;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,YAAY,CAAC,eAAe,CAAC;aAc9C,IAAI,EAAE,MAAM;aACZ,YAAY,EAAE,mBAAmB;IAC1C,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAf/B,OAAO,CAAC,QAAQ,CAAkB;IAElC,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAGpB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,mBAAmB,EAC1C,GAAG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G,MAAM,EAAE;IAUtE;;;;;;;;;;OAUG;IACH,OAAO,CAAC,4BAA4B;IAwCpC;;;;OAIG;IACI,sBAAsB,CAAC,gBAAgB,EAAE,MAAM,EAAE;IAsBxD;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAiDnB,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAoB3C,eAAe,IAAI,aAAa;CAOvC"}
|
package/lib/blobManager.js
CHANGED
|
@@ -80,10 +80,6 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
80
80
|
// Called when a blob node is requested. blobPath is the path of the blob's node in GC's graph.
|
|
81
81
|
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
82
82
|
blobRequested,
|
|
83
|
-
// Called when a reference is added to a blob. For instance, when creating a localId / storageId to storageId
|
|
84
|
-
// mapping in the redirect table.
|
|
85
|
-
// Node path formats - `/<BlobManager.basePath>/<blobId>`.
|
|
86
|
-
addedBlobReference,
|
|
87
83
|
// Called to check if a blob has been deleted by GC.
|
|
88
84
|
// blobPath's format - `/<BlobManager.basePath>/<blobId>`.
|
|
89
85
|
isBlobDeleted, runtime, stashedBlobs = {}, getCurrentReferenceTimestampMs) {
|
|
@@ -92,7 +88,6 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
92
88
|
this.getStorage = getStorage;
|
|
93
89
|
this.sendBlobAttachOp = sendBlobAttachOp;
|
|
94
90
|
this.blobRequested = blobRequested;
|
|
95
|
-
this.addedBlobReference = addedBlobReference;
|
|
96
91
|
this.isBlobDeleted = isBlobDeleted;
|
|
97
92
|
this.runtime = runtime;
|
|
98
93
|
this.getCurrentReferenceTimestampMs = getCurrentReferenceTimestampMs;
|
|
@@ -170,14 +165,6 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
170
165
|
}
|
|
171
166
|
}
|
|
172
167
|
}
|
|
173
|
-
/**
|
|
174
|
-
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`
|
|
175
|
-
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
176
|
-
* referenced by storing these handles in a referenced DDS.
|
|
177
|
-
*/
|
|
178
|
-
getBlobGCNodePath(blobId) {
|
|
179
|
-
return `/${BlobManager.basePath}/${blobId}`;
|
|
180
|
-
}
|
|
181
168
|
/**
|
|
182
169
|
* Set of actual storage IDs (i.e., IDs that can be requested from storage). This will be empty if the container is
|
|
183
170
|
* detached or there are no (non-pending) attachment blobs in the document
|
|
@@ -213,7 +200,7 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
213
200
|
storageId = attachedStorageId;
|
|
214
201
|
}
|
|
215
202
|
// Let runtime know that the corresponding GC node was requested.
|
|
216
|
-
this.blobRequested(
|
|
203
|
+
this.blobRequested(getGCNodePathFromBlobId(blobId));
|
|
217
204
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "AttachmentReadBlob", id: storageId }, async () => {
|
|
218
205
|
return this.getStorage().readBlob(storageId);
|
|
219
206
|
}, { end: true, cancel: "error" });
|
|
@@ -260,11 +247,6 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
260
247
|
*/
|
|
261
248
|
setRedirection(fromId, toId) {
|
|
262
249
|
this.redirectTable.set(fromId, toId);
|
|
263
|
-
// Notify runtime of a reference added if toId is not undefined. It can be undefined when a blob is uploaded in
|
|
264
|
-
// detached mode. In this case, the entry will be updated when the blob is updated.
|
|
265
|
-
if (toId !== undefined) {
|
|
266
|
-
this.addedBlobReference(this.getBlobGCNodePath(fromId), this.getBlobGCNodePath(toId));
|
|
267
|
-
}
|
|
268
250
|
}
|
|
269
251
|
deleteAndEmitsIfEmpty(id) {
|
|
270
252
|
if (this.pendingBlobs.has(id)) {
|
|
@@ -486,6 +468,23 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
486
468
|
}
|
|
487
469
|
return table;
|
|
488
470
|
}
|
|
471
|
+
summarize(telemetryContext) {
|
|
472
|
+
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
473
|
+
const blobIds = this.storageIds.size > 0
|
|
474
|
+
? Array.from(this.storageIds)
|
|
475
|
+
: Array.from(this.redirectTable.keys());
|
|
476
|
+
const builder = new SummaryTreeBuilder();
|
|
477
|
+
blobIds.forEach((blobId) => {
|
|
478
|
+
builder.addAttachment(blobId);
|
|
479
|
+
});
|
|
480
|
+
// Any non-identity entries in the table need to be saved in the summary
|
|
481
|
+
if (this.redirectTable.size > blobIds.length) {
|
|
482
|
+
builder.addBlob(BlobManager.redirectTableBlobName,
|
|
483
|
+
// filter out identity entries
|
|
484
|
+
JSON.stringify(Array.from(this.redirectTable.entries()).filter(([localId, storageId]) => localId !== storageId)));
|
|
485
|
+
}
|
|
486
|
+
return builder.getSummaryTree();
|
|
487
|
+
}
|
|
489
488
|
/**
|
|
490
489
|
* Generates data used for garbage collection. Each blob uploaded represents a node in the GC graph as it can be
|
|
491
490
|
* individually referenced by storing its handle in a referenced DDS. Returns the list of blob ids as GC nodes.
|
|
@@ -496,27 +495,27 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
496
495
|
const gcData = { gcNodes: {} };
|
|
497
496
|
for (const [localId, storageId] of this.redirectTable) {
|
|
498
497
|
assert(!!storageId, 0x390 /* Must be attached to get GC data */);
|
|
499
|
-
|
|
498
|
+
// Only return local ids as GC nodes because a blob can only be referenced via its local id. The storage
|
|
499
|
+
// id entries have the same key and value, ignore them.
|
|
500
|
+
// The outbound routes are empty because a blob node cannot reference other nodes. It can only be referenced
|
|
501
|
+
// by adding its handle to a referenced DDS.
|
|
502
|
+
if (localId !== storageId) {
|
|
503
|
+
gcData.gcNodes[getGCNodePathFromBlobId(localId)] = [];
|
|
504
|
+
}
|
|
500
505
|
}
|
|
501
506
|
return gcData;
|
|
502
507
|
}
|
|
503
508
|
/**
|
|
504
509
|
* This is called to update blobs whose routes are unused. The unused blobs are deleted.
|
|
505
|
-
* @param unusedRoutes - The routes of the blob nodes that are unused.
|
|
510
|
+
* @param unusedRoutes - The routes of the blob nodes that are unused. These routes will be based off of local ids.
|
|
506
511
|
*/
|
|
507
512
|
updateUnusedRoutes(unusedRoutes) {
|
|
508
|
-
|
|
509
|
-
// `/<BlobManager.basePath>/<blobId>`.
|
|
510
|
-
for (const route of unusedRoutes) {
|
|
511
|
-
const pathParts = route.split("/");
|
|
512
|
-
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x2d5 /* "Invalid blob node id in unused routes." */);
|
|
513
|
-
const blobId = pathParts[2];
|
|
514
|
-
this.redirectTable.delete(blobId);
|
|
515
|
-
}
|
|
513
|
+
this.deleteBlobsFromRedirectTable(unusedRoutes);
|
|
516
514
|
}
|
|
517
515
|
/**
|
|
518
516
|
* Delete attachment blobs that are sweep ready.
|
|
519
|
-
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted.
|
|
517
|
+
* @param sweepReadyBlobRoutes - The routes of blobs that are sweep ready and should be deleted. These routes will
|
|
518
|
+
* be based off of local ids.
|
|
520
519
|
* @returns - The routes of blobs that were deleted.
|
|
521
520
|
*/
|
|
522
521
|
deleteSweepReadyNodes(sweepReadyBlobRoutes) {
|
|
@@ -524,21 +523,55 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
524
523
|
if (this.mc.config.getBoolean(sweepAttachmentBlobsKey) !== true) {
|
|
525
524
|
return [];
|
|
526
525
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
526
|
+
this.deleteBlobsFromRedirectTable(sweepReadyBlobRoutes);
|
|
527
|
+
return Array.from(sweepReadyBlobRoutes);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Delete blobs with the given routes from the redirect table.
|
|
531
|
+
* The routes are GC nodes paths of format -`/<BlobManager.basePath>/<blobId>`. The blob ids are all local ids.
|
|
532
|
+
* Deleting the blobs involves 2 steps:
|
|
533
|
+
* 1. The redirect table entry for the local ids are deleted.
|
|
534
|
+
* 2. If the storage ids corresponding to the deleted local ids are not in-use anymore, the redirect table entries
|
|
535
|
+
* for the storage ids are deleted as well.
|
|
536
|
+
*
|
|
537
|
+
* Note that this does not delete the blobs from storage service immediately. Deleting the blobs from redirect table
|
|
538
|
+
* will remove them the next summary. The service would them delete them some time in the future.
|
|
539
|
+
*/
|
|
540
|
+
deleteBlobsFromRedirectTable(blobRoutes) {
|
|
541
|
+
if (blobRoutes.length === 0) {
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
// This tracks the storage ids of local ids that are deleted. After the local ids have been deleted, if any of
|
|
545
|
+
// these storage ids are unused, they will be deleted as well.
|
|
546
|
+
const maybeUnusedStorageIds = new Set();
|
|
547
|
+
for (const route of blobRoutes) {
|
|
548
|
+
const blobId = getBlobIdFromGCNodePath(route);
|
|
533
549
|
if (!this.redirectTable.has(blobId)) {
|
|
534
550
|
this.mc.logger.sendErrorEvent({
|
|
535
551
|
eventName: "DeletedAttachmentBlobNotFound",
|
|
536
552
|
blobId,
|
|
537
553
|
});
|
|
554
|
+
continue;
|
|
538
555
|
}
|
|
556
|
+
const storageId = this.redirectTable.get(blobId);
|
|
557
|
+
assert(!!storageId, 0x5bb /* Must be attached to run GC */);
|
|
558
|
+
maybeUnusedStorageIds.add(storageId);
|
|
539
559
|
this.redirectTable.delete(blobId);
|
|
540
560
|
}
|
|
541
|
-
|
|
561
|
+
// Find out storage ids that are in-use and remove them from maybeUnusedStorageIds. A storage id is in-use if
|
|
562
|
+
// the redirect table has a local id -> storage id entry for it.
|
|
563
|
+
for (const [localId, storageId] of this.redirectTable.entries()) {
|
|
564
|
+
assert(!!storageId, 0x5bc /* Must be attached to run GC */);
|
|
565
|
+
// For every storage id, the redirect table has a id -> id entry. These do not make the storage id in-use.
|
|
566
|
+
if (maybeUnusedStorageIds.has(storageId) && localId !== storageId) {
|
|
567
|
+
maybeUnusedStorageIds.delete(storageId);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
// For unused storage ids, delete their id -> id entries from the redirect table.
|
|
571
|
+
// This way they'll be absent from the next summary, and the service is free to delete them from storage.
|
|
572
|
+
for (const storageId of maybeUnusedStorageIds) {
|
|
573
|
+
this.redirectTable.delete(storageId);
|
|
574
|
+
}
|
|
542
575
|
}
|
|
543
576
|
/**
|
|
544
577
|
* This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
|
|
@@ -550,9 +583,8 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
550
583
|
// The routes or blob node paths are in the same format as returned in getGCData -
|
|
551
584
|
// `/<BlobManager.basePath>/<blobId>`.
|
|
552
585
|
for (const route of tombstonedRoutes) {
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
tombstonedBlobsSet.add(pathParts[2]);
|
|
586
|
+
const blobId = getBlobIdFromGCNodePath(route);
|
|
587
|
+
tombstonedBlobsSet.add(blobId);
|
|
556
588
|
}
|
|
557
589
|
// Remove blobs from the tombstone list that were tombstoned but aren't anymore as per the tombstoneRoutes.
|
|
558
590
|
for (const blobId of this.tombstonedBlobs) {
|
|
@@ -577,7 +609,7 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
577
609
|
* 3. "valid" - It has not been deleted or tombstoned.
|
|
578
610
|
*/
|
|
579
611
|
let state = "valid";
|
|
580
|
-
if (this.isBlobDeleted(
|
|
612
|
+
if (this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {
|
|
581
613
|
state = "deleted";
|
|
582
614
|
}
|
|
583
615
|
else if (this.tombstonedBlobs.has(blobId)) {
|
|
@@ -602,23 +634,6 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
602
634
|
throw error;
|
|
603
635
|
}
|
|
604
636
|
}
|
|
605
|
-
summarize(telemetryContext) {
|
|
606
|
-
// if storageIds is empty, it means we are detached and have only local IDs, or that there are no blobs attached
|
|
607
|
-
const blobIds = this.storageIds.size > 0
|
|
608
|
-
? Array.from(this.storageIds)
|
|
609
|
-
: Array.from(this.redirectTable.keys());
|
|
610
|
-
const builder = new SummaryTreeBuilder();
|
|
611
|
-
blobIds.forEach((blobId) => {
|
|
612
|
-
builder.addAttachment(blobId);
|
|
613
|
-
});
|
|
614
|
-
// Any non-identity entries in the table need to be saved in the summary
|
|
615
|
-
if (this.redirectTable.size > blobIds.length) {
|
|
616
|
-
builder.addBlob(BlobManager.redirectTableBlobName,
|
|
617
|
-
// filter out identity entries
|
|
618
|
-
JSON.stringify(Array.from(this.redirectTable.entries()).filter(([localId, storageId]) => localId !== storageId)));
|
|
619
|
-
}
|
|
620
|
-
return builder.getSummaryTree();
|
|
621
|
-
}
|
|
622
637
|
setRedirectTable(table) {
|
|
623
638
|
assert(this.runtime.attachState === AttachState.Detached, 0x252 /* "redirect table can only be set in detached container" */);
|
|
624
639
|
assert(this.redirectTable.size === table.size, 0x391 /* Redirect table size must match BlobManager's local ID count */);
|
|
@@ -639,4 +654,20 @@ export class BlobManager extends TypedEventEmitter {
|
|
|
639
654
|
}
|
|
640
655
|
BlobManager.basePath = "_blobs";
|
|
641
656
|
BlobManager.redirectTableBlobName = ".redirectTable";
|
|
657
|
+
/**
|
|
658
|
+
* For a blobId, returns its path in GC's graph. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
|
|
659
|
+
* This path must match the path of the blob handle returned by the createBlob API because blobs are marked
|
|
660
|
+
* referenced by storing these handles in a referenced DDS.
|
|
661
|
+
*/
|
|
662
|
+
function getGCNodePathFromBlobId(blobId) {
|
|
663
|
+
return `/${BlobManager.basePath}/${blobId}`;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* For a given GC node path, return the blobId. The node path is of the format `/<BlobManager.basePath>/<blobId>`.
|
|
667
|
+
*/
|
|
668
|
+
function getBlobIdFromGCNodePath(nodePath) {
|
|
669
|
+
const pathParts = nodePath.split("/");
|
|
670
|
+
assert(pathParts.length === 3 && pathParts[1] === BlobManager.basePath, 0x5bd /* Invalid blob node path */);
|
|
671
|
+
return pathParts[2];
|
|
672
|
+
}
|
|
642
673
|
//# sourceMappingURL=blobManager.js.map
|