@fluidframework/container-runtime 2.0.0-internal.6.0.0 → 2.0.0-internal.6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +15 -11
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +1 -2
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/deltaManagerProxyBase.d.ts +35 -0
- package/dist/deltaManagerProxyBase.d.ts.map +1 -0
- package/dist/deltaManagerProxyBase.js +77 -0
- package/dist/deltaManagerProxyBase.js.map +1 -0
- package/dist/deltaManagerSummarizerProxy.d.ts +1 -1
- package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
- package/dist/deltaManagerSummarizerProxy.js +2 -2
- package/dist/deltaManagerSummarizerProxy.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/summary/runningSummarizer.d.ts.map +1 -1
- package/dist/summary/runningSummarizer.js +8 -24
- package/dist/summary/runningSummarizer.js.map +1 -1
- package/dist/summary/summaryGenerator.d.ts.map +1 -1
- package/dist/summary/summaryGenerator.js +0 -1
- package/dist/summary/summaryGenerator.js.map +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +15 -11
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +1 -2
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/deltaManagerProxyBase.d.ts +35 -0
- package/lib/deltaManagerProxyBase.d.ts.map +1 -0
- package/lib/deltaManagerProxyBase.js +73 -0
- package/lib/deltaManagerProxyBase.js.map +1 -0
- package/lib/deltaManagerSummarizerProxy.d.ts +1 -1
- package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
- package/lib/deltaManagerSummarizerProxy.js +1 -1
- package/lib/deltaManagerSummarizerProxy.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/summary/runningSummarizer.d.ts.map +1 -1
- package/lib/summary/runningSummarizer.js +8 -24
- package/lib/summary/runningSummarizer.js.map +1 -1
- package/lib/summary/summaryGenerator.d.ts.map +1 -1
- package/lib/summary/summaryGenerator.js +0 -1
- package/lib/summary/summaryGenerator.js.map +1 -1
- package/package.json +19 -31
- package/src/containerRuntime.ts +21 -16
- package/src/dataStoreContext.ts +1 -2
- package/src/deltaManagerProxyBase.ts +111 -0
- package/src/deltaManagerSummarizerProxy.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/summary/runningSummarizer.ts +9 -31
- package/src/summary/summaryGenerator.ts +0 -1
|
@@ -11,7 +11,6 @@ import { opSize } from "../opProperties";
|
|
|
11
11
|
import { SummarizeHeuristicRunner } from "./summarizerHeuristics";
|
|
12
12
|
import { raceTimer, SummarizeResultBuilder, SummaryGenerator, } from "./summaryGenerator";
|
|
13
13
|
const maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes
|
|
14
|
-
const defaultNumberSummarizationAttempts = 2; // only up to 2 attempts
|
|
15
14
|
/**
|
|
16
15
|
* An instance of RunningSummarizer manages the heuristics for summarizing.
|
|
17
16
|
* Until disposed, the instance of RunningSummarizer can assume that it is
|
|
@@ -378,26 +377,12 @@ export class RunningSummarizer {
|
|
|
378
377
|
const attempts = [
|
|
379
378
|
{ refreshLatestAck: false, fullTree: false },
|
|
380
379
|
{ refreshLatestAck: true, fullTree: false },
|
|
381
|
-
{ refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },
|
|
382
|
-
{ refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },
|
|
383
380
|
];
|
|
384
381
|
let overrideDelaySeconds;
|
|
385
382
|
let summaryAttempts = 0;
|
|
386
383
|
let summaryAttemptsPerPhase = 0;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
defaultNumberSummarizationAttempts;
|
|
390
|
-
if (totalAttempts > attempts.length) {
|
|
391
|
-
this.mc.logger.sendTelemetryEvent({
|
|
392
|
-
eventName: "InvalidSummarizerAttempts",
|
|
393
|
-
attempts: totalAttempts,
|
|
394
|
-
});
|
|
395
|
-
totalAttempts = defaultNumberSummarizationAttempts;
|
|
396
|
-
}
|
|
397
|
-
else if (totalAttempts < 1) {
|
|
398
|
-
throw new UsageError("Invalid number of attempts.");
|
|
399
|
-
}
|
|
400
|
-
for (let summaryAttemptPhase = 0; summaryAttemptPhase < totalAttempts;) {
|
|
384
|
+
let summaryAttemptPhase = 0;
|
|
385
|
+
while (summaryAttemptPhase < attempts.length) {
|
|
401
386
|
if (this.cancellationToken.cancelled) {
|
|
402
387
|
return;
|
|
403
388
|
}
|
|
@@ -406,30 +391,29 @@ export class RunningSummarizer {
|
|
|
406
391
|
return;
|
|
407
392
|
}
|
|
408
393
|
summaryAttemptsPerPhase++;
|
|
409
|
-
const
|
|
394
|
+
const summarizeOptions = attempts[summaryAttemptPhase];
|
|
410
395
|
const summarizeProps = {
|
|
411
396
|
reason,
|
|
412
397
|
summaryAttempts,
|
|
413
398
|
summaryAttemptsPerPhase,
|
|
414
399
|
summaryAttemptPhase: summaryAttemptPhase + 1,
|
|
415
|
-
...
|
|
400
|
+
...summarizeOptions,
|
|
416
401
|
};
|
|
417
402
|
// Note: no need to account for cancellationToken.waitCancelled here, as
|
|
418
403
|
// this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.
|
|
419
|
-
const resultSummarize = this.generator.summarize(summarizeProps,
|
|
404
|
+
const resultSummarize = this.generator.summarize(summarizeProps, summarizeOptions, cancellationToken);
|
|
420
405
|
const result = await resultSummarize.receivedSummaryAckOrNack;
|
|
421
406
|
if (result.success) {
|
|
422
407
|
return;
|
|
423
408
|
}
|
|
424
409
|
// Check for retryDelay that can come from summaryNack or upload summary flow.
|
|
425
410
|
// Retry the same step only once per retryAfter response.
|
|
426
|
-
|
|
427
|
-
if (
|
|
411
|
+
const delaySeconds = result.retryAfterSeconds;
|
|
412
|
+
if (delaySeconds === undefined || summaryAttemptsPerPhase > 1) {
|
|
428
413
|
summaryAttemptPhase++;
|
|
429
414
|
summaryAttemptsPerPhase = 0;
|
|
430
415
|
}
|
|
431
|
-
|
|
432
|
-
if (delaySeconds > 0) {
|
|
416
|
+
if (delaySeconds !== undefined) {
|
|
433
417
|
this.mc.logger.sendPerformanceEvent({
|
|
434
418
|
eventName: "SummarizeAttemptDelay",
|
|
435
419
|
duration: delaySeconds,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../../src/summary/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,YAAY,EAEZ,4BAA4B,EAC5B,iBAAiB,GACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAmBlE,OAAO,EACN,SAAS,EAET,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D,MAAM,kCAAkC,GAAG,CAAC,CAAC,CAAC,wBAAwB;AAEtE;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAgG7B,YACC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*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tisFluidError,\n\tMonitoringContext,\n\tcreateChildMonitoringContext,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryConfiguration } from \"../containerRuntime\";\nimport { opSize } from \"../opProperties\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n\tIEnqueueSummarizeOptions,\n\tISummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tIOnDemandSummarizeOptions,\n\tEnqueueSummarizeResult,\n\tSummarizerStopReason,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tISummaryCancellationToken,\n\tISummarizeResults,\n\tISummarizeTelemetryProperties,\n\tISummarizerRuntime,\n\tISummarizeRunnerTelemetry,\n\tIRefreshSummaryAckOptions,\n} from \"./summarizerTypes\";\nimport { IAckedSummary, IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n\traceTimer,\n\tSummarizeReason,\n\tSummarizeResultBuilder,\n\tSummaryGenerator,\n} from \"./summaryGenerator\";\n\nconst maxSummarizeAckWaitTime = 10 * 60 * 1000; // 10 minutes\n\nconst defaultNumberSummarizationAttempts = 2; // only up to 2 attempts\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 implements IDisposable {\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\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// Before doing any heuristics or proceeding with its refreshing, if there is a summary ack received while\n\t\t// this summarizer catches up, let's refresh state before proceeding with the summarization.\n\t\tconst lastAckRefSeq = await summarizer.handleSummaryAck();\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Handle summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(lastAckRefSeq).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() {\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\toptions: 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\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\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\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\tif (configuration.state !== \"disableHeuristics\") {\n\t\t\tassert(\n\t\t\t\tthis.configuration.state === \"enabled\",\n\t\t\t\t0x2ea /* \"Configuration state should be enabled\" */,\n\t\t\t);\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tthis.configuration,\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(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\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\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\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\t}\n\n\tprivate async handleSummaryAck(): Promise<number> {\n\t\tconst lastAck: IAckedSummary | undefined = this.summaryCollection.latestAck;\n\t\tlet refSequenceNumber = -1;\n\t\t// In case we haven't received the lastestAck yet, just return.\n\t\tif (lastAck !== undefined) {\n\t\t\trefSequenceNumber = lastAck.summaryOp.referenceSequenceNumber;\n\t\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\t\tconst summaryOpHandle = lastAck.summaryOp.contents.handle;\n\t\t\tconst summaryAckHandle = lastAck.summaryAck.contents.handle;\n\t\t\twhile (this.summarizingLock !== undefined) {\n\t\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t});\n\t\t\t\tawait this.summarizingLock;\n\t\t\t}\n\n\t\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t\t// executing the refreshLatestSummaryAck.\n\t\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\t\tawait this.lockedSummaryAction(\n\t\t\t\t() => {},\n\t\t\t\tasync () =>\n\t\t\t\t\tthis.refreshLatestSummaryAckCallback({\n\t\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\t\tsummaryLogger,\n\t\t\t\t\t}).catch(async (error) => {\n\t\t\t\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t\t\t\t// summary, we might me missing a summary ack, so in that case we are still fine as the\n\t\t\t\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t\t\t\t// by calling `refreshLatestSummaryAckFromServer` and we will be fine.\n\t\t\t\t\t\tconst isIgnoredError =\n\t\t\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError;\n\n\t\t\t\t\t\tsummaryLogger.sendTelemetryEvent(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\terror,\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\trefSequenceNumber++;\n\t\t}\n\t\treturn refSequenceNumber;\n\t}\n\n\t/**\n\t * Responsible for receiving and processing all the summaryAcks.\n\t * In case there was a summary ack processed by the running summarizer before processIncomingSummaryAcks is called,\n\t * it will wait for the summary ack that is newer than the one indicated by the lastAckRefSeq.\n\t * @param lastAckRefSeq - Identifies the minimum reference sequence number the summarizer needs to wait for.\n\t * In case of a negative number, the summarizer will wait for ANY summary ack that is greater than the deltaManager's initial sequence number,\n\t * and, in case of a positive one, it will wait for a summary ack that is greater than this current reference sequence number.\n\t */\n\tprivate async processIncomingSummaryAcks(lastAckRefSeq: number) {\n\t\tlet refSequenceNumber =\n\t\t\tlastAckRefSeq > 0 ? lastAckRefSeq : this.runtime.deltaManager.initialSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\n\t\t\t// Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n\t\t\t// we record undefined, not previous handles.\n\t\t\tawait this.summaryCollection.waitSummaryAck(refSequenceNumber);\n\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"processIncomingSummaryAcks\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tlastAckRefSeq,\n\t\t\t});\n\n\t\t\trefSequenceNumber = await this.handleSummaryAck();\n\t\t\t// A valid Summary Ack must have been processed.\n\t\t\tassert(refSequenceNumber >= 0, 0x58f /* Invalid ref sequence number */);\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 = (summaryOpRefSeq) =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/** We only want a single heuristic runner micro-task (will provide better optimized grouping of ops) */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean) {\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\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(op: ISequencedDocumentMessage, runtimeMessage: boolean): 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\tdefault:\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\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 (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n\t\t\tif (this.summarizingLock === undefined) {\n\t\t\t\tthis.trySummarizeOnce(\n\t\t\t\t\t// summarizeProps\n\t\t\t\t\t{ reason: \"lastSummary\" },\n\t\t\t\t\t// ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n\t\t\t\t\t{},\n\t\t\t\t);\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\t}\n\n\tprivate async waitStart() {\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() {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction() {\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 - result of action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\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 * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken = this.cancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\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 summarizeResult = this.generator.summarize(\n\t\t\t\t\tsummarizeProps,\n\t\t\t\t\toptions,\n\t\t\t\t\tcancellationToken,\n\t\t\t\t\tresultsBuilder,\n\t\t\t\t);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\treturn summarizeResult.receivedSummaryAckOrNack;\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/** Heuristics summarize attempt. */\n\tprivate trySummarize(\n\t\treason: SummarizeReason,\n\t\tcancellationToken = this.cancellationToken,\n\t): 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\tconst attempts: (ISummarizeOptions & { delaySeconds?: number })[] = [\n\t\t\t\t\t{ refreshLatestAck: false, fullTree: false },\n\t\t\t\t\t{ refreshLatestAck: true, fullTree: false },\n\t\t\t\t\t{ refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },\n\t\t\t\t\t{ refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },\n\t\t\t\t];\n\t\t\t\tlet overrideDelaySeconds: number | undefined;\n\t\t\t\tlet summaryAttempts = 0;\n\t\t\t\tlet summaryAttemptsPerPhase = 0;\n\t\t\t\t// Reducing the default number of attempts to defaultNumberofSummarizationAttempts.\n\t\t\t\tlet totalAttempts =\n\t\t\t\t\tthis.mc.config.getNumber(\"Fluid.Summarizer.Attempts\") ??\n\t\t\t\t\tdefaultNumberSummarizationAttempts;\n\n\t\t\t\tif (totalAttempts > attempts.length) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"InvalidSummarizerAttempts\",\n\t\t\t\t\t\tattempts: totalAttempts,\n\t\t\t\t\t});\n\t\t\t\t\ttotalAttempts = defaultNumberSummarizationAttempts;\n\t\t\t\t} else if (totalAttempts < 1) {\n\t\t\t\t\tthrow new UsageError(\"Invalid number of attempts.\");\n\t\t\t\t}\n\n\t\t\t\tfor (let summaryAttemptPhase = 0; summaryAttemptPhase < totalAttempts; ) {\n\t\t\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// We only want to attempt 1 summary when reason is \"lastSummary\"\n\t\t\t\t\tif (++summaryAttempts > 1 && reason === \"lastSummary\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tsummaryAttemptsPerPhase++;\n\n\t\t\t\t\tconst { delaySeconds: regularDelaySeconds = 0, ...options } =\n\t\t\t\t\t\tattempts[summaryAttemptPhase];\n\n\t\t\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\t\t\treason,\n\t\t\t\t\t\tsummaryAttempts,\n\t\t\t\t\t\tsummaryAttemptsPerPhase,\n\t\t\t\t\t\tsummaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n\t\t\t\t\t\t...options,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Note: no need to account for cancellationToken.waitCancelled here, as\n\t\t\t\t\t// this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n\t\t\t\t\tconst resultSummarize = this.generator.summarize(\n\t\t\t\t\t\tsummarizeProps,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\tcancellationToken,\n\t\t\t\t\t);\n\t\t\t\t\tconst result = await resultSummarize.receivedSummaryAckOrNack;\n\n\t\t\t\t\tif (result.success) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for retryDelay that can come from summaryNack or upload summary flow.\n\t\t\t\t\t// Retry the same step only once per retryAfter response.\n\t\t\t\t\toverrideDelaySeconds = result.retryAfterSeconds;\n\t\t\t\t\tif (overrideDelaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n\t\t\t\t\t\tsummaryAttemptPhase++;\n\t\t\t\t\t\tsummaryAttemptsPerPhase = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst delaySeconds = overrideDelaySeconds ?? regularDelaySeconds;\n\n\t\t\t\t\tif (delaySeconds > 0) {\n\t\t\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\t\t\tduration: delaySeconds,\n\t\t\t\t\t\t\tsummaryNackDelay: overrideDelaySeconds !== undefined,\n\t\t\t\t\t\t\t...summarizeProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait delay(delaySeconds * 1000);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\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/** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n\tpublic summarizeOnDemand(\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t\t{ reason, ...options }: IOnDemandSummarizeOptions,\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\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 result = this.trySummarizeOnce(\n\t\t\t{ reason: `onDemand/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n\tpublic enqueueSummarize({\n\t\treason,\n\t\tafterSequenceNumber = 0,\n\t\toverride = false,\n\t\t...options\n\t}: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst onDemandReason = `enqueue;${reason}` as const;\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\tundefined,\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\t\tthis.enqueuedSummary = {\n\t\t\treason: onDemandReason,\n\t\t\tafterSequenceNumber,\n\t\t\toptions,\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 }\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary() {\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, options } = 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{ reason: `enqueuedSummary/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary() {\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\tundefined,\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/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,YAAY,EAEZ,4BAA4B,EAC5B,iBAAiB,GACjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAA6B,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAmBlE,OAAO,EACN,SAAS,EAET,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAgG7B,YACC,UAAgC,EACf,cAAqC,EACrC,aAAoC,EACpC,qBAEgB,EAChB,+BAEC,EACD,aAAsC,EACtC,iBAAoC,EACpC,iBAA4C,EAC5C,sBAA8D,EAC9D,OAA2B;QAZ3B,mBAAc,GAAd,cAAc,CAAuB;QACrC,kBAAa,GAAb,aAAa,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAEL;QAChB,oCAA+B,GAA/B,+BAA+B,CAE9B;QACD,kBAAa,GAAb,aAAa,CAAyB;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B;QAC7B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CACvC,uCAAuC,EACvC,SAAS,CACT,CAAC;YACF,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SACjC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tisFluidError,\n\tMonitoringContext,\n\tcreateChildMonitoringContext,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\nimport { ISummaryConfiguration } from \"../containerRuntime\";\nimport { opSize } from \"../opProperties\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n\tIEnqueueSummarizeOptions,\n\tISummarizeOptions,\n\tISummarizeHeuristicData,\n\tISummarizeHeuristicRunner,\n\tIOnDemandSummarizeOptions,\n\tEnqueueSummarizeResult,\n\tSummarizerStopReason,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tISummaryCancellationToken,\n\tISummarizeResults,\n\tISummarizeTelemetryProperties,\n\tISummarizerRuntime,\n\tISummarizeRunnerTelemetry,\n\tIRefreshSummaryAckOptions,\n} from \"./summarizerTypes\";\nimport { IAckedSummary, IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n\traceTimer,\n\tSummarizeReason,\n\tSummarizeResultBuilder,\n\tSummaryGenerator,\n} from \"./summaryGenerator\";\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 implements IDisposable {\n\tpublic static async start(\n\t\tlogger: ITelemetryBaseLogger,\n\t\tsummaryWatcher: IClientSummaryWatcher,\n\t\tconfiguration: ISummaryConfiguration,\n\t\tsubmitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n\t\trefreshLatestSummaryAckCallback: (options: IRefreshSummaryAckOptions) => Promise<void>,\n\t\theuristicData: ISummarizeHeuristicData,\n\t\tsummaryCollection: SummaryCollection,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tstopSummarizerCallback: (reason: SummarizerStopReason) => void,\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// Before doing any heuristics or proceeding with its refreshing, if there is a summary ack received while\n\t\t// this summarizer catches up, let's refresh state before proceeding with the summarization.\n\t\tconst lastAckRefSeq = await summarizer.handleSummaryAck();\n\n\t\tawait summarizer.waitStart();\n\n\t\t// Handle summary acks asynchronously\n\t\t// Note: no exceptions are thrown from processIncomingSummaryAcks handler as it handles all exceptions\n\t\tsummarizer.processIncomingSummaryAcks(lastAckRefSeq).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() {\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\toptions: 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\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\t\tprivate readonly cancellationToken: ISummaryCancellationToken,\n\t\tprivate readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n\t\tprivate readonly runtime: ISummarizerRuntime,\n\t) {\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\tif (configuration.state !== \"disableHeuristics\") {\n\t\t\tassert(\n\t\t\t\tthis.configuration.state === \"enabled\",\n\t\t\t\t0x2ea /* \"Configuration state should be enabled\" */,\n\t\t\t);\n\t\t\tthis.heuristicRunner = new SummarizeHeuristicRunner(\n\t\t\t\theuristicData,\n\t\t\t\tthis.configuration,\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(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\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\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\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\t}\n\n\tprivate async handleSummaryAck(): Promise<number> {\n\t\tconst lastAck: IAckedSummary | undefined = this.summaryCollection.latestAck;\n\t\tlet refSequenceNumber = -1;\n\t\t// In case we haven't received the lastestAck yet, just return.\n\t\tif (lastAck !== undefined) {\n\t\t\trefSequenceNumber = lastAck.summaryOp.referenceSequenceNumber;\n\t\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\t\t\tconst summaryOpHandle = lastAck.summaryOp.contents.handle;\n\t\t\tconst summaryAckHandle = lastAck.summaryAck.contents.handle;\n\t\t\twhile (this.summarizingLock !== undefined) {\n\t\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"RefreshAttemptWithSummarizerRunning\",\n\t\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t});\n\t\t\t\tawait this.summarizingLock;\n\t\t\t}\n\n\t\t\t// Make sure we block any summarizer from being executed/enqueued while\n\t\t\t// executing the refreshLatestSummaryAck.\n\t\t\t// https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n\t\t\tawait this.lockedSummaryAction(\n\t\t\t\t() => {},\n\t\t\t\tasync () =>\n\t\t\t\t\tthis.refreshLatestSummaryAckCallback({\n\t\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\t\tsummaryRefSeq: refSequenceNumber,\n\t\t\t\t\t\tsummaryLogger,\n\t\t\t\t\t}).catch(async (error) => {\n\t\t\t\t\t\t// If the error is 404, so maybe the fetched version no longer exists on server. We just\n\t\t\t\t\t\t// ignore this error in that case, as that means we will have another summaryAck for the\n\t\t\t\t\t\t// latest version with which we will refresh the state. However in case of single commit\n\t\t\t\t\t\t// summary, we might me missing a summary ack, so in that case we are still fine as the\n\t\t\t\t\t\t// code in `submitSummary` function in container runtime, will refresh the latest state\n\t\t\t\t\t\t// by calling `refreshLatestSummaryAckFromServer` and we will be fine.\n\t\t\t\t\t\tconst isIgnoredError =\n\t\t\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError;\n\n\t\t\t\t\t\tsummaryLogger.sendTelemetryEvent(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\teventName: isIgnoredError\n\t\t\t\t\t\t\t\t\t? \"HandleSummaryAckErrorIgnored\"\n\t\t\t\t\t\t\t\t\t: \"HandleLastSummaryAckError\",\n\t\t\t\t\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\t\t\t\t\tproposalHandle: summaryOpHandle,\n\t\t\t\t\t\t\t\tackHandle: summaryAckHandle,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\terror,\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\trefSequenceNumber++;\n\t\t}\n\t\treturn refSequenceNumber;\n\t}\n\n\t/**\n\t * Responsible for receiving and processing all the summaryAcks.\n\t * In case there was a summary ack processed by the running summarizer before processIncomingSummaryAcks is called,\n\t * it will wait for the summary ack that is newer than the one indicated by the lastAckRefSeq.\n\t * @param lastAckRefSeq - Identifies the minimum reference sequence number the summarizer needs to wait for.\n\t * In case of a negative number, the summarizer will wait for ANY summary ack that is greater than the deltaManager's initial sequence number,\n\t * and, in case of a positive one, it will wait for a summary ack that is greater than this current reference sequence number.\n\t */\n\tprivate async processIncomingSummaryAcks(lastAckRefSeq: number) {\n\t\tlet refSequenceNumber =\n\t\t\tlastAckRefSeq > 0 ? lastAckRefSeq : this.runtime.deltaManager.initialSequenceNumber;\n\t\twhile (!this.disposed) {\n\t\t\tconst summaryLogger = this.tryGetCorrelatedLogger(refSequenceNumber) ?? this.mc.logger;\n\n\t\t\t// Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n\t\t\t// we record undefined, not previous handles.\n\t\t\tawait this.summaryCollection.waitSummaryAck(refSequenceNumber);\n\n\t\t\tsummaryLogger.sendTelemetryEvent({\n\t\t\t\teventName: \"processIncomingSummaryAcks\",\n\t\t\t\treferenceSequenceNumber: refSequenceNumber,\n\t\t\t\tlastAckRefSeq,\n\t\t\t});\n\n\t\t\trefSequenceNumber = await this.handleSummaryAck();\n\t\t\t// A valid Summary Ack must have been processed.\n\t\t\tassert(refSequenceNumber >= 0, 0x58f /* Invalid ref sequence number */);\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 = (summaryOpRefSeq) =>\n\t\tthis.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n\t\t\t? this.mc.logger\n\t\t\t: undefined;\n\n\t/** We only want a single heuristic runner micro-task (will provide better optimized grouping of ops) */\n\tprivate heuristicRunnerMicroTaskExists = false;\n\n\tpublic handleOp(op: ISequencedDocumentMessage, runtimeMessage: boolean) {\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\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(op: ISequencedDocumentMessage, runtimeMessage: boolean): 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\tdefault:\n\t\t\t\treturn runtimeMessage || this.nonRuntimeOpCanTriggerSummary();\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 (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n\t\t\tif (this.summarizingLock === undefined) {\n\t\t\t\tthis.trySummarizeOnce(\n\t\t\t\t\t// summarizeProps\n\t\t\t\t\t{ reason: \"lastSummary\" },\n\t\t\t\t\t// ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n\t\t\t\t\t{},\n\t\t\t\t);\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\t}\n\n\tprivate async waitStart() {\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() {\n\t\tthis.summarizeCount++;\n\t}\n\n\tprivate afterSummaryAction() {\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 - result of action.\n\t */\n\tprivate async lockedSummaryAction<T>(\n\t\tbefore: () => void,\n\t\taction: () => Promise<T>,\n\t\tafter: () => void,\n\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 * @returns ISummarizeResult - result of running a summary.\n\t */\n\tprivate trySummarizeOnce(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken = this.cancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\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 summarizeResult = this.generator.summarize(\n\t\t\t\t\tsummarizeProps,\n\t\t\t\t\toptions,\n\t\t\t\t\tcancellationToken,\n\t\t\t\t\tresultsBuilder,\n\t\t\t\t);\n\t\t\t\t// ensure we wait till the end of the process\n\t\t\t\treturn summarizeResult.receivedSummaryAckOrNack;\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/** Heuristics summarize attempt. */\n\tprivate trySummarize(\n\t\treason: SummarizeReason,\n\t\tcancellationToken = this.cancellationToken,\n\t): 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\tconst attempts: ISummarizeOptions[] = [\n\t\t\t\t\t{ refreshLatestAck: false, fullTree: false },\n\t\t\t\t\t{ refreshLatestAck: true, fullTree: false },\n\t\t\t\t];\n\t\t\t\tlet overrideDelaySeconds: number | undefined;\n\t\t\t\tlet summaryAttempts = 0;\n\t\t\t\tlet summaryAttemptsPerPhase = 0;\n\t\t\t\tlet summaryAttemptPhase = 0;\n\t\t\t\twhile (summaryAttemptPhase < attempts.length) {\n\t\t\t\t\tif (this.cancellationToken.cancelled) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// We only want to attempt 1 summary when reason is \"lastSummary\"\n\t\t\t\t\tif (++summaryAttempts > 1 && reason === \"lastSummary\") {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tsummaryAttemptsPerPhase++;\n\n\t\t\t\t\tconst summarizeOptions = attempts[summaryAttemptPhase];\n\t\t\t\t\tconst summarizeProps: ISummarizeTelemetryProperties = {\n\t\t\t\t\t\treason,\n\t\t\t\t\t\tsummaryAttempts,\n\t\t\t\t\t\tsummaryAttemptsPerPhase,\n\t\t\t\t\t\tsummaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n\t\t\t\t\t\t...summarizeOptions,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Note: no need to account for cancellationToken.waitCancelled here, as\n\t\t\t\t\t// this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n\t\t\t\t\tconst resultSummarize = this.generator.summarize(\n\t\t\t\t\t\tsummarizeProps,\n\t\t\t\t\t\tsummarizeOptions,\n\t\t\t\t\t\tcancellationToken,\n\t\t\t\t\t);\n\t\t\t\t\tconst result = await resultSummarize.receivedSummaryAckOrNack;\n\n\t\t\t\t\tif (result.success) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Check for retryDelay that can come from summaryNack or upload summary flow.\n\t\t\t\t\t// Retry the same step only once per retryAfter response.\n\t\t\t\t\tconst delaySeconds = result.retryAfterSeconds;\n\t\t\t\t\tif (delaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n\t\t\t\t\t\tsummaryAttemptPhase++;\n\t\t\t\t\t\tsummaryAttemptsPerPhase = 0;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (delaySeconds !== undefined) {\n\t\t\t\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\t\t\t\teventName: \"SummarizeAttemptDelay\",\n\t\t\t\t\t\t\tduration: delaySeconds,\n\t\t\t\t\t\t\tsummaryNackDelay: overrideDelaySeconds !== undefined,\n\t\t\t\t\t\t\t...summarizeProps,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tawait delay(delaySeconds * 1000);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.stopSummarizerCallback(\"failToSummarize\");\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/** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n\tpublic summarizeOnDemand(\n\t\tresultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n\t\t{ reason, ...options }: IOnDemandSummarizeOptions,\n\t): ISummarizeResults {\n\t\tif (this.stopping) {\n\t\t\tresultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\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 result = this.trySummarizeOnce(\n\t\t\t{ reason: `onDemand/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn result;\n\t}\n\n\t/** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n\tpublic enqueueSummarize({\n\t\treason,\n\t\tafterSequenceNumber = 0,\n\t\toverride = false,\n\t\t...options\n\t}: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n\t\tconst onDemandReason = `enqueue;${reason}` as const;\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\tundefined,\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t\toverridden = true;\n\t\t}\n\t\tthis.enqueuedSummary = {\n\t\t\treason: onDemandReason,\n\t\t\tafterSequenceNumber,\n\t\t\toptions,\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 }\n\t\t\t: results;\n\t}\n\n\tprivate tryRunEnqueuedSummary() {\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, options } = 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{ reason: `enqueuedSummary/${reason}` },\n\t\t\toptions,\n\t\t\tthis.cancellationToken,\n\t\t\tresultsBuilder,\n\t\t);\n\t\treturn true;\n\t}\n\n\tprivate disposeEnqueuedSummary() {\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\tundefined,\n\t\t\t);\n\t\t\tthis.enqueuedSummary = undefined;\n\t\t}\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryGenerator.d.ts","sourceRoot":"","sources":["../../src/summary/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,mBAAmB,EAEnB,YAAY,EAEZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAEN,QAAQ,EACR,aAAa,EACb,mBAAmB,EAE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iBAAiB;YAYN,aAAa;IAmP3B,OAAO,CAAC,8BAA8B;IA6CtC,OAAO,CAAC,qBAAqB;IAetB,OAAO;CAGd"}
|
|
@@ -117,7 +117,6 @@ export class SummaryGenerator {
|
|
|
117
117
|
const { refreshLatestAck, fullTree } = options;
|
|
118
118
|
const logger = createChildLogger({
|
|
119
119
|
logger: this.logger,
|
|
120
|
-
namespace: undefined,
|
|
121
120
|
properties: { all: summarizeProps },
|
|
122
121
|
});
|
|
123
122
|
// Note: timeSinceLastAttempt and timeSinceLastSummary for the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summaryGenerator.js","sourceRoot":"","sources":["../../src/summary/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GACjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACN,MAAM,EACN,QAAQ,EAGR,KAAK,GACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAwBrE,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,OAAmB,EACnB,KAAmC,EACnC,iBAA6C;IAE7C,MAAM,QAAQ,GAAkC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAY,CAAA,CAAC;QAC7D,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAY,CAAA,CAAC;KAC9D,CAAC;IACF,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACpC,QAAQ,CAAC,IAAI,CACZ,iBAAiB,CAAC,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port {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tLoggingError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils\";\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\n\nimport {\n\tassert,\n\tDeferred,\n\tIPromiseTimer,\n\tIPromiseTimerResult,\n\tTimer,\n} from \"@fluidframework/common-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { getRetryDelaySecondsFromError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIAckSummaryResult,\n\tINackSummaryResult,\n\tISummarizeOptions,\n\tIBroadcastSummaryResult,\n\tISummarizeResults,\n\tISummarizeHeuristicData,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tSummarizeResultPart,\n\tISummaryCancellationToken,\n\tISummarizeTelemetryProperties,\n\tSummaryGeneratorTelemetry,\n\tSummaryStage,\n\tSubmitSummaryFailureData,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher } from \"./summaryCollection\";\n\nexport type raceTimerResult<T> =\n\t| { result: \"done\"; value: T }\n\t| { result: IPromiseTimerResult[\"timerResult\"] }\n\t| { result: \"cancelled\" };\n\n/** Helper function to wait for a promise or PromiseTimer to elapse. */\nexport async function raceTimer<T>(\n\tpromise: Promise<T>,\n\ttimer: Promise<IPromiseTimerResult>,\n\tcancellationToken?: ISummaryCancellationToken,\n): Promise<raceTimerResult<T>> {\n\tconst promises: Promise<raceTimerResult<T>>[] = [\n\t\tpromise.then((value) => ({ result: \"done\", value } as const)),\n\t\ttimer.then(({ timerResult: result }) => ({ result } as const)),\n\t];\n\tif (cancellationToken !== undefined) {\n\t\tpromises.push(\n\t\t\tcancellationToken.waitCancelled.then(() => ({ result: \"cancelled\" } as const)),\n\t\t);\n\t}\n\treturn Promise.race(promises);\n}\n\n// Send some telemetry if generate summary takes too long\nconst maxSummarizeTimeoutTime = 20000; // 20 sec\nconst maxSummarizeTimeoutCount = 5; // Double and resend 5 times\n\nexport type SummarizeReason =\n\t/**\n\t * Attempt to summarize after idle timeout has elapsed.\n\t * Idle timer restarts whenever an op is received. So this\n\t * triggers only after some amount of time has passed with\n\t * no ops being received.\n\t */\n\t| \"idle\"\n\t/**\n\t * Attempt to summarize after a maximum time since last\n\t * successful summary has passed. This measures time since\n\t * last summary ack op was processed.\n\t */\n\t| \"maxTime\"\n\t/**\n\t * Attempt to summarize after a maximum number of ops have\n\t * passed since the last successful summary. This compares\n\t * op sequence numbers with the reference sequence number\n\t * of the summarize op corresponding to the last summary\n\t * ack op.\n\t */\n\t| \"maxOps\"\n\t/**\n\t * Special case to attempt to summarize one last time before the\n\t * summarizer client closes itself. This is to prevent cases where\n\t * the summarizer client never gets a chance to summarize, because\n\t * there are too many outstanding ops and/or parent client cannot\n\t * stay connected long enough for summarizer client to catch up.\n\t */\n\t| \"lastSummary\"\n\t/** On-demand summary requested with specified reason. */\n\t| `onDemand;${string}`\n\t/** Enqueue summarize attempt with specified reason. */\n\t| `enqueue;${string}`;\n\nconst summarizeErrors = {\n\t/**\n\t * Error encountered while generating the summary tree, uploading\n\t * it to storage, or submitting the op. It could be a result of\n\t * the client becoming disconnected while generating or an actual error.\n\t */\n\tsubmitSummaryFailure: \"Error while generating, uploading, or submitting summary\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving the summarize op\n\t * sent by this summarize attempt. It is expected to be broadcast quickly.\n\t */\n\tsummaryOpWaitTimeout: \"Timeout while waiting for summarize op broadcast\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving either a\n\t * summaryAck or summaryNack op from the server in response to this\n\t * summarize attempt. It is expected that the server should respond.\n\t */\n\tsummaryAckWaitTimeout: \"Timeout while waiting for summaryAck/summaryNack op\",\n\t/**\n\t * The server responded with a summaryNack op, thus rejecting this\n\t * summarize attempt.\n\t */\n\tsummaryNack: \"Server rejected summary via summaryNack op\",\n\n\tdisconnect: \"Summary cancelled due to summarizer or main client disconnect\",\n} as const;\n\n// Helper functions to report failures and return.\nexport const getFailMessage = (errorCode: keyof typeof summarizeErrors) =>\n\t`${errorCode}: ${summarizeErrors[errorCode]}`;\n\nexport class SummarizeResultBuilder {\n\tpublic readonly summarySubmitted = new Deferred<\n\t\tSummarizeResultPart<SubmitSummaryResult, SubmitSummaryFailureData>\n\t>();\n\tpublic readonly summaryOpBroadcasted = new Deferred<\n\t\tSummarizeResultPart<IBroadcastSummaryResult>\n\t>();\n\tpublic readonly receivedSummaryAckOrNack = new Deferred<\n\t\tSummarizeResultPart<IAckSummaryResult, INackSummaryResult>\n\t>();\n\n\tpublic fail(\n\t\tmessage: string,\n\t\terror: any,\n\t\tstage: SummaryStage = \"unknown\",\n\t\tnackSummaryResult?: INackSummaryResult,\n\t\tretryAfterSeconds?: number,\n\t) {\n\t\tassert(\n\t\t\t!this.receivedSummaryAckOrNack.isCompleted,\n\t\t\t0x25e /* \"no reason to call fail if all promises have been completed\" */,\n\t\t);\n\n\t\tconst result: SummarizeResultPart<undefined> = {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t\tdata: undefined,\n\t\t\terror,\n\t\t\tretryAfterSeconds,\n\t\t} as const;\n\t\tthis.summarySubmitted.resolve({ ...result, data: { stage } });\n\t\tthis.summaryOpBroadcasted.resolve(result);\n\t\tthis.receivedSummaryAckOrNack.resolve({ ...result, data: nackSummaryResult });\n\t}\n\tpublic build(): ISummarizeResults {\n\t\treturn {\n\t\t\tsummarySubmitted: this.summarySubmitted.promise,\n\t\t\tsummaryOpBroadcasted: this.summaryOpBroadcasted.promise,\n\t\t\treceivedSummaryAckOrNack: this.receivedSummaryAckOrNack.promise,\n\t\t} as const;\n\t}\n}\n\n/**\n * Errors type for errors hit during summary that may be retriable.\n */\nexport class RetriableSummaryError extends LoggingError {\n\tpublic readonly canRetry = this.retryAfterSeconds !== undefined;\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly retryAfterSeconds?: number,\n\t\tprops?: ITelemetryProperties,\n\t) {\n\t\tsuper(message, props);\n\t}\n}\n\n/**\n * This class generates and tracks a summary attempt.\n */\nexport class SummaryGenerator {\n\tprivate readonly summarizeTimer: Timer;\n\tconstructor(\n\t\tprivate readonly pendingAckTimer: IPromiseTimer,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly successfulSummaryCallback: () => void,\n\t\tprivate readonly summaryWatcher: Pick<IClientSummaryWatcher, \"watchSummary\">,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.summarizeTimer = new Timer(maxSummarizeTimeoutTime, () =>\n\t\t\tthis.summarizeTimerHandler(maxSummarizeTimeoutTime, 1),\n\t\t);\n\t}\n\n\t/**\n\t * Generates summary and listens for broadcast and ack/nack.\n\t * Returns true for ack, false for nack, and undefined for failure or timeout.\n\t * @param reason - reason for summarizing\n\t * @param options - refreshLatestAck to fetch summary ack info from server,\n\t * fullTree to generate tree without any summary handles even if unchanged\n\t */\n\tpublic summarize(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tthis.summarizeCore(summarizeProps, options, resultsBuilder, cancellationToken).catch(\n\t\t\t(error) => {\n\t\t\t\tconst message = \"UnexpectedSummarizeError\";\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: message, ...summarizeProps }, error);\n\t\t\t\tresultsBuilder.fail(message, error);\n\t\t\t},\n\t\t);\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\tprivate async summarizeCore(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t): Promise<void> {\n\t\tconst { refreshLatestAck, fullTree } = options;\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tnamespace: undefined,\n\t\t\tproperties: { all: summarizeProps },\n\t\t});\n\n\t\t// Note: timeSinceLastAttempt and timeSinceLastSummary for the\n\t\t// first summary are basically the time since the summarizer was loaded.\n\t\tconst timeSinceLastAttempt = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\tconst timeSinceLastSummary =\n\t\t\tDate.now() - this.heuristicData.lastSuccessfulSummary.summaryTime;\n\t\tlet summarizeTelemetryProps: SummaryGeneratorTelemetry = {\n\t\t\tfullTree,\n\t\t\ttimeSinceLastAttempt,\n\t\t\ttimeSinceLastSummary,\n\t\t};\n\n\t\tconst summarizeEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"Summarize\",\n\t\t\t\trefreshLatestAck,\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\n\t\tlet summaryData: SubmitSummaryResult | undefined;\n\t\tconst fail = (\n\t\t\terrorCode: keyof typeof summarizeErrors,\n\t\t\terror?: any,\n\t\t\tproperties?: SummaryGeneratorTelemetry,\n\t\t\tnackSummaryResult?: INackSummaryResult,\n\t\t) => {\n\t\t\t// UploadSummary may fail with 429 and retryAfter - respect that\n\t\t\t// Summary Nack also can have retryAfter, it's parsed below and comes as a property.\n\t\t\tconst retryAfterSeconds = getRetryDelaySecondsFromError(error);\n\n\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t// If failure happened on upload, we may not yet realized that socket disconnected, so check\n\t\t\t// offlineError too.\n\t\t\tconst category =\n\t\t\t\tcancellationToken.cancelled || error?.errorType === DriverErrorType.offlineError\n\t\t\t\t\t? \"generic\"\n\t\t\t\t\t: \"error\";\n\n\t\t\tconst reason = getFailMessage(errorCode);\n\t\t\tsummarizeEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\t...properties,\n\t\t\t\t\treason,\n\t\t\t\t\tcategory,\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t},\n\t\t\t\terror ?? reason,\n\t\t\t); // disconnect & summaryAckTimeout do not have proper error.\n\n\t\t\t// If summarize did not hit an unexpected error, summaryData would be available. Otherwise, the state is\n\t\t\t// unknown.\n\t\t\tconst stage = summaryData?.stage ?? \"unknown\";\n\t\t\tresultsBuilder.fail(reason, error, stage, nackSummaryResult, retryAfterSeconds);\n\t\t};\n\n\t\t// Wait to generate and send summary\n\t\tthis.summarizeTimer.start();\n\t\ttry {\n\t\t\t// Need to save refSeqNum before we record new attempt (happens as part of submitSummaryCallback)\n\t\t\tconst lastAttemptRefSeqNum = this.heuristicData.lastAttempt.refSequenceNumber;\n\n\t\t\tsummaryData = await this.submitSummaryCallback({\n\t\t\t\tfullTree,\n\t\t\t\trefreshLatestAck,\n\t\t\t\tsummaryLogger: logger,\n\t\t\t\tcancellationToken,\n\t\t\t});\n\n\t\t\t// Cumulatively add telemetry properties based on how far generateSummary went.\n\t\t\tconst referenceSequenceNumber = summaryData.referenceSequenceNumber;\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\treferenceSequenceNumber,\n\t\t\t\tminimumSequenceNumber: summaryData.minimumSequenceNumber,\n\t\t\t\topsSinceLastAttempt: referenceSequenceNumber - lastAttemptRefSeqNum,\n\t\t\t\topsSinceLastSummary:\n\t\t\t\t\treferenceSequenceNumber -\n\t\t\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\tstage: summaryData.stage,\n\t\t\t};\n\t\t\tsummarizeTelemetryProps = this.addSummaryDataToTelemetryProps(\n\t\t\t\tsummaryData,\n\t\t\t\tsummarizeTelemetryProps,\n\t\t\t);\n\n\t\t\tif (summaryData.stage !== \"submit\") {\n\t\t\t\treturn fail(\"submitSummaryFailure\", summaryData.error, summarizeTelemetryProps);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * With incremental summaries, if the full tree was not summarized, only data stores that changed should\n\t\t\t * be summarized. A data store is considered changed if either or both of the following is true:\n\t\t\t * - It has received an op.\n\t\t\t * - Its reference state changed, i.e., it went from referenced to unreferenced or vice-versa.\n\t\t\t *\n\t\t\t * In the extreme case, every op can be for a different data store and each op can result in the reference\n\t\t\t * state change of multiple data stores. So, the total number of data stores that are summarized should not\n\t\t\t * exceed the number of ops since last summary + number of data store whose reference state changed.\n\t\t\t */\n\t\t\tif (!fullTree && !summaryData.forcedFullTree) {\n\t\t\t\tconst { summarizedDataStoreCount, gcStateUpdatedDataStoreCount = 0 } =\n\t\t\t\t\tsummaryData.summaryStats;\n\t\t\t\tif (\n\t\t\t\t\tsummarizedDataStoreCount >\n\t\t\t\t\tgcStateUpdatedDataStoreCount + this.heuristicData.opsSinceLastSummary\n\t\t\t\t) {\n\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"IncrementalSummaryViolation\",\n\t\t\t\t\t\tsummarizedDataStoreCount,\n\t\t\t\t\t\tgcStateUpdatedDataStoreCount,\n\t\t\t\t\t\topsSinceLastSummary: this.heuristicData.opsSinceLastSummary,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Log event here on summary success only, as Summarize_cancel duplicates failure logging.\n\t\t\tsummarizeEvent.reportEvent(\"generate\", { ...summarizeTelemetryProps });\n\t\t\tresultsBuilder.summarySubmitted.resolve({ success: true, data: summaryData });\n\t\t} catch (error) {\n\t\t\treturn fail(\"submitSummaryFailure\", error);\n\t\t} finally {\n\t\t\tif (summaryData === undefined) {\n\t\t\t\tthis.heuristicData.recordAttempt();\n\t\t\t}\n\t\t\tthis.summarizeTimer.clear();\n\t\t}\n\n\t\ttry {\n\t\t\tconst pendingTimeoutP = this.pendingAckTimer.start();\n\t\t\tconst summary = this.summaryWatcher.watchSummary(summaryData.clientSequenceNumber);\n\n\t\t\t// Wait for broadcast\n\t\t\tconst waitBroadcastResult = await raceTimer(\n\t\t\t\tsummary.waitBroadcast(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitBroadcastResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\", summaryData.stage);\n\t\t\t}\n\t\t\tif (waitBroadcastResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryOpWaitTimeout\", summaryData.stage);\n\t\t\t}\n\t\t\tconst summarizeOp = waitBroadcastResult.value;\n\n\t\t\tconst broadcastDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\t\tresultsBuilder.summaryOpBroadcasted.resolve({\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: { summarizeOp, broadcastDuration },\n\t\t\t});\n\n\t\t\tthis.heuristicData.lastAttempt.summarySequenceNumber = summarizeOp.sequenceNumber;\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"Summarize_Op\",\n\t\t\t\tduration: broadcastDuration,\n\t\t\t\treferenceSequenceNumber: summarizeOp.referenceSequenceNumber,\n\t\t\t\tsummarySequenceNumber: summarizeOp.sequenceNumber,\n\t\t\t\thandle: summarizeOp.contents.handle,\n\t\t\t});\n\n\t\t\t// Wait for ack/nack\n\t\t\tconst waitAckNackResult = await raceTimer(\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitAckNackResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\");\n\t\t\t}\n\t\t\tif (waitAckNackResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryAckWaitTimeout\");\n\t\t\t}\n\t\t\tconst ackNackOp = waitAckNackResult.value;\n\t\t\tthis.pendingAckTimer.clear();\n\n\t\t\t// Update for success/failure\n\t\t\tconst ackNackDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\n\t\t\t// adding new properties\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\tackWaitDuration: ackNackDuration,\n\t\t\t\tackNackSequenceNumber: ackNackOp.sequenceNumber,\n\t\t\t\tsummarySequenceNumber: ackNackOp.contents.summaryProposal.summarySequenceNumber,\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t};\n\t\t\tif (ackNackOp.type === MessageType.SummaryAck) {\n\t\t\t\tthis.heuristicData.markLastAttemptAsSuccessful();\n\t\t\t\tthis.successfulSummaryCallback();\n\t\t\t\tsummarizeEvent.end({\n\t\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\t\thandle: ackNackOp.contents.handle,\n\t\t\t\t});\n\t\t\t\tresultsBuilder.receivedSummaryAckOrNack.resolve({\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsummaryAckOp: ackNackOp,\n\t\t\t\t\t\tackNackDuration,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Check for retryDelay in summaryNack response.\n\t\t\t\tassert(ackNackOp.type === MessageType.SummaryNack, 0x274 /* \"type check\" */);\n\t\t\t\tconst summaryNack = ackNackOp.contents;\n\t\t\t\tconst errorMessage = summaryNack?.message;\n\t\t\t\tconst retryAfterSeconds = summaryNack?.retryAfter;\n\n\t\t\t\t// pre-0.58 error message prefix: summaryNack\n\t\t\t\tconst error = new LoggingError(`Received summaryNack`, {\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t\terrorMessage,\n\t\t\t\t});\n\n\t\t\t\tassert(\n\t\t\t\t\tgetRetryDelaySecondsFromError(error) === retryAfterSeconds,\n\t\t\t\t\t0x25f /* \"retryAfterSeconds\" */,\n\t\t\t\t);\n\t\t\t\t// This will only set resultsBuilder.receivedSummaryAckOrNack, as other promises are already set.\n\t\t\t\treturn fail(\n\t\t\t\t\t\"summaryNack\",\n\t\t\t\t\terror,\n\t\t\t\t\t{ ...summarizeTelemetryProps, nackRetryAfter: retryAfterSeconds },\n\t\t\t\t\t{ summaryNackOp: ackNackOp, ackNackDuration },\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.pendingAckTimer.clear();\n\t\t}\n\t}\n\n\tprivate addSummaryDataToTelemetryProps(\n\t\tsummaryData: SubmitSummaryResult,\n\t\tinitialProps: SummaryGeneratorTelemetry,\n\t): SummaryGeneratorTelemetry {\n\t\tswitch (summaryData.stage) {\n\t\t\tcase \"base\":\n\t\t\t\treturn initialProps;\n\n\t\t\tcase \"generate\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t};\n\n\t\t\tcase \"upload\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t};\n\n\t\t\tcase \"submit\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t\tclientSequenceNumber: summaryData.clientSequenceNumber,\n\t\t\t\t\thasMissingOpData: this.heuristicData.hasMissingOpData,\n\t\t\t\t\topsSizesSinceLastSummary: this.heuristicData.totalOpsSize,\n\t\t\t\t\tnonRuntimeOpsSinceLastSummary: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\truntimeOpsSinceLastSummary: this.heuristicData.numRuntimeOps,\n\t\t\t\t};\n\n\t\t\tdefault:\n\t\t\t\tassert(true, 0x397 /* Unexpected summary stage */);\n\t\t}\n\n\t\treturn initialProps;\n\t}\n\n\tprivate summarizeTimerHandler(time: number, count: number) {\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName: \"SummarizeTimeout\",\n\t\t\ttimeoutTime: time,\n\t\t\ttimeoutCount: count,\n\t\t});\n\t\tif (count < maxSummarizeTimeoutCount) {\n\t\t\t// Double and start a new timer\n\t\t\tconst nextTime = time * 2;\n\t\t\tthis.summarizeTimer.start(nextTime, () =>\n\t\t\t\tthis.summarizeTimerHandler(nextTime, count + 1),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic dispose() {\n\t\tthis.summarizeTimer.clear();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"summaryGenerator.js","sourceRoot":"","sources":["../../src/summary/summaryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GACjB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACN,MAAM,EACN,QAAQ,EAGR,KAAK,GACL,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAwBrE,uEAAuE;AACvE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,OAAmB,EACnB,KAAmC,EACnC,iBAA6C;IAE7C,MAAM,QAAQ,GAAkC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAY,CAAA,CAAC;QAC7D,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAY,CAAA,CAAC;KAC9D,CAAC;IACF,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACpC,QAAQ,CAAC,IAAI,CACZ,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,EAAY,CAA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f,GAAG,WAAW,CAAC,YAAY;oBAC3B,gBAAgB,EAAE,WAAW,CAAC,gBAAgB;oBAC9C,MAAM,EAAE,WAAW,CAAC,MAAM;oBAC1B,cAAc,EAAE,WAAW,CAAC,cAAc;oBAC1C,oBAAoB,EAAE,WAAW,CAAC,oBAAoB;oBACtD,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,gBAAgB;oBACrD,wBAAwB,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY;oBACzD,6BAA6B,EAAE,IAAI,CAAC,aAAa,CAAC,gBAAgB;oBAClE,0BAA0B,EAAE,IAAI,CAAC,aAAa,CAAC,aAAa;iBAC5D,CAAC;YAEH;gBACC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACpD;QAED,OAAO,YAAY,CAAC;IACrB,CAAC;IAEO,qBAAqB,CAAC,IAAY,EAAE,KAAa;QACxD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;YAChC,SAAS,EAAE,kBAAkB;YAC7B,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACnB,CAAC,CAAC;QACH,IAAI,KAAK,GAAG,wBAAwB,EAAE;YACrC,+BAA+B;YAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC;YAC1B,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,CACxC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAC/C,CAAC;SACF;IACF,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tLoggingError,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils\";\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\n\nimport {\n\tassert,\n\tDeferred,\n\tIPromiseTimer,\n\tIPromiseTimerResult,\n\tTimer,\n} from \"@fluidframework/common-utils\";\nimport { MessageType } from \"@fluidframework/protocol-definitions\";\nimport { getRetryDelaySecondsFromError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIAckSummaryResult,\n\tINackSummaryResult,\n\tISummarizeOptions,\n\tIBroadcastSummaryResult,\n\tISummarizeResults,\n\tISummarizeHeuristicData,\n\tISubmitSummaryOptions,\n\tSubmitSummaryResult,\n\tSummarizeResultPart,\n\tISummaryCancellationToken,\n\tISummarizeTelemetryProperties,\n\tSummaryGeneratorTelemetry,\n\tSummaryStage,\n\tSubmitSummaryFailureData,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher } from \"./summaryCollection\";\n\nexport type raceTimerResult<T> =\n\t| { result: \"done\"; value: T }\n\t| { result: IPromiseTimerResult[\"timerResult\"] }\n\t| { result: \"cancelled\" };\n\n/** Helper function to wait for a promise or PromiseTimer to elapse. */\nexport async function raceTimer<T>(\n\tpromise: Promise<T>,\n\ttimer: Promise<IPromiseTimerResult>,\n\tcancellationToken?: ISummaryCancellationToken,\n): Promise<raceTimerResult<T>> {\n\tconst promises: Promise<raceTimerResult<T>>[] = [\n\t\tpromise.then((value) => ({ result: \"done\", value } as const)),\n\t\ttimer.then(({ timerResult: result }) => ({ result } as const)),\n\t];\n\tif (cancellationToken !== undefined) {\n\t\tpromises.push(\n\t\t\tcancellationToken.waitCancelled.then(() => ({ result: \"cancelled\" } as const)),\n\t\t);\n\t}\n\treturn Promise.race(promises);\n}\n\n// Send some telemetry if generate summary takes too long\nconst maxSummarizeTimeoutTime = 20000; // 20 sec\nconst maxSummarizeTimeoutCount = 5; // Double and resend 5 times\n\nexport type SummarizeReason =\n\t/**\n\t * Attempt to summarize after idle timeout has elapsed.\n\t * Idle timer restarts whenever an op is received. So this\n\t * triggers only after some amount of time has passed with\n\t * no ops being received.\n\t */\n\t| \"idle\"\n\t/**\n\t * Attempt to summarize after a maximum time since last\n\t * successful summary has passed. This measures time since\n\t * last summary ack op was processed.\n\t */\n\t| \"maxTime\"\n\t/**\n\t * Attempt to summarize after a maximum number of ops have\n\t * passed since the last successful summary. This compares\n\t * op sequence numbers with the reference sequence number\n\t * of the summarize op corresponding to the last summary\n\t * ack op.\n\t */\n\t| \"maxOps\"\n\t/**\n\t * Special case to attempt to summarize one last time before the\n\t * summarizer client closes itself. This is to prevent cases where\n\t * the summarizer client never gets a chance to summarize, because\n\t * there are too many outstanding ops and/or parent client cannot\n\t * stay connected long enough for summarizer client to catch up.\n\t */\n\t| \"lastSummary\"\n\t/** On-demand summary requested with specified reason. */\n\t| `onDemand;${string}`\n\t/** Enqueue summarize attempt with specified reason. */\n\t| `enqueue;${string}`;\n\nconst summarizeErrors = {\n\t/**\n\t * Error encountered while generating the summary tree, uploading\n\t * it to storage, or submitting the op. It could be a result of\n\t * the client becoming disconnected while generating or an actual error.\n\t */\n\tsubmitSummaryFailure: \"Error while generating, uploading, or submitting summary\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving the summarize op\n\t * sent by this summarize attempt. It is expected to be broadcast quickly.\n\t */\n\tsummaryOpWaitTimeout: \"Timeout while waiting for summarize op broadcast\",\n\t/**\n\t * The summaryAckWaitTimeout time has elapsed before receiving either a\n\t * summaryAck or summaryNack op from the server in response to this\n\t * summarize attempt. It is expected that the server should respond.\n\t */\n\tsummaryAckWaitTimeout: \"Timeout while waiting for summaryAck/summaryNack op\",\n\t/**\n\t * The server responded with a summaryNack op, thus rejecting this\n\t * summarize attempt.\n\t */\n\tsummaryNack: \"Server rejected summary via summaryNack op\",\n\n\tdisconnect: \"Summary cancelled due to summarizer or main client disconnect\",\n} as const;\n\n// Helper functions to report failures and return.\nexport const getFailMessage = (errorCode: keyof typeof summarizeErrors) =>\n\t`${errorCode}: ${summarizeErrors[errorCode]}`;\n\nexport class SummarizeResultBuilder {\n\tpublic readonly summarySubmitted = new Deferred<\n\t\tSummarizeResultPart<SubmitSummaryResult, SubmitSummaryFailureData>\n\t>();\n\tpublic readonly summaryOpBroadcasted = new Deferred<\n\t\tSummarizeResultPart<IBroadcastSummaryResult>\n\t>();\n\tpublic readonly receivedSummaryAckOrNack = new Deferred<\n\t\tSummarizeResultPart<IAckSummaryResult, INackSummaryResult>\n\t>();\n\n\tpublic fail(\n\t\tmessage: string,\n\t\terror: any,\n\t\tstage: SummaryStage = \"unknown\",\n\t\tnackSummaryResult?: INackSummaryResult,\n\t\tretryAfterSeconds?: number,\n\t) {\n\t\tassert(\n\t\t\t!this.receivedSummaryAckOrNack.isCompleted,\n\t\t\t0x25e /* \"no reason to call fail if all promises have been completed\" */,\n\t\t);\n\n\t\tconst result: SummarizeResultPart<undefined> = {\n\t\t\tsuccess: false,\n\t\t\tmessage,\n\t\t\tdata: undefined,\n\t\t\terror,\n\t\t\tretryAfterSeconds,\n\t\t} as const;\n\t\tthis.summarySubmitted.resolve({ ...result, data: { stage } });\n\t\tthis.summaryOpBroadcasted.resolve(result);\n\t\tthis.receivedSummaryAckOrNack.resolve({ ...result, data: nackSummaryResult });\n\t}\n\tpublic build(): ISummarizeResults {\n\t\treturn {\n\t\t\tsummarySubmitted: this.summarySubmitted.promise,\n\t\t\tsummaryOpBroadcasted: this.summaryOpBroadcasted.promise,\n\t\t\treceivedSummaryAckOrNack: this.receivedSummaryAckOrNack.promise,\n\t\t} as const;\n\t}\n}\n\n/**\n * Errors type for errors hit during summary that may be retriable.\n */\nexport class RetriableSummaryError extends LoggingError {\n\tpublic readonly canRetry = this.retryAfterSeconds !== undefined;\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly retryAfterSeconds?: number,\n\t\tprops?: ITelemetryProperties,\n\t) {\n\t\tsuper(message, props);\n\t}\n}\n\n/**\n * This class generates and tracks a summary attempt.\n */\nexport class SummaryGenerator {\n\tprivate readonly summarizeTimer: Timer;\n\tconstructor(\n\t\tprivate readonly pendingAckTimer: IPromiseTimer,\n\t\tprivate readonly heuristicData: ISummarizeHeuristicData,\n\t\tprivate readonly submitSummaryCallback: (\n\t\t\toptions: ISubmitSummaryOptions,\n\t\t) => Promise<SubmitSummaryResult>,\n\t\tprivate readonly successfulSummaryCallback: () => void,\n\t\tprivate readonly summaryWatcher: Pick<IClientSummaryWatcher, \"watchSummary\">,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {\n\t\tthis.summarizeTimer = new Timer(maxSummarizeTimeoutTime, () =>\n\t\t\tthis.summarizeTimerHandler(maxSummarizeTimeoutTime, 1),\n\t\t);\n\t}\n\n\t/**\n\t * Generates summary and listens for broadcast and ack/nack.\n\t * Returns true for ack, false for nack, and undefined for failure or timeout.\n\t * @param reason - reason for summarizing\n\t * @param options - refreshLatestAck to fetch summary ack info from server,\n\t * fullTree to generate tree without any summary handles even if unchanged\n\t */\n\tpublic summarize(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t\tresultsBuilder = new SummarizeResultBuilder(),\n\t): ISummarizeResults {\n\t\tthis.summarizeCore(summarizeProps, options, resultsBuilder, cancellationToken).catch(\n\t\t\t(error) => {\n\t\t\t\tconst message = \"UnexpectedSummarizeError\";\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: message, ...summarizeProps }, error);\n\t\t\t\tresultsBuilder.fail(message, error);\n\t\t\t},\n\t\t);\n\n\t\treturn resultsBuilder.build();\n\t}\n\n\tprivate async summarizeCore(\n\t\tsummarizeProps: ISummarizeTelemetryProperties,\n\t\toptions: ISummarizeOptions,\n\t\tresultsBuilder: SummarizeResultBuilder,\n\t\tcancellationToken: ISummaryCancellationToken,\n\t): Promise<void> {\n\t\tconst { refreshLatestAck, fullTree } = options;\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: this.logger,\n\t\t\tproperties: { all: summarizeProps },\n\t\t});\n\n\t\t// Note: timeSinceLastAttempt and timeSinceLastSummary for the\n\t\t// first summary are basically the time since the summarizer was loaded.\n\t\tconst timeSinceLastAttempt = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\tconst timeSinceLastSummary =\n\t\t\tDate.now() - this.heuristicData.lastSuccessfulSummary.summaryTime;\n\t\tlet summarizeTelemetryProps: SummaryGeneratorTelemetry = {\n\t\t\tfullTree,\n\t\t\ttimeSinceLastAttempt,\n\t\t\ttimeSinceLastSummary,\n\t\t};\n\n\t\tconst summarizeEvent = PerformanceEvent.start(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"Summarize\",\n\t\t\t\trefreshLatestAck,\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\n\t\tlet summaryData: SubmitSummaryResult | undefined;\n\t\tconst fail = (\n\t\t\terrorCode: keyof typeof summarizeErrors,\n\t\t\terror?: any,\n\t\t\tproperties?: SummaryGeneratorTelemetry,\n\t\t\tnackSummaryResult?: INackSummaryResult,\n\t\t) => {\n\t\t\t// UploadSummary may fail with 429 and retryAfter - respect that\n\t\t\t// Summary Nack also can have retryAfter, it's parsed below and comes as a property.\n\t\t\tconst retryAfterSeconds = getRetryDelaySecondsFromError(error);\n\n\t\t\t// Report any failure as an error unless it was due to cancellation (like \"disconnected\" error)\n\t\t\t// If failure happened on upload, we may not yet realized that socket disconnected, so check\n\t\t\t// offlineError too.\n\t\t\tconst category =\n\t\t\t\tcancellationToken.cancelled || error?.errorType === DriverErrorType.offlineError\n\t\t\t\t\t? \"generic\"\n\t\t\t\t\t: \"error\";\n\n\t\t\tconst reason = getFailMessage(errorCode);\n\t\t\tsummarizeEvent.cancel(\n\t\t\t\t{\n\t\t\t\t\t...properties,\n\t\t\t\t\treason,\n\t\t\t\t\tcategory,\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t},\n\t\t\t\terror ?? reason,\n\t\t\t); // disconnect & summaryAckTimeout do not have proper error.\n\n\t\t\t// If summarize did not hit an unexpected error, summaryData would be available. Otherwise, the state is\n\t\t\t// unknown.\n\t\t\tconst stage = summaryData?.stage ?? \"unknown\";\n\t\t\tresultsBuilder.fail(reason, error, stage, nackSummaryResult, retryAfterSeconds);\n\t\t};\n\n\t\t// Wait to generate and send summary\n\t\tthis.summarizeTimer.start();\n\t\ttry {\n\t\t\t// Need to save refSeqNum before we record new attempt (happens as part of submitSummaryCallback)\n\t\t\tconst lastAttemptRefSeqNum = this.heuristicData.lastAttempt.refSequenceNumber;\n\n\t\t\tsummaryData = await this.submitSummaryCallback({\n\t\t\t\tfullTree,\n\t\t\t\trefreshLatestAck,\n\t\t\t\tsummaryLogger: logger,\n\t\t\t\tcancellationToken,\n\t\t\t});\n\n\t\t\t// Cumulatively add telemetry properties based on how far generateSummary went.\n\t\t\tconst referenceSequenceNumber = summaryData.referenceSequenceNumber;\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\treferenceSequenceNumber,\n\t\t\t\tminimumSequenceNumber: summaryData.minimumSequenceNumber,\n\t\t\t\topsSinceLastAttempt: referenceSequenceNumber - lastAttemptRefSeqNum,\n\t\t\t\topsSinceLastSummary:\n\t\t\t\t\treferenceSequenceNumber -\n\t\t\t\t\tthis.heuristicData.lastSuccessfulSummary.refSequenceNumber,\n\t\t\t\tstage: summaryData.stage,\n\t\t\t};\n\t\t\tsummarizeTelemetryProps = this.addSummaryDataToTelemetryProps(\n\t\t\t\tsummaryData,\n\t\t\t\tsummarizeTelemetryProps,\n\t\t\t);\n\n\t\t\tif (summaryData.stage !== \"submit\") {\n\t\t\t\treturn fail(\"submitSummaryFailure\", summaryData.error, summarizeTelemetryProps);\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * With incremental summaries, if the full tree was not summarized, only data stores that changed should\n\t\t\t * be summarized. A data store is considered changed if either or both of the following is true:\n\t\t\t * - It has received an op.\n\t\t\t * - Its reference state changed, i.e., it went from referenced to unreferenced or vice-versa.\n\t\t\t *\n\t\t\t * In the extreme case, every op can be for a different data store and each op can result in the reference\n\t\t\t * state change of multiple data stores. So, the total number of data stores that are summarized should not\n\t\t\t * exceed the number of ops since last summary + number of data store whose reference state changed.\n\t\t\t */\n\t\t\tif (!fullTree && !summaryData.forcedFullTree) {\n\t\t\t\tconst { summarizedDataStoreCount, gcStateUpdatedDataStoreCount = 0 } =\n\t\t\t\t\tsummaryData.summaryStats;\n\t\t\t\tif (\n\t\t\t\t\tsummarizedDataStoreCount >\n\t\t\t\t\tgcStateUpdatedDataStoreCount + this.heuristicData.opsSinceLastSummary\n\t\t\t\t) {\n\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"IncrementalSummaryViolation\",\n\t\t\t\t\t\tsummarizedDataStoreCount,\n\t\t\t\t\t\tgcStateUpdatedDataStoreCount,\n\t\t\t\t\t\topsSinceLastSummary: this.heuristicData.opsSinceLastSummary,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Log event here on summary success only, as Summarize_cancel duplicates failure logging.\n\t\t\tsummarizeEvent.reportEvent(\"generate\", { ...summarizeTelemetryProps });\n\t\t\tresultsBuilder.summarySubmitted.resolve({ success: true, data: summaryData });\n\t\t} catch (error) {\n\t\t\treturn fail(\"submitSummaryFailure\", error);\n\t\t} finally {\n\t\t\tif (summaryData === undefined) {\n\t\t\t\tthis.heuristicData.recordAttempt();\n\t\t\t}\n\t\t\tthis.summarizeTimer.clear();\n\t\t}\n\n\t\ttry {\n\t\t\tconst pendingTimeoutP = this.pendingAckTimer.start();\n\t\t\tconst summary = this.summaryWatcher.watchSummary(summaryData.clientSequenceNumber);\n\n\t\t\t// Wait for broadcast\n\t\t\tconst waitBroadcastResult = await raceTimer(\n\t\t\t\tsummary.waitBroadcast(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitBroadcastResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\", summaryData.stage);\n\t\t\t}\n\t\t\tif (waitBroadcastResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryOpWaitTimeout\", summaryData.stage);\n\t\t\t}\n\t\t\tconst summarizeOp = waitBroadcastResult.value;\n\n\t\t\tconst broadcastDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\t\t\tresultsBuilder.summaryOpBroadcasted.resolve({\n\t\t\t\tsuccess: true,\n\t\t\t\tdata: { summarizeOp, broadcastDuration },\n\t\t\t});\n\n\t\t\tthis.heuristicData.lastAttempt.summarySequenceNumber = summarizeOp.sequenceNumber;\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"Summarize_Op\",\n\t\t\t\tduration: broadcastDuration,\n\t\t\t\treferenceSequenceNumber: summarizeOp.referenceSequenceNumber,\n\t\t\t\tsummarySequenceNumber: summarizeOp.sequenceNumber,\n\t\t\t\thandle: summarizeOp.contents.handle,\n\t\t\t});\n\n\t\t\t// Wait for ack/nack\n\t\t\tconst waitAckNackResult = await raceTimer(\n\t\t\t\tsummary.waitAckNack(),\n\t\t\t\tpendingTimeoutP,\n\t\t\t\tcancellationToken,\n\t\t\t);\n\t\t\tif (waitAckNackResult.result === \"cancelled\") {\n\t\t\t\treturn fail(\"disconnect\");\n\t\t\t}\n\t\t\tif (waitAckNackResult.result !== \"done\") {\n\t\t\t\treturn fail(\"summaryAckWaitTimeout\");\n\t\t\t}\n\t\t\tconst ackNackOp = waitAckNackResult.value;\n\t\t\tthis.pendingAckTimer.clear();\n\n\t\t\t// Update for success/failure\n\t\t\tconst ackNackDuration = Date.now() - this.heuristicData.lastAttempt.summaryTime;\n\n\t\t\t// adding new properties\n\t\t\tsummarizeTelemetryProps = {\n\t\t\t\tackWaitDuration: ackNackDuration,\n\t\t\t\tackNackSequenceNumber: ackNackOp.sequenceNumber,\n\t\t\t\tsummarySequenceNumber: ackNackOp.contents.summaryProposal.summarySequenceNumber,\n\t\t\t\t...summarizeTelemetryProps,\n\t\t\t};\n\t\t\tif (ackNackOp.type === MessageType.SummaryAck) {\n\t\t\t\tthis.heuristicData.markLastAttemptAsSuccessful();\n\t\t\t\tthis.successfulSummaryCallback();\n\t\t\t\tsummarizeEvent.end({\n\t\t\t\t\t...summarizeTelemetryProps,\n\t\t\t\t\thandle: ackNackOp.contents.handle,\n\t\t\t\t});\n\t\t\t\tresultsBuilder.receivedSummaryAckOrNack.resolve({\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsummaryAckOp: ackNackOp,\n\t\t\t\t\t\tackNackDuration,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Check for retryDelay in summaryNack response.\n\t\t\t\tassert(ackNackOp.type === MessageType.SummaryNack, 0x274 /* \"type check\" */);\n\t\t\t\tconst summaryNack = ackNackOp.contents;\n\t\t\t\tconst errorMessage = summaryNack?.message;\n\t\t\t\tconst retryAfterSeconds = summaryNack?.retryAfter;\n\n\t\t\t\t// pre-0.58 error message prefix: summaryNack\n\t\t\t\tconst error = new LoggingError(`Received summaryNack`, {\n\t\t\t\t\tretryAfterSeconds,\n\t\t\t\t\terrorMessage,\n\t\t\t\t});\n\n\t\t\t\tassert(\n\t\t\t\t\tgetRetryDelaySecondsFromError(error) === retryAfterSeconds,\n\t\t\t\t\t0x25f /* \"retryAfterSeconds\" */,\n\t\t\t\t);\n\t\t\t\t// This will only set resultsBuilder.receivedSummaryAckOrNack, as other promises are already set.\n\t\t\t\treturn fail(\n\t\t\t\t\t\"summaryNack\",\n\t\t\t\t\terror,\n\t\t\t\t\t{ ...summarizeTelemetryProps, nackRetryAfter: retryAfterSeconds },\n\t\t\t\t\t{ summaryNackOp: ackNackOp, ackNackDuration },\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.pendingAckTimer.clear();\n\t\t}\n\t}\n\n\tprivate addSummaryDataToTelemetryProps(\n\t\tsummaryData: SubmitSummaryResult,\n\t\tinitialProps: SummaryGeneratorTelemetry,\n\t): SummaryGeneratorTelemetry {\n\t\tswitch (summaryData.stage) {\n\t\t\tcase \"base\":\n\t\t\t\treturn initialProps;\n\n\t\t\tcase \"generate\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t};\n\n\t\t\tcase \"upload\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t};\n\n\t\t\tcase \"submit\":\n\t\t\t\treturn {\n\t\t\t\t\t...initialProps,\n\t\t\t\t\t...summaryData.summaryStats,\n\t\t\t\t\tgenerateDuration: summaryData.generateDuration,\n\t\t\t\t\thandle: summaryData.handle,\n\t\t\t\t\tuploadDuration: summaryData.uploadDuration,\n\t\t\t\t\tclientSequenceNumber: summaryData.clientSequenceNumber,\n\t\t\t\t\thasMissingOpData: this.heuristicData.hasMissingOpData,\n\t\t\t\t\topsSizesSinceLastSummary: this.heuristicData.totalOpsSize,\n\t\t\t\t\tnonRuntimeOpsSinceLastSummary: this.heuristicData.numNonRuntimeOps,\n\t\t\t\t\truntimeOpsSinceLastSummary: this.heuristicData.numRuntimeOps,\n\t\t\t\t};\n\n\t\t\tdefault:\n\t\t\t\tassert(true, 0x397 /* Unexpected summary stage */);\n\t\t}\n\n\t\treturn initialProps;\n\t}\n\n\tprivate summarizeTimerHandler(time: number, count: number) {\n\t\tthis.logger.sendPerformanceEvent({\n\t\t\teventName: \"SummarizeTimeout\",\n\t\t\ttimeoutTime: time,\n\t\t\ttimeoutCount: count,\n\t\t});\n\t\tif (count < maxSummarizeTimeoutCount) {\n\t\t\t// Double and start a new timer\n\t\t\tconst nextTime = time * 2;\n\t\t\tthis.summarizeTimer.start(nextTime, () =>\n\t\t\t\tthis.summarizeTimerHandler(nextTime, count + 1),\n\t\t\t);\n\t\t}\n\t}\n\n\tpublic dispose() {\n\t\tthis.summarizeTimer.clear();\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-runtime",
|
|
3
|
-
"version": "2.0.0-internal.6.
|
|
3
|
+
"version": "2.0.0-internal.6.1.1",
|
|
4
4
|
"description": "Fluid container runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
39
39
|
"@fluidframework/common-utils": "^1.1.1",
|
|
40
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.6.
|
|
41
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.6.
|
|
42
|
-
"@fluidframework/container-utils": ">=2.0.0-internal.6.
|
|
43
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.
|
|
44
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.6.
|
|
45
|
-
"@fluidframework/datastore": ">=2.0.0-internal.6.
|
|
46
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.6.
|
|
47
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.6.
|
|
40
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
41
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
42
|
+
"@fluidframework/container-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
43
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
44
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
45
|
+
"@fluidframework/datastore": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
46
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
47
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
48
48
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
49
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.6.
|
|
50
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.6.
|
|
51
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.6.
|
|
49
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
50
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
51
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
52
52
|
"double-ended-queue": "^2.1.0-0",
|
|
53
53
|
"events": "^3.1.0",
|
|
54
54
|
"lz4js": "^0.2.0",
|
|
@@ -56,15 +56,15 @@
|
|
|
56
56
|
"uuid": "^8.3.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.6.
|
|
59
|
+
"@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
60
60
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
61
|
-
"@fluid-tools/build-cli": "^0.
|
|
61
|
+
"@fluid-tools/build-cli": "^0.22.0",
|
|
62
62
|
"@fluidframework/build-common": "^2.0.0",
|
|
63
|
-
"@fluidframework/build-tools": "^0.
|
|
64
|
-
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.
|
|
63
|
+
"@fluidframework/build-tools": "^0.22.0",
|
|
64
|
+
"@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.6.0.0",
|
|
65
65
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
66
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.
|
|
67
|
-
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.
|
|
66
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
67
|
+
"@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
|
|
68
68
|
"@microsoft/api-extractor": "^7.34.4",
|
|
69
69
|
"@types/double-ended-queue": "^2.1.0",
|
|
70
70
|
"@types/events": "^3.0.0",
|
|
@@ -86,19 +86,7 @@
|
|
|
86
86
|
"typescript": "~4.5.5"
|
|
87
87
|
},
|
|
88
88
|
"typeValidation": {
|
|
89
|
-
"broken": {
|
|
90
|
-
"RemovedInterfaceDeclaration_IRootSummaryTreeWithStats": {
|
|
91
|
-
"forwardCompat": false,
|
|
92
|
-
"backCompat": false
|
|
93
|
-
},
|
|
94
|
-
"ClassDeclaration_ContainerRuntime": {
|
|
95
|
-
"forwardCompat": false,
|
|
96
|
-
"backCompat": false
|
|
97
|
-
},
|
|
98
|
-
"InterfaceDeclaration_ISummarizerRuntime": {
|
|
99
|
-
"backCompat": false
|
|
100
|
-
}
|
|
101
|
-
}
|
|
89
|
+
"broken": {}
|
|
102
90
|
},
|
|
103
91
|
"scripts": {
|
|
104
92
|
"build": "fluid-build . --task build",
|
package/src/containerRuntime.ts
CHANGED
|
@@ -2852,7 +2852,6 @@ export class ContainerRuntime
|
|
|
2852
2852
|
const latestSnapshotInfo = await this.refreshLatestSummaryAckFromServer(
|
|
2853
2853
|
createChildLogger({
|
|
2854
2854
|
logger: summaryNumberLogger,
|
|
2855
|
-
namespace: undefined,
|
|
2856
2855
|
properties: { all: { safeSummary: true } },
|
|
2857
2856
|
}),
|
|
2858
2857
|
);
|
|
@@ -2952,6 +2951,27 @@ export class ContainerRuntime
|
|
|
2952
2951
|
error,
|
|
2953
2952
|
};
|
|
2954
2953
|
}
|
|
2954
|
+
|
|
2955
|
+
// If validateSummaryBeforeUpload is true, validate that the summary generated by the summarizer nodes is
|
|
2956
|
+
// correct before this summary is uploaded.
|
|
2957
|
+
if (this.validateSummaryBeforeUpload) {
|
|
2958
|
+
const validateResult = this.summarizerNode.validateSummary();
|
|
2959
|
+
if (!validateResult.success) {
|
|
2960
|
+
const { success, ...loggingProps } = validateResult;
|
|
2961
|
+
const error = new RetriableSummaryError(
|
|
2962
|
+
validateResult.reason,
|
|
2963
|
+
validateResult.retryAfterSeconds,
|
|
2964
|
+
{ ...loggingProps },
|
|
2965
|
+
);
|
|
2966
|
+
return {
|
|
2967
|
+
stage: "base",
|
|
2968
|
+
referenceSequenceNumber: summaryRefSeqNum,
|
|
2969
|
+
minimumSequenceNumber,
|
|
2970
|
+
error,
|
|
2971
|
+
};
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2955
2975
|
const { summary: summaryTree, stats: partialStats } = summarizeResult;
|
|
2956
2976
|
|
|
2957
2977
|
// Now that we have generated the summary, update the message at last summary to the last message processed.
|
|
@@ -2988,21 +3008,6 @@ export class ContainerRuntime
|
|
|
2988
3008
|
forcedFullTree,
|
|
2989
3009
|
} as const;
|
|
2990
3010
|
|
|
2991
|
-
// If validateSummaryBeforeUpload is true, validate that the summary generated by the summarizer nodes is
|
|
2992
|
-
// correct before this summary is uploaded.
|
|
2993
|
-
if (this.validateSummaryBeforeUpload) {
|
|
2994
|
-
const validateResult = this.summarizerNode.validateSummary();
|
|
2995
|
-
if (!validateResult.success) {
|
|
2996
|
-
const { success, ...loggingProps } = validateResult;
|
|
2997
|
-
const error = new RetriableSummaryError(
|
|
2998
|
-
validateResult.reason,
|
|
2999
|
-
validateResult.retryAfterSeconds,
|
|
3000
|
-
{ ...loggingProps },
|
|
3001
|
-
);
|
|
3002
|
-
return { stage: "base", ...generateSummaryData, error };
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
3011
|
continueResult = checkContinue();
|
|
3007
3012
|
if (!continueResult.continue) {
|
|
3008
3013
|
return { stage: "generate", ...generateSummaryData, error: continueResult.error };
|
package/src/dataStoreContext.ts
CHANGED
|
@@ -849,8 +849,7 @@ export abstract class FluidDataStoreContext
|
|
|
849
849
|
await this.realize();
|
|
850
850
|
}
|
|
851
851
|
assert(!!this.channel, 0x14c /* "Channel must exist when rebasing ops" */);
|
|
852
|
-
|
|
853
|
-
return this.channel.applyStashedOp(innerContents.content);
|
|
852
|
+
return this.channel.applyStashedOp(contents);
|
|
854
853
|
}
|
|
855
854
|
|
|
856
855
|
private verifyNotClosed(
|