@fluidframework/container-runtime 2.0.0-internal.2.3.1 → 2.0.0-internal.2.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 +3 -1
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +35 -2
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +2 -2
- package/dist/containerRuntime.js.map +1 -1
- package/dist/garbageCollection.d.ts +15 -7
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +96 -36
- package/dist/garbageCollection.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/summarizer.js.map +1 -1
- package/lib/blobManager.d.ts +3 -1
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +35 -2
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +2 -2
- package/lib/containerRuntime.js.map +1 -1
- package/lib/garbageCollection.d.ts +15 -7
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +97 -37
- package/lib/garbageCollection.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/summarizer.js.map +1 -1
- package/package.json +37 -20
- package/src/blobManager.ts +41 -2
- package/src/containerRuntime.ts +2 -1
- package/src/garbageCollection.ts +103 -34
- package/src/packageVersion.ts +1 -1
- package/src/summarizer.ts +1 -1
package/lib/summarizer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO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,QAAQ,0CAAE,MAAM;oBACxC,SAAS,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,QAAQ,0CAAE,MAAM;iBAC/C,EAAE,KAAK,CAAC,CAAC;aACb;YACD,iBAAiB,EAAE,CAAC;SACvB;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { Deferred } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ILoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverErrorType, DriverHeader } from \"@fluidframework/driver-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n IFluidErrorBase,\n isFluidError,\n LoggingError,\n wrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n FluidObject,\n IFluidHandleContext,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { ISummaryConfiguration } from \"./containerRuntime\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { IAckedSummary, SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorMessage: string, logged: boolean) => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n } finally {\n this.close();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n public close() {\n // This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n // unless stop() was called earlier\n this.dispose();\n (this.runtime.disposeFn ?? this.runtime.closeFn)()\n }\n\n private async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(\n !runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason));\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Should we try to run a last summary for the given stop reason?\n * Currently only allows \"parentNotConnected\"\n * @param stopReason - SummarizerStopReason\n * @returns - true if the stop reason can run a last summary\n */\n public static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n return stopReason === \"parentNotConnected\";\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n config: JSON.stringify(this.configurationGetter()),\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorMessage: string) => {\n if (!this._disposed) {\n this.logger.sendErrorEvent({ eventName: \"summarizingError\" },\n createSummarizingWarning(errorMessage, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n this.runtime,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // Successfully created the cancellation token. Start the summarizer.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const startP = this.start(this.runtime.clientId!, runCoordinator);\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.close();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n } catch (error) {\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n let ack: IAckedSummary | undefined;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n // Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n // we record undefined, not previous handles.\n ack = undefined;\n ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n const summaryOpHandle = ack.summaryOp.contents.handle;\n const summaryAckHandle = ack.summaryAck.contents.handle;\n // Make sure we block any summarizer from being executed/enqueued while\n // executing the refreshLatestSummaryAck.\n // https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n await this.runningSummarizer.lockedRefreshSummaryAckAction(async () =>\n this.internalsProvider.refreshLatestSummaryAck({\n proposalHandle: summaryOpHandle,\n ackHandle: summaryAckHandle,\n summaryRefSeq: refSequenceNumber,\n summaryLogger },\n ).catch(async (error) => {\n // If the error is 404, so maybe the fetched version no longer exists on server. We just\n // ignore this error in that case, as that means we will have another summaryAck for the\n // latest version with which we will refresh the state. However in case of single commit\n // summary, we might me missing a summary ack, so in that case we are still fine as the\n // code in `submitSummary` function in container runtime, will refresh the latest state\n // by calling `refreshLatestSummaryAckFromServer` and we will be fine.\n if (isFluidError(error)\n && error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n summaryLogger.sendTelemetryEvent({\n eventName: \"HandleSummaryAckErrorIgnored\",\n referenceSequenceNumber: refSequenceNumber,\n proposalHandle: summaryOpHandle,\n ackHandle: summaryAckHandle,\n }, error);\n } else {\n throw error;\n }\n }),\n );\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n handle: ack?.summaryOp?.contents?.handle,\n ackHandle: ack?.summaryAck?.contents?.handle,\n }, error);\n }\n refSequenceNumber++;\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summ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AAE,uBAAuB;oBAClC,uBAAuB,EAAE,iBAAiB;oBAC1C,MAAM,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,0CAAE,QAAQ,0CAAE,MAAM;oBACxC,SAAS,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,QAAQ,0CAAE,MAAM;iBAC/C,EAAE,KAAK,CAAC,CAAC;aACb;YACD,iBAAiB,EAAE,CAAC;SACvB;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { Deferred } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ILoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverErrorType, DriverHeader } from \"@fluidframework/driver-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n IFluidErrorBase,\n isFluidError,\n LoggingError,\n wrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n FluidObject,\n IFluidHandleContext,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { ISummaryConfiguration } from \"./containerRuntime\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { IAckedSummary, SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorMessage: string, logged: boolean) => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n } finally {\n this.close();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n public close() {\n // This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n // unless stop() was called earlier\n this.dispose();\n (this.runtime.disposeFn ?? this.runtime.closeFn)();\n }\n\n private async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(\n !runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason));\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Should we try to run a last summary for the given stop reason?\n * Currently only allows \"parentNotConnected\"\n * @param stopReason - SummarizerStopReason\n * @returns - true if the stop reason can run a last summary\n */\n public static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n return stopReason === \"parentNotConnected\";\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n config: JSON.stringify(this.configurationGetter()),\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorMessage: string) => {\n if (!this._disposed) {\n this.logger.sendErrorEvent({ eventName: \"summarizingError\" },\n createSummarizingWarning(errorMessage, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n this.runtime,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // Successfully created the cancellation token. Start the summarizer.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const startP = this.start(this.runtime.clientId!, runCoordinator);\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.close();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n } catch (error) {\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n let ack: IAckedSummary | undefined;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n // Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n // we record undefined, not previous handles.\n ack = undefined;\n ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n const summaryOpHandle = ack.summaryOp.contents.handle;\n const summaryAckHandle = ack.summaryAck.contents.handle;\n // Make sure we block any summarizer from being executed/enqueued while\n // executing the refreshLatestSummaryAck.\n // https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n await this.runningSummarizer.lockedRefreshSummaryAckAction(async () =>\n this.internalsProvider.refreshLatestSummaryAck({\n proposalHandle: summaryOpHandle,\n ackHandle: summaryAckHandle,\n summaryRefSeq: refSequenceNumber,\n summaryLogger },\n ).catch(async (error) => {\n // If the error is 404, so maybe the fetched version no longer exists on server. We just\n // ignore this error in that case, as that means we will have another summaryAck for the\n // latest version with which we will refresh the state. However in case of single commit\n // summary, we might me missing a summary ack, so in that case we are still fine as the\n // code in `submitSummary` function in container runtime, will refresh the latest state\n // by calling `refreshLatestSummaryAckFromServer` and we will be fine.\n if (isFluidError(error)\n && error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n summaryLogger.sendTelemetryEvent({\n eventName: \"HandleSummaryAckErrorIgnored\",\n referenceSequenceNumber: refSequenceNumber,\n proposalHandle: summaryOpHandle,\n ackHandle: summaryAckHandle,\n }, error);\n } else {\n throw error;\n }\n }),\n );\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n handle: ack?.summaryOp?.contents?.handle,\n ackHandle: ack?.summaryAck?.contents?.handle,\n }, error);\n }\n refSequenceNumber++;\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.0.0-internal.2.
|
|
3
|
+
"version": "2.0.0-internal.2.4.0",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -65,32 +65,32 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
67
67
|
"@fluidframework/common-utils": "^1.0.0",
|
|
68
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.2.
|
|
69
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.
|
|
70
|
-
"@fluidframework/container-utils": ">=2.0.0-internal.2.
|
|
71
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.2.
|
|
72
|
-
"@fluidframework/datastore": ">=2.0.0-internal.2.
|
|
73
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.2.
|
|
74
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.2.
|
|
75
|
-
"@fluidframework/garbage-collector": ">=2.0.0-internal.2.
|
|
68
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
69
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
70
|
+
"@fluidframework/container-utils": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
71
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
72
|
+
"@fluidframework/datastore": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
73
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
74
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
75
|
+
"@fluidframework/garbage-collector": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
76
76
|
"@fluidframework/protocol-base": "^0.1038.2000",
|
|
77
77
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
78
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.2.
|
|
79
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.2.
|
|
80
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.2.
|
|
78
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
79
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
80
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
81
81
|
"double-ended-queue": "^2.1.0-0",
|
|
82
82
|
"events": "^3.1.0",
|
|
83
83
|
"lz4js": "^0.2.0",
|
|
84
84
|
"uuid": "^8.3.1"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@fluid-tools/build-cli": "^0.
|
|
87
|
+
"@fluid-tools/build-cli": "^0.8.0",
|
|
88
88
|
"@fluidframework/build-common": "^1.1.0",
|
|
89
|
-
"@fluidframework/build-tools": "^0.
|
|
90
|
-
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.
|
|
89
|
+
"@fluidframework/build-tools": "^0.8.0",
|
|
90
|
+
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.2.0",
|
|
91
91
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
92
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.
|
|
93
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.
|
|
92
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
93
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.4.0 <2.0.0-internal.3.0.0",
|
|
94
94
|
"@microsoft/api-extractor": "^7.22.2",
|
|
95
95
|
"@rushstack/eslint-config": "^2.5.1",
|
|
96
96
|
"@types/double-ended-queue": "^2.1.0",
|
|
@@ -109,8 +109,25 @@
|
|
|
109
109
|
"typescript": "~4.5.5"
|
|
110
110
|
},
|
|
111
111
|
"typeValidation": {
|
|
112
|
-
"version": "2.0.0-internal.2.3.
|
|
113
|
-
"baselineRange": "2.0.0-internal.2.3.0",
|
|
114
|
-
"
|
|
112
|
+
"version": "2.0.0-internal.2.3.0",
|
|
113
|
+
"baselineRange": ">=2.0.0-internal.2.2.0 <2.0.0-internal.2.3.0",
|
|
114
|
+
"baselineVersion": "2.0.0-internal.2.2.0",
|
|
115
|
+
"broken": {
|
|
116
|
+
"RemovedVariableDeclaration_gcBlobPrefix": {
|
|
117
|
+
"forwardCompat": false,
|
|
118
|
+
"backCompat": false
|
|
119
|
+
},
|
|
120
|
+
"RemovedVariableDeclaration_gcTombstoneBlobKey": {
|
|
121
|
+
"forwardCompat": false,
|
|
122
|
+
"backCompat": false
|
|
123
|
+
},
|
|
124
|
+
"RemovedVariableDeclaration_gcTreeKey": {
|
|
125
|
+
"forwardCompat": false,
|
|
126
|
+
"backCompat": false
|
|
127
|
+
},
|
|
128
|
+
"ClassDeclaration_ContainerRuntime": {
|
|
129
|
+
"forwardCompat": false
|
|
130
|
+
}
|
|
131
|
+
}
|
|
115
132
|
}
|
|
116
133
|
}
|
package/src/blobManager.ts
CHANGED
|
@@ -101,12 +101,17 @@ enum PendingBlobStatus {
|
|
|
101
101
|
OfflinePendingOp,
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
type ICreateBlobResponseWithTTL = ICreateBlobResponse & Partial<Record<"minTTLInSeconds", number>>;
|
|
105
|
+
|
|
104
106
|
interface PendingBlob {
|
|
105
107
|
blob: ArrayBufferLike;
|
|
106
108
|
status: PendingBlobStatus;
|
|
107
109
|
storageId?: string;
|
|
108
110
|
handleP: Deferred<IFluidHandle<ArrayBufferLike>>;
|
|
109
111
|
uploadP: Promise<ICreateBlobResponse>;
|
|
112
|
+
localUploadTime?: number;
|
|
113
|
+
serverUploadTime?: number;
|
|
114
|
+
minTTLInSeconds?: number;
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
export interface IPendingBlobs { [id: string]: { blob: string; }; }
|
|
@@ -179,6 +184,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
179
184
|
private readonly addedBlobReference: (fromNodePath: string, toNodePath: string) => void,
|
|
180
185
|
private readonly runtime: IBlobManagerRuntime,
|
|
181
186
|
stashedBlobs: IPendingBlobs = {},
|
|
187
|
+
private readonly getCurrentReferenceTimestampMs: () => number | undefined,
|
|
182
188
|
) {
|
|
183
189
|
super();
|
|
184
190
|
this.mc = loggerToMonitoringContext(ChildLogger.create(this.runtime.logger, "BlobManager"));
|
|
@@ -398,12 +404,15 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
398
404
|
}
|
|
399
405
|
}
|
|
400
406
|
|
|
401
|
-
private onUploadResolve(localId: string, response:
|
|
407
|
+
private onUploadResolve(localId: string, response: ICreateBlobResponseWithTTL) {
|
|
402
408
|
const entry = this.pendingBlobs.get(localId);
|
|
403
409
|
assert(entry?.status === PendingBlobStatus.OnlinePendingUpload ||
|
|
404
410
|
entry?.status === PendingBlobStatus.OfflinePendingUpload,
|
|
405
411
|
0x386 /* Must have pending blob entry for uploaded blob */);
|
|
406
412
|
entry.storageId = response.id;
|
|
413
|
+
entry.localUploadTime = Date.now();
|
|
414
|
+
entry.minTTLInSeconds = response.minTTLInSeconds;
|
|
415
|
+
entry.serverUploadTime = this.getCurrentReferenceTimestampMs();
|
|
407
416
|
if (this.runtime.connected) {
|
|
408
417
|
if (entry.status === PendingBlobStatus.OnlinePendingUpload) {
|
|
409
418
|
// Send a blob attach op. This serves two purposes:
|
|
@@ -411,6 +420,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
411
420
|
// until its storage ID is added to the next summary.
|
|
412
421
|
// 2. It will create a local ID to storage ID mapping in all clients which is needed to retrieve the
|
|
413
422
|
// blob from the server via the storage ID.
|
|
423
|
+
this.logTimeInfo(entry, "sendBlobAttachResolveTTL");
|
|
414
424
|
this.sendBlobAttachOp(localId, response.id);
|
|
415
425
|
if (this.storageIds.has(response.id)) {
|
|
416
426
|
// The blob is de-duped. Set up a local ID to storage ID mapping and return the blob. Since this is
|
|
@@ -472,6 +482,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
472
482
|
* is called on reconnection.
|
|
473
483
|
*/
|
|
474
484
|
if (entry.status !== PendingBlobStatus.OnlinePendingOp) {
|
|
485
|
+
this.logTimeInfo(entry, "sendBlobAttachTransitionOfflineTTL");
|
|
475
486
|
this.sendBlobAttachOp(localId, entry.storageId);
|
|
476
487
|
}
|
|
477
488
|
|
|
@@ -491,9 +502,12 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
491
502
|
assert(!!metadata, 0x38b /* Resubmitted ops must have metadata */);
|
|
492
503
|
const { localId, blobId }: { localId?: string; blobId?: string } = metadata;
|
|
493
504
|
assert(localId !== undefined, 0x50d /* local ID not available on reSubmit */);
|
|
505
|
+
const pendingEntry = this.pendingBlobs.get(localId);
|
|
506
|
+
if (pendingEntry) {
|
|
507
|
+
this.logTimeInfo(pendingEntry, "sendBlobAttachResubmitTTL");
|
|
508
|
+
}
|
|
494
509
|
if (!blobId) {
|
|
495
510
|
// We submitted this op while offline. The blob should have been uploaded by now.
|
|
496
|
-
const pendingEntry = this.pendingBlobs.get(localId);
|
|
497
511
|
assert(pendingEntry?.status === PendingBlobStatus.OfflinePendingOp &&
|
|
498
512
|
!!pendingEntry?.storageId, 0x38d /* blob must be uploaded before resubmitting BlobAttach op */);
|
|
499
513
|
return this.sendBlobAttachOp(localId, pendingEntry.storageId);
|
|
@@ -501,6 +515,31 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
|
|
|
501
515
|
return this.sendBlobAttachOp(localId, blobId);
|
|
502
516
|
}
|
|
503
517
|
|
|
518
|
+
private logTimeInfo(pendingEntry: PendingBlob, eventName: string) {
|
|
519
|
+
let timeLapseSinceLocalUpload: number = 0;
|
|
520
|
+
let timeLapseSinceServerUpload: number = 0;
|
|
521
|
+
let expiredUsingLocalTime;
|
|
522
|
+
let expiredUsingServerTime;
|
|
523
|
+
if(pendingEntry.localUploadTime){
|
|
524
|
+
timeLapseSinceLocalUpload = (Date.now() - pendingEntry.localUploadTime) / 1000;
|
|
525
|
+
expiredUsingLocalTime = (pendingEntry.minTTLInSeconds?? 0) - timeLapseSinceLocalUpload < 0 ? true : false;
|
|
526
|
+
}
|
|
527
|
+
if(pendingEntry.serverUploadTime){
|
|
528
|
+
timeLapseSinceServerUpload = (Date.now() - pendingEntry.serverUploadTime) / 1000;
|
|
529
|
+
expiredUsingServerTime = (pendingEntry.minTTLInSeconds?? 0) - timeLapseSinceServerUpload < 0 ? true : false;
|
|
530
|
+
}
|
|
531
|
+
this.mc.logger.sendTelemetryEvent({
|
|
532
|
+
eventName,
|
|
533
|
+
entryStatus: pendingEntry.status,
|
|
534
|
+
timeLapseSinceLocalUpload,
|
|
535
|
+
timeLapseSinceServerUpload,
|
|
536
|
+
minTTLInSeconds: pendingEntry.minTTLInSeconds,
|
|
537
|
+
expiredUsingLocalTime,
|
|
538
|
+
expiredUsingServerTime,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
}
|
|
542
|
+
|
|
504
543
|
public processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean) {
|
|
505
544
|
const localId = message.metadata?.localId;
|
|
506
545
|
const blobId = message.metadata?.blobId;
|
package/src/containerRuntime.ts
CHANGED
|
@@ -762,7 +762,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
762
762
|
if (loadSequenceNumberVerification === "log") {
|
|
763
763
|
logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
|
|
764
764
|
} else {
|
|
765
|
-
// Call both close and dispose as
|
|
765
|
+
// Call both close and dispose as closeFn implementation will no longer dispose runtime in future
|
|
766
766
|
context.closeFn(error);
|
|
767
767
|
context.disposeFn?.(error);
|
|
768
768
|
}
|
|
@@ -1198,6 +1198,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
|
|
|
1198
1198
|
(fromPath: string, toPath: string) => this.garbageCollector.addedOutboundReference(fromPath, toPath),
|
|
1199
1199
|
this,
|
|
1200
1200
|
pendingRuntimeState?.pendingAttachmentBlobs,
|
|
1201
|
+
() => this.getCurrentReferenceTimestampMs(),
|
|
1201
1202
|
);
|
|
1202
1203
|
|
|
1203
1204
|
this.scheduleManager = new ScheduleManager(
|
package/src/garbageCollection.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
IGarbageCollectionNodeData,
|
|
31
31
|
IGarbageCollectionSummaryDetailsLegacy,
|
|
32
32
|
ISummaryTreeWithStats,
|
|
33
|
+
gcDeletedBlobKey,
|
|
33
34
|
} from "@fluidframework/runtime-definitions";
|
|
34
35
|
import {
|
|
35
36
|
mergeStats,
|
|
@@ -172,6 +173,8 @@ export interface IGarbageCollector {
|
|
|
172
173
|
): void;
|
|
173
174
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
174
175
|
addedOutboundReference(fromNodePath: string, toNodePath: string): void;
|
|
176
|
+
/** Returns true if this node has been deleted by GC during sweep phase. */
|
|
177
|
+
isNodeDeleted(nodePath: string): boolean;
|
|
175
178
|
setConnectionState(connected: boolean, clientId?: string): void;
|
|
176
179
|
dispose(): void;
|
|
177
180
|
}
|
|
@@ -226,6 +229,7 @@ interface IUnreferencedEventProps {
|
|
|
226
229
|
interface IGCSummaryTrackingData {
|
|
227
230
|
serializedGCState: string | undefined;
|
|
228
231
|
serializedTombstones: string | undefined;
|
|
232
|
+
serializedDeletedNodes: string | undefined;
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
/**
|
|
@@ -419,7 +423,10 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
419
423
|
// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of
|
|
420
424
|
// outbound routes from that node.
|
|
421
425
|
private readonly newReferencesSinceLastRun: Map<string, string[]> = new Map();
|
|
426
|
+
// A list of nodes that have been tombstoned.
|
|
422
427
|
private tombstones: string[] = [];
|
|
428
|
+
// A list of nodes that have been deleted during sweep phase.
|
|
429
|
+
private deletedNodes: Set<string> = new Set();
|
|
423
430
|
|
|
424
431
|
/**
|
|
425
432
|
* Keeps track of the GC data from the latest summary successfully submitted to and acked from the server.
|
|
@@ -565,8 +572,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
565
572
|
// flag in GC options to false.
|
|
566
573
|
this.gcEnabled = this.gcOptions.gcAllowed !== false;
|
|
567
574
|
// The sweep phase has to be explicitly enabled by setting the sweepAllowed flag in GC options to true.
|
|
568
|
-
|
|
569
|
-
this.sweepEnabled = this.gcOptions.sweepAllowed === true || testOverrideSweepTimeoutMs !== undefined;
|
|
575
|
+
this.sweepEnabled = this.gcOptions.sweepAllowed === true;
|
|
570
576
|
|
|
571
577
|
// Set the Session Expiry only if the flag is enabled and GC is enabled.
|
|
572
578
|
if (this.mc.config.getBoolean(runSessionExpiryKey) && this.gcEnabled) {
|
|
@@ -640,8 +646,9 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
640
646
|
|
|
641
647
|
// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
|
|
642
648
|
this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? this.gcOptions.runGCInTestMode === true;
|
|
643
|
-
// Whether we are running in tombstone mode. This is
|
|
644
|
-
|
|
649
|
+
// Whether we are running in tombstone mode. This is enabled by default if sweep won't run. It can be disabled
|
|
650
|
+
// via feature flags.
|
|
651
|
+
this.tombstoneMode = !this.shouldRunSweep && this.mc.config.getBoolean(disableTombstoneKey) !== true;
|
|
645
652
|
|
|
646
653
|
// If GC ran in the container that generated the base snapshot, it will have a GC tree.
|
|
647
654
|
this.wasGCRunInLatestSummary = baseSnapshot?.trees[gcTreeKey] !== undefined;
|
|
@@ -704,7 +711,9 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
704
711
|
}
|
|
705
712
|
// If there is only one node (root node just added above), either GC is disabled or we are loading from
|
|
706
713
|
// the first summary generated by detached container. In both cases, GC was not run - return undefined.
|
|
707
|
-
return Object.keys(gcState.gcNodes).length === 1
|
|
714
|
+
return Object.keys(gcState.gcNodes).length === 1
|
|
715
|
+
? undefined
|
|
716
|
+
: { gcState, tombstones: undefined, deletedNodes: undefined };
|
|
708
717
|
} catch (error) {
|
|
709
718
|
const dpe = DataProcessingError.wrapIfUnrecognized(
|
|
710
719
|
error,
|
|
@@ -782,24 +791,33 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
782
791
|
}
|
|
783
792
|
|
|
784
793
|
/**
|
|
785
|
-
* Called during container initialization. Initialize the tombstone state
|
|
786
|
-
*
|
|
787
|
-
* in use or not.
|
|
794
|
+
* Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done
|
|
795
|
+
* during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.
|
|
788
796
|
*/
|
|
789
797
|
public async initializeBaseState(): Promise<void> {
|
|
790
798
|
const baseSnapshotData = await this.baseSnapshotDataP;
|
|
791
799
|
/**
|
|
792
|
-
* The base snapshot data
|
|
800
|
+
* The base snapshot data will not be present if the container is loaded from:
|
|
793
801
|
* 1. The first summary created by the detached container.
|
|
794
802
|
* 2. A summary that was generated with GC disabled.
|
|
795
803
|
* 3. A summary that was generated before GC even existed.
|
|
796
|
-
* 4. A summary that was generated with tombstone feature disabled.
|
|
797
804
|
*/
|
|
798
|
-
if (
|
|
805
|
+
if (baseSnapshotData === undefined) {
|
|
799
806
|
return;
|
|
800
807
|
}
|
|
801
|
-
|
|
802
|
-
|
|
808
|
+
|
|
809
|
+
// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not
|
|
810
|
+
// to identify deleted nodes' usage.
|
|
811
|
+
if (baseSnapshotData.deletedNodes !== undefined) {
|
|
812
|
+
this.deletedNodes = new Set(baseSnapshotData.deletedNodes);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of
|
|
816
|
+
// tombstone routes.
|
|
817
|
+
if (this.tombstoneMode && baseSnapshotData.tombstones !== undefined) {
|
|
818
|
+
this.tombstones = Array.from(baseSnapshotData.tombstones);
|
|
819
|
+
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
820
|
+
}
|
|
803
821
|
}
|
|
804
822
|
|
|
805
823
|
/**
|
|
@@ -831,9 +849,29 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
831
849
|
};
|
|
832
850
|
this.unreferencedNodesState.clear();
|
|
833
851
|
|
|
834
|
-
// If
|
|
835
|
-
//
|
|
836
|
-
|
|
852
|
+
// If running sweep, the tombstone state represents the list of nodes that have been deleted during sweep.
|
|
853
|
+
// If running in tombstone mode, the tombstone state represents the list of nodes that have been marked as
|
|
854
|
+
// tombstones.
|
|
855
|
+
// If this call is because we are refreshing from a snapshot due to an ack, it is likely that the GC state
|
|
856
|
+
// in the snapshot is newer than this client's. And so, the deleted / tombstone nodes need to be updated.
|
|
857
|
+
if (this.shouldRunSweep) {
|
|
858
|
+
const snapshotDeletedNodes = snapshotData?.tombstones ? new Set(snapshotData.tombstones) : undefined;
|
|
859
|
+
// If the snapshot contains deleted nodes that are not yet deleted by this client, ask the runtime to
|
|
860
|
+
// delete them.
|
|
861
|
+
if (snapshotDeletedNodes !== undefined) {
|
|
862
|
+
const newDeletedNodes: string[] = [];
|
|
863
|
+
for (const nodeId of snapshotDeletedNodes) {
|
|
864
|
+
if (!this.deletedNodes.has(nodeId)) {
|
|
865
|
+
newDeletedNodes.push(nodeId);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (newDeletedNodes.length > 0) {
|
|
869
|
+
// Call container runtime to delete these nodes and add deleted nodes to this.deletedNodes.
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
} else if (this.tombstoneMode) {
|
|
873
|
+
// The snapshot may contain more or fewer tombstone nodes than this client. Update tombstone state and
|
|
874
|
+
// notify the runtime to update its state as well.
|
|
837
875
|
this.tombstones = snapshotData?.tombstones ? Array.from(snapshotData.tombstones) : [];
|
|
838
876
|
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
839
877
|
}
|
|
@@ -869,6 +907,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
869
907
|
this.latestSummaryData = {
|
|
870
908
|
serializedGCState: JSON.stringify(generateSortedGCState(snapshotData.gcState)),
|
|
871
909
|
serializedTombstones: JSON.stringify(snapshotData.tombstones),
|
|
910
|
+
serializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),
|
|
872
911
|
};
|
|
873
912
|
}
|
|
874
913
|
}
|
|
@@ -1020,18 +1059,26 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
1020
1059
|
}
|
|
1021
1060
|
|
|
1022
1061
|
const serializedGCState = JSON.stringify(generateSortedGCState(gcState));
|
|
1062
|
+
// Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so
|
|
1063
|
+
// to identify deleted nodes' usage.
|
|
1064
|
+
const serializedDeletedNodes = this.deletedNodes.size > 0
|
|
1065
|
+
? JSON.stringify(Array.from(this.deletedNodes).sort())
|
|
1066
|
+
: undefined;
|
|
1067
|
+
// If running in tombstone mode, serialize and write tombstones, if any.
|
|
1023
1068
|
const serializedTombstones = this.tombstoneMode
|
|
1024
1069
|
? (this.tombstones.length > 0 ? JSON.stringify(this.tombstones.sort()) : undefined)
|
|
1025
1070
|
: undefined;
|
|
1026
1071
|
|
|
1027
1072
|
/**
|
|
1028
|
-
* Incremental summary of GC data - If
|
|
1029
|
-
*
|
|
1073
|
+
* Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,
|
|
1074
|
+
* write summary handle instead of summary tree for GC.
|
|
1075
|
+
* Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and
|
|
1076
|
+
* for each of these that did not change, write a summary handle.
|
|
1030
1077
|
*/
|
|
1031
1078
|
if (this.trackGCState) {
|
|
1032
|
-
this.pendingSummaryData = { serializedGCState, serializedTombstones };
|
|
1079
|
+
this.pendingSummaryData = { serializedGCState, serializedTombstones, serializedDeletedNodes };
|
|
1033
1080
|
if (trackState && !fullTree && this.latestSummaryData !== undefined) {
|
|
1034
|
-
// If
|
|
1081
|
+
// If nothing changed since last summary, send a summary handle for the entire GC data.
|
|
1035
1082
|
if (this.latestSummaryData.serializedGCState === serializedGCState
|
|
1036
1083
|
&& this.latestSummaryData.serializedTombstones === serializedTombstones) {
|
|
1037
1084
|
const stats = mergeStats();
|
|
@@ -1046,26 +1093,30 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
1046
1093
|
};
|
|
1047
1094
|
}
|
|
1048
1095
|
|
|
1049
|
-
// If
|
|
1050
|
-
return this.buildGCSummaryTree(
|
|
1096
|
+
// If some state changed, build a GC summary tree.
|
|
1097
|
+
return this.buildGCSummaryTree(
|
|
1098
|
+
serializedGCState, serializedTombstones, serializedDeletedNodes, true /* trackState */);
|
|
1051
1099
|
}
|
|
1052
1100
|
}
|
|
1053
1101
|
// If not tracking GC state, build a GC summary tree without any summary handles.
|
|
1054
|
-
return this.buildGCSummaryTree(
|
|
1102
|
+
return this.buildGCSummaryTree(
|
|
1103
|
+
serializedGCState, serializedTombstones, serializedDeletedNodes, false /* trackState */);
|
|
1055
1104
|
}
|
|
1056
1105
|
|
|
1057
1106
|
/**
|
|
1058
|
-
* Builds the GC summary tree which contains GC state and
|
|
1059
|
-
* If trackState is false,
|
|
1060
|
-
* If trackState is true,
|
|
1107
|
+
* Builds the GC summary tree which contains GC state, deleted nodes and tombstones.
|
|
1108
|
+
* If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.
|
|
1109
|
+
* If trackState is true, only states that changed are written. Rest are written as handles.
|
|
1061
1110
|
* @param serializedGCState - The GC state serialized as string.
|
|
1062
|
-
* @param serializedTombstones -
|
|
1111
|
+
* @param serializedTombstones - The tombstone state serialized as string.
|
|
1112
|
+
* @param serializedDeletedNodes - Deleted nodes serialized as string.
|
|
1063
1113
|
* @param trackState - Whether we are tracking GC state across summaries.
|
|
1064
1114
|
* @returns the GC summary tree.
|
|
1065
1115
|
*/
|
|
1066
1116
|
private buildGCSummaryTree(
|
|
1067
1117
|
serializedGCState: string,
|
|
1068
1118
|
serializedTombstones: string | undefined,
|
|
1119
|
+
serializedDeletedNodes: string | undefined,
|
|
1069
1120
|
trackState: boolean,
|
|
1070
1121
|
): ISummaryTreeWithStats {
|
|
1071
1122
|
const gcStateBlobKey = `${gcBlobPrefix}_root`;
|
|
@@ -1078,16 +1129,26 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
1078
1129
|
builder.addBlob(gcStateBlobKey, serializedGCState);
|
|
1079
1130
|
}
|
|
1080
1131
|
|
|
1081
|
-
// If
|
|
1082
|
-
|
|
1132
|
+
// If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a
|
|
1133
|
+
// summary blob.
|
|
1134
|
+
if (serializedTombstones !== undefined) {
|
|
1135
|
+
if (this.latestSummaryData?.serializedTombstones === serializedTombstones && trackState) {
|
|
1136
|
+
builder.addHandle(gcTombstoneBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcTombstoneBlobKey}`);
|
|
1137
|
+
} else {
|
|
1138
|
+
builder.addBlob(gcTombstoneBlobKey, serializedTombstones);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
// If there are no deleted nodes, return the summary tree.
|
|
1143
|
+
if (serializedDeletedNodes === undefined) {
|
|
1083
1144
|
return builder.getSummaryTree();
|
|
1084
1145
|
}
|
|
1085
1146
|
|
|
1086
|
-
// If the
|
|
1087
|
-
if (this.latestSummaryData?.
|
|
1088
|
-
builder.addHandle(
|
|
1147
|
+
// If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.
|
|
1148
|
+
if (this.latestSummaryData?.serializedDeletedNodes === serializedDeletedNodes && trackState) {
|
|
1149
|
+
builder.addHandle(gcDeletedBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcDeletedBlobKey}`);
|
|
1089
1150
|
} else {
|
|
1090
|
-
builder.addBlob(
|
|
1151
|
+
builder.addBlob(gcDeletedBlobKey, serializedDeletedNodes);
|
|
1091
1152
|
}
|
|
1092
1153
|
return builder.getSummaryTree();
|
|
1093
1154
|
}
|
|
@@ -1257,6 +1318,14 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
1257
1318
|
}
|
|
1258
1319
|
}
|
|
1259
1320
|
|
|
1321
|
+
/**
|
|
1322
|
+
* Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
|
|
1323
|
+
* cases where objects are used after they are deleted and throw / log errors accordingly.
|
|
1324
|
+
*/
|
|
1325
|
+
public isNodeDeleted(nodePath: string): boolean {
|
|
1326
|
+
return this.deletedNodes.has(nodePath);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1260
1329
|
public dispose(): void {
|
|
1261
1330
|
this.sessionExpiryTimer?.clear();
|
|
1262
1331
|
this.sessionExpiryTimer = undefined;
|
|
@@ -1640,7 +1709,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
1640
1709
|
}
|
|
1641
1710
|
}
|
|
1642
1711
|
|
|
1643
|
-
// If SweepReady Usage Detection is
|
|
1712
|
+
// If SweepReady Usage Detection is enabled, the handler may close the interactive container.
|
|
1644
1713
|
// Once Sweep is fully implemented, this will be removed since the objects will be gone
|
|
1645
1714
|
// and errors will arise elsewhere in the runtime
|
|
1646
1715
|
if (state === UnreferencedState.SweepReady) {
|