@fluidframework/container-runtime 2.74.0-370705 → 2.80.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/CHANGELOG.md +8 -0
- package/container-runtime.test-files.tar +0 -0
- package/dist/blobManager/blobManager.d.ts +0 -2
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +4 -5
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/channelCollection.d.ts +3 -3
- package/dist/channelCollection.d.ts.map +1 -1
- package/dist/channelCollection.js +20 -2
- package/dist/channelCollection.js.map +1 -1
- package/dist/containerRuntime.d.ts +5 -0
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +13 -7
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +1 -1
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts +56 -9
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +56 -9
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runtimeLayerCompatState.d.ts +10 -6
- package/dist/runtimeLayerCompatState.d.ts.map +1 -1
- package/dist/runtimeLayerCompatState.js +16 -6
- package/dist/runtimeLayerCompatState.js.map +1 -1
- package/dist/summary/summarizerClientElection.d.ts.map +1 -1
- package/dist/summary/summarizerClientElection.js +1 -0
- package/dist/summary/summarizerClientElection.js.map +1 -1
- package/dist/summary/summarizerTypes.d.ts +5 -0
- package/dist/summary/summarizerTypes.d.ts.map +1 -1
- package/dist/summary/summarizerTypes.js.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/runningSummarizer.d.ts +3 -1
- package/dist/summary/summaryDelayLoadedModule/runningSummarizer.d.ts.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/runningSummarizer.js +39 -18
- package/dist/summary/summaryDelayLoadedModule/runningSummarizer.js.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/summarizer.d.ts +1 -1
- package/dist/summary/summaryDelayLoadedModule/summarizer.d.ts.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/summarizer.js +13 -11
- package/dist/summary/summaryDelayLoadedModule/summarizer.js.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/summaryGenerator.d.ts +4 -1
- package/dist/summary/summaryDelayLoadedModule/summaryGenerator.d.ts.map +1 -1
- package/dist/summary/summaryDelayLoadedModule/summaryGenerator.js +30 -9
- package/dist/summary/summaryDelayLoadedModule/summaryGenerator.js.map +1 -1
- package/dist/summary/summaryManager.d.ts +1 -1
- package/dist/summary/summaryManager.d.ts.map +1 -1
- package/dist/summary/summaryManager.js +10 -9
- package/dist/summary/summaryManager.js.map +1 -1
- package/eslint.config.mts +31 -0
- package/lib/blobManager/blobManager.d.ts +0 -2
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +4 -5
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/channelCollection.d.ts +3 -3
- package/lib/channelCollection.d.ts.map +1 -1
- package/lib/channelCollection.js +20 -2
- package/lib/channelCollection.js.map +1 -1
- package/lib/containerRuntime.d.ts +5 -0
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +13 -7
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +1 -1
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts +56 -9
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +56 -9
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runtimeLayerCompatState.d.ts +10 -6
- package/lib/runtimeLayerCompatState.d.ts.map +1 -1
- package/lib/runtimeLayerCompatState.js +15 -5
- package/lib/runtimeLayerCompatState.js.map +1 -1
- package/lib/summary/summarizerClientElection.d.ts.map +1 -1
- package/lib/summary/summarizerClientElection.js +1 -0
- package/lib/summary/summarizerClientElection.js.map +1 -1
- package/lib/summary/summarizerTypes.d.ts +5 -0
- package/lib/summary/summarizerTypes.d.ts.map +1 -1
- package/lib/summary/summarizerTypes.js.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/runningSummarizer.d.ts +3 -1
- package/lib/summary/summaryDelayLoadedModule/runningSummarizer.d.ts.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/runningSummarizer.js +39 -18
- package/lib/summary/summaryDelayLoadedModule/runningSummarizer.js.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/summarizer.d.ts +1 -1
- package/lib/summary/summaryDelayLoadedModule/summarizer.d.ts.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/summarizer.js +13 -11
- package/lib/summary/summaryDelayLoadedModule/summarizer.js.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/summaryGenerator.d.ts +4 -1
- package/lib/summary/summaryDelayLoadedModule/summaryGenerator.d.ts.map +1 -1
- package/lib/summary/summaryDelayLoadedModule/summaryGenerator.js +26 -5
- package/lib/summary/summaryDelayLoadedModule/summaryGenerator.js.map +1 -1
- package/lib/summary/summaryManager.d.ts +1 -1
- package/lib/summary/summaryManager.d.ts.map +1 -1
- package/lib/summary/summaryManager.js +10 -9
- package/lib/summary/summaryManager.js.map +1 -1
- package/package.json +27 -26
- package/src/blobManager/blobManager.ts +3 -7
- package/src/channelCollection.ts +29 -5
- package/src/containerRuntime.ts +19 -6
- package/src/dataStoreContext.ts +2 -2
- package/src/dataStoreContexts.ts +56 -9
- package/src/packageVersion.ts +1 -1
- package/src/runtimeLayerCompatState.ts +25 -9
- package/src/summary/summarizerClientElection.ts +1 -0
- package/src/summary/summarizerTypes.ts +5 -0
- package/src/summary/summaryDelayLoadedModule/runningSummarizer.ts +54 -26
- package/src/summary/summaryDelayLoadedModule/summarizer.ts +13 -11
- package/src/summary/summaryDelayLoadedModule/summaryGenerator.ts +35 -5
- package/src/summary/summaryManager.ts +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/runningSummarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAQjE,kEAA4F;AAC5F,0EAIqD;AACrD,uEAOkD;AAElD,2DAA+C;AAiB/C,8DAA+F;AAO/F,mDAA0F;AAC1F,uEAAqE;AACrE,+DAAyD;AACzD,uEAAmE;AAGnE,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D;;;;;;GAMG;AACH,MAAa,iBACZ,SAAQ,gCAAoC;IAGrC,MAAM,CAAC,KAAK,CAAC,KAAK,CACxB,MAA4B,EAC5B,cAAqC,EACrC,aAAoC,EAEpC,qBAAuF,EAEvF,+BAAsF,EACtF,aAAsC,EACtC,iBAAoC,EAEpC,iBAA4C,EAC5C,sBAA8D,EAE9D,OAA2B;QAE3B,MAAM,UAAU,GAAG,IAAI,iBAAiB,CACvC,MAAM,EACN,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,+BAA+B,EAC/B,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,OAAO,CACP,CAAC;QAEF,wGAAwG;QACxG,yEAAyE;QACzE,yGAAyG;QACzG,0GAA0G;QAC1G,qDAAqD;QACrD,IAAI,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC,qBAAqB,GAAG,CAAC,CAAC;QACjF,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;QAC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9B,OAAO,KAAK,CAAC;QACd,CAAC;QACD,IACC,IAAI,CAAC,eAAe,KAAK,SAAS;YAClC,IAAI,CAAC,aAAa,CAAC,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB;YAClF,IAAI,CAAC,eAAe,KAAK,SAAS,EACjC,CAAC;YACF,uFAAuF;YACvF,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAC1E,+FAA+F;QAC/F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,gBAAgB,CACpB,EAAE,eAAe,EAAE,mBAAmB,MAAM,EAAE,EAAE,EAChD,gBAAgB,EAChB,cAAc,CACd,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IAEO,sBAAsB;QAC7B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,IAAI,0CAAqB,CAAC,uCAAuC,CAAC,CAClE,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAClC,CAAC;IACF,CAAC;CACD;AA37BD,8CA27BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizeEventProps,\n\tISummarizerEvents,\n\tISummarizerObservabilityProps,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred, PromiseTimer, delay } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverErrorTypes,\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype MonitoringContext,\n\tUsageError,\n\tcreateChildLogger,\n\tcreateChildMonitoringContext,\n\tisFluidError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { opSize } from \"../../opProperties.js\";\nimport type {\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tIRefreshSummaryAckOptions,\n\tIRetriableFailureError,\n\tISubmitSummaryOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tISummarizeOptions,\n\tISummarizerRuntime,\n\tISummarizeRunnerTelemetry,\n\tISummarizeTelemetryProperties,\n\tISummaryCancellationToken,\n\tISummaryConfiguration,\n\tSubmitSummaryResult,\n} from \"../summarizerTypes.js\";\nimport { raceTimer, RetriableSummaryError, type SummarizeReason } from \"../summarizerUtils.js\";\nimport type {\n\tIAckedSummary,\n\tIClientSummaryWatcher,\n\tSummaryCollection,\n} from \"../summaryCollection.js\";\n\nimport { defaultMaxAttempts, defaultMaxAttemptsForSubmitFailures } from \"./summarizer.js\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics.js\";\nimport { SummaryGenerator } from \"./summaryGenerator.js\";\nimport { SummarizeResultBuilder } from \"./summaryResultBuilder.js\";\nimport type { EnqueueSummarizeResult, ISummarizeResults } from \"./summaryResultTypes.js\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\n\t\truntime: ISummarizerRuntime,\n\t): Promise<RunningSummarizer> {\n\t\tconst summarizer = new RunningSummarizer(\n\t\t\tlogger,\n\t\t\tsummaryWatcher,\n\t\t\tconfiguration,\n\t\t\tsubmitSummaryCallback,\n\t\t\trefreshLatestSummaryAckCallback,\n\t\t\theuristicData,\n\t\t\tsummaryCollection,\n\t\t\tcancellationToken,\n\t\t\tstopSummarizerCallback,\n\t\t\truntime,\n\t\t);\n\n\t\t// If there have been any acks newer that the one this client loaded from until now, process them before\n\t\t// starting the running summarizer which will trigger summary heuristics.\n\t\t// This is done primarily to handle scenarios where the summarizer loads from a cached snapshot and there\n\t\t// is newer one available. The ack for the newer summary is processed before summarizing because otherwise\n\t\t// that summary would fail as it has an older parent.\n\t\tlet nextReferenceSequenceNumber = runtime.deltaManager.initialSequenceNumber + 1;\n\t\tconst latestAck = summaryCollection.latestAck;\n\t\tif (\n\t\t\tlatestAck !== undefined &&\n\t\t\tlatestAck.summaryOp.referenceSequenceNumber >= nextReferenceSequenceNumber\n\t\t) {\n\t\t\tawait summarizer.handleSummaryAck(latestAck);\n\t\t\tnextReferenceSequenceNumber = latestAck.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Process summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(nextReferenceSequenceNumber).catch((error) => {\n\t\t\tcreateChildLogger({ logger }).sendErrorEvent(\n\t\t\t\t{ eventName: \"HandleSummaryAckFatalError\" },\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\t// Update heuristic counts\n\t\t// By the time we get here, there are potentially ops missing from the heuristic summary counts\n\t\t// Examples of where this could happen:\n\t\t// 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n\t\t// listen for the op events (will get missed by the handlers in the current workflow)\n\t\t// 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n\t\tconst diff =\n\t\t\truntime.deltaManager.lastSequenceNumber -\n\t\t\t(heuristicData.lastSuccessfulSummary.refSequenceNumber +\n\t\t\t\theuristicData.numNonRuntimeOps +\n\t\t\t\theuristicData.numRuntimeOps);\n\t\theuristicData.hasMissingOpData = diff > 0;\n\n\t\tif (heuristicData.hasMissingOpData) {\n\t\t\t// Split the diff 50-50 and increment the counts appropriately\n\t\t\theuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n\t\t\theuristicData.numRuntimeOps += Math.floor(diff / 2);\n\t\t}\n\n\t\t// Update last seq number (in case the handlers haven't processed anything yet)\n\t\theuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n\t\t// Start heuristics\n\t\tsummarizer.heuristicRunner?.start();\n\t\tsummarizer.heuristicRunner?.run();\n\n\t\treturn summarizer;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\tprivate stopping = false;\n\tprivate _disposed = false;\n\tprivate summarizingLock: Promise<void> | undefined;\n\tprivate tryWhileSummarizing = false;\n\tprivate readonly pendingAckTimer: PromiseTimer;\n\tprivate heuristicRunner?: ISummarizeHeuristicRunner;\n\tprivate readonly generator: SummaryGenerator;\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate enqueuedSummary:\n\t\t| {\n\t\t\t\treason: SummarizeReason;\n\t\t\t\tafterSequenceNumber: number;\n\t\t\t\tsummarizeOptions: ISummarizeOptions;\n\t\t\t\treadonly resultsBuilder: SummarizeResultBuilder;\n\t\t }\n\t\t| undefined;\n\tprivate summarizeCount = 0;\n\tprivate totalSuccessfulAttempts = 0;\n\tprivate initialized = false;\n\n\tprivate readonly runtimeListener: (\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage?: boolean,\n\t) => void;\n\n\t/**\n\t * The maximum number of summary attempts to do when submit summary fails.\n\t */\n\tprivate readonly maxAttemptsForSubmitFailures: number;\n\n\t/**\n\t * These are necessary to store outside of methods because of the logic around runnning a lastSummary.\n\t * We want the lastSummary to also be captured as \"all attempts failed\".\n\t */\n\tprivate lastSummarizeFailureEventProps: Omit<ISummarizeEventProps, \"result\"> | undefined =\n\t\tundefined;\n\n\tprivate constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summaryWatcher: IClientSummaryWatcher,\n\t\tprivate readonly configuration: ISummaryConfiguration,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly refreshLatestSummaryAckCallback: (\n\t\t\toptions: IRefreshSummaryAckOptions,\n\t\t) => Promise<void>,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\n\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\n\t\tsuper();\n\n\t\tconst telemetryProps: ISummarizeRunnerTelemetry = {\n\t\t\tsummarizeCount: () => this.summarizeCount,\n\t\t\tsummarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: baseLogger,\n\t\t\tnamespace: \"Running\",\n\t\t\tproperties: {\n\t\t\t\tall: telemetryProps,\n\t\t\t},\n\t\t});\n\n\t\t// Only create heuristics when in 'enabled' mode.\n\t\t// This bypasses heuristics for 'disableHeuristics' and 'summaryOnRequest' configurations.\n\t\tif (configuration.state === \"enabled\") {\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tconfiguration,\n\t\t\t\t(reason) => this.trySummarize(reason),\n\t\t\t\tthis.mc.logger,\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tthis.configuration.state !== \"disabled\",\n\t\t\t0x2eb /* \"Summary not supported with configuration disabled\" */,\n\t\t);\n\n\t\t// Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n\t\t// configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n\t\tconst maxAckWaitTime = Math.min(\n\t\t\tthis.configuration.maxAckWaitTime,\n\t\t\tmaxSummarizeAckWaitTime,\n\t\t);\n\n\t\tthis.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {\n\t\t\t// Note: summarizeCount (from ChildLogger definition) may be 0,\n\t\t\t// since this code path is hit when RunningSummarizer first starts up,\n\t\t\t// before this instance has kicked off a new summarize run.\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"SummaryAckWaitTimeout\",\n\t\t\t\tmessage: \"Pending summary ack not received in time\",\n\t\t\t\tmaxAckWaitTime,\n\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\ttimePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n\t\t\t});\n\t\t});\n\t\t// Set up pending ack timeout by op timestamp differences for previous summaries.\n\t\tsummaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n\t\t\tif (this.pendingAckTimer.hasTimer) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"MissingSummaryAckFoundByOps\",\n\t\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\t});\n\t\t\t\tthis.pendingAckTimer.clear();\n\t\t\t}\n\t\t});\n\n\t\tconst immediatelyRefreshLatestSummaryAck =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Summarizer.immediatelyRefreshLatestSummaryAck\") ?? true;\n\t\tthis.generator = new SummaryGenerator(\n\t\t\tthis.pendingAckTimer,\n\t\t\tthis.heuristicData,\n\t\t\tthis.submitSummaryCallback,\n\t\t\t() => {\n\t\t\t\tthis.totalSuccessfulAttempts++;\n\t\t\t},\n\n\t\t\tasync (options: IRefreshSummaryAckOptions) => {\n\t\t\t\tif (immediatelyRefreshLatestSummaryAck) {\n\t\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.summaryWatcher,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// Listen to runtime for ops\n\t\tthis.runtimeListener = (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t\tthis.handleOp(op, runtimeMessage === true);\n\t\t};\n\t\tthis.runtime.on(\"op\", this.runtimeListener);\n\n\t\t// The max attempts for submit failures can be overridden via a feature flag. This allows us to\n\t\t// tweak this as per telemetry data until we arrive at a stable number.\n\t\t// If its set to a number higher than `defaultMaxAttemptsForSubmitFailures`, it will be ignored.\n\t\tconst overrideMaxAttempts = this.mc.config.getNumber(\n\t\t\t\"Fluid.Summarizer.AttemptsForSubmitFailures\",\n\t\t);\n\t\tthis.maxAttemptsForSubmitFailures =\n\t\t\toverrideMaxAttempts !== undefined &&\n\t\t\toverrideMaxAttempts < defaultMaxAttemptsForSubmitFailures\n\t\t\t\t? overrideMaxAttempts\n\t\t\t\t: defaultMaxAttemptsForSubmitFailures;\n\t}\n\n\tprivate async handleSummaryAck(ack: IAckedSummary): Promise<void> {\n\t\tconst refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\tconst summaryOpHandle = ack.summaryOp.contents.handle;\n\t\tconst summaryAckHandle = ack.summaryAck.contents.handle;\n\t\twhile (this.summarizingLock !== undefined) {\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t});\n\t\t\tawait this.summarizingLock;\n\t\t}\n\n\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t// executing the refreshLatestSummaryAck.\n\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\tawait this.lockedSummaryAction(\n\t\t\t() => {},\n\t\t\tasync () => {\n\t\t\t\tconst options: IRefreshSummaryAckOptions = {\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t};\n\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n\n\tprivate readonly refreshLatestSummaryAckAndHandleError = async (\n\t\toptions: IRefreshSummaryAckOptions,\n\t): Promise<void> => {\n\t\treturn this.refreshLatestSummaryAckCallback(options).catch(async (error) => {\n\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t// summary, we might be missing a summary ack, so in that case we are still fine as the\n\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t// by calling `prefetchLatestSummaryThenClose`. We will load the next summarizer from the\n\t\t\t// updated state and be fine.\n\t\t\tconst isIgnoredError =\n\t\t\t\tisFluidError(error) &&\n\t\t\t\terror.errorType === DriverErrorTypes.fileNotFoundOrAccessDeniedError;\n\n\t\t\toptions.summaryLogger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\treferenceSequenceNumber: options.summaryRefSeq,\n\t\t\t\t\tproposalHandle: options.proposalHandle,\n\t\t\t\t\tackHandle: options.ackHandle,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\t};\n\n\t/**\n\t * Responsible for receiving and processing all the summary acks.\n\t * It starts processing ACKs after the one for the summary this client loaded from (initialSequenceNumber). Any\n\t * ACK before that is not interesting as it will simply be ignored.\n\t *\n\t * @param referenceSequenceNumber - The referenceSequenceNumber of the summary from which to start processing\n\t * acks.\n\t */\n\tprivate async processIncomingSummaryAcks(referenceSequenceNumber: number): Promise<void> {\n\t\t// Start waiting for acks that are for summaries newer that the one this client loaded from.\n\t\tlet nextReferenceSequenceNumber = referenceSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst ackedSummary = await this.summaryCollection.waitSummaryAck(\n\t\t\t\tnextReferenceSequenceNumber,\n\t\t\t);\n\t\t\tawait this.handleSummaryAck(ackedSummary);\n\t\t\tnextReferenceSequenceNumber = ackedSummary.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.runtime.off(\"op\", this.runtimeListener);\n\t\tthis.summaryWatcher.dispose();\n\t\tthis.heuristicRunner?.dispose();\n\t\tthis.heuristicRunner = undefined;\n\t\tthis.generator.dispose();\n\t\tthis.pendingAckTimer.clear();\n\t\tthis.disposeEnqueuedSummary();\n\t\tthis._disposed = true;\n\t\tthis.stopping = true;\n\t}\n\n\t/**\n\t * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n\t * If some other Summarizer code wants that event on their logs they can get it here,\n\t * but only if they're logging about that same summary.\n\t * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n\t */\n\tpublic tryGetCorrelatedLogger = (\n\t\tsummaryOpRefSeq: number,\n\t): ITelemetryLoggerExt | undefined =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/**\n\t * We only want a single heuristic runner micro-task (will provide better optimized grouping of ops)\n\t */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean): void {\n\t\tthis.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n\t\tif (runtimeMessage) {\n\t\t\tthis.heuristicData.numRuntimeOps++;\n\t\t} else {\n\t\t\tthis.heuristicData.numNonRuntimeOps++;\n\t\t}\n\n\t\tthis.heuristicData.totalOpsSize += opSize(op);\n\n\t\t// Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n\t\tif (\n\t\t\tthis.initialized &&\n\t\t\tthis.opCanTriggerSummary(op, runtimeMessage) &&\n\t\t\t!this.tryRunEnqueuedSummary() &&\n\t\t\t!this.heuristicRunnerMicroTaskExists\n\t\t) {\n\t\t\tthis.heuristicRunnerMicroTaskExists = true;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.heuristicRunnerMicroTaskExists = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Can the given op trigger a summary?\n\t * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n\t * @param op - op to check\n\t * @returns true if this op can trigger a summary\n\t */\n\tprivate opCanTriggerSummary(\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage: boolean,\n\t): boolean {\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack: {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nonRuntimeOpCanTriggerSummary(): boolean {\n\t\tconst opsSinceLastAck =\n\t\t\tthis.heuristicData.lastOpSequenceNumber -\n\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\treturn (\n\t\t\tthis.configuration.state === \"enabled\" &&\n\t\t\t(this.configuration.nonRuntimeHeuristicThreshold === undefined ||\n\t\t\t\tthis.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck)\n\t\t);\n\t}\n\n\tpublic async waitStop(allowLastSummary: boolean): Promise<void> {\n\t\tif (this.stopping) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopping = true;\n\n\t\tthis.disposeEnqueuedSummary();\n\n\t\t// This will try to run lastSummary if needed.\n\t\tif (\n\t\t\tallowLastSummary &&\n\t\t\tthis.heuristicRunner?.shouldRunLastSummary() === true &&\n\t\t\tthis.summarizingLock === undefined\n\t\t) {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t// summarizeProps\n\t\t\t\t{ summarizeReason: \"lastSummary\" },\n\t\t\t\t{},\n\t\t\t\tundefined,\n\t\t\t\ttrue /* isLastSummary */,\n\t\t\t);\n\t\t}\n\n\t\t// Note that trySummarizeOnce() call above returns right away, without waiting.\n\t\t// So we need to wait for its completion, otherwise it would be destroyed right away.\n\t\t// That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n\t\t// submit summary. We should reconsider this flow and make summarizer move to exit faster.\n\t\t// This resolves when the current pending summary gets an ack or fails.\n\t\tawait this.summarizingLock;\n\n\t\tif (this.lastSummarizeFailureEventProps !== undefined) {\n\t\t\tthis.emit(\"summarizeAllAttemptsFailed\", {\n\t\t\t\t...this.lastSummarizeFailureEventProps,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t}\n\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t}\n\n\tprivate async waitStart(): Promise<void> {\n\t\t// Wait no longer than ack timeout for all pending\n\t\tconst waitStartResult = await raceTimer(\n\t\t\tthis.summaryWatcher.waitFlushed(),\n\t\t\tthis.pendingAckTimer.start(),\n\t\t);\n\t\tthis.pendingAckTimer.clear();\n\n\t\t// Remove pending ack wait timeout by op timestamp comparison, because\n\t\t// it has race conditions with summaries submitted by this same client.\n\t\tthis.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n\t\tif (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n\t\t\tthis.heuristicData.updateWithLastSummaryAckInfo({\n\t\t\t\trefSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n\t\t\t\t// This will be the Summarizer starting point so only use timestamps from client's machine.\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t\tsummarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n\t\t\t});\n\t\t}\n\t\tthis.initialized = true;\n\t}\n\n\tprivate beforeSummaryAction(): void {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction(): void {\n\t\tconst retry = this.tryWhileSummarizing;\n\t\tthis.tryWhileSummarizing = false;\n\n\t\t// After summarizing, we should check to see if we need to summarize again.\n\t\t// Rerun the heuristics and check for enqueued summaries.\n\t\tif (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n\t\t\tthis.heuristicRunner?.run();\n\t\t}\n\t}\n\n\t/**\n\t * Runs single summary action that prevents any other concurrent actions.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * @param before - set of instructions to run before running the action.\n\t * @param action - action to perform.\n\t * @param after - set of instructions to run after running the action.\n\t * @returns The result of the action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\t): Promise<T> {\n\t\tassert(\n\t\t\tthis.summarizingLock === undefined,\n\t\t\t0x25b /* \"Caller is responsible for checking lock\" */,\n\t\t);\n\n\t\tconst summarizingLock = new Deferred<void>();\n\t\tthis.summarizingLock = summarizingLock.promise;\n\n\t\tbefore();\n\n\t\treturn action().finally(() => {\n\t\t\tsummarizingLock.resolve();\n\t\t\tthis.summarizingLock = undefined;\n\t\t\tafter();\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summarize attempt\n\t * @param summarizeProps - props to log with each telemetry event associated with this attempt\n\t * @param options - summary options\n\t * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n\t * @param resultsBuilder - optional, result builder to use.\n\t * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?\n\t * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t\tisLastSummary = false,\n\t): ISummarizeResults {\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\t\tlogger: this.mc.logger,\n\t\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t\t});\n\n\t\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\t};\n\t\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions, resultsBuilder);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\tconst result = await summarizeResult.receivedSummaryAckOrNack;\n\n\t\t\t\tif (result.success) {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"success\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"failure\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\t\tsummaryAttempts: 1,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresult.error,\n\t\t\t\t\t);\n\t\t\t\t\tif (isLastSummary) {\n\t\t\t\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\t\t\t\tcurrentAttempt: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\tmaxAttempts: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\t// SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n\t\t\t// on resultsBuilder\n\t\t\t// We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n\t\t\t// and take a appropriate action.\n\t\t});\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * Heuristics summarize attempt.\n\t */\n\tprivate trySummarize(reason: SummarizeReason): void {\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n\t\t\t// if it's still needed\n\t\t\tthis.tryWhileSummarizing = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\treturn this.trySummarizeWithRetries(reason);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n\t\t});\n\t}\n\n\t/**\n\t * Tries to summarize with retries where retry is based on the failure params.\n\t * For example, summarization may be retried for failures with \"retryAfterSeconds\" param.\n\t */\n\tprivate async trySummarizeWithRetries(\n\t\treason: SummarizeReason,\n\t): Promise<ISummarizeResults | undefined> {\n\t\t// Helper to set summarize options, telemetry properties and call summarize.\n\t\tconst attemptSummarize = (\n\t\t\tattemptNumber: number,\n\t\t\tfinalAttempt: boolean,\n\t\t): {\n\t\t\tsummarizeProps: ISummarizeTelemetryProperties;\n\t\t\tsummarizeResult: ISummarizeResults;\n\t\t} => {\n\t\t\tconst summarizeOptions: ISummarizeOptions = {\n\t\t\t\tfullTree: false,\n\t\t\t};\n\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\tsummarizeReason: reason,\n\t\t\t\tsummaryAttempts: attemptNumber,\n\t\t\t\t...summarizeOptions,\n\t\t\t\tfinalAttempt,\n\t\t\t};\n\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\tlogger: this.mc.logger,\n\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t});\n\n\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t...summarizeOptions,\n\t\t\t\tsummaryLogger,\n\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\tfinalAttempt,\n\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t};\n\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions);\n\t\t\treturn { summarizeProps, summarizeResult };\n\t\t};\n\n\t\t// The max number of attempts are based on the stage at which summarization failed. If it fails before it is\n\t\t// submitted, a different value is used compared to if it fails after submission. Usually, in the former case,\n\t\t// we would retry more often as its cheaper and retries are likely to succeed.\n\t\t// This makes it harder to predict how many attempts would actually happen as that depends on how far an attempt\n\t\t// made. To keep things simple, the max attempts is reset after every attempt based on where it failed. This may\n\t\t// result in some failures not being retried depending on what happened before this attempt. That's fine because\n\t\t// such scenarios are very unlikely and even if it happens, it would resolve when a new summarizer starts over.\n\t\t// For example - When failure switches from one the submit failures to nack failure, only one more retry will\n\t\t// happen irrespective of the value of `defaultMaxAttempts`.\n\t\tlet maxAttempts = defaultMaxAttempts;\n\t\tlet currentAttempt = 0;\n\t\tlet retryAfterSeconds: number | undefined;\n\t\tlet done = false;\n\t\tlet status: \"success\" | \"failure\" | \"canceled\" = \"success\";\n\t\tlet results: ISummarizeResults | undefined;\n\t\tlet error: IRetriableFailureError | undefined;\n\t\tlet failureMessage: string | undefined;\n\t\tdo {\n\t\t\tcurrentAttempt++;\n\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\tstatus = \"canceled\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst attemptResult = attemptSummarize(currentAttempt, false /* finalAttempt */);\n\t\t\tresults = attemptResult.summarizeResult;\n\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\t\tif (ackNackResult.success) {\n\t\t\t\tstatus = \"success\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Update max attempts from the failure result.\n\t\t\t// If submit summary failed, use maxAttemptsForSubmitFailures. Else use the defaultMaxAttempts.\n\t\t\t// Note: Check \"summarySubmitted\" result first because if it fails, ack nack would fail as well.\n\t\t\tconst submitSummaryResult = await results.summarySubmitted;\n\t\t\tmaxAttempts = submitSummaryResult.success\n\t\t\t\t? defaultMaxAttempts\n\t\t\t\t: this.maxAttemptsForSubmitFailures;\n\n\t\t\t// Emit \"summarize\" event for this failed attempt.\n\t\t\tstatus = \"failure\";\n\t\t\terror = ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.message;\n\t\t\tretryAfterSeconds = error.retryAfterSeconds;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\n\t\t\t// Break if the failure doesn't have \"retryAfterSeconds\" or we are one less from max number of attempts.\n\t\t\t// Note that the final attempt if \"retryAfterSeconds\" does exist happens outside of the do..while loop.\n\t\t\tif (retryAfterSeconds === undefined || currentAttempt >= maxAttempts - 1) {\n\t\t\t\tdone = true;\n\t\t\t}\n\n\t\t\t// If the failure has \"retryAfterSeconds\", add a delay of that time before starting the next attempt.\n\t\t\tif (retryAfterSeconds !== undefined && retryAfterSeconds > 0) {\n\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\tduration: retryAfterSeconds * 1000,\n\t\t\t\t\tsummaryNackDelay: ackNackResult.data !== undefined, // This will only be defined only for nack failures.\n\t\t\t\t\tstage: submitSummaryResult.data?.stage,\n\t\t\t\t\t...attemptResult.summarizeProps,\n\t\t\t\t});\n\t\t\t\tawait delay(retryAfterSeconds * 1000);\n\t\t\t}\n\t\t} while (!done);\n\n\t\t// If the attempt was successful, emit \"summarize\" event and return. A failed attempt may be retried below.\n\t\tif (status !== \"failure\") {\n\t\t\tthis.emit(\"summarize\", {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn results;\n\t\t}\n\n\t\t// If summarization wasn't successful above and the failure contains \"retryAfterSeconds\", perform one last\n\t\t// attempt. This gives a chance to the runtime to perform additional steps in the last attempt.\n\t\tif (retryAfterSeconds !== undefined) {\n\t\t\tconst { summarizeResult } = attemptSummarize(++currentAttempt, true /* finalAttempt */);\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await summarizeResult.receivedSummaryAckOrNack;\n\t\t\tstatus = ackNackResult.success ? \"success\" : \"failure\";\n\t\t\terror = ackNackResult.success ? undefined : ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.success ? undefined : ackNackResult.message;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\t\t\tresults = summarizeResult;\n\t\t}\n\n\t\t// If summarization is still unsuccessful, stop the summarizer.\n\t\tif (status === \"failure\") {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\tmaxAttempts,\n\t\t\t\t\tsummaryAttempts: currentAttempt,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t};\n\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Attempts to generate a summary on demand with retries in case of failures. The retry logic is the same\n\t * as heuristics based summaries.\n\t */\n\tprivate async summarizeOnDemandWithRetries(\n\t\treason: SummarizeReason,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t): Promise<ISummarizeResults> {\n\t\tconst results = await this.trySummarizeWithRetries(reason);\n\t\tif (results === undefined) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"Summarization was canceled\",\n\t\t\t\tnew RetriableSummaryError(\"Summarization was canceled\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\tconst submitResult = await results.summarySubmitted;\n\t\tconst summaryOpBroadcastedResult = await results.summaryOpBroadcasted;\n\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\tresultsBuilder.summarySubmitted.resolve(submitResult);\n\t\tresultsBuilder.summaryOpBroadcasted.resolve(summaryOpBroadcastedResult);\n\t\tresultsBuilder.receivedSummaryAckOrNack.resolve(ackNackResult);\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).summarizeOnDemand}\n\t */\n\tpublic summarizeOnDemand(\n\t\toptions: IOnDemandSummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\t// Check for concurrent summary attempts. If one is found,\n\t\t// return a promise that caller can await before trying again.\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// The heuristics are blocking concurrent summarize attempts.\n\t\t\tthrow new UsageError(\"Attempted to run an already-running summarizer on demand\");\n\t\t}\n\n\t\tconst { reason, ...summarizeOptions } = options;\n\t\tif (options.retryOnFailure === true) {\n\t\t\tthis.summarizeOnDemandWithRetries(`onDemand;${reason}`, resultsBuilder).catch(\n\t\t\t\t(error: IRetriableFailureError) => {\n\t\t\t\t\tresultsBuilder.fail(\"summarize failed\", error);\n\t\t\t\t},\n\t\t\t);\n\t\t} else {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t{ summarizeReason: `onDemand/${reason}` },\n\t\t\t\tsummarizeOptions,\n\t\t\t\tresultsBuilder,\n\t\t\t);\n\t\t}\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).enqueueSummarize}\n\t */\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst { reason, afterSequenceNumber = 0, override = false, ...summarizeOptions } = options;\n\t\tlet overridden = false;\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tif (!override) {\n\t\t\t\treturn { alreadyEnqueued: true };\n\t\t\t}\n\t\t\t// Override existing enqueued summarize attempt.\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"Aborted; overridden by another enqueue summarize attempt\",\n\t\t\t\tnew RetriableSummaryError(\n\t\t\t\t\t\"Summary was overridden by another enqueue summarize attempt\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\n\t\tthis.enqueuedSummary = {\n\t\t\treason: `enqueue;${reason}`,\n\t\t\tafterSequenceNumber,\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder: new SummarizeResultBuilder(),\n\t\t};\n\t\tconst results = this.enqueuedSummary.resultsBuilder.build();\n\t\tthis.tryRunEnqueuedSummary();\n\t\treturn overridden\n\t\t\t? {\n\t\t\t\t\t...results,\n\t\t\t\t\talreadyEnqueued: true,\n\t\t\t\t\toverridden: true,\n\t\t\t\t}\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary(): boolean {\n\t\tif (this.stopping) {\n\t\t\tthis.disposeEnqueuedSummary();\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tthis.enqueuedSummary === undefined ||\n\t\t\tthis.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber ||\n\t\t\tthis.summarizingLock !== undefined\n\t\t) {\n\t\t\t// If no enqueued summary is ready or a summary is already in progress, take no action.\n\t\t\treturn false;\n\t\t}\n\t\tconst { reason, resultsBuilder, summarizeOptions } = this.enqueuedSummary;\n\t\t// Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n\t\tthis.enqueuedSummary = undefined;\n\t\tthis.trySummarizeOnce(\n\t\t\t{ summarizeReason: `enqueuedSummary/${reason}` },\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary(): void {\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/runningSumm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CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,IAAI,0CAAqB,CAAC,uCAAuC,CAAC,CAClE,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAClC,CAAC;IACF,CAAC;CACD;AAv9BD,8CAu9BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizeEventProps,\n\tISummarizerEvents,\n\tISummarizerObservabilityProps,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred, PromiseTimer, delay } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverErrorTypes,\n\tMessageType,\n\ttype ISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype MonitoringContext,\n\tUsageError,\n\tcreateChildLogger,\n\tcreateChildMonitoringContext,\n\tisFluidError,\n\ttype ITelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { opSize } from \"../../opProperties.js\";\nimport type {\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tIRefreshSummaryAckOptions,\n\tIRetriableFailureError,\n\tISubmitSummaryOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tISummarizeOptions,\n\tISummarizerRuntime,\n\tISummarizeRunnerTelemetry,\n\tISummarizeTelemetryProperties,\n\tISummaryCancellationToken,\n\tISummaryConfiguration,\n\tSubmitSummaryResult,\n} from \"../summarizerTypes.js\";\nimport { raceTimer, RetriableSummaryError, type SummarizeReason } from \"../summarizerUtils.js\";\nimport type {\n\tIAckedSummary,\n\tIClientSummaryWatcher,\n\tSummaryCollection,\n} from \"../summaryCollection.js\";\n\nimport { defaultMaxAttempts, defaultMaxAttemptsForSubmitFailures } from \"./summarizer.js\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics.js\";\nimport { SummaryGenerator } from \"./summaryGenerator.js\";\nimport { SummarizeResultBuilder } from \"./summaryResultBuilder.js\";\nimport type { EnqueueSummarizeResult, ISummarizeResults } from \"./summaryResultTypes.js\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\n/**\n * An instance of RunningSummarizer manages the heuristics for summarizing.\n * Until disposed, the instance of RunningSummarizer can assume that it is\n * in a state of running, meaning it is connected and initialized. It keeps\n * track of summaries that it is generating as they are broadcast and acked/nacked.\n * This object is created and controlled by Summarizer object.\n */\nexport class RunningSummarizer\n\textends TypedEventEmitter<ISummarizerEvents>\n\timplements IDisposable\n{\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\n\t\truntime: ISummarizerRuntime,\n\t): Promise<RunningSummarizer> {\n\t\tconst summarizer = new RunningSummarizer(\n\t\t\tlogger,\n\t\t\tsummaryWatcher,\n\t\t\tconfiguration,\n\t\t\tsubmitSummaryCallback,\n\t\t\trefreshLatestSummaryAckCallback,\n\t\t\theuristicData,\n\t\t\tsummaryCollection,\n\t\t\tcancellationToken,\n\t\t\tstopSummarizerCallback,\n\t\t\truntime,\n\t\t);\n\n\t\t// If there have been any acks newer that the one this client loaded from until now, process them before\n\t\t// starting the running summarizer which will trigger summary heuristics.\n\t\t// This is done primarily to handle scenarios where the summarizer loads from a cached snapshot and there\n\t\t// is newer one available. The ack for the newer summary is processed before summarizing because otherwise\n\t\t// that summary would fail as it has an older parent.\n\t\tlet nextReferenceSequenceNumber = runtime.deltaManager.initialSequenceNumber + 1;\n\t\tconst latestAck = summaryCollection.latestAck;\n\t\tif (\n\t\t\tlatestAck !== undefined &&\n\t\t\tlatestAck.summaryOp.referenceSequenceNumber >= nextReferenceSequenceNumber\n\t\t) {\n\t\t\tawait summarizer.handleSummaryAck(latestAck);\n\t\t\tnextReferenceSequenceNumber = latestAck.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Process summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(nextReferenceSequenceNumber).catch((error) => {\n\t\t\tcreateChildLogger({ logger }).sendErrorEvent(\n\t\t\t\t{ eventName: \"HandleSummaryAckFatalError\" },\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\n\t\t// Update heuristic counts\n\t\t// By the time we get here, there are potentially ops missing from the heuristic summary counts\n\t\t// Examples of where this could happen:\n\t\t// 1. Op is processed during the time that we are initiating the RunningSummarizer instance but before we\n\t\t// listen for the op events (will get missed by the handlers in the current workflow)\n\t\t// 2. Op was sequenced after the last time we summarized (op sequence number > summarize ref sequence number)\n\t\tconst diff =\n\t\t\truntime.deltaManager.lastSequenceNumber -\n\t\t\t(heuristicData.lastSuccessfulSummary.refSequenceNumber +\n\t\t\t\theuristicData.numNonRuntimeOps +\n\t\t\t\theuristicData.numRuntimeOps);\n\t\theuristicData.hasMissingOpData = diff > 0;\n\n\t\tif (heuristicData.hasMissingOpData) {\n\t\t\t// Split the diff 50-50 and increment the counts appropriately\n\t\t\theuristicData.numNonRuntimeOps += Math.ceil(diff / 2);\n\t\t\theuristicData.numRuntimeOps += Math.floor(diff / 2);\n\t\t}\n\n\t\t// Update last seq number (in case the handlers haven't processed anything yet)\n\t\theuristicData.lastOpSequenceNumber = runtime.deltaManager.lastSequenceNumber;\n\n\t\t// Start heuristics\n\t\tsummarizer.heuristicRunner?.start();\n\t\tsummarizer.heuristicRunner?.run();\n\n\t\treturn summarizer;\n\t}\n\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\tprivate stopping = false;\n\tprivate _disposed = false;\n\tprivate summarizingLock: Promise<void> | undefined;\n\tprivate tryWhileSummarizing = false;\n\tprivate readonly pendingAckTimer: PromiseTimer;\n\tprivate heuristicRunner?: ISummarizeHeuristicRunner;\n\tprivate readonly generator: SummaryGenerator;\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate enqueuedSummary:\n\t\t| {\n\t\t\t\treason: SummarizeReason;\n\t\t\t\tafterSequenceNumber: number;\n\t\t\t\tsummarizeOptions: ISummarizeOptions;\n\t\t\t\treadonly resultsBuilder: SummarizeResultBuilder;\n\t\t }\n\t\t| undefined;\n\tprivate summarizeCount = 0;\n\tprivate totalSuccessfulAttempts = 0;\n\tprivate initialized = false;\n\n\t/**\n\t * The maximum number of summary attempts to do when submit summary fails.\n\t */\n\tprivate readonly maxAttemptsForSubmitFailures: number;\n\n\t/**\n\t * These are necessary to store outside of methods because of the logic around runnning a lastSummary.\n\t * We want the lastSummary to also be captured as \"all attempts failed\".\n\t */\n\tprivate lastSummarizeFailureEventProps: Omit<ISummarizeEventProps, \"result\"> | undefined =\n\t\tundefined;\n\n\tprivate constructor(\n\t\tbaseLogger: ITelemetryBaseLogger,\n\t\tprivate readonly summaryWatcher: IClientSummaryWatcher,\n\t\tprivate readonly configuration: ISummaryConfiguration,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly refreshLatestSummaryAckCallback: (\n\t\t\toptions: IRefreshSummaryAckOptions,\n\t\t) => Promise<void>,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly summaryCollection: SummaryCollection,\n\n\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\n\t\tsuper();\n\n\t\tconst telemetryProps: ISummarizeRunnerTelemetry = {\n\t\t\tsummarizeCount: () => this.summarizeCount,\n\t\t\tsummarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: baseLogger,\n\t\t\tnamespace: \"Running\",\n\t\t\tproperties: {\n\t\t\t\tall: telemetryProps,\n\t\t\t},\n\t\t});\n\n\t\t// Only create heuristics when in 'enabled' mode.\n\t\t// This bypasses heuristics for 'disableHeuristics' and 'summaryOnRequest' configurations.\n\t\tif (configuration.state === \"enabled\") {\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tconfiguration,\n\t\t\t\t(reason) => this.trySummarize(reason),\n\t\t\t\tthis.mc.logger,\n\t\t\t);\n\t\t}\n\n\t\tassert(\n\t\t\tthis.configuration.state !== \"disabled\",\n\t\t\t0x2eb /* \"Summary not supported with configuration disabled\" */,\n\t\t);\n\n\t\t// Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n\t\t// configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n\n\t\tconst maxAckWaitTime = Math.min(\n\t\t\tthis.configuration.maxAckWaitTime,\n\t\t\tmaxSummarizeAckWaitTime,\n\t\t);\n\n\t\tthis.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {\n\t\t\t// Note: summarizeCount (from ChildLogger definition) may be 0,\n\t\t\t// since this code path is hit when RunningSummarizer first starts up,\n\t\t\t// before this instance has kicked off a new summarize run.\n\t\t\tthis.mc.logger.sendErrorEvent({\n\t\t\t\teventName: \"SummaryAckWaitTimeout\",\n\t\t\t\tmessage: \"Pending summary ack not received in time\",\n\t\t\t\tmaxAckWaitTime,\n\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\ttimePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n\t\t\t});\n\t\t});\n\t\t// Set up pending ack timeout by op timestamp differences for previous summaries.\n\t\tsummaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n\t\t\tif (this.pendingAckTimer.hasTimer) {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"MissingSummaryAckFoundByOps\",\n\t\t\t\t\treferenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n\t\t\t\t\tsummarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n\t\t\t\t});\n\t\t\t\tthis.pendingAckTimer.clear();\n\t\t\t}\n\t\t});\n\n\t\tconst immediatelyRefreshLatestSummaryAck =\n\t\t\tthis.mc.config.getBoolean(\"Fluid.Summarizer.immediatelyRefreshLatestSummaryAck\") ?? true;\n\t\tthis.generator = new SummaryGenerator(\n\t\t\tthis.pendingAckTimer,\n\t\t\tthis.heuristicData,\n\t\t\tthis.submitSummaryCallback,\n\t\t\t() => {\n\t\t\t\tthis.totalSuccessfulAttempts++;\n\t\t\t},\n\n\t\t\tasync (options: IRefreshSummaryAckOptions) => {\n\t\t\t\tif (immediatelyRefreshLatestSummaryAck) {\n\t\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.summaryWatcher,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// The max attempts for submit failures can be overridden via a feature flag. This allows us to\n\t\t// tweak this as per telemetry data until we arrive at a stable number.\n\t\t// If its set to a number higher than `defaultMaxAttemptsForSubmitFailures`, it will be ignored.\n\t\tconst overrideMaxAttempts = this.mc.config.getNumber(\n\t\t\t\"Fluid.Summarizer.AttemptsForSubmitFailures\",\n\t\t);\n\t\tthis.maxAttemptsForSubmitFailures =\n\t\t\toverrideMaxAttempts !== undefined &&\n\t\t\toverrideMaxAttempts < defaultMaxAttemptsForSubmitFailures\n\t\t\t\t? overrideMaxAttempts\n\t\t\t\t: defaultMaxAttemptsForSubmitFailures;\n\n\t\tthis.setupEventListeners();\n\t}\n\n\tprivate async handleSummaryAck(ack: IAckedSummary): Promise<void> {\n\t\tconst refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\tconst summaryOpHandle = ack.summaryOp.contents.handle;\n\t\tconst summaryAckHandle = ack.summaryAck.contents.handle;\n\t\twhile (this.summarizingLock !== undefined) {\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t});\n\t\t\tawait this.summarizingLock;\n\t\t}\n\n\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t// executing the refreshLatestSummaryAck.\n\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\tawait this.lockedSummaryAction(\n\t\t\t() => {},\n\t\t\tasync () => {\n\t\t\t\tconst options: IRefreshSummaryAckOptions = {\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t};\n\t\t\t\tawait this.refreshLatestSummaryAckAndHandleError(options);\n\t\t\t},\n\t\t\t() => {},\n\t\t);\n\t}\n\n\tprivate readonly refreshLatestSummaryAckAndHandleError = async (\n\t\toptions: IRefreshSummaryAckOptions,\n\t): Promise<void> => {\n\t\treturn this.refreshLatestSummaryAckCallback(options).catch(async (error) => {\n\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t// summary, we might be missing a summary ack, so in that case we are still fine as the\n\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t// by calling `prefetchLatestSummaryThenClose`. We will load the next summarizer from the\n\t\t\t// updated state and be fine.\n\t\t\tconst isIgnoredError =\n\t\t\t\tisFluidError(error) &&\n\t\t\t\terror.errorType === DriverErrorTypes.fileNotFoundOrAccessDeniedError;\n\n\t\t\toptions.summaryLogger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\treferenceSequenceNumber: options.summaryRefSeq,\n\t\t\t\t\tproposalHandle: options.proposalHandle,\n\t\t\t\t\tackHandle: options.ackHandle,\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\t};\n\n\t/**\n\t * Responsible for receiving and processing all the summary acks.\n\t * It starts processing ACKs after the one for the summary this client loaded from (initialSequenceNumber). Any\n\t * ACK before that is not interesting as it will simply be ignored.\n\t *\n\t * @param referenceSequenceNumber - The referenceSequenceNumber of the summary from which to start processing\n\t * acks.\n\t */\n\tprivate async processIncomingSummaryAcks(referenceSequenceNumber: number): Promise<void> {\n\t\t// Start waiting for acks that are for summaries newer that the one this client loaded from.\n\t\tlet nextReferenceSequenceNumber = referenceSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst ackedSummary = await this.summaryCollection.waitSummaryAck(\n\t\t\t\tnextReferenceSequenceNumber,\n\t\t\t);\n\t\t\tawait this.handleSummaryAck(ackedSummary);\n\t\t\tnextReferenceSequenceNumber = ackedSummary.summaryOp.referenceSequenceNumber + 1;\n\t\t}\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.cleanupEventListeners();\n\t\tthis.summaryWatcher.dispose();\n\t\tthis.heuristicRunner?.dispose();\n\t\tthis.heuristicRunner = undefined;\n\t\tthis.generator.dispose();\n\t\tthis.pendingAckTimer.clear();\n\t\tthis.disposeEnqueuedSummary();\n\t\tthis._disposed = true;\n\t\tthis.stopping = true;\n\t}\n\n\tprivate readonly eventsCleanup: (() => void)[] = [];\n\n\tprivate setupEventListeners(): void {\n\t\tconst runtimeListener: (op: ISequencedDocumentMessage, runtimeMessage?: boolean) => void =\n\t\t\t(op: ISequencedDocumentMessage, runtimeMessage?: boolean) => {\n\t\t\t\tthis.handleOp(op, runtimeMessage === true);\n\t\t\t};\n\t\tthis.runtime.on(\"op\", runtimeListener);\n\t\tthis.eventsCleanup.push(() => this.runtime.off(\"op\", runtimeListener));\n\n\t\t// Forward events\n\t\tfor (const event of [\"summarizeTimeout\"] as const) {\n\t\t\tconst listener = (...args: unknown[]): void => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\tthis.generator.on(event, listener);\n\t\t\tthis.eventsCleanup.push(() => this.generator.off(event, listener));\n\t\t}\n\t}\n\n\tprivate cleanupEventListeners(): void {\n\t\tfor (const cleanup of this.eventsCleanup) {\n\t\t\tcleanup();\n\t\t}\n\t\tthis.eventsCleanup.length = 0;\n\t}\n\n\t/**\n\t * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n\t * If some other Summarizer code wants that event on their logs they can get it here,\n\t * but only if they're logging about that same summary.\n\t * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n\t */\n\tpublic tryGetCorrelatedLogger = (\n\t\tsummaryOpRefSeq: number,\n\t): ITelemetryLoggerExt | undefined =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/**\n\t * We only want a single heuristic runner micro-task (will provide better optimized grouping of ops)\n\t */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean): void {\n\t\tthis.heuristicData.lastOpSequenceNumber = op.sequenceNumber;\n\n\t\tif (runtimeMessage) {\n\t\t\tthis.heuristicData.numRuntimeOps++;\n\t\t} else {\n\t\t\tthis.heuristicData.numNonRuntimeOps++;\n\t\t}\n\n\t\tthis.heuristicData.totalOpsSize += opSize(op);\n\n\t\t// Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n\t\tif (\n\t\t\tthis.initialized &&\n\t\t\tthis.opCanTriggerSummary(op, runtimeMessage) &&\n\t\t\t!this.tryRunEnqueuedSummary() &&\n\t\t\t!this.heuristicRunnerMicroTaskExists\n\t\t) {\n\t\t\tthis.heuristicRunnerMicroTaskExists = true;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => {\n\t\t\t\t\tthis.heuristicRunner?.run();\n\t\t\t\t})\n\t\t\t\t.finally(() => {\n\t\t\t\t\tthis.heuristicRunnerMicroTaskExists = false;\n\t\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Can the given op trigger a summary?\n\t * # Currently always prevents summaries for Summarize and SummaryAck/Nack ops\n\t * @param op - op to check\n\t * @returns true if this op can trigger a summary\n\t */\n\tprivate opCanTriggerSummary(\n\t\top: ISequencedDocumentMessage,\n\t\truntimeMessage: boolean,\n\t): boolean {\n\t\tswitch (op.type) {\n\t\t\tcase MessageType.Summarize:\n\t\t\tcase MessageType.SummaryAck:\n\t\t\tcase MessageType.SummaryNack: {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate nonRuntimeOpCanTriggerSummary(): boolean {\n\t\tconst opsSinceLastAck =\n\t\t\tthis.heuristicData.lastOpSequenceNumber -\n\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber;\n\t\treturn (\n\t\t\tthis.configuration.state === \"enabled\" &&\n\t\t\t(this.configuration.nonRuntimeHeuristicThreshold === undefined ||\n\t\t\t\tthis.configuration.nonRuntimeHeuristicThreshold <= opsSinceLastAck)\n\t\t);\n\t}\n\n\tpublic async waitStop(allowLastSummary: boolean): Promise<void> {\n\t\tif (this.stopping) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopping = true;\n\n\t\tthis.disposeEnqueuedSummary();\n\n\t\t// This will try to run lastSummary if needed.\n\t\tif (\n\t\t\tallowLastSummary &&\n\t\t\tthis.heuristicRunner?.shouldRunLastSummary() === true &&\n\t\t\tthis.summarizingLock === undefined\n\t\t) {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t// summarizeProps\n\t\t\t\t{ summarizeReason: \"lastSummary\" },\n\t\t\t\t{},\n\t\t\t\tundefined,\n\t\t\t\ttrue /* isLastSummary */,\n\t\t\t);\n\t\t}\n\n\t\t// Note that trySummarizeOnce() call above returns right away, without waiting.\n\t\t// So we need to wait for its completion, otherwise it would be destroyed right away.\n\t\t// That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n\t\t// submit summary. We should reconsider this flow and make summarizer move to exit faster.\n\t\t// This resolves when the current pending summary gets an ack or fails.\n\t\tawait this.summarizingLock;\n\n\t\tif (this.lastSummarizeFailureEventProps !== undefined) {\n\t\t\tthis.emit(\"summarizeAllAttemptsFailed\", {\n\t\t\t\t...this.lastSummarizeFailureEventProps,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t}\n\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t}\n\n\tprivate async waitStart(): Promise<void> {\n\t\t// Wait no longer than ack timeout for all pending\n\t\tconst waitStartResult = await raceTimer(\n\t\t\tthis.summaryWatcher.waitFlushed(),\n\t\t\tthis.pendingAckTimer.start(),\n\t\t);\n\t\tthis.pendingAckTimer.clear();\n\n\t\t// Remove pending ack wait timeout by op timestamp comparison, because\n\t\t// it has race conditions with summaries submitted by this same client.\n\t\tthis.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n\t\tif (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n\t\t\tthis.heuristicData.updateWithLastSummaryAckInfo({\n\t\t\t\trefSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n\t\t\t\t// This will be the Summarizer starting point so only use timestamps from client's machine.\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t\tsummarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n\t\t\t});\n\t\t}\n\t\tthis.initialized = true;\n\t}\n\n\tprivate beforeSummaryAction(): void {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction(): void {\n\t\tconst retry = this.tryWhileSummarizing;\n\t\tthis.tryWhileSummarizing = false;\n\n\t\t// After summarizing, we should check to see if we need to summarize again.\n\t\t// Rerun the heuristics and check for enqueued summaries.\n\t\tif (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n\t\t\tthis.heuristicRunner?.run();\n\t\t}\n\t}\n\n\t/**\n\t * Runs single summary action that prevents any other concurrent actions.\n\t * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n\t * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n\t * @param before - set of instructions to run before running the action.\n\t * @param action - action to perform.\n\t * @param after - set of instructions to run after running the action.\n\t * @returns The result of the action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\t): Promise<T> {\n\t\tassert(\n\t\t\tthis.summarizingLock === undefined,\n\t\t\t0x25b /* \"Caller is responsible for checking lock\" */,\n\t\t);\n\n\t\tconst summarizingLock = new Deferred<void>();\n\t\tthis.summarizingLock = summarizingLock.promise;\n\n\t\tbefore();\n\n\t\treturn action().finally(() => {\n\t\t\tsummarizingLock.resolve();\n\t\t\tthis.summarizingLock = undefined;\n\t\t\tafter();\n\t\t});\n\t}\n\n\t/**\n\t * Runs single summarize attempt\n\t * @param summarizeProps - props to log with each telemetry event associated with this attempt\n\t * @param options - summary options\n\t * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n\t * @param resultsBuilder - optional, result builder to use.\n\t * @param isLastSummary - optional, is the call to this method for a last summary when shutting down the summarizer?\n\t * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t\tisLastSummary = false,\n\t): ISummarizeResults {\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\t\tlogger: this.mc.logger,\n\t\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t\t});\n\n\t\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t\t...options,\n\t\t\t\t\tsummaryLogger,\n\t\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\t};\n\t\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions, resultsBuilder);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\tconst result = await summarizeResult.receivedSummaryAckOrNack;\n\n\t\t\t\tif (result.success) {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"success\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tthis.lastSummarizeFailureEventProps = undefined;\n\t\t\t\t} else {\n\t\t\t\t\tthis.emit(\"summarize\", {\n\t\t\t\t\t\tresult: \"failure\",\n\t\t\t\t\t\tcurrentAttempt: 1,\n\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t});\n\t\t\t\t\tsummaryLogger.sendErrorEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\t\t\tmaxAttempts: 1,\n\t\t\t\t\t\t\tsummaryAttempts: 1,\n\t\t\t\t\t\t\tisLastSummary,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tresult.error,\n\t\t\t\t\t);\n\t\t\t\t\tif (isLastSummary) {\n\t\t\t\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\t\t\t\tcurrentAttempt: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\tmaxAttempts: (this.lastSummarizeFailureEventProps?.currentAttempt ?? 0) + 1,\n\t\t\t\t\t\t\terror: result.error,\n\t\t\t\t\t\t\tfailureMessage: result.message,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\t// SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n\t\t\t// on resultsBuilder\n\t\t\t// We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n\t\t\t// and take a appropriate action.\n\t\t});\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t * Heuristics summarize attempt.\n\t */\n\tprivate trySummarize(reason: SummarizeReason): void {\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n\t\t\t// if it's still needed\n\t\t\tthis.tryWhileSummarizing = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.lockedSummaryAction(\n\t\t\t() => {\n\t\t\t\tthis.beforeSummaryAction();\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\treturn this.trySummarizeWithRetries(reason);\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tthis.afterSummaryAction();\n\t\t\t},\n\t\t).catch((error) => {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{ eventName: \"UnexpectedSummarizeError\", summarizeReason: reason },\n\t\t\t\terror,\n\t\t\t);\n\t\t});\n\t}\n\n\t/**\n\t * Tries to summarize with retries where retry is based on the failure params.\n\t * For example, summarization may be retried for failures with \"retryAfterSeconds\" param.\n\t */\n\tprivate async trySummarizeWithRetries(\n\t\treason: SummarizeReason,\n\t\tsummarizeOptions: ISummarizeOptions = {},\n\t): Promise<ISummarizeResults | undefined> {\n\t\t// Helper to set summarize options, telemetry properties and call summarize.\n\t\tconst attemptSummarize = (\n\t\t\tattemptNumber: number,\n\t\t\tfinalAttempt: boolean,\n\t\t): {\n\t\t\tsummarizeProps: ISummarizeTelemetryProperties;\n\t\t\tsummarizeResult: ISummarizeResults;\n\t\t} => {\n\t\t\tconst attemptSummarizeOptions: ISummarizeOptions = {\n\t\t\t\tfullTree: summarizeOptions.fullTree ?? false,\n\t\t\t};\n\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\tsummarizeReason: reason,\n\t\t\t\tsummaryAttempts: attemptNumber,\n\t\t\t\t...attemptSummarizeOptions,\n\t\t\t\tfinalAttempt,\n\t\t\t};\n\t\t\tconst summaryLogger = createChildLogger({\n\t\t\t\tlogger: this.mc.logger,\n\t\t\t\tproperties: { all: summarizeProps },\n\t\t\t});\n\n\t\t\tconst summaryOptions: ISubmitSummaryOptions = {\n\t\t\t\t...attemptSummarizeOptions,\n\t\t\t\tsummaryLogger,\n\t\t\t\tcancellationToken: this.cancellationToken,\n\t\t\t\tfinalAttempt,\n\t\t\t\tlatestSummaryRefSeqNum: this.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t};\n\t\t\tconst summarizeResult = this.generator.summarize(summaryOptions);\n\t\t\treturn { summarizeProps, summarizeResult };\n\t\t};\n\n\t\t// The max number of attempts are based on the stage at which summarization failed. If it fails before it is\n\t\t// submitted, a different value is used compared to if it fails after submission. Usually, in the former case,\n\t\t// we would retry more often as its cheaper and retries are likely to succeed.\n\t\t// This makes it harder to predict how many attempts would actually happen as that depends on how far an attempt\n\t\t// made. To keep things simple, the max attempts is reset after every attempt based on where it failed. This may\n\t\t// result in some failures not being retried depending on what happened before this attempt. That's fine because\n\t\t// such scenarios are very unlikely and even if it happens, it would resolve when a new summarizer starts over.\n\t\t// For example - When failure switches from one the submit failures to nack failure, only one more retry will\n\t\t// happen irrespective of the value of `defaultMaxAttempts`.\n\t\tlet maxAttempts = defaultMaxAttempts;\n\t\tlet currentAttempt = 0;\n\t\tlet retryAfterSeconds: number | undefined;\n\t\tlet done = false;\n\t\tlet status: \"success\" | \"failure\" | \"canceled\" = \"success\";\n\t\tlet results: ISummarizeResults | undefined;\n\t\tlet error: IRetriableFailureError | undefined;\n\t\tlet failureMessage: string | undefined;\n\t\tdo {\n\t\t\tcurrentAttempt++;\n\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\tstatus = \"canceled\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst attemptResult = attemptSummarize(currentAttempt, false /* finalAttempt */);\n\t\t\tresults = attemptResult.summarizeResult;\n\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\t\tif (ackNackResult.success) {\n\t\t\t\tstatus = \"success\";\n\t\t\t\tdone = true;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Update max attempts from the failure result.\n\t\t\t// If submit summary failed, use maxAttemptsForSubmitFailures. Else use the defaultMaxAttempts.\n\t\t\t// Note: Check \"summarySubmitted\" result first because if it fails, ack nack would fail as well.\n\t\t\tconst submitSummaryResult = await results.summarySubmitted;\n\t\t\tmaxAttempts = submitSummaryResult.success\n\t\t\t\t? defaultMaxAttempts\n\t\t\t\t: this.maxAttemptsForSubmitFailures;\n\n\t\t\t// Emit \"summarize\" event for this failed attempt.\n\t\t\tstatus = \"failure\";\n\t\t\terror = ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.message;\n\t\t\tretryAfterSeconds = error.retryAfterSeconds;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\n\t\t\t// Break if the failure doesn't have \"retryAfterSeconds\" or we are one less from max number of attempts.\n\t\t\t// Note that the final attempt if \"retryAfterSeconds\" does exist happens outside of the do..while loop.\n\t\t\tif (retryAfterSeconds === undefined || currentAttempt >= maxAttempts - 1) {\n\t\t\t\tdone = true;\n\t\t\t}\n\n\t\t\t// If the failure has \"retryAfterSeconds\", add a delay of that time before starting the next attempt.\n\t\t\tif (retryAfterSeconds !== undefined && retryAfterSeconds > 0) {\n\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\tduration: retryAfterSeconds * 1000,\n\t\t\t\t\tsummaryNackDelay: ackNackResult.data !== undefined, // This will only be defined only for nack failures.\n\t\t\t\t\tstage: submitSummaryResult.data?.stage,\n\t\t\t\t\t...attemptResult.summarizeProps,\n\t\t\t\t});\n\t\t\t\tawait delay(retryAfterSeconds * 1000);\n\t\t\t}\n\t\t} while (!done);\n\n\t\t// If the attempt was successful, emit \"summarize\" event and return. A failed attempt may be retried below.\n\t\tif (status !== \"failure\") {\n\t\t\tthis.emit(\"summarize\", {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn results;\n\t\t}\n\n\t\t// If summarization wasn't successful above and the failure contains \"retryAfterSeconds\", perform one last\n\t\t// attempt. This gives a chance to the runtime to perform additional steps in the last attempt.\n\t\tif (retryAfterSeconds !== undefined) {\n\t\t\tconst { summarizeResult } = attemptSummarize(++currentAttempt, true /* finalAttempt */);\n\t\t\t// Ack / nack is the final step, so if it succeeds we're done.\n\t\t\tconst ackNackResult = await summarizeResult.receivedSummaryAckOrNack;\n\t\t\tstatus = ackNackResult.success ? \"success\" : \"failure\";\n\t\t\terror = ackNackResult.success ? undefined : ackNackResult.error;\n\t\t\tfailureMessage = ackNackResult.success ? undefined : ackNackResult.message;\n\t\t\tconst eventProps: ISummarizeEventProps & ISummarizerObservabilityProps = {\n\t\t\t\tresult: status,\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t\tnumUnsummarizedRuntimeOps: this.heuristicData.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this.heuristicData.numNonRuntimeOps,\n\t\t\t};\n\t\t\tthis.emit(\"summarize\", eventProps);\n\t\t\tresults = summarizeResult;\n\t\t}\n\n\t\t// If summarization is still unsuccessful, stop the summarizer.\n\t\tif (status === \"failure\") {\n\t\t\tthis.mc.logger.sendErrorEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"SummarizeFailed\",\n\t\t\t\t\tmaxAttempts,\n\t\t\t\t\tsummaryAttempts: currentAttempt,\n\t\t\t\t\tsummarizeReason: reason,\n\t\t\t\t\tisLastSummary: reason === \"lastSummary\",\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.lastSummarizeFailureEventProps = {\n\t\t\t\tcurrentAttempt,\n\t\t\t\tmaxAttempts,\n\t\t\t\terror,\n\t\t\t\tfailureMessage,\n\t\t\t};\n\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\n\t\t}\n\t\treturn results;\n\t}\n\n\t/**\n\t * Attempts to generate a summary on demand with retries in case of failures. The retry logic is the same\n\t * as heuristics based summaries.\n\t */\n\tprivate async summarizeOnDemandWithRetries(\n\t\treason: SummarizeReason,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t\tsummarizeOptions: ISummarizeOptions = {},\n\t): Promise<ISummarizeResults> {\n\t\tconst results = await this.trySummarizeWithRetries(reason, summarizeOptions);\n\t\tif (results === undefined) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"Summarization was canceled\",\n\t\t\t\tnew RetriableSummaryError(\"Summarization was canceled\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\tconst submitResult = await results.summarySubmitted;\n\t\tconst summaryOpBroadcastedResult = await results.summaryOpBroadcasted;\n\t\tconst ackNackResult = await results.receivedSummaryAckOrNack;\n\t\tresultsBuilder.summarySubmitted.resolve(submitResult);\n\t\tresultsBuilder.summaryOpBroadcasted.resolve(summaryOpBroadcastedResult);\n\t\tresultsBuilder.receivedSummaryAckOrNack.resolve(ackNackResult);\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).summarizeOnDemand}\n\t */\n\tpublic summarizeOnDemand(\n\t\toptions: IOnDemandSummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\treturn resultsBuilder.build();\n\t\t}\n\t\t// Check for concurrent summary attempts. If one is found,\n\t\t// return a promise that caller can await before trying again.\n\t\tif (this.summarizingLock !== undefined) {\n\t\t\t// The heuristics are blocking concurrent summarize attempts.\n\t\t\tthrow new UsageError(\"Attempted to run an already-running summarizer on demand\");\n\t\t}\n\n\t\tconst { reason, retryOnFailure, ...summarizeOptions } = options;\n\t\tif (retryOnFailure === true) {\n\t\t\tthis.summarizeOnDemandWithRetries(\n\t\t\t\t`onDemand;${reason}`,\n\t\t\t\tresultsBuilder,\n\t\t\t\tsummarizeOptions,\n\t\t\t).catch((error: IRetriableFailureError) => {\n\t\t\t\tresultsBuilder.fail(\"summarize failed\", error);\n\t\t\t});\n\t\t} else {\n\t\t\tthis.trySummarizeOnce(\n\t\t\t\t{ summarizeReason: `onDemand/${reason}` },\n\t\t\t\tsummarizeOptions,\n\t\t\t\tresultsBuilder,\n\t\t\t);\n\t\t}\n\t\treturn resultsBuilder.build();\n\t}\n\n\t/**\n\t *{@inheritdoc (ISummarizer:interface).enqueueSummarize}\n\t */\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst { reason, afterSequenceNumber = 0, override = false, ...summarizeOptions } = options;\n\t\tlet overridden = false;\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tif (!override) {\n\t\t\t\treturn { alreadyEnqueued: true };\n\t\t\t}\n\t\t\t// Override existing enqueued summarize attempt.\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"Aborted; overridden by another enqueue summarize attempt\",\n\t\t\t\tnew RetriableSummaryError(\n\t\t\t\t\t\"Summary was overridden by another enqueue summarize attempt\",\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\n\t\tthis.enqueuedSummary = {\n\t\t\treason: `enqueue;${reason}`,\n\t\t\tafterSequenceNumber,\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder: new SummarizeResultBuilder(),\n\t\t};\n\t\tconst results = this.enqueuedSummary.resultsBuilder.build();\n\t\tthis.tryRunEnqueuedSummary();\n\t\treturn overridden\n\t\t\t? {\n\t\t\t\t\t...results,\n\t\t\t\t\talreadyEnqueued: true,\n\t\t\t\t\toverridden: true,\n\t\t\t\t}\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary(): boolean {\n\t\tif (this.stopping) {\n\t\t\tthis.disposeEnqueuedSummary();\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tthis.enqueuedSummary === undefined ||\n\t\t\tthis.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber ||\n\t\t\tthis.summarizingLock !== undefined\n\t\t) {\n\t\t\t// If no enqueued summary is ready or a summary is already in progress, take no action.\n\t\t\treturn false;\n\t\t}\n\t\tconst { reason, resultsBuilder, summarizeOptions } = this.enqueuedSummary;\n\t\t// Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n\t\tthis.enqueuedSummary = undefined;\n\t\tthis.trySummarizeOnce(\n\t\t\t{ summarizeReason: `enqueuedSummary/${reason}` },\n\t\t\tsummarizeOptions,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary(): void {\n\t\tif (this.enqueuedSummary !== undefined) {\n\t\t\tthis.enqueuedSummary.resultsBuilder.fail(\n\t\t\t\t\"RunningSummarizer stopped or disposed\",\n\t\t\t\tnew RetriableSummaryError(\"RunningSummarizer stopped or disposed\"),\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -102,7 +102,7 @@ export declare class Summarizer extends TypedEventEmitter<ISummarizerEvents> imp
|
|
|
102
102
|
summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults;
|
|
103
103
|
enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult;
|
|
104
104
|
recordSummaryAttempt?(summaryRefSeqNum?: number): void;
|
|
105
|
-
private readonly
|
|
105
|
+
private readonly forwardedEventsCleanup;
|
|
106
106
|
private setupForwardedEvents;
|
|
107
107
|
private cleanupForwardedEvents;
|
|
108
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EACX,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,wDAAwD,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAEpF,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,YAAY,EAIZ,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAEzB,WAAW,EACX,4BAA4B,EAC5B,kBAAkB,EAClB,mBAAmB,EAEnB,qBAAqB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AAI1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEzF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC;;;GAGG;AACH,eAAO,MAAM,mCAAmC,IAAI,CAAC;AAErD,qBAAa,kBACZ,SAAQ,YACR,YAAW,mBAAmB,EAAE,eAAe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B,KACxB,OAAO,CAAC,gCAAgC,CAAC;IASlC,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAuBnE;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IAIxC,KAAK,IAAI,IAAI;YAON,OAAO;IA+DrB;;;;;OAKG;WACW,2BAA2B,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO;IAIpF,OAAO,CAAC,cAAc,CAAsC;IAE5D;;;;;;;;OAQG;YACW,KAAK;IA0DnB;;;;;OAKG;IACI,OAAO,IAAI,IAAI;IAYf,iBAAiB,CAAC,OAAO,EAAE,yBAAyB,GAAG,iBAAiB;IA4DxE,gBAAgB,CAAC,OAAO,EAAE,wBAAwB,GAAG,sBAAsB;IAW3E,oBAAoB,CAAC,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7D,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAsB;IAE7D,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,sBAAsB;CAM9B"}
|
|
@@ -66,7 +66,7 @@ class Summarizer extends client_utils_1.TypedEventEmitter {
|
|
|
66
66
|
this._disposed = false;
|
|
67
67
|
this.starting = false;
|
|
68
68
|
this.stopDeferred = new internal_1.Deferred();
|
|
69
|
-
this.
|
|
69
|
+
this.forwardedEventsCleanup = [];
|
|
70
70
|
this.logger = (0, internal_2.createChildLogger)({
|
|
71
71
|
logger: this.runtime.baseLogger,
|
|
72
72
|
namespace: "Summarizer",
|
|
@@ -211,7 +211,7 @@ class Summarizer extends client_utils_1.TypedEventEmitter {
|
|
|
211
211
|
async (...args) => this.internalsProvider.refreshLatestSummaryAck(...args), // refreshLatestSummaryAckCallback
|
|
212
212
|
this._heuristicData, this.summaryCollection, runCoordinator /* cancellationToken */, (reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */, this.runtime);
|
|
213
213
|
this.runningSummarizer = runningSummarizer;
|
|
214
|
-
this.setupForwardedEvents();
|
|
214
|
+
this.setupForwardedEvents(runningSummarizer);
|
|
215
215
|
this.starting = false;
|
|
216
216
|
return runningSummarizer;
|
|
217
217
|
}
|
|
@@ -295,22 +295,24 @@ class Summarizer extends client_utils_1.TypedEventEmitter {
|
|
|
295
295
|
recordSummaryAttempt(summaryRefSeqNum) {
|
|
296
296
|
this._heuristicData?.recordAttempt(summaryRefSeqNum);
|
|
297
297
|
}
|
|
298
|
-
setupForwardedEvents() {
|
|
299
|
-
for (const event of [
|
|
298
|
+
setupForwardedEvents(runningSummarizer) {
|
|
299
|
+
for (const event of [
|
|
300
|
+
"summarize",
|
|
301
|
+
"summarizeAllAttemptsFailed",
|
|
302
|
+
"summarizeTimeout",
|
|
303
|
+
]) {
|
|
300
304
|
const listener = (...args) => {
|
|
301
305
|
this.emit(event, ...args);
|
|
302
306
|
};
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
this.runningSummarizer?.on(event, listener);
|
|
306
|
-
this.forwardedEvents.set(event, listener);
|
|
307
|
+
runningSummarizer.on(event, listener);
|
|
308
|
+
this.forwardedEventsCleanup.push(() => runningSummarizer.off(event, listener));
|
|
307
309
|
}
|
|
308
310
|
}
|
|
309
311
|
cleanupForwardedEvents() {
|
|
310
|
-
for (const
|
|
311
|
-
|
|
312
|
+
for (const cleanup of this.forwardedEventsCleanup) {
|
|
313
|
+
cleanup();
|
|
312
314
|
}
|
|
313
|
-
this.
|
|
315
|
+
this.forwardedEventsCleanup.length = 0;
|
|
314
316
|
}
|
|
315
317
|
}
|
|
316
318
|
exports.Summarizer = Summarizer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/summarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAMjE,kEAA+D;AAC/D,uEAOkD;AAiBlD,iEAA2D;AAC3D,uEAAmE;AACnE,uEAAmE;AAGnE;;;GAGG;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,CAAC;QACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzD,CAAC;IAEM,oBAAoB,CAAE,gBAAyB;QACrD,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAIO,oBAAoB;QAC3B,KAAK,MAAM,KAAK,IAAI,CAAC,WAAW,EAAE,4BAA4B,CAAC,EAAE,CAAC;YACjE,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAe,EAAQ,EAAE;gBAC7C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC;YACF,2BAA2B;YAC3B,qGAAqG;YACrG,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC,KAAY,EAAE,QAAQ,CAAC,CAAC;YACnD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IAEO,sBAAsB;QAC7B,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;YAChE,IAAI,CAAC,iBAAiB,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;CACD;AA7UD,gCA6UC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IFluidHandleContext } from \"@fluidframework/core-interfaces/internal\";\nimport { Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IFluidErrorBase,\n\ttype ITelemetryLoggerExt,\n\tLoggingError,\n\tUsageError,\n\tcreateChildLogger,\n\twrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type {\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizer,\n\tISummarizerInternalsProvider,\n\tISummarizerRuntime,\n\tISummarizingWarning,\n\tIRetriableFailureError,\n\tISummaryConfiguration,\n} from \"../summarizerTypes.js\";\nimport type { SummaryCollection } from \"../summaryCollection.js\";\n\nimport type { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator.js\";\nimport { RunningSummarizer } from \"./runningSummarizer.js\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics.js\";\nimport { SummarizeResultBuilder } from \"./summaryResultBuilder.js\";\nimport type { EnqueueSummarizeResult, ISummarizeResults } from \"./summaryResultTypes.js\";\n\n/**\n * The maximum number of summarization attempts that will be done by default in case of failures\n * that can be retried.\n */\nexport const defaultMaxAttempts = 2;\n/**\n * The default value for maximum number of summarization attempts that will be done for summarization failures where\n * submit fails and the failure can be retried.\n */\nexport const defaultMaxAttemptsForSubmitFailures = 5;\n\nexport class SummarizingWarning\n\textends LoggingError\n\timplements ISummarizingWarning, IFluidErrorBase\n{\n\treadonly errorType = \"summarizingError\";\n\treadonly canRetry = true;\n\n\tconstructor(\n\t\terrorMessage: string,\n\t\treadonly logged: boolean = false,\n\t) {\n\t\tsuper(errorMessage);\n\t}\n\n\tstatic wrap(\n\t\terror: unknown,\n\t\tlogged: boolean = false,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SummarizingWarning {\n\t\tconst newErrorFn = (errMsg: string): SummarizingWarning =>\n\t\t\tnew SummarizingWarning(errMsg, logged);\n\t\treturn wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n\t}\n}\n\nexport const createSummarizingWarning = (\n\terrorMessage: string,\n\tlogged: boolean,\n): SummarizingWarning => 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 * @internal\n */\nexport class Summarizer extends TypedEventEmitter<ISummarizerEvents> implements ISummarizer {\n\tpublic get ISummarizer(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate runningSummarizer?: RunningSummarizer;\n\tprivate _disposed: boolean = false;\n\tprivate starting: boolean = false;\n\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tconstructor(\n\t\t/**\n\t\t * Reference to runtime that created this object.\n\t\t * i.e. runtime with clientType === \"summarizer\"\n\t\t */\n\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t\tprivate readonly configurationGetter: () => ISummaryConfiguration,\n\t\t/**\n\t\t * Represents an object that can generate summary.\n\t\t * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n\t\t */\n\n\t\tprivate readonly internalsProvider: ISummarizerInternalsProvider,\n\t\thandleContext: IFluidHandleContext,\n\t\tpublic readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly runCoordinatorCreateFn: (\n\t\t\truntime: IConnectableRuntime,\n\t\t) => Promise<ICancellableSummarizerController>,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"Summarizer\",\n\t\t});\n\t}\n\n\tpublic async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\ttry {\n\t\t\tconst stopReason = await this.runCore(onBehalfOf);\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn stopReason;\n\t\t} catch (error) {\n\t\t\tthis.stop(\"summarizerException\");\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason: \"summarizerException\",\n\t\t\t\terror,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Stops the summarizer from running. This will complete\n\t * the run promise, and also close the container.\n\t * @param reason - reason code for stopping\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tthis.stopDeferred.resolve(reason);\n\t}\n\n\tpublic close(): void {\n\t\t// This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n\t\t// unless stop() was called earlier\n\t\tthis.dispose();\n\t\tthis.runtime.disposeFn();\n\t}\n\n\tprivate async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\tconst runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(\n\t\t\tthis.runtime,\n\t\t);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n\t\t// eslint-disable-next-line no-void\n\t\tvoid stopP.then((reason) => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"StoppingSummarizer\",\n\t\t\t\tonBehalfOf,\n\t\t\t\treason,\n\t\t\t});\n\t\t});\n\n\t\tif (runCoordinator.cancelled) {\n\t\t\tthis.emit(\"summarizerStartupFailed\", {\n\t\t\t\treason: await runCoordinator.waitCancelled,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn runCoordinator.waitCancelled;\n\t\t}\n\n\t\tthis.emit(\"summarizerStart\", {\n\t\t\tonBehalfOf,\n\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t});\n\n\t\tconst runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopReason = await stopP;\n\n\t\t// There are two possible approaches here:\n\t\t// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n\t\t// faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n\t\t// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n\t\t// The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n\t\t// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n\t\t// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n\t\t// In general, it's more wasted resources.\n\t\t// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n\t\t// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n\t\t// substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n\t\t// conflict with new summarizer client starting on different client.\n\t\t// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n\t\t// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n\t\t// cons of #2 substantially.\n\n\t\t// Cleanup after running\n\t\tawait runningSummarizer.waitStop(\n\t\t\t!runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason),\n\t\t);\n\n\t\t// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n\t\trunCoordinator.stop(stopReason);\n\n\t\treturn stopReason;\n\t}\n\n\t/**\n\t * Should we try to run a last summary for the given stop reason?\n\t * Currently only allows \"parentNotConnected\"\n\t * @param stopReason - SummarizerStopReason\n\t * @returns `true` if the stop reason can run a last summary, otherwise `false`.\n\t */\n\tpublic static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n\t\treturn stopReason === \"parentNotConnected\";\n\t}\n\n\tprivate _heuristicData: ISummarizeHeuristicData | undefined;\n\n\t/**\n\t * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n\t * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n\t * (in the on-demand case).\n\t * @param onBehalfOf - ID of the client that requested that the summarizer start\n\t * @param runCoordinator - cancellation token\n\t * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n\t * @returns A promise that is fulfilled when the RunningSummarizer is ready.\n\t */\n\tprivate async start(\n\t\tonBehalfOf: string,\n\n\t\trunCoordinator: ICancellableSummarizerController,\n\t): Promise<RunningSummarizer> {\n\t\tif (this.runningSummarizer) {\n\t\t\tif (this.runningSummarizer.disposed) {\n\t\t\t\tthrow new UsageError(\"Starting a disposed summarizer\");\n\t\t\t}\n\t\t\treturn this.runningSummarizer;\n\t\t}\n\t\tif (this.starting) {\n\t\t\tthrow new UsageError(\"Attempting to start a summarizer that is already starting\");\n\t\t}\n\t\tthis.starting = true;\n\t\t// Initialize values and first ack (time is not exact)\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"RunningSummarizer\",\n\t\t\tonBehalfOf,\n\t\t\tinitSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\tconfig: JSON.stringify(this.configurationGetter()),\n\t\t});\n\n\t\t// Summarizing container ID (with clientType === \"summarizer\")\n\t\tconst clientId = this.runtime.clientId;\n\t\tif (clientId === undefined) {\n\t\t\tthrow new UsageError(\"clientId should be defined if connected.\");\n\t\t}\n\n\t\tthis._heuristicData = new SummarizeHeuristicData(\n\t\t\tthis.runtime.deltaManager.lastSequenceNumber,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * summary attempt baseline for heuristics\n\t\t\t\t */\n\t\t\t\trefSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t} as const,\n\t\t);\n\n\t\tconst runningSummarizer = await RunningSummarizer.start(\n\t\t\tthis.logger,\n\t\t\tthis.summaryCollection.createWatcher(clientId),\n\t\t\tthis.configurationGetter(),\n\t\t\tasync (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n\t\t\tasync (...args) => this.internalsProvider.refreshLatestSummaryAck(...args), // refreshLatestSummaryAckCallback\n\t\t\tthis._heuristicData,\n\t\t\tthis.summaryCollection,\n\t\t\trunCoordinator /* cancellationToken */,\n\t\t\t(reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */,\n\t\t\tthis.runtime,\n\t\t);\n\t\tthis.runningSummarizer = runningSummarizer;\n\t\tthis.setupForwardedEvents();\n\t\tthis.starting = false;\n\t\treturn runningSummarizer;\n\t}\n\n\t/**\n\t * Disposes of resources after running. This cleanup will\n\t * clear any outstanding timers and reset some of the state\n\t * properties.\n\t * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n\t */\n\tpublic dispose(): void {\n\t\t// Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n\t\tthis.stop(\"summarizerClientDisconnected\");\n\n\t\tthis._disposed = true;\n\t\tif (this.runningSummarizer) {\n\t\t\tthis.cleanupForwardedEvents();\n\t\t\tthis.runningSummarizer.dispose();\n\t\t\tthis.runningSummarizer = undefined;\n\t\t}\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\ttry {\n\t\t\tif (this._disposed || this.runningSummarizer?.disposed === true) {\n\t\t\t\tthrow new UsageError(\"Summarizer is already disposed.\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.runtime.summarizerClientId !== undefined &&\n\t\t\t\tthis.runtime.summarizerClientId !== this.runtime.clientId\n\t\t\t) {\n\t\t\t\t// If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n\t\t\t\t// This is to prevent the on-demand summary and heuristic-based summary from stepping on\n\t\t\t\t// each other.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"On-demand summary attempted while an elected summarizer is present\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst builder = new SummarizeResultBuilder();\n\t\t\tif (this.runningSummarizer) {\n\t\t\t\t// Summarizer is already running. Go ahead and start.\n\t\t\t\treturn this.runningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t}\n\n\t\t\t// Summarizer isn't running, so we need to start it, which is an async operation.\n\t\t\t// Manage the promise related to creating the cancellation token here.\n\t\t\t// The promises related to starting, summarizing,\n\t\t\t// and submitting are communicated to the caller through the results builder.\n\t\t\tconst coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n\t\t\tcoordinatorCreateP\n\t\t\t\t.then((runCoordinator) => {\n\t\t\t\t\t// Successfully created the cancellation token. Start the summarizer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst startP = this.start(this.runtime.clientId!, runCoordinator);\n\t\t\t\t\tstartP\n\t\t\t\t\t\t.then(async (runningSummarizer) => {\n\t\t\t\t\t\t\t// Successfully started the summarizer. Run it.\n\t\t\t\t\t\t\trunningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t\t\t\t\t// Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n\t\t\t\t\t\t\tconst stopReason = await Promise.race([\n\t\t\t\t\t\t\t\tthis.stopDeferred.promise,\n\t\t\t\t\t\t\t\trunCoordinator.waitCancelled,\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tawait runningSummarizer.waitStop(false);\n\t\t\t\t\t\t\trunCoordinator.stop(stopReason);\n\t\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\t\t\tbuilder.fail(\"Failed to start summarizer\", error);\n\t\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\tbuilder.fail(\"Failed to create cancellation token\", error);\n\t\t\t\t});\n\n\t\t\treturn builder.build();\n\t\t} catch (error) {\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t}\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (\n\t\t\tthis._disposed ||\n\t\t\tthis.runningSummarizer === undefined ||\n\t\t\tthis.runningSummarizer.disposed\n\t\t) {\n\t\t\tthrow new UsageError(\"Summarizer is not running or already disposed.\");\n\t\t}\n\t\treturn this.runningSummarizer.enqueueSummarize(options);\n\t}\n\n\tpublic recordSummaryAttempt?(summaryRefSeqNum?: number): void {\n\t\tthis._heuristicData?.recordAttempt(summaryRefSeqNum);\n\t}\n\n\tprivate readonly forwardedEvents = new Map<string, () => void>();\n\n\tprivate setupForwardedEvents(): void {\n\t\tfor (const event of [\"summarize\", \"summarizeAllAttemptsFailed\"]) {\n\t\t\tconst listener = (...args: unknown[]): void => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\t// TODO: better typing here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument\n\t\t\tthis.runningSummarizer?.on(event as any, listener);\n\t\t\tthis.forwardedEvents.set(event, listener);\n\t\t}\n\t}\n\n\tprivate cleanupForwardedEvents(): void {\n\t\tfor (const [event, listener] of this.forwardedEvents.entries()) {\n\t\t\tthis.runningSummarizer?.off(event, listener);\n\t\t}\n\t\tthis.forwardedEvents.clear();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/summarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AAMjE,kEAA+D;AAC/D,uEAOkD;AAiBlD,iEAA2D;AAC3D,uEAAmE;AACnE,uEAAmE;AAGnE;;;GAGG;AACU,QAAA,kBAAkB,GAAG,CAAC,CAAC;AACpC;;;GAGG;AACU,QAAA,mCAAmC,GAAG,CAAC,CAAC;AAErD,MAAa,kBACZ,SAAQ,uBAAY;IAMpB,YAC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,CAAC,cAAc,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACtD,CAAC;IAIO,oBAAoB,CAAC,iBAAoC;QAChE,KAAK,MAAM,KAAK,IAAI;YACnB,WAAW;YACX,4BAA4B;YAC5B,kBAAkB;SACT,EAAE,CAAC;YACZ,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAe,EAAQ,EAAE;gBAC7C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;YAC3B,CAAC,CAAC;YACF,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACtC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;QAChF,CAAC;IACF,CAAC;IAEO,sBAAsB;QAC7B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YACnD,OAAO,EAAE,CAAC;QACX,CAAC;QACD,IAAI,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC,CAAC;IACxC,CAAC;CACD;AA/UD,gCA+UC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type {\n\tISummarizerEvents,\n\tSummarizerStopReason,\n} from \"@fluidframework/container-runtime-definitions/internal\";\nimport type { IFluidHandleContext } from \"@fluidframework/core-interfaces/internal\";\nimport { Deferred } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IFluidErrorBase,\n\ttype ITelemetryLoggerExt,\n\tLoggingError,\n\tUsageError,\n\tcreateChildLogger,\n\twrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type {\n\tIConnectableRuntime,\n\tIEnqueueSummarizeOptions,\n\tIOnDemandSummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizer,\n\tISummarizerInternalsProvider,\n\tISummarizerRuntime,\n\tISummarizingWarning,\n\tIRetriableFailureError,\n\tISummaryConfiguration,\n} from \"../summarizerTypes.js\";\nimport type { SummaryCollection } from \"../summaryCollection.js\";\n\nimport type { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator.js\";\nimport { RunningSummarizer } from \"./runningSummarizer.js\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics.js\";\nimport { SummarizeResultBuilder } from \"./summaryResultBuilder.js\";\nimport type { EnqueueSummarizeResult, ISummarizeResults } from \"./summaryResultTypes.js\";\n\n/**\n * The maximum number of summarization attempts that will be done by default in case of failures\n * that can be retried.\n */\nexport const defaultMaxAttempts = 2;\n/**\n * The default value for maximum number of summarization attempts that will be done for summarization failures where\n * submit fails and the failure can be retried.\n */\nexport const defaultMaxAttemptsForSubmitFailures = 5;\n\nexport class SummarizingWarning\n\textends LoggingError\n\timplements ISummarizingWarning, IFluidErrorBase\n{\n\treadonly errorType = \"summarizingError\";\n\treadonly canRetry = true;\n\n\tconstructor(\n\t\terrorMessage: string,\n\t\treadonly logged: boolean = false,\n\t) {\n\t\tsuper(errorMessage);\n\t}\n\n\tstatic wrap(\n\t\terror: unknown,\n\t\tlogged: boolean = false,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SummarizingWarning {\n\t\tconst newErrorFn = (errMsg: string): SummarizingWarning =>\n\t\t\tnew SummarizingWarning(errMsg, logged);\n\t\treturn wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n\t}\n}\n\nexport const createSummarizingWarning = (\n\terrorMessage: string,\n\tlogged: boolean,\n): SummarizingWarning => 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 * @internal\n */\nexport class Summarizer extends TypedEventEmitter<ISummarizerEvents> implements ISummarizer {\n\tpublic get ISummarizer(): this {\n\t\treturn this;\n\t}\n\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate runningSummarizer?: RunningSummarizer;\n\tprivate _disposed: boolean = false;\n\tprivate starting: boolean = false;\n\n\tprivate readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n\tconstructor(\n\t\t/**\n\t\t * Reference to runtime that created this object.\n\t\t * i.e. runtime with clientType === \"summarizer\"\n\t\t */\n\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t\tprivate readonly configurationGetter: () => ISummaryConfiguration,\n\t\t/**\n\t\t * Represents an object that can generate summary.\n\t\t * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n\t\t */\n\n\t\tprivate readonly internalsProvider: ISummarizerInternalsProvider,\n\t\thandleContext: IFluidHandleContext,\n\t\tpublic readonly summaryCollection: SummaryCollection,\n\t\tprivate readonly runCoordinatorCreateFn: (\n\t\t\truntime: IConnectableRuntime,\n\t\t) => Promise<ICancellableSummarizerController>,\n\t) {\n\t\tsuper();\n\t\tthis.logger = createChildLogger({\n\t\t\tlogger: this.runtime.baseLogger,\n\t\t\tnamespace: \"Summarizer\",\n\t\t});\n\t}\n\n\tpublic async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\ttry {\n\t\t\tconst stopReason = await this.runCore(onBehalfOf);\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn stopReason;\n\t\t} catch (error) {\n\t\t\tthis.stop(\"summarizerException\");\n\t\t\tthis.emit(\"summarizerStop\", {\n\t\t\t\tstopReason: \"summarizerException\",\n\t\t\t\terror,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t} finally {\n\t\t\tthis.close();\n\t\t}\n\t}\n\n\t/**\n\t * Stops the summarizer from running. This will complete\n\t * the run promise, and also close the container.\n\t * @param reason - reason code for stopping\n\t */\n\tpublic stop(reason: SummarizerStopReason): void {\n\t\tthis.stopDeferred.resolve(reason);\n\t}\n\n\tpublic close(): void {\n\t\t// This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n\t\t// unless stop() was called earlier\n\t\tthis.dispose();\n\t\tthis.runtime.disposeFn();\n\t}\n\n\tprivate async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n\t\tconst runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(\n\t\t\tthis.runtime,\n\t\t);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n\t\t// eslint-disable-next-line no-void\n\t\tvoid stopP.then((reason) => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"StoppingSummarizer\",\n\t\t\t\tonBehalfOf,\n\t\t\t\treason,\n\t\t\t});\n\t\t});\n\n\t\tif (runCoordinator.cancelled) {\n\t\t\tthis.emit(\"summarizerStartupFailed\", {\n\t\t\t\treason: await runCoordinator.waitCancelled,\n\t\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t\t});\n\t\t\treturn runCoordinator.waitCancelled;\n\t\t}\n\n\t\tthis.emit(\"summarizerStart\", {\n\t\t\tonBehalfOf,\n\t\t\tnumUnsummarizedRuntimeOps: this._heuristicData?.numRuntimeOps,\n\t\t\tnumUnsummarizedNonRuntimeOps: this._heuristicData?.numNonRuntimeOps,\n\t\t});\n\n\t\tconst runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n\t\t// Wait for either external signal to cancel, or loss of connectivity.\n\t\tconst stopReason = await stopP;\n\n\t\t// There are two possible approaches here:\n\t\t// 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n\t\t// faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n\t\t// We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n\t\t// The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n\t\t// did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n\t\t// that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n\t\t// In general, it's more wasted resources.\n\t\t// 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n\t\t// that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n\t\t// substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n\t\t// conflict with new summarizer client starting on different client.\n\t\t// As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n\t\t// summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n\t\t// cons of #2 substantially.\n\n\t\t// Cleanup after running\n\t\tawait runningSummarizer.waitStop(\n\t\t\t!runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason),\n\t\t);\n\n\t\t// Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n\t\trunCoordinator.stop(stopReason);\n\n\t\treturn stopReason;\n\t}\n\n\t/**\n\t * Should we try to run a last summary for the given stop reason?\n\t * Currently only allows \"parentNotConnected\"\n\t * @param stopReason - SummarizerStopReason\n\t * @returns `true` if the stop reason can run a last summary, otherwise `false`.\n\t */\n\tpublic static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n\t\treturn stopReason === \"parentNotConnected\";\n\t}\n\n\tprivate _heuristicData: ISummarizeHeuristicData | undefined;\n\n\t/**\n\t * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n\t * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n\t * (in the on-demand case).\n\t * @param onBehalfOf - ID of the client that requested that the summarizer start\n\t * @param runCoordinator - cancellation token\n\t * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n\t * @returns A promise that is fulfilled when the RunningSummarizer is ready.\n\t */\n\tprivate async start(\n\t\tonBehalfOf: string,\n\n\t\trunCoordinator: ICancellableSummarizerController,\n\t): Promise<RunningSummarizer> {\n\t\tif (this.runningSummarizer) {\n\t\t\tif (this.runningSummarizer.disposed) {\n\t\t\t\tthrow new UsageError(\"Starting a disposed summarizer\");\n\t\t\t}\n\t\t\treturn this.runningSummarizer;\n\t\t}\n\t\tif (this.starting) {\n\t\t\tthrow new UsageError(\"Attempting to start a summarizer that is already starting\");\n\t\t}\n\t\tthis.starting = true;\n\t\t// Initialize values and first ack (time is not exact)\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"RunningSummarizer\",\n\t\t\tonBehalfOf,\n\t\t\tinitSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\tconfig: JSON.stringify(this.configurationGetter()),\n\t\t});\n\n\t\t// Summarizing container ID (with clientType === \"summarizer\")\n\t\tconst clientId = this.runtime.clientId;\n\t\tif (clientId === undefined) {\n\t\t\tthrow new UsageError(\"clientId should be defined if connected.\");\n\t\t}\n\n\t\tthis._heuristicData = new SummarizeHeuristicData(\n\t\t\tthis.runtime.deltaManager.lastSequenceNumber,\n\t\t\t{\n\t\t\t\t/**\n\t\t\t\t * summary attempt baseline for heuristics\n\t\t\t\t */\n\t\t\t\trefSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n\t\t\t\tsummaryTime: Date.now(),\n\t\t\t} as const,\n\t\t);\n\n\t\tconst runningSummarizer = await RunningSummarizer.start(\n\t\t\tthis.logger,\n\t\t\tthis.summaryCollection.createWatcher(clientId),\n\t\t\tthis.configurationGetter(),\n\t\t\tasync (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n\t\t\tasync (...args) => this.internalsProvider.refreshLatestSummaryAck(...args), // refreshLatestSummaryAckCallback\n\t\t\tthis._heuristicData,\n\t\t\tthis.summaryCollection,\n\t\t\trunCoordinator /* cancellationToken */,\n\t\t\t(reason) => runCoordinator.stop(reason) /* stopSummarizerCallback */,\n\t\t\tthis.runtime,\n\t\t);\n\t\tthis.runningSummarizer = runningSummarizer;\n\t\tthis.setupForwardedEvents(runningSummarizer);\n\t\tthis.starting = false;\n\t\treturn runningSummarizer;\n\t}\n\n\t/**\n\t * Disposes of resources after running. This cleanup will\n\t * clear any outstanding timers and reset some of the state\n\t * properties.\n\t * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n\t */\n\tpublic dispose(): void {\n\t\t// Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n\t\tthis.stop(\"summarizerClientDisconnected\");\n\n\t\tthis._disposed = true;\n\t\tif (this.runningSummarizer) {\n\t\t\tthis.cleanupForwardedEvents();\n\t\t\tthis.runningSummarizer.dispose();\n\t\t\tthis.runningSummarizer = undefined;\n\t\t}\n\t}\n\n\tpublic summarizeOnDemand(options: IOnDemandSummarizeOptions): ISummarizeResults {\n\t\ttry {\n\t\t\tif (this._disposed || this.runningSummarizer?.disposed === true) {\n\t\t\t\tthrow new UsageError(\"Summarizer is already disposed.\");\n\t\t\t}\n\t\t\tif (\n\t\t\t\tthis.runtime.summarizerClientId !== undefined &&\n\t\t\t\tthis.runtime.summarizerClientId !== this.runtime.clientId\n\t\t\t) {\n\t\t\t\t// If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n\t\t\t\t// This is to prevent the on-demand summary and heuristic-based summary from stepping on\n\t\t\t\t// each other.\n\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\"On-demand summary attempted while an elected summarizer is present\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst builder = new SummarizeResultBuilder();\n\t\t\tif (this.runningSummarizer) {\n\t\t\t\t// Summarizer is already running. Go ahead and start.\n\t\t\t\treturn this.runningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t}\n\n\t\t\t// Summarizer isn't running, so we need to start it, which is an async operation.\n\t\t\t// Manage the promise related to creating the cancellation token here.\n\t\t\t// The promises related to starting, summarizing,\n\t\t\t// and submitting are communicated to the caller through the results builder.\n\t\t\tconst coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n\t\t\tcoordinatorCreateP\n\t\t\t\t.then((runCoordinator) => {\n\t\t\t\t\t// Successfully created the cancellation token. Start the summarizer.\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\tconst startP = this.start(this.runtime.clientId!, runCoordinator);\n\t\t\t\t\tstartP\n\t\t\t\t\t\t.then(async (runningSummarizer) => {\n\t\t\t\t\t\t\t// Successfully started the summarizer. Run it.\n\t\t\t\t\t\t\trunningSummarizer.summarizeOnDemand(options, builder);\n\t\t\t\t\t\t\t// Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n\t\t\t\t\t\t\tconst stopReason = await Promise.race([\n\t\t\t\t\t\t\t\tthis.stopDeferred.promise,\n\t\t\t\t\t\t\t\trunCoordinator.waitCancelled,\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tawait runningSummarizer.waitStop(false);\n\t\t\t\t\t\t\trunCoordinator.stop(stopReason);\n\t\t\t\t\t\t\tthis.close();\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\t\t\tbuilder.fail(\"Failed to start summarizer\", error);\n\t\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.catch((error: IRetriableFailureError) => {\n\t\t\t\t\tbuilder.fail(\"Failed to create cancellation token\", error);\n\t\t\t\t});\n\n\t\t\treturn builder.build();\n\t\t} catch (error) {\n\t\t\tthrow SummarizingWarning.wrap(error, false /* logged */, this.logger);\n\t\t}\n\t}\n\n\tpublic enqueueSummarize(options: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tif (\n\t\t\tthis._disposed ||\n\t\t\tthis.runningSummarizer === undefined ||\n\t\t\tthis.runningSummarizer.disposed\n\t\t) {\n\t\t\tthrow new UsageError(\"Summarizer is not running or already disposed.\");\n\t\t}\n\t\treturn this.runningSummarizer.enqueueSummarize(options);\n\t}\n\n\tpublic recordSummaryAttempt?(summaryRefSeqNum?: number): void {\n\t\tthis._heuristicData?.recordAttempt(summaryRefSeqNum);\n\t}\n\n\tprivate readonly forwardedEventsCleanup: (() => void)[] = [];\n\n\tprivate setupForwardedEvents(runningSummarizer: RunningSummarizer): void {\n\t\tfor (const event of [\n\t\t\t\"summarize\",\n\t\t\t\"summarizeAllAttemptsFailed\",\n\t\t\t\"summarizeTimeout\",\n\t\t] as const) {\n\t\t\tconst listener = (...args: unknown[]): void => {\n\t\t\t\tthis.emit(event, ...args);\n\t\t\t};\n\t\t\trunningSummarizer.on(event, listener);\n\t\t\tthis.forwardedEventsCleanup.push(() => runningSummarizer.off(event, listener));\n\t\t}\n\t}\n\n\tprivate cleanupForwardedEvents(): void {\n\t\tfor (const cleanup of this.forwardedEventsCleanup) {\n\t\t\tcleanup();\n\t\t}\n\t\tthis.forwardedEventsCleanup.length = 0;\n\t}\n}\n"]}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
+
import type { ISummarizerEvents } from "@fluidframework/container-runtime-definitions/internal";
|
|
5
7
|
import { type IPromiseTimer } from "@fluidframework/core-utils/internal";
|
|
6
8
|
import { type ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
7
9
|
import type { IRefreshSummaryAckOptions, ISubmitSummaryOptions, ISummarizeHeuristicData, SubmitSummaryResult } from "../summarizerTypes.js";
|
|
@@ -11,7 +13,7 @@ import type { ISummarizeResults } from "./summaryResultTypes.js";
|
|
|
11
13
|
/**
|
|
12
14
|
* This class generates and tracks a summary attempt.
|
|
13
15
|
*/
|
|
14
|
-
export declare class SummaryGenerator {
|
|
16
|
+
export declare class SummaryGenerator extends TypedEventEmitter<ISummarizerEvents> {
|
|
15
17
|
private readonly pendingAckTimer;
|
|
16
18
|
private readonly heuristicData;
|
|
17
19
|
private readonly submitSummaryCallback;
|
|
@@ -20,6 +22,7 @@ export declare class SummaryGenerator {
|
|
|
20
22
|
private readonly summaryWatcher;
|
|
21
23
|
private readonly logger;
|
|
22
24
|
private readonly summarizeTimer;
|
|
25
|
+
private activeTelemetryContext?;
|
|
23
26
|
constructor(pendingAckTimer: IPromiseTimer, heuristicData: ISummarizeHeuristicData, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, successfulSummaryCallback: () => void, refreshLatestSummaryCallback: (options: IRefreshSummaryAckOptions) => Promise<void>, summaryWatcher: Pick<IClientSummaryWatcher, "watchSummary">, logger: ITelemetryLoggerExt);
|
|
24
27
|
/**
|
|
25
28
|
* Generates summary and listens for broadcast and ack/nack.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryGenerator.d.ts","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAU,KAAK,aAAa,EAAS,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"summaryGenerator.d.ts","sourceRoot":"","sources":["../../../src/summary/summaryDelayLoadedModule/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wDAAwD,CAAC;AAChG,OAAO,EAAU,KAAK,aAAa,EAAS,MAAM,qCAAqC,CAAC;AAIxF,OAAO,EAEN,KAAK,mBAAmB,EAGxB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,yBAAyB,EAEzB,qBAAqB,EACrB,uBAAuB,E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