@fluidframework/container-runtime 2.0.0-internal.2.3.1 → 2.0.0-internal.2.4.1

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.
@@ -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,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAW,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACH,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,eAAe,GAClB,MAAM,iCAAiC,CAAC;AASzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAIhD,YACI,YAAoB,EACX,SAAkB,KAAK;QAEhC,KAAK,CAAC,YAAY,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAAiB;QAL3B,cAAS,GAAG,gBAAgB,CAAC;QAC7B,aAAQ,GAAG,IAAI,CAAC;IAOzB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAU,EAAE,SAAkB,KAAK,EAAE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AE,KAAK,CAAC,CAAC;qBACb;yBAAM;wBACH,MAAM,KAAK,CAAC;qBACf;gBACL,CAAC,CAAC,CACL,CAAC;aACL;YAAC,OAAO,KAAK,EAAE;gBACZ,aAAa,CAAC,cAAc,CAAC;oBACzB,SAAS,EAAE,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"]}
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,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAW,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACH,WAAW,EAEX,YAAY,EACZ,YAAY,EACZ,eAAe,GAClB,MAAM,iCAAiC,CAAC;AASzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAIhD,YACI,YAAoB,EACX,SAAkB,KAAK;QAEhC,KAAK,CAAC,YAAY,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAAiB;QAL3B,cAAS,GAAG,g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,SAAS,EAAE,8BAA8B;4BACzC,uBAAuB,EAAE,iBAAiB;4BAC1C,cAAc,EAAE,eAAe;4BAC/B,SAAS,EAAE,gBAAgB;yBAC9B,EAAE,KAAK,CAAC,CAAC;qBACb;yBAAM;wBACH,MAAM,KAAK,CAAC;qBACf;gBACL,CAAC,CAAC,CACL,CAAC;aACL;YAAC,OAAO,KAAK,EAAE;gBACZ,aAAa,CAAC,cAAc,CAAC;oBACzB,SAAS,EAAE,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.1",
3
+ "version": "2.0.0-internal.2.4.1",
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.3.1 <2.0.0-internal.3.0.0",
69
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
70
- "@fluidframework/container-utils": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
71
- "@fluidframework/core-interfaces": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
72
- "@fluidframework/datastore": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
73
- "@fluidframework/driver-definitions": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
74
- "@fluidframework/driver-utils": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
75
- "@fluidframework/garbage-collector": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
68
+ "@fluidframework/container-definitions": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
69
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
70
+ "@fluidframework/container-utils": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
71
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
72
+ "@fluidframework/datastore": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
73
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
74
+ "@fluidframework/driver-utils": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
75
+ "@fluidframework/garbage-collector": ">=2.0.0-internal.2.4.1 <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.3.1 <2.0.0-internal.3.0.0",
79
- "@fluidframework/runtime-utils": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
80
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
78
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
79
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
80
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.2.4.1 <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.7.0",
87
+ "@fluid-tools/build-cli": "^0.8.0",
88
88
  "@fluidframework/build-common": "^1.1.0",
89
- "@fluidframework/build-tools": "^0.7.0",
90
- "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.3.0",
89
+ "@fluidframework/build-tools": "^0.8.0",
90
+ "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.2.4.0",
91
91
  "@fluidframework/eslint-config-fluid": "^2.0.0",
92
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
93
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.3.1 <2.0.0-internal.3.0.0",
92
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.2.4.1 <2.0.0-internal.3.0.0",
93
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.2.4.1 <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,9 @@
109
109
  "typescript": "~4.5.5"
110
110
  },
111
111
  "typeValidation": {
112
- "version": "2.0.0-internal.2.3.1",
113
- "baselineRange": "2.0.0-internal.2.3.0",
112
+ "version": "2.0.0-internal.2.4.0",
113
+ "previousVersionStyle": "previousPatch",
114
+ "baselineRange": "2.0.0-internal.2.4.0",
114
115
  "broken": {}
115
116
  }
116
117
  }
@@ -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: ICreateBlobResponse) {
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;
@@ -94,6 +94,7 @@ import {
94
94
  addSummarizeResultToSummary,
95
95
  addTreeToSummary,
96
96
  createRootSummarizerNodeWithGC,
97
+ IFetchSnapshotResult,
97
98
  IRootSummarizerNodeWithGC,
98
99
  RequestParser,
99
100
  create404Response,
@@ -103,6 +104,7 @@ import {
103
104
  seqFromTree,
104
105
  calculateStats,
105
106
  TelemetryContext,
107
+ ReadAndParseBlob,
106
108
  } from "@fluidframework/runtime-utils";
107
109
  import { GCDataBuilder, trimLeadingAndTrailingSlashes } from "@fluidframework/garbage-collector";
108
110
  import { v4 as uuid } from "uuid";
@@ -762,7 +764,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
762
764
  if (loadSequenceNumberVerification === "log") {
763
765
  logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
764
766
  } else {
765
- // Call both close and dispose as close implementation will no longer dispose runtime in future (2.0.0-internal.3.0.0)
767
+ // Call both close and dispose as closeFn implementation will no longer dispose runtime in future
766
768
  context.closeFn(error);
767
769
  context.disposeFn?.(error);
768
770
  }
@@ -1198,6 +1200,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
1198
1200
  (fromPath: string, toPath: string) => this.garbageCollector.addedOutboundReference(fromPath, toPath),
1199
1201
  this,
1200
1202
  pendingRuntimeState?.pendingAttachmentBlobs,
1203
+ () => this.getCurrentReferenceTimestampMs(),
1201
1204
  );
1202
1205
 
1203
1206
  this.scheduleManager = new ScheduleManager(
@@ -2801,18 +2804,17 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
2801
2804
  // The call to fetch the snapshot is very expensive and not always needed.
2802
2805
  // It should only be done by the summarizerNode, if required.
2803
2806
  // When fetching from storage we will always get the latest version and do not use the ackHandle.
2804
- const snapshotTreeFetcher = async () => {
2807
+ const fetchLatestSnapshot: () => Promise<IFetchSnapshotResult> = async () => {
2805
2808
  const fetchResult = await this.fetchLatestSnapshotFromStorage(
2806
2809
  summaryLogger,
2807
2810
  {
2808
- eventName: "RefreshLatestSummaryGetSnapshot",
2811
+ eventName: "RefreshLatestSummaryAckFetch",
2809
2812
  ackHandle,
2810
- summaryRefSeq,
2811
- fetchLatest: true,
2813
+ targetSequenceNumber: summaryRefSeq,
2812
2814
  },
2815
+ readAndParseBlob,
2813
2816
  );
2814
2817
 
2815
- const latestSnapshotRefSeq = await seqFromTree(fetchResult.snapshotTree, readAndParseBlob);
2816
2818
  /**
2817
2819
  * If the fetched snapshot is older than the one for which the ack was received, close the container.
2818
2820
  * This should never happen because an ack should be sent after the latest summary is updated in the server.
@@ -2823,7 +2825,7 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
2823
2825
  * such cases, the file will be rolled back along with the ack and we will eventually reach a consistent
2824
2826
  * state.
2825
2827
  */
2826
- if (latestSnapshotRefSeq < summaryRefSeq) {
2828
+ if (fetchResult.latestSnapshotRefSeq < summaryRefSeq) {
2827
2829
  const error = DataProcessingError.create(
2828
2830
  "Fetched snapshot is older than the received ack",
2829
2831
  "RefreshLatestSummaryAck",
@@ -2831,44 +2833,36 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
2831
2833
  {
2832
2834
  ackHandle,
2833
2835
  summaryRefSeq,
2834
- latestSnapshotRefSeq,
2836
+ latestSnapshotRefSeq: fetchResult.latestSnapshotRefSeq,
2835
2837
  },
2836
2838
  );
2837
2839
  this.closeFn(error);
2838
2840
  throw error;
2839
2841
  }
2840
2842
 
2841
- summaryLogger.sendTelemetryEvent(
2842
- {
2843
- eventName: "LatestSummaryRetrieved",
2844
- ackHandle,
2845
- lastSequenceNumber: latestSnapshotRefSeq,
2846
- targetSequenceNumber: summaryRefSeq,
2847
- });
2848
-
2849
2843
  // In case we had to retrieve the latest snapshot and it is different than summaryRefSeq,
2850
2844
  // wait for the delta manager to catch up before refreshing the latest Summary.
2851
- await this.waitForDeltaManagerToCatchup(latestSnapshotRefSeq,
2852
- summaryLogger);
2845
+ await this.waitForDeltaManagerToCatchup(
2846
+ fetchResult.latestSnapshotRefSeq,
2847
+ summaryLogger,
2848
+ );
2853
2849
 
2854
- return fetchResult.snapshotTree;
2850
+ return {
2851
+ snapshotTree: fetchResult.snapshotTree,
2852
+ snapshotRefSeq: fetchResult.latestSnapshotRefSeq,
2853
+ };
2855
2854
  };
2856
2855
 
2857
2856
  const result = await this.summarizerNode.refreshLatestSummary(
2858
2857
  proposalHandle,
2859
2858
  summaryRefSeq,
2860
- snapshotTreeFetcher,
2859
+ fetchLatestSnapshot,
2861
2860
  readAndParseBlob,
2862
2861
  summaryLogger,
2863
2862
  );
2864
2863
 
2865
2864
  // Notify the garbage collector so it can update its latest summary state.
2866
- await this.garbageCollector.refreshLatestSummary(
2867
- result,
2868
- proposalHandle,
2869
- summaryRefSeq,
2870
- readAndParseBlob,
2871
- );
2865
+ await this.garbageCollector.refreshLatestSummary(proposalHandle, result, readAndParseBlob);
2872
2866
  }
2873
2867
 
2874
2868
  /**
@@ -2880,30 +2874,31 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
2880
2874
  private async refreshLatestSummaryAckFromServer(
2881
2875
  summaryLogger: ITelemetryLogger,
2882
2876
  ): Promise<{ latestSnapshotRefSeq: number; latestSnapshotVersionId: string | undefined; }> {
2883
- const { snapshotTree, versionId } = await this.fetchLatestSnapshotFromStorage(
2884
- summaryLogger,
2885
- {
2886
- eventName: "RefreshLatestSummaryGetSnapshot",
2887
- fetchLatest: true,
2888
- },
2889
- );
2890
-
2891
2877
  const readAndParseBlob = async <T>(id: string) => readAndParse<T>(this.storage, id);
2892
- const latestSnapshotRefSeq = await seqFromTree(snapshotTree, readAndParseBlob);
2893
-
2878
+ const { snapshotTree, versionId, latestSnapshotRefSeq } =
2879
+ await this.fetchLatestSnapshotFromStorage(
2880
+ summaryLogger,
2881
+ {
2882
+ eventName: "RefreshLatestSummaryFromServerFetch",
2883
+ },
2884
+ readAndParseBlob,
2885
+ );
2886
+ const fetchLatestSnapshot: IFetchSnapshotResult = {
2887
+ snapshotTree,
2888
+ snapshotRefSeq: latestSnapshotRefSeq,
2889
+ };
2894
2890
  const result = await this.summarizerNode.refreshLatestSummary(
2895
- undefined,
2891
+ undefined /* proposalHandle */,
2896
2892
  latestSnapshotRefSeq,
2897
- async () => snapshotTree,
2893
+ async () => fetchLatestSnapshot,
2898
2894
  readAndParseBlob,
2899
2895
  summaryLogger,
2900
2896
  );
2901
2897
 
2902
2898
  // Notify the garbage collector so it can update its latest summary state.
2903
2899
  await this.garbageCollector.refreshLatestSummary(
2900
+ undefined /* proposalHandle */,
2904
2901
  result,
2905
- undefined,
2906
- latestSnapshotRefSeq,
2907
2902
  readAndParseBlob,
2908
2903
  )
2909
2904
 
@@ -2913,29 +2908,54 @@ export class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>
2913
2908
  private async fetchLatestSnapshotFromStorage(
2914
2909
  logger: ITelemetryLogger,
2915
2910
  event: ITelemetryGenericEvent,
2916
- ): Promise<{ snapshotTree: ISnapshotTree; versionId: string; }> {
2911
+ readAndParseBlob: ReadAndParseBlob,
2912
+ ): Promise<{ snapshotTree: ISnapshotTree; versionId: string; latestSnapshotRefSeq: number }> {
2917
2913
  return PerformanceEvent.timedExecAsync(
2918
- logger, event, async (perfEvent: {
2914
+ logger,
2915
+ event,
2916
+ async (perfEvent: {
2919
2917
  end: (arg0: {
2920
2918
  getVersionDuration?: number | undefined;
2921
2919
  getSnapshotDuration?: number | undefined;
2920
+ snapshotRefSeq?: number | undefined;
2921
+ snapshotVersion?: string | undefined;
2922
2922
  }) => void;
2923
2923
  }) => {
2924
- const stats: { getVersionDuration?: number; getSnapshotDuration?: number; } = {};
2924
+ const stats: {
2925
+ getVersionDuration?: number;
2926
+ getSnapshotDuration?: number;
2927
+ snapshotRefSeq?: number;
2928
+ snapshotVersion?: string;
2929
+ } = {};
2925
2930
  const trace = Trace.start();
2926
2931
 
2927
2932
  const versions = await this.storage.getVersions(
2928
- null, 1, "refreshLatestSummaryAckFromServer", FetchSource.noCache);
2929
- assert(!!versions && !!versions[0], 0x137 /* "Failed to get version from storage" */);
2933
+ null,
2934
+ 1,
2935
+ "refreshLatestSummaryAckFromServer",
2936
+ FetchSource.noCache,
2937
+ );
2938
+ assert(
2939
+ !!versions && !!versions[0],
2940
+ 0x137 /* "Failed to get version from storage" */,
2941
+ );
2930
2942
  stats.getVersionDuration = trace.trace().duration;
2931
2943
 
2932
2944
  const maybeSnapshot = await this.storage.getSnapshotTree(versions[0]);
2933
2945
  assert(!!maybeSnapshot, 0x138 /* "Failed to get snapshot from storage" */);
2934
2946
  stats.getSnapshotDuration = trace.trace().duration;
2947
+ const latestSnapshotRefSeq = await seqFromTree(maybeSnapshot, readAndParseBlob);
2948
+ stats.snapshotRefSeq = latestSnapshotRefSeq;
2949
+ stats.snapshotVersion = versions[0].id;
2935
2950
 
2936
2951
  perfEvent.end(stats);
2937
- return { snapshotTree: maybeSnapshot, versionId: versions[0].id };
2938
- });
2952
+ return {
2953
+ snapshotTree: maybeSnapshot,
2954
+ versionId: versions[0].id,
2955
+ latestSnapshotRefSeq,
2956
+ };
2957
+ },
2958
+ );
2939
2959
  }
2940
2960
 
2941
2961
  public notifyAttaching(snapshot: ISnapshotTreeWithBlobContents) {