@fluidframework/container-runtime 2.0.0-dev.1.4.5.105745 → 2.0.0-dev.2.2.0.111723
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/.eslintrc.js +1 -1
- package/dist/batchManager.d.ts +11 -6
- package/dist/batchManager.d.ts.map +1 -1
- package/dist/batchManager.js +23 -13
- package/dist/batchManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +74 -20
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +190 -137
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +6 -0
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +14 -21
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +71 -57
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.js +1 -1
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStores.d.ts +11 -10
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +50 -20
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +36 -19
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +207 -121
- package/dist/garbageCollection.js.map +1 -1
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +3 -12
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/opCompressor.d.ts +18 -0
- package/dist/opCompressor.d.ts.map +1 -0
- package/dist/opCompressor.js +50 -0
- package/dist/opCompressor.js.map +1 -0
- package/dist/opDecompressor.d.ts +20 -0
- package/dist/opDecompressor.d.ts.map +1 -0
- package/dist/opDecompressor.js +72 -0
- package/dist/opDecompressor.js.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +6 -26
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +42 -62
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/runningSummarizer.d.ts +3 -2
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +10 -3
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summarizer.js +7 -2
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerClientElection.js +1 -1
- package/dist/summarizerClientElection.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +0 -3
- package/dist/summarizerHeuristics.js.map +1 -1
- package/dist/summarizerTypes.d.ts +19 -2
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts +4 -2
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +3 -2
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +10 -6
- package/dist/summaryManager.js.map +1 -1
- package/garbageCollection.md +27 -22
- package/lib/batchManager.d.ts +11 -6
- package/lib/batchManager.d.ts.map +1 -1
- package/lib/batchManager.js +23 -13
- package/lib/batchManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +74 -20
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +189 -136
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +6 -0
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +14 -21
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +75 -61
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.js +1 -1
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStores.d.ts +11 -10
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +53 -23
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +36 -19
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +208 -122
- package/lib/garbageCollection.js.map +1 -1
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +3 -12
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/index.d.ts +4 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/opCompressor.d.ts +18 -0
- package/lib/opCompressor.d.ts.map +1 -0
- package/lib/opCompressor.js +46 -0
- package/lib/opCompressor.js.map +1 -0
- package/lib/opDecompressor.d.ts +20 -0
- package/lib/opDecompressor.d.ts.map +1 -0
- package/lib/opDecompressor.js +68 -0
- package/lib/opDecompressor.js.map +1 -0
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +6 -26
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +42 -62
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/runningSummarizer.d.ts +3 -2
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +10 -3
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summarizer.js +7 -2
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerClientElection.js +1 -1
- package/lib/summarizerClientElection.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +0 -3
- package/lib/summarizerHeuristics.js.map +1 -1
- package/lib/summarizerTypes.d.ts +19 -2
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts +4 -2
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +3 -2
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +10 -6
- package/lib/summaryManager.js.map +1 -1
- package/package.json +37 -63
- package/prettier.config.cjs +8 -0
- package/src/batchManager.ts +32 -15
- package/src/containerRuntime.ts +260 -156
- package/src/dataStore.ts +13 -1
- package/src/dataStoreContext.ts +100 -76
- package/src/dataStoreContexts.ts +1 -1
- package/src/dataStores.ts +61 -23
- package/src/garbageCollection.ts +257 -126
- package/src/gcSweepReadyUsageDetection.ts +2 -10
- package/src/index.ts +4 -4
- package/src/opCompressor.ts +59 -0
- package/src/opDecompressor.ts +82 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +57 -96
- package/src/runningSummarizer.ts +11 -3
- package/src/scheduleManager.ts +1 -0
- package/src/summarizer.ts +6 -6
- package/src/summarizerClientElection.ts +1 -1
- package/src/summarizerHeuristics.ts +0 -3
- package/src/summarizerTypes.ts +20 -7
- package/src/summaryFormat.ts +4 -2
- package/src/summaryGenerator.ts +3 -2
- package/src/summaryManager.ts +18 -7
package/lib/dataStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.d.ts","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataStore.d.ts","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAUtE,OAAO,EAAe,UAAU,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAEtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,uCAAuC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,+BACJ,GAAG,yDAIlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,0BACJ,sBAAsB,cACjC,MAAM,WACT,gBAAgB,cACb,UAAU,UACd,gBAAgB,KACzB,UAA2F,CAAC"}
|
package/lib/dataStore.js
CHANGED
|
@@ -111,6 +111,12 @@ class DataStore {
|
|
|
111
111
|
async request(request) {
|
|
112
112
|
return this.fluidDataStoreChannel.request(request);
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}
|
|
116
|
+
*/
|
|
117
|
+
get entryPoint() {
|
|
118
|
+
return this.fluidDataStoreChannel.entryPoint;
|
|
119
|
+
}
|
|
114
120
|
get IFluidRouter() { return this.fluidDataStoreChannel; }
|
|
115
121
|
async ackBasedPromise(executor) {
|
|
116
122
|
let rejectBecauseDispose;
|
package/lib/dataStore.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7D,OAAO,EAAE,gBAAgB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;QACrC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAiB;QAC3B,OAAO,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAYD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAExD,KAAK,CAAC,eAAe,CACzB,QAC2C;QAE3C,IAAI,oBAAgC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,oBAAoB;gBAChB,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC,CAAC;YAElG,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;gBACvB,oBAAoB,EAAE,CAAC;gBACvB,OAAO;aACV;YAED,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { AliasResult, IDataStore, IFluidDataStoreChannel } from \"@fluidframework/runtime-definitions\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ContainerRuntime } from \"./containerRuntime\";\nimport { DataStores } from \"./dataStores\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n /** The internal id of the datastore */\n readonly internalId: string;\n /** The alias name to be assigned to the datastore */\n readonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n maybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n return typeof maybeDataStoreAliasMessage?.internalId === \"string\"\n && typeof maybeDataStoreAliasMessage?.alias === \"string\";\n};\n\nexport const channelToDataStore = (\n fluidDataStoreChannel: IFluidDataStoreChannel,\n internalId: string,\n runtime: ContainerRuntime,\n datastores: DataStores,\n logger: ITelemetryLogger,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, runtime, datastores, logger);\n\nenum AliasState {\n Aliased = \"Aliased\",\n Aliasing = \"Aliasing\",\n None = \"None\",\n}\n\nclass DataStore implements IDataStore {\n private aliasState: AliasState = AliasState.None;\n private alias: string | undefined;\n private readonly pendingAliases: Map<string, Promise<AliasResult>>;\n private aliasResult: Promise<AliasResult> | undefined;\n\n async trySetAlias(alias: string): Promise<AliasResult> {\n if (alias.includes(\"/\")) {\n throw new UsageError(`The alias cannot contain slashes: '${alias}'`);\n }\n\n switch (this.aliasState) {\n // If we're already aliasing, check if it's for the same value and return\n // the stored promise, otherwise return 'AlreadyAliased'\n case AliasState.Aliasing:\n assert(this.aliasResult !== undefined,\n 0x316 /* There should be a cached promise of in-progress aliasing */);\n await this.aliasResult;\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n // If this datastore is already aliased, return true only if this\n // is a repeated call for the same alias\n case AliasState.Aliased:\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n case AliasState.None: {\n const existingAlias = this.pendingAliases.get(alias);\n if (existingAlias !== undefined) {\n // There is already another datastore which will be aliased\n // to the same name\n return \"Conflict\";\n }\n\n // There is no current or past alias operation for this datastore,\n // or for this alias, so it is safe to continue execution\n break;\n }\n\n default: unreachableCase(this.aliasState);\n }\n\n this.aliasState = AliasState.Aliasing;\n this.aliasResult = this.trySetAliasInternal(alias);\n this.pendingAliases.set(alias, this.aliasResult);\n return this.aliasResult;\n }\n\n async trySetAliasInternal(alias: string): Promise<AliasResult> {\n const message: IDataStoreAliasMessage = {\n internalId: this.internalId,\n alias,\n };\n\n this.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n if (this.runtime.attachState === AttachState.Detached) {\n const localResult = this.datastores.processAliasMessageCore(message);\n // Explicitly lock-out future attempts of aliasing,\n // regardless of result\n this.aliasState = AliasState.Aliased;\n return localResult ? \"Success\" : \"Conflict\";\n }\n\n const aliased = await this\n .ackBasedPromise<boolean>((resolve) => {\n this.runtime.submitDataStoreAliasOp(message, resolve);\n })\n .catch((error) => {\n this.logger.sendErrorEvent({\n eventName: \"AliasingException\",\n alias: {\n value: alias,\n tag: TelemetryDataTag.UserData,\n },\n internalId: {\n value: this.internalId,\n tag: TelemetryDataTag.CodeArtifact,\n },\n }, error);\n\n return false;\n }).finally(() => {\n this.pendingAliases.delete(alias);\n });\n\n if (!aliased) {\n this.aliasState = AliasState.None;\n this.aliasResult = undefined;\n return \"Conflict\";\n }\n\n this.alias = alias;\n this.aliasState = AliasState.Aliased;\n return \"Success\";\n }\n\n async request(request: IRequest): Promise<IResponse> {\n return this.fluidDataStoreChannel.request(request);\n }\n\n constructor(\n private readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n private readonly internalId: string,\n private readonly runtime: ContainerRuntime,\n private readonly datastores: DataStores,\n private readonly logger: ITelemetryLogger,\n ) {\n this.pendingAliases = datastores.pendingAliases;\n }\n\n public get IFluidRouter() { return this.fluidDataStoreChannel; }\n\n private async ackBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataStore.js","sourceRoot":"","sources":["../src/dataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAQ7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAenE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACnC,0BAA+B,EACqB,EAAE;IACtD,OAAO,OAAO,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,UAAU,CAAA,KAAK,QAAQ;WAC1D,OAAO,CAAA,0BAA0B,aAA1B,0BAA0B,uBAA1B,0BAA0B,CAAE,KAAK,CAAA,KAAK,QAAQ,CAAC;AACjE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAC9B,qBAA6C,EAC7C,UAAkB,EAClB,OAAyB,EACzB,UAAsB,EACtB,MAAwB,EACd,EAAE,CAAC,IAAI,SAAS,CAAC,qBAAqB,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAE/F,IAAK,UAIJ;AAJD,WAAK,UAAU;IACX,iCAAmB,CAAA;IACnB,mCAAqB,CAAA;IACrB,2BAAa,CAAA;AACjB,CAAC,EAJI,UAA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C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport {\n FluidObject,\n IFluidHandle,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { AliasResult, IDataStore, IFluidDataStoreChannel } from \"@fluidframework/runtime-definitions\";\nimport { TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { ContainerRuntime } from \"./containerRuntime\";\nimport { DataStores } from \"./dataStores\";\n\n/**\n * Interface for an op to be used for assigning an\n * alias to a datastore\n */\nexport interface IDataStoreAliasMessage {\n /** The internal id of the datastore */\n readonly internalId: string;\n /** The alias name to be assigned to the datastore */\n readonly alias: string;\n}\n\n/**\n * Type guard that returns true if the given alias message is actually an instance of\n * a class which implements {@link IDataStoreAliasMessage}\n * @param maybeDataStoreAliasMessage - message object to be validated\n * @returns True if the {@link IDataStoreAliasMessage} is fully implemented, false otherwise\n */\nexport const isDataStoreAliasMessage = (\n maybeDataStoreAliasMessage: any,\n): maybeDataStoreAliasMessage is IDataStoreAliasMessage => {\n return typeof maybeDataStoreAliasMessage?.internalId === \"string\"\n && typeof maybeDataStoreAliasMessage?.alias === \"string\";\n};\n\nexport const channelToDataStore = (\n fluidDataStoreChannel: IFluidDataStoreChannel,\n internalId: string,\n runtime: ContainerRuntime,\n datastores: DataStores,\n logger: ITelemetryLogger,\n): IDataStore => new DataStore(fluidDataStoreChannel, internalId, runtime, datastores, logger);\n\nenum AliasState {\n Aliased = \"Aliased\",\n Aliasing = \"Aliasing\",\n None = \"None\",\n}\n\nclass DataStore implements IDataStore {\n private aliasState: AliasState = AliasState.None;\n private alias: string | undefined;\n private readonly pendingAliases: Map<string, Promise<AliasResult>>;\n private aliasResult: Promise<AliasResult> | undefined;\n\n async trySetAlias(alias: string): Promise<AliasResult> {\n if (alias.includes(\"/\")) {\n throw new UsageError(`The alias cannot contain slashes: '${alias}'`);\n }\n\n switch (this.aliasState) {\n // If we're already aliasing, check if it's for the same value and return\n // the stored promise, otherwise return 'AlreadyAliased'\n case AliasState.Aliasing:\n assert(this.aliasResult !== undefined,\n 0x316 /* There should be a cached promise of in-progress aliasing */);\n await this.aliasResult;\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n // If this datastore is already aliased, return true only if this\n // is a repeated call for the same alias\n case AliasState.Aliased:\n return this.alias === alias ? \"Success\" : \"AlreadyAliased\";\n\n case AliasState.None: {\n const existingAlias = this.pendingAliases.get(alias);\n if (existingAlias !== undefined) {\n // There is already another datastore which will be aliased\n // to the same name\n return \"Conflict\";\n }\n\n // There is no current or past alias operation for this datastore,\n // or for this alias, so it is safe to continue execution\n break;\n }\n\n default: unreachableCase(this.aliasState);\n }\n\n this.aliasState = AliasState.Aliasing;\n this.aliasResult = this.trySetAliasInternal(alias);\n this.pendingAliases.set(alias, this.aliasResult);\n return this.aliasResult;\n }\n\n async trySetAliasInternal(alias: string): Promise<AliasResult> {\n const message: IDataStoreAliasMessage = {\n internalId: this.internalId,\n alias,\n };\n\n this.fluidDataStoreChannel.makeVisibleAndAttachGraph();\n\n if (this.runtime.attachState === AttachState.Detached) {\n const localResult = this.datastores.processAliasMessageCore(message);\n // Explicitly lock-out future attempts of aliasing,\n // regardless of result\n this.aliasState = AliasState.Aliased;\n return localResult ? \"Success\" : \"Conflict\";\n }\n\n const aliased = await this\n .ackBasedPromise<boolean>((resolve) => {\n this.runtime.submitDataStoreAliasOp(message, resolve);\n })\n .catch((error) => {\n this.logger.sendErrorEvent({\n eventName: \"AliasingException\",\n alias: {\n value: alias,\n tag: TelemetryDataTag.UserData,\n },\n internalId: {\n value: this.internalId,\n tag: TelemetryDataTag.CodeArtifact,\n },\n }, error);\n\n return false;\n }).finally(() => {\n this.pendingAliases.delete(alias);\n });\n\n if (!aliased) {\n this.aliasState = AliasState.None;\n this.aliasResult = undefined;\n return \"Conflict\";\n }\n\n this.alias = alias;\n this.aliasState = AliasState.Aliased;\n return \"Success\";\n }\n\n async request(request: IRequest): Promise<IResponse> {\n return this.fluidDataStoreChannel.request(request);\n }\n\n /**\n * {@inheritDoc @fluidframework/runtime-definitions#IDataStore.entryPoint}\n */\n get entryPoint(): IFluidHandle<FluidObject> | undefined {\n return this.fluidDataStoreChannel.entryPoint;\n }\n\n constructor(\n private readonly fluidDataStoreChannel: IFluidDataStoreChannel,\n private readonly internalId: string,\n private readonly runtime: ContainerRuntime,\n private readonly datastores: DataStores,\n private readonly logger: ITelemetryLogger,\n ) {\n this.pendingAliases = datastores.pendingAliases;\n }\n\n public get IFluidRouter() { return this.fluidDataStoreChannel; }\n\n private async ackBasedPromise<T>(\n executor: (resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void) => void,\n ): Promise<T> {\n let rejectBecauseDispose: () => void;\n return new Promise<T>((resolve, reject) => {\n rejectBecauseDispose =\n () => reject(new Error(\"ContainerRuntime disposed while this ack-based Promise was pending\"));\n\n if (this.runtime.disposed) {\n rejectBecauseDispose();\n return;\n }\n\n this.runtime.on(\"dispose\", rejectBecauseDispose);\n executor(resolve, reject);\n }).finally(() => {\n this.runtime.off(\"dispose\", rejectBecauseDispose);\n });\n }\n}\n"]}
|
|
@@ -9,7 +9,7 @@ import { Deferred, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
|
9
9
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
10
10
|
import { IClientDetails, IDocumentMessage, IQuorumClients, ISequencedDocumentMessage, ISnapshotTree, ITreeEntry } from "@fluidframework/protocol-definitions";
|
|
11
11
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
12
|
-
import { BindState, CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase,
|
|
12
|
+
import { BindState, CreateChildSummarizerNodeFn, CreateChildSummarizerNodeParam, IAttachMessage, IFluidDataStoreChannel, IFluidDataStoreContext, IFluidDataStoreContextDetached, IFluidDataStoreContextEvents, IFluidDataStoreRegistry, IGarbageCollectionData, IGarbageCollectionDetailsBase, IInboundSignalMessage, IProvideFluidDataStoreFactory, ISummarizeResult, ISummarizerNodeWithGC, SummarizeInternalFn, ITelemetryContext } from "@fluidframework/runtime-definitions";
|
|
13
13
|
import { ContainerRuntime } from "./containerRuntime";
|
|
14
14
|
export declare function createAttributesBlob(pkg: readonly string[], isRootDataStore: boolean): ITreeEntry;
|
|
15
15
|
interface ISnapshotDetails {
|
|
@@ -24,7 +24,6 @@ export interface IFluidDataStoreContextProps {
|
|
|
24
24
|
readonly storage: IDocumentStorageService;
|
|
25
25
|
readonly scope: FluidObject;
|
|
26
26
|
readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
|
|
27
|
-
readonly writeGCDataAtRoot: boolean;
|
|
28
27
|
readonly pkg?: Readonly<string[]>;
|
|
29
28
|
}
|
|
30
29
|
/** Properties necessary for creating a local FluidDataStoreContext */
|
|
@@ -40,7 +39,7 @@ export interface ILocalFluidDataStoreContextProps extends IFluidDataStoreContext
|
|
|
40
39
|
}
|
|
41
40
|
/** Properties necessary for creating a remote FluidDataStoreContext */
|
|
42
41
|
export interface IRemoteFluidDataStoreContextProps extends IFluidDataStoreContextProps {
|
|
43
|
-
readonly snapshotTree: ISnapshotTree |
|
|
42
|
+
readonly snapshotTree: ISnapshotTree | undefined;
|
|
44
43
|
readonly getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase | undefined>;
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
@@ -64,6 +63,14 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
64
63
|
get baseSnapshot(): ISnapshotTree | undefined;
|
|
65
64
|
private _disposed;
|
|
66
65
|
get disposed(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Tombstone is a temporary feature that prevents a data store from sending / receiving ops, signals and from
|
|
68
|
+
* loading.
|
|
69
|
+
*/
|
|
70
|
+
private _tombstoned;
|
|
71
|
+
get tombstoned(): boolean;
|
|
72
|
+
/** If true, throw an error when a tombstone data store is used. */
|
|
73
|
+
private readonly throwOnTombstoneUsage;
|
|
67
74
|
get attachState(): AttachState;
|
|
68
75
|
get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined;
|
|
69
76
|
/**
|
|
@@ -93,19 +100,19 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
93
100
|
protected _attachState: AttachState;
|
|
94
101
|
private _isInMemoryRoot;
|
|
95
102
|
protected readonly summarizerNode: ISummarizerNodeWithGC;
|
|
96
|
-
private readonly
|
|
103
|
+
private readonly mc;
|
|
97
104
|
private readonly thresholdOpsCounter;
|
|
98
105
|
private static readonly pendingOpsCountThreshold;
|
|
99
|
-
private
|
|
106
|
+
private lastUsedRoutes;
|
|
100
107
|
readonly id: string;
|
|
101
108
|
private readonly _containerRuntime;
|
|
102
109
|
readonly storage: IDocumentStorageService;
|
|
103
110
|
readonly scope: FluidObject;
|
|
104
|
-
private readonly writeGCDataAtRoot;
|
|
105
111
|
protected pkg?: readonly string[];
|
|
106
112
|
constructor(props: IFluidDataStoreContextProps, existing: boolean, bindState: BindState, // Used to assert for state tracking purposes
|
|
107
113
|
isLocalDataStore: boolean, makeLocallyVisibleFn: () => void);
|
|
108
114
|
dispose(): void;
|
|
115
|
+
setTombstone(tombstone: boolean): void;
|
|
109
116
|
private rejectDeferredRealize;
|
|
110
117
|
realize(): Promise<IFluidDataStoreChannel>;
|
|
111
118
|
protected factoryFromPackagePath(packages?: readonly string[]): Promise<{
|
|
@@ -162,10 +169,8 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
162
169
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
163
170
|
*
|
|
164
171
|
* @param usedRoutes - The routes that are used in this data store.
|
|
165
|
-
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
166
|
-
* as part of this GC run, this should be used to update the time when it happens.
|
|
167
172
|
*/
|
|
168
|
-
updateUsedRoutes(usedRoutes: string[]
|
|
173
|
+
updateUsedRoutes(usedRoutes: string[]): void;
|
|
169
174
|
/**
|
|
170
175
|
* Called when a new outbound reference is added to another node. This is used by garbage collection to identify
|
|
171
176
|
* all references added in the system.
|
|
@@ -211,10 +216,6 @@ export declare abstract class FluidDataStoreContext extends TypedEventEmitter<IF
|
|
|
211
216
|
* It will be removed, as the source of truth for this flag will be the aliasing blob.
|
|
212
217
|
*/
|
|
213
218
|
setInMemoryRoot(): void;
|
|
214
|
-
/**
|
|
215
|
-
* @deprecated Renamed to `{@link FluidDataStoreContext.getBaseGCDetails}()`.
|
|
216
|
-
*/
|
|
217
|
-
abstract getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
218
219
|
abstract getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
219
220
|
reSubmit(contents: any, localOpMetadata: unknown): void;
|
|
220
221
|
rollback(contents: any, localOpMetadata: unknown): void;
|
|
@@ -229,10 +230,6 @@ export declare class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
229
230
|
constructor(props: IRemoteFluidDataStoreContextProps);
|
|
230
231
|
private readonly initialSnapshotDetailsP;
|
|
231
232
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
232
|
-
/**
|
|
233
|
-
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
234
|
-
*/
|
|
235
|
-
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
236
233
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
237
234
|
generateAttachMessage(): IAttachMessage;
|
|
238
235
|
}
|
|
@@ -249,10 +246,6 @@ export declare class LocalFluidDataStoreContextBase extends FluidDataStoreContex
|
|
|
249
246
|
private attachListeners;
|
|
250
247
|
generateAttachMessage(): IAttachMessage;
|
|
251
248
|
getInitialSnapshotDetails(): Promise<ISnapshotDetails>;
|
|
252
|
-
/**
|
|
253
|
-
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
254
|
-
*/
|
|
255
|
-
getInitialGCSummaryDetails(): Promise<IGarbageCollectionSummaryDetails>;
|
|
256
249
|
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
257
250
|
}
|
|
258
251
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"dataStoreContext.d.ts","sourceRoot":"","sources":["../src/dataStoreContext.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,CAAC;AACzG,OAAO,EACH,WAAW,EACX,QAAQ,EACR,SAAS,EACT,YAAY,EACf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,aAAa,EACb,WAAW,EACX,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEH,QAAQ,EAER,iBAAiB,EACpB,MAAM,8BAA8B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;IAqBpD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CA0CrC;IAEU,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAItD,gBAAgB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAIhE,qBAAqB,IAAI,cAAc;CAGjD;AAED;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,qBAAqB;IACrE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;IACzD;;OAEG;IACH,SAAgB,WAAW,CAAC,EAAE,GAAG,CAAC;gBAEtB,KAAK,EAAE,gCAAgC;IAiBnD,OAAO,CAAC,eAAe;IAWhB,qBAAqB,IAAI,cAAc;IA4BjC,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAiCtD,gBAAgB,IAAI,OAAO,CAAC,6BAA6B,CAAC;CAI1E;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,8BAA8B;gBAC9D,KAAK,EAAE,gCAAgC;CAGtD;AAED;;;;;GAKG;AACH,qBAAa,kCACT,SAAQ,8BACR,YAAW,8BAA8B;gBAC7B,KAAK,EAAE,gCAAgC;IAKtC,aAAa,CACtB,QAAQ,EAAE,6BAA6B,EACvC,gBAAgB,EAAE,sBAAsB;IA+B/B,yBAAyB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAMtE"}
|
package/lib/dataStoreContext.js
CHANGED
|
@@ -6,11 +6,13 @@ import { AttachState, } from "@fluidframework/container-definitions";
|
|
|
6
6
|
import { assert, Deferred, LazyPromise, TypedEventEmitter, } from "@fluidframework/common-utils";
|
|
7
7
|
import { readAndParse } from "@fluidframework/driver-utils";
|
|
8
8
|
import { BlobTreeEntry } from "@fluidframework/protocol-base";
|
|
9
|
-
import { BindState, channelsTreeName,
|
|
10
|
-
import { addBlobToSummary, convertSummaryTreeToITree } from "@fluidframework/runtime-utils";
|
|
11
|
-
import { ChildLogger, LoggingError, TelemetryDataTag, ThresholdCounter, } from "@fluidframework/telemetry-utils";
|
|
12
|
-
import { DataProcessingError } from "@fluidframework/container-utils";
|
|
9
|
+
import { BindState, channelsTreeName, } from "@fluidframework/runtime-definitions";
|
|
10
|
+
import { addBlobToSummary, convertSummaryTreeToITree, packagePathToTelemetryProperty, } from "@fluidframework/runtime-utils";
|
|
11
|
+
import { ChildLogger, loggerToMonitoringContext, LoggingError, TelemetryDataTag, ThresholdCounter, } from "@fluidframework/telemetry-utils";
|
|
12
|
+
import { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, } from "@fluidframework/container-utils";
|
|
13
13
|
import { dataStoreAttributesBlobName, hasIsolatedChannels, wrapSummaryInChannelsTree, getAttributesFormatVersion, getFluidDataStoreAttributes, } from "./summaryFormat";
|
|
14
|
+
import { throwOnTombstoneUsageKey } from "./garbageCollection";
|
|
15
|
+
import { summarizerClientType } from "./summarizerClientElection";
|
|
14
16
|
function createAttributes(pkg, isRootDataStore) {
|
|
15
17
|
const stringifiedPkg = JSON.stringify(pkg);
|
|
16
18
|
return {
|
|
@@ -35,6 +37,11 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
35
37
|
this.isLocalDataStore = isLocalDataStore;
|
|
36
38
|
this.makeLocallyVisibleFn = makeLocallyVisibleFn;
|
|
37
39
|
this._disposed = false;
|
|
40
|
+
/**
|
|
41
|
+
* Tombstone is a temporary feature that prevents a data store from sending / receiving ops, signals and from
|
|
42
|
+
* loading.
|
|
43
|
+
*/
|
|
44
|
+
this._tombstoned = false;
|
|
38
45
|
this.detachedRuntimeCreation = false;
|
|
39
46
|
this.loaded = false;
|
|
40
47
|
this.pending = [];
|
|
@@ -43,7 +50,6 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
43
50
|
this.id = props.id;
|
|
44
51
|
this.storage = props.storage;
|
|
45
52
|
this.scope = props.scope;
|
|
46
|
-
this.writeGCDataAtRoot = props.writeGCDataAtRoot;
|
|
47
53
|
this.pkg = props.pkg;
|
|
48
54
|
// URIs use slashes as delimiters. Handles use URIs.
|
|
49
55
|
// Thus having slashes in types almost guarantees trouble down the road!
|
|
@@ -59,8 +65,12 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
59
65
|
};
|
|
60
66
|
const thisSummarizeInternal = async (fullTree, trackState, telemetryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext);
|
|
61
67
|
this.summarizerNode = props.createSummarizerNodeFn(thisSummarizeInternal, async (fullGC) => this.getGCDataInternal(fullGC), async () => this.getBaseGCDetails());
|
|
62
|
-
this.
|
|
63
|
-
this.thresholdOpsCounter = new ThresholdCounter(FluidDataStoreContext.pendingOpsCountThreshold, this.
|
|
68
|
+
this.mc = loggerToMonitoringContext(ChildLogger.create(this.logger, "FluidDataStoreContext"));
|
|
69
|
+
this.thresholdOpsCounter = new ThresholdCounter(FluidDataStoreContext.pendingOpsCountThreshold, this.mc.logger);
|
|
70
|
+
// Tombstone should only throw when the feature flag is enabled and the client isn't a summarizer
|
|
71
|
+
this.throwOnTombstoneUsage =
|
|
72
|
+
this.mc.config.getBoolean(throwOnTombstoneUsageKey) === true &&
|
|
73
|
+
this.clientDetails.type !== summarizerClientType;
|
|
64
74
|
}
|
|
65
75
|
get packagePath() {
|
|
66
76
|
assert(this.pkg !== undefined, 0x139 /* "Undefined package path" */);
|
|
@@ -97,6 +107,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
97
107
|
return this._baseSnapshot;
|
|
98
108
|
}
|
|
99
109
|
get disposed() { return this._disposed; }
|
|
110
|
+
get tombstoned() { return this._tombstoned; }
|
|
100
111
|
get attachState() {
|
|
101
112
|
return this._attachState;
|
|
102
113
|
}
|
|
@@ -135,6 +146,12 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
135
146
|
}).catch((error) => { });
|
|
136
147
|
}
|
|
137
148
|
}
|
|
149
|
+
setTombstone(tombstone) {
|
|
150
|
+
if (this.tombstoned === tombstone) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this._tombstoned = tombstone;
|
|
154
|
+
}
|
|
138
155
|
rejectDeferredRealize(reason, packageName) {
|
|
139
156
|
throw new LoggingError(reason, { packageName: { value: packageName, tag: TelemetryDataTag.CodeArtifact } });
|
|
140
157
|
}
|
|
@@ -203,7 +220,8 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
203
220
|
* its new client ID when we are connecting or connected.
|
|
204
221
|
*/
|
|
205
222
|
setConnectionState(connected, clientId) {
|
|
206
|
-
this
|
|
223
|
+
// ConnectionState should not fail in tombstone mode as this is internally run
|
|
224
|
+
this.verifyNotClosed("setConnectionState", false /* checkTombstone */);
|
|
207
225
|
// Connection events are ignored if the store is not yet loaded
|
|
208
226
|
if (!this.loaded) {
|
|
209
227
|
return;
|
|
@@ -214,7 +232,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
214
232
|
}
|
|
215
233
|
process(messageArg, local, localOpMetadata) {
|
|
216
234
|
var _a;
|
|
217
|
-
this.verifyNotClosed();
|
|
235
|
+
this.verifyNotClosed("process", true, extractSafePropertiesFromMessage(messageArg));
|
|
218
236
|
const innerContents = messageArg.contents;
|
|
219
237
|
const message = Object.assign(Object.assign({}, messageArg), { type: innerContents.type, contents: innerContents.content });
|
|
220
238
|
this.summarizerNode.recordChange(message);
|
|
@@ -230,7 +248,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
230
248
|
}
|
|
231
249
|
processSignal(message, local) {
|
|
232
250
|
var _a;
|
|
233
|
-
this.verifyNotClosed();
|
|
251
|
+
this.verifyNotClosed("processSignal");
|
|
234
252
|
// Signals are ignored if the store is not yet loaded
|
|
235
253
|
if (!this.loaded) {
|
|
236
254
|
return;
|
|
@@ -264,10 +282,6 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
264
282
|
const isRoot = await this.isRoot();
|
|
265
283
|
const attributes = createAttributes(pkg, isRoot);
|
|
266
284
|
addBlobToSummary(summarizeResult, dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
267
|
-
// Add GC data to the summary if it's not written at the root.
|
|
268
|
-
if (!this.writeGCDataAtRoot) {
|
|
269
|
-
addBlobToSummary(summarizeResult, gcBlobKey, JSON.stringify(this.summarizerNode.getGCSummaryDetails()));
|
|
270
|
-
}
|
|
271
285
|
// If we are not referenced, mark the summary tree as unreferenced. Also, update unreferenced blob
|
|
272
286
|
// size in the summary stats with the blobs size of this data store.
|
|
273
287
|
if (!this.summarizerNode.isReferenced()) {
|
|
@@ -312,20 +326,16 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
312
326
|
* 5. To update the timestamp when this data store or any children are marked as unreferenced.
|
|
313
327
|
*
|
|
314
328
|
* @param usedRoutes - The routes that are used in this data store.
|
|
315
|
-
* @param gcTimestamp - The time when GC was run that generated these used routes. If any node becomes unreferenced
|
|
316
|
-
* as part of this GC run, this should be used to update the time when it happens.
|
|
317
329
|
*/
|
|
318
|
-
updateUsedRoutes(usedRoutes
|
|
330
|
+
updateUsedRoutes(usedRoutes) {
|
|
319
331
|
// Update the used routes in this data store's summarizer node.
|
|
320
|
-
this.summarizerNode.updateUsedRoutes(usedRoutes
|
|
332
|
+
this.summarizerNode.updateUsedRoutes(usedRoutes);
|
|
321
333
|
/**
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* child's reference state changes, the gcTimestamp has to be used to update its unreferencedTimestamp. Since
|
|
326
|
-
* it will result in a change in this data store's used routes, it will be realized to regenerate its summary.
|
|
334
|
+
* Store the used routes to update the channel if the data store is not loaded yet. If the used routes changed
|
|
335
|
+
* since the previous run, the data store will be loaded during summarize since the used state changed. So, it's
|
|
336
|
+
* safe to only store the last used routes.
|
|
327
337
|
*/
|
|
328
|
-
this.
|
|
338
|
+
this.lastUsedRoutes = usedRoutes;
|
|
329
339
|
// If we are loaded, call the channel so it can update the used routes of the child contexts.
|
|
330
340
|
// If we are not loaded, we will update this when we are realized.
|
|
331
341
|
if (this.loaded) {
|
|
@@ -350,13 +360,13 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
350
360
|
updateChannelUsedRoutes() {
|
|
351
361
|
assert(this.loaded, 0x144 /* "Channel should be loaded when updating used routes" */);
|
|
352
362
|
assert(this.channel !== undefined, 0x145 /* "Channel should be present when data store is loaded" */);
|
|
353
|
-
// If there is no
|
|
354
|
-
if (this.
|
|
363
|
+
// If there is no lastUsedRoutes, GC has not run up until this point.
|
|
364
|
+
if (this.lastUsedRoutes === undefined) {
|
|
355
365
|
return;
|
|
356
366
|
}
|
|
357
367
|
// Remove the route to this data store, if it exists.
|
|
358
|
-
const usedChannelRoutes = this.
|
|
359
|
-
this.channel.updateUsedRoutes(usedChannelRoutes
|
|
368
|
+
const usedChannelRoutes = this.lastUsedRoutes.filter((id) => { return id !== "/" && id !== ""; });
|
|
369
|
+
this.channel.updateUsedRoutes(usedChannelRoutes);
|
|
360
370
|
}
|
|
361
371
|
/**
|
|
362
372
|
* @deprecated 0.18.Should call request on the runtime directly
|
|
@@ -366,7 +376,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
366
376
|
return runtime.request(request);
|
|
367
377
|
}
|
|
368
378
|
submitMessage(type, content, localOpMetadata) {
|
|
369
|
-
this.verifyNotClosed();
|
|
379
|
+
this.verifyNotClosed("submitMessage");
|
|
370
380
|
assert(!!this.channel, 0x146 /* "Channel must exist when submitting message" */);
|
|
371
381
|
const fluidDataStoreContent = {
|
|
372
382
|
content,
|
|
@@ -384,7 +394,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
384
394
|
*
|
|
385
395
|
*/
|
|
386
396
|
setChannelDirty(address) {
|
|
387
|
-
this.verifyNotClosed();
|
|
397
|
+
this.verifyNotClosed("setChannelDirty");
|
|
388
398
|
// Get the latest sequence number.
|
|
389
399
|
const latestSequenceNumber = this.deltaManager.lastSequenceNumber;
|
|
390
400
|
this.summarizerNode.invalidate(latestSequenceNumber);
|
|
@@ -394,7 +404,7 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
submitSignal(type, content) {
|
|
397
|
-
this.verifyNotClosed();
|
|
407
|
+
this.verifyNotClosed("submitSignal");
|
|
398
408
|
assert(!!this.channel, 0x147 /* "Channel must exist on submitting signal" */);
|
|
399
409
|
return this._containerRuntime.submitDataStoreSignal(this.id, type, content);
|
|
400
410
|
}
|
|
@@ -485,9 +495,25 @@ export class FluidDataStoreContext extends TypedEventEmitter {
|
|
|
485
495
|
const innerContents = contents;
|
|
486
496
|
return this.channel.applyStashedOp(innerContents.content);
|
|
487
497
|
}
|
|
488
|
-
verifyNotClosed() {
|
|
498
|
+
verifyNotClosed(callSite, checkTombstone = true, safeTelemetryProps = {}) {
|
|
489
499
|
if (this._disposed) {
|
|
490
|
-
throw new Error(
|
|
500
|
+
throw new Error(`Context is closed! Call site [${callSite}]`);
|
|
501
|
+
}
|
|
502
|
+
if (checkTombstone && this.tombstoned) {
|
|
503
|
+
const messageString = `Context is tombstoned! Call site [${callSite}]`;
|
|
504
|
+
const error = new DataCorruptionError(messageString, Object.assign({ errorMessage: messageString }, safeTelemetryProps));
|
|
505
|
+
// Always log an error when tombstoned data store is used. However, throw an error only if
|
|
506
|
+
// throwOnTombstoneUsage is set.
|
|
507
|
+
this.mc.logger.sendErrorEvent({
|
|
508
|
+
eventName: "GC_Tombstone_DataStore_Changed",
|
|
509
|
+
callSite,
|
|
510
|
+
pkg: packagePathToTelemetryProperty(this.pkg),
|
|
511
|
+
}, error);
|
|
512
|
+
// Always log an error when tombstoned data store is used. However, throw an error only if
|
|
513
|
+
// throwOnTombstoneUsage is set and the client is not a summarizer.
|
|
514
|
+
if (this.throwOnTombstoneUsage) {
|
|
515
|
+
throw error;
|
|
516
|
+
}
|
|
491
517
|
}
|
|
492
518
|
}
|
|
493
519
|
getCreateChildSummarizerNodeFn(id, createParam) {
|
|
@@ -506,23 +532,12 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
506
532
|
throw new Error("Already attached");
|
|
507
533
|
});
|
|
508
534
|
this.initialSnapshotDetailsP = new LazyPromise(async () => {
|
|
509
|
-
var _a
|
|
510
|
-
let tree;
|
|
535
|
+
var _a;
|
|
536
|
+
let tree = this.initSnapshotValue;
|
|
511
537
|
let isRootDataStore = true;
|
|
512
|
-
if (typeof this.initSnapshotValue === "string") {
|
|
513
|
-
const commit = (await this.storage.getVersions(this.initSnapshotValue, 1))[0];
|
|
514
|
-
tree = (_a = await this.storage.getSnapshotTree(commit)) !== null && _a !== void 0 ? _a : undefined;
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
tree = this.initSnapshotValue;
|
|
518
|
-
}
|
|
519
|
-
const localReadAndParse = async (id) => readAndParse(this.storage, id);
|
|
520
|
-
if (tree) {
|
|
521
|
-
tree = await this.summarizerNode.loadBaseSummary(tree, localReadAndParse);
|
|
522
|
-
}
|
|
523
538
|
if (!!tree && tree.blobs[dataStoreAttributesBlobName] !== undefined) {
|
|
524
539
|
// Need to get through snapshot and use that to populate extraBlobs
|
|
525
|
-
const attributes = await
|
|
540
|
+
const attributes = await readAndParse(this.storage, tree.blobs[dataStoreAttributesBlobName]);
|
|
526
541
|
let pkgFromSnapshot;
|
|
527
542
|
// Use the snapshotFormatVersion to determine how the pkg is encoded in the snapshot.
|
|
528
543
|
// For snapshotFormatVersion = "0.1" (1) or above, pkg is jsonified, otherwise it is just a string.
|
|
@@ -541,7 +556,7 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
541
556
|
* data stores in older documents are not garbage collected incorrectly. This may lead to additional
|
|
542
557
|
* roots in the document but they won't break.
|
|
543
558
|
*/
|
|
544
|
-
isRootDataStore = (
|
|
559
|
+
isRootDataStore = (_a = attributes.isRootDataStore) !== null && _a !== void 0 ? _a : true;
|
|
545
560
|
if (hasIsolatedChannels(attributes)) {
|
|
546
561
|
tree = tree.trees[channelsTreeName];
|
|
547
562
|
assert(tree !== undefined, 0x1fe /* "isolated channels subtree should exist in remote datastore snapshot" */);
|
|
@@ -559,16 +574,13 @@ export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
559
574
|
var _a;
|
|
560
575
|
return (_a = (await props.getBaseGCDetails())) !== null && _a !== void 0 ? _a : {};
|
|
561
576
|
});
|
|
577
|
+
if (props.snapshotTree !== undefined) {
|
|
578
|
+
this.summarizerNode.updateBaseSummaryState(props.snapshotTree);
|
|
579
|
+
}
|
|
562
580
|
}
|
|
563
581
|
async getInitialSnapshotDetails() {
|
|
564
582
|
return this.initialSnapshotDetailsP;
|
|
565
583
|
}
|
|
566
|
-
/**
|
|
567
|
-
* @deprecated Renamed to {@link RemoteFluidDataStoreContext.getBaseGCDetails}.
|
|
568
|
-
*/
|
|
569
|
-
async getInitialGCSummaryDetails() {
|
|
570
|
-
return this.getBaseGCDetails();
|
|
571
|
-
}
|
|
572
584
|
async getBaseGCDetails() {
|
|
573
585
|
return this.baseGCDetailsP;
|
|
574
586
|
}
|
|
@@ -648,13 +660,6 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
648
660
|
snapshot,
|
|
649
661
|
};
|
|
650
662
|
}
|
|
651
|
-
/**
|
|
652
|
-
* @deprecated Renamed to {@link LocalFluidDataStoreContextBase.getBaseGCDetails}.
|
|
653
|
-
*/
|
|
654
|
-
async getInitialGCSummaryDetails() {
|
|
655
|
-
// Local data store does not have initial summary.
|
|
656
|
-
return {};
|
|
657
|
-
}
|
|
658
663
|
async getBaseGCDetails() {
|
|
659
664
|
// Local data store does not have initial summary.
|
|
660
665
|
return {};
|
|
@@ -683,6 +688,7 @@ export class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreConte
|
|
|
683
688
|
this.detachedRuntimeCreation = true;
|
|
684
689
|
}
|
|
685
690
|
async attachRuntime(registry, dataStoreChannel) {
|
|
691
|
+
var _a;
|
|
686
692
|
assert(this.detachedRuntimeCreation, 0x154 /* "runtime creation is already attached" */);
|
|
687
693
|
this.detachedRuntimeCreation = false;
|
|
688
694
|
assert(this.channelDeferred === undefined, 0x155 /* "channel deferral is already set" */);
|
|
@@ -693,6 +699,14 @@ export class LocalDetachedFluidDataStoreContext extends LocalFluidDataStoreConte
|
|
|
693
699
|
assert(this.registry === undefined, 0x157 /* "datastore registry already attached" */);
|
|
694
700
|
this.registry = entry.registry;
|
|
695
701
|
super.bindRuntime(dataStoreChannel);
|
|
702
|
+
// Load the handle to the data store's entryPoint to make sure that for a detached data store, the entryPoint
|
|
703
|
+
// initialization function is called before the data store gets attached and potentially connected to the
|
|
704
|
+
// delta stream, so it gets a chance to do things while the data store is still "purely local".
|
|
705
|
+
// This preserves the behavior from before we introduced entryPoints, where the instantiateDataStore method
|
|
706
|
+
// of data store factories tends to construct the data object (at least kick off an async method that returns
|
|
707
|
+
// it); that code moved to the entryPoint initialization function, so we want to ensure it still executes
|
|
708
|
+
// before the data store is attached.
|
|
709
|
+
await ((_a = dataStoreChannel.entryPoint) === null || _a === void 0 ? void 0 : _a.get());
|
|
696
710
|
if (await this.isRoot()) {
|
|
697
711
|
dataStoreChannel.makeVisibleAndAttachGraph();
|
|
698
712
|
}
|