@fluidframework/container-runtime 2.0.0-internal.5.2.0 → 2.0.0-internal.5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/blobManager.d.ts +5 -2
  3. package/dist/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager.js +51 -22
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/connectionTelemetry.d.ts.map +1 -1
  7. package/dist/connectionTelemetry.js +8 -1
  8. package/dist/connectionTelemetry.js.map +1 -1
  9. package/dist/containerRuntime.d.ts +4 -15
  10. package/dist/containerRuntime.d.ts.map +1 -1
  11. package/dist/containerRuntime.js +12 -7
  12. package/dist/containerRuntime.js.map +1 -1
  13. package/dist/dataStoreContext.d.ts.map +1 -1
  14. package/dist/dataStoreContext.js +4 -3
  15. package/dist/dataStoreContext.js.map +1 -1
  16. package/dist/dataStoreContexts.d.ts.map +1 -1
  17. package/dist/dataStoreContexts.js +2 -1
  18. package/dist/dataStoreContexts.js.map +1 -1
  19. package/dist/dataStores.d.ts +1 -2
  20. package/dist/dataStores.d.ts.map +1 -1
  21. package/dist/dataStores.js +2 -1
  22. package/dist/dataStores.js.map +1 -1
  23. package/dist/gc/garbageCollection.d.ts.map +1 -1
  24. package/dist/gc/garbageCollection.js +4 -3
  25. package/dist/gc/garbageCollection.js.map +1 -1
  26. package/dist/gc/gcTelemetry.d.ts +1 -1
  27. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  28. package/dist/gc/gcTelemetry.js.map +1 -1
  29. package/dist/metadata.d.ts +18 -0
  30. package/dist/metadata.d.ts.map +1 -0
  31. package/dist/metadata.js +7 -0
  32. package/dist/metadata.js.map +1 -0
  33. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  34. package/dist/opLifecycle/opDecompressor.js +14 -8
  35. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  36. package/dist/opLifecycle/opGroupingManager.d.ts +1 -1
  37. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  38. package/dist/opLifecycle/opGroupingManager.js +2 -6
  39. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  40. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  41. package/dist/opLifecycle/opSplitter.js +2 -0
  42. package/dist/opLifecycle/opSplitter.js.map +1 -1
  43. package/dist/opLifecycle/outbox.d.ts +5 -1
  44. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  45. package/dist/opLifecycle/outbox.js +45 -27
  46. package/dist/opLifecycle/outbox.js.map +1 -1
  47. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  48. package/dist/opLifecycle/remoteMessageProcessor.js +3 -1
  49. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  50. package/dist/packageVersion.d.ts +1 -1
  51. package/dist/packageVersion.js +1 -1
  52. package/dist/packageVersion.js.map +1 -1
  53. package/dist/pendingStateManager.d.ts +1 -1
  54. package/dist/pendingStateManager.d.ts.map +1 -1
  55. package/dist/pendingStateManager.js +13 -5
  56. package/dist/pendingStateManager.js.map +1 -1
  57. package/dist/scheduleManager.d.ts.map +1 -1
  58. package/dist/scheduleManager.js +8 -2
  59. package/dist/scheduleManager.js.map +1 -1
  60. package/dist/summary/summarizerNode/summarizerNode.d.ts +1 -1
  61. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  62. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  63. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  64. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +3 -2
  65. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  66. package/dist/summary/summarizerTypes.d.ts +2 -1
  67. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  68. package/dist/summary/summarizerTypes.js.map +1 -1
  69. package/dist/summary/summaryCollection.d.ts.map +1 -1
  70. package/dist/summary/summaryCollection.js +4 -0
  71. package/dist/summary/summaryCollection.js.map +1 -1
  72. package/dist/summary/summaryGenerator.d.ts +1 -1
  73. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  74. package/dist/summary/summaryGenerator.js.map +1 -1
  75. package/lib/blobManager.d.ts +5 -2
  76. package/lib/blobManager.d.ts.map +1 -1
  77. package/lib/blobManager.js +51 -22
  78. package/lib/blobManager.js.map +1 -1
  79. package/lib/connectionTelemetry.d.ts.map +1 -1
  80. package/lib/connectionTelemetry.js +8 -1
  81. package/lib/connectionTelemetry.js.map +1 -1
  82. package/lib/containerRuntime.d.ts +4 -15
  83. package/lib/containerRuntime.d.ts.map +1 -1
  84. package/lib/containerRuntime.js +12 -7
  85. package/lib/containerRuntime.js.map +1 -1
  86. package/lib/dataStoreContext.d.ts.map +1 -1
  87. package/lib/dataStoreContext.js +4 -3
  88. package/lib/dataStoreContext.js.map +1 -1
  89. package/lib/dataStoreContexts.d.ts.map +1 -1
  90. package/lib/dataStoreContexts.js +2 -1
  91. package/lib/dataStoreContexts.js.map +1 -1
  92. package/lib/dataStores.d.ts +1 -2
  93. package/lib/dataStores.d.ts.map +1 -1
  94. package/lib/dataStores.js +2 -1
  95. package/lib/dataStores.js.map +1 -1
  96. package/lib/gc/garbageCollection.d.ts.map +1 -1
  97. package/lib/gc/garbageCollection.js +2 -1
  98. package/lib/gc/garbageCollection.js.map +1 -1
  99. package/lib/gc/gcTelemetry.d.ts +1 -1
  100. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  101. package/lib/gc/gcTelemetry.js.map +1 -1
  102. package/lib/metadata.d.ts +18 -0
  103. package/lib/metadata.d.ts.map +1 -0
  104. package/lib/metadata.js +6 -0
  105. package/lib/metadata.js.map +1 -0
  106. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  107. package/lib/opLifecycle/opDecompressor.js +14 -8
  108. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  109. package/lib/opLifecycle/opGroupingManager.d.ts +1 -1
  110. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  111. package/lib/opLifecycle/opGroupingManager.js +2 -6
  112. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  113. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  114. package/lib/opLifecycle/opSplitter.js +2 -0
  115. package/lib/opLifecycle/opSplitter.js.map +1 -1
  116. package/lib/opLifecycle/outbox.d.ts +5 -1
  117. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  118. package/lib/opLifecycle/outbox.js +45 -27
  119. package/lib/opLifecycle/outbox.js.map +1 -1
  120. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  121. package/lib/opLifecycle/remoteMessageProcessor.js +3 -1
  122. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  123. package/lib/packageVersion.d.ts +1 -1
  124. package/lib/packageVersion.js +1 -1
  125. package/lib/packageVersion.js.map +1 -1
  126. package/lib/pendingStateManager.d.ts +1 -1
  127. package/lib/pendingStateManager.d.ts.map +1 -1
  128. package/lib/pendingStateManager.js +13 -5
  129. package/lib/pendingStateManager.js.map +1 -1
  130. package/lib/scheduleManager.d.ts.map +1 -1
  131. package/lib/scheduleManager.js +8 -2
  132. package/lib/scheduleManager.js.map +1 -1
  133. package/lib/summary/summarizerNode/summarizerNode.d.ts +1 -1
  134. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  135. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  136. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  137. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +2 -1
  138. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  139. package/lib/summary/summarizerTypes.d.ts +2 -1
  140. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  141. package/lib/summary/summarizerTypes.js.map +1 -1
  142. package/lib/summary/summaryCollection.d.ts.map +1 -1
  143. package/lib/summary/summaryCollection.js +4 -0
  144. package/lib/summary/summaryCollection.js.map +1 -1
  145. package/lib/summary/summaryGenerator.d.ts +1 -1
  146. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  147. package/lib/summary/summaryGenerator.js.map +1 -1
  148. package/package.json +19 -18
  149. package/src/blobManager.ts +68 -27
  150. package/src/connectionTelemetry.ts +10 -1
  151. package/src/containerRuntime.ts +14 -25
  152. package/src/dataStoreContext.ts +5 -4
  153. package/src/dataStoreContexts.ts +2 -1
  154. package/src/dataStores.ts +8 -3
  155. package/src/gc/garbageCollection.ts +2 -1
  156. package/src/gc/gcTelemetry.ts +1 -1
  157. package/src/metadata.ts +19 -0
  158. package/src/opLifecycle/README.md +20 -0
  159. package/src/opLifecycle/opDecompressor.ts +41 -13
  160. package/src/opLifecycle/opGroupingManager.ts +14 -7
  161. package/src/opLifecycle/opSplitter.ts +3 -1
  162. package/src/opLifecycle/outbox.ts +61 -38
  163. package/src/opLifecycle/remoteMessageProcessor.ts +5 -1
  164. package/src/packageVersion.ts +1 -1
  165. package/src/pendingStateManager.ts +20 -9
  166. package/src/scheduleManager.ts +15 -6
  167. package/src/summary/summarizerNode/summarizerNode.ts +1 -1
  168. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +2 -1
  169. package/src/summary/summarizerTypes.ts +2 -1
  170. package/src/summary/summaryCollection.ts +6 -2
  171. package/src/summary/summaryGenerator.ts +1 -1
@@ -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,WAAW,GACX,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,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AC,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\tChildLogger,\n} from \"@fluidframework/telemetry-utils\";\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\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 = ChildLogger.create(this.logger, undefined, { all: summarizeProps });\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,WAAW,GACX,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,CAA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n * Licensed under the MIT License.\n */\n\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tLoggingError,\n\tChildLogger,\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 = ChildLogger.create(this.logger, undefined, { all: summarizeProps });\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.5.2.0",
3
+ "version": "2.0.0-internal.5.3.0",
4
4
  "description": "Fluid container runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -37,17 +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.5.2.0 <2.0.0-internal.5.3.0",
41
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
42
- "@fluidframework/container-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
43
- "@fluidframework/core-interfaces": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
44
- "@fluidframework/datastore": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
45
- "@fluidframework/driver-definitions": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
46
- "@fluidframework/driver-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
40
+ "@fluidframework/container-definitions": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
41
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
42
+ "@fluidframework/container-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
43
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
44
+ "@fluidframework/core-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
45
+ "@fluidframework/datastore": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
46
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
47
+ "@fluidframework/driver-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
47
48
  "@fluidframework/protocol-definitions": "^1.1.0",
48
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
49
- "@fluidframework/runtime-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
50
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
49
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
50
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
51
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
51
52
  "double-ended-queue": "^2.1.0-0",
52
53
  "events": "^3.1.0",
53
54
  "lz4js": "^0.2.0",
@@ -55,15 +56,15 @@
55
56
  "uuid": "^8.3.1"
56
57
  },
57
58
  "devDependencies": {
58
- "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
59
+ "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
59
60
  "@fluid-tools/benchmark": "^0.48.0",
60
- "@fluid-tools/build-cli": "^0.20.0",
61
+ "@fluid-tools/build-cli": "^0.21.0",
61
62
  "@fluidframework/build-common": "^1.2.0",
62
- "@fluidframework/build-tools": "^0.20.0",
63
- "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.5.0.0",
63
+ "@fluidframework/build-tools": "^0.21.0",
64
+ "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.5.2.0",
64
65
  "@fluidframework/eslint-config-fluid": "^2.0.0",
65
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
66
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.5.2.0 <2.0.0-internal.5.3.0",
66
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
67
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.5.3.0 <2.0.0-internal.5.4.0",
67
68
  "@microsoft/api-extractor": "^7.34.4",
68
69
  "@types/double-ended-queue": "^2.1.0",
69
70
  "@types/events": "^3.0.0",
@@ -112,6 +113,6 @@
112
113
  "tsc": "tsc",
113
114
  "tsc:watch": "tsc --watch",
114
115
  "typetests:gen": "fluid-type-test-generator",
115
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
116
+ "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
116
117
  }
117
118
  }
@@ -45,6 +45,7 @@ import { ContainerRuntime, TombstoneResponseHeaderKey } from "./containerRuntime
45
45
  import { sendGCUnexpectedUsageEvent, sweepAttachmentBlobsKey, throwOnTombstoneLoadKey } from "./gc";
46
46
  import { Throttler, formExponentialFn, IThrottler } from "./throttler";
47
47
  import { summarizerClientType } from "./summary";
48
+ import { IBlobMetadata } from "./metadata";
48
49
 
49
50
  /**
50
51
  * This class represents blob (long string)
@@ -70,12 +71,16 @@ export class BlobHandle implements IFluidHandle<ArrayBufferLike> {
70
71
  public readonly path: string,
71
72
  public readonly routeContext: IFluidHandleContext,
72
73
  public get: () => Promise<any>,
74
+ private readonly onAttachGraph?: () => void,
73
75
  ) {
74
76
  this.absolutePath = generateHandleContextPath(path, this.routeContext);
75
77
  }
76
78
 
77
79
  public attachGraph() {
78
- this.attached = true;
80
+ if (!this.attached) {
81
+ this.attached = true;
82
+ this.onAttachGraph?.();
83
+ }
79
84
  }
80
85
 
81
86
  public bind(handle: IFluidHandle) {
@@ -132,14 +137,22 @@ interface PendingBlob {
132
137
  blob: ArrayBufferLike;
133
138
  status: PendingBlobStatus;
134
139
  storageId?: string;
135
- handleP: Deferred<IFluidHandle<ArrayBufferLike>>;
140
+ handleP: Deferred<BlobHandle>;
136
141
  uploadP?: Promise<ICreateBlobResponse>;
137
142
  uploadTime?: number;
138
143
  minTTLInSeconds?: number;
144
+ attached?: boolean;
145
+ acked?: boolean;
139
146
  }
140
147
 
141
148
  export interface IPendingBlobs {
142
- [id: string]: { blob: string; uploadTime?: number; minTTLInSeconds?: number };
149
+ [id: string]: {
150
+ blob: string;
151
+ uploadTime?: number;
152
+ minTTLInSeconds?: number;
153
+ attached?: boolean;
154
+ acked?: boolean;
155
+ };
143
156
  }
144
157
 
145
158
  export interface IBlobManagerEvents {
@@ -227,11 +240,14 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
227
240
  this.runtime.clientDetails.type !== summarizerClientType;
228
241
 
229
242
  this.runtime.on("disconnected", () => this.onDisconnected());
243
+
230
244
  this.redirectTable = this.load(snapshot);
231
245
 
232
246
  // Begin uploading stashed blobs from previous container instance
233
247
  Object.entries(stashedBlobs).forEach(([localId, entry]) => {
234
248
  const blob = stringToBuffer(entry.blob, "base64");
249
+ const attached = entry.attached;
250
+ const acked = entry.acked;
235
251
  if (entry.minTTLInSeconds && entry.uploadTime) {
236
252
  const timeLapseSinceLocalUpload = (Date.now() - entry.uploadTime) / 1000;
237
253
  // stashed entries with more than half-life in storage will not be reuploaded
@@ -243,6 +259,8 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
243
259
  uploadP: undefined,
244
260
  uploadTime: entry.uploadTime,
245
261
  minTTLInSeconds: entry.minTTLInSeconds,
262
+ attached,
263
+ acked,
246
264
  });
247
265
  return;
248
266
  }
@@ -252,6 +270,8 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
252
270
  status: PendingBlobStatus.OfflinePendingUpload,
253
271
  handleP: new Deferred(),
254
272
  uploadP: this.uploadBlob(localId, blob),
273
+ attached,
274
+ acked,
255
275
  });
256
276
  });
257
277
 
@@ -391,13 +411,23 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
391
411
  );
392
412
  }
393
413
 
394
- private getBlobHandle(id: string): IFluidHandle<ArrayBufferLike> {
414
+ private getBlobHandle(id: string): BlobHandle {
395
415
  assert(
396
416
  this.redirectTable.has(id) || this.pendingBlobs.has(id),
397
417
  0x384 /* requesting handle for unknown blob */,
398
418
  );
399
- return new BlobHandle(`${BlobManager.basePath}/${id}`, this.routeContext, async () =>
400
- this.getBlob(id),
419
+ const pending = this.pendingBlobs.get(id);
420
+ const callback = pending
421
+ ? () => {
422
+ pending.attached = true;
423
+ this.deletePendingBlobMaybe(id);
424
+ }
425
+ : undefined;
426
+ return new BlobHandle(
427
+ `${BlobManager.basePath}/${id}`,
428
+ this.routeContext,
429
+ async () => this.getBlob(id),
430
+ callback,
401
431
  );
402
432
  }
403
433
 
@@ -433,6 +463,8 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
433
463
  status: PendingBlobStatus.OnlinePendingUpload,
434
464
  handleP: new Deferred(),
435
465
  uploadP: this.uploadBlob(localId, blob),
466
+ attached: false,
467
+ acked: false,
436
468
  };
437
469
  this.pendingBlobs.set(localId, pendingEntry);
438
470
 
@@ -459,11 +491,14 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
459
491
  this.redirectTable.set(fromId, toId);
460
492
  }
461
493
 
462
- private deleteAndEmitsIfEmpty(id: string) {
494
+ private deletePendingBlobMaybe(id: string) {
463
495
  if (this.pendingBlobs.has(id)) {
464
- this.pendingBlobs.delete(id);
465
- if (!this.hasPendingBlobs) {
466
- this.emit("noPendingBlobs");
496
+ const entry = this.pendingBlobs.get(id);
497
+ if (entry?.attached && entry?.acked) {
498
+ this.pendingBlobs.delete(id);
499
+ if (!this.hasPendingBlobs) {
500
+ this.emit("noPendingBlobs");
501
+ }
467
502
  }
468
503
  }
469
504
  }
@@ -493,7 +528,7 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
493
528
  // happened before and so, the server won't delete it.
494
529
  this.setRedirection(localId, response.id);
495
530
  entry.handleP.resolve(this.getBlobHandle(localId));
496
- this.deleteAndEmitsIfEmpty(localId);
531
+ this.deletePendingBlobMaybe(localId);
497
532
  } else {
498
533
  // If there is already an op for this storage ID, append the local ID to the list. Once any op for
499
534
  // this storage ID is ack'd, all pending blobs for it can be resolved since the op will keep the
@@ -594,8 +629,8 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
594
629
  }
595
630
 
596
631
  public processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean) {
597
- const localId = message.metadata?.localId;
598
- const blobId = message.metadata?.blobId;
632
+ const localId = (message.metadata as IBlobMetadata | undefined)?.localId;
633
+ const blobId = (message.metadata as IBlobMetadata | undefined)?.blobId;
599
634
  assert(blobId !== undefined, 0x12a /* "Missing blob id on metadata" */);
600
635
 
601
636
  // Set up a mapping from local ID to storage ID. This is crucial since without this the blob cannot be
@@ -616,23 +651,29 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
616
651
  // This is safe because the server will keep the blob alive and the op containing the local ID to
617
652
  // storage ID is already in flight and any op containing this local ID will be sequenced after that.
618
653
  waitingBlobs.forEach((pendingLocalId) => {
619
- const pendingBlobEntry = this.pendingBlobs.get(pendingLocalId);
654
+ const entry = this.pendingBlobs.get(pendingLocalId);
620
655
  assert(
621
- pendingBlobEntry !== undefined,
656
+ entry !== undefined,
622
657
  0x38f /* local online BlobAttach op with no pending blob entry */,
623
658
  );
624
659
 
625
660
  // It's possible we transitioned to offline flow while waiting for this op.
626
- if (pendingBlobEntry.status === PendingBlobStatus.OnlinePendingOp) {
661
+ if (entry.status === PendingBlobStatus.OnlinePendingOp) {
627
662
  this.setRedirection(pendingLocalId, blobId);
628
- pendingBlobEntry.handleP.resolve(this.getBlobHandle(pendingLocalId));
629
- this.deleteAndEmitsIfEmpty(pendingLocalId);
663
+ entry.acked = true;
664
+ entry.handleP.resolve(this.getBlobHandle(pendingLocalId));
665
+ this.deletePendingBlobMaybe(pendingLocalId);
630
666
  }
631
667
  });
632
668
  this.opsInFlight.delete(blobId);
633
669
  }
634
- // For blobs that were transitioned to offline flow while waiting for this op, the entry should be deleted.
635
- this.deleteAndEmitsIfEmpty(localId);
670
+ // offline flow does not resolve the handle (since it was already resolved)
671
+ // but we still need to delete the entry in case is acked and attached.
672
+ const localEntry = this.pendingBlobs.get(localId);
673
+ if (localEntry) {
674
+ localEntry.acked = true;
675
+ this.deletePendingBlobMaybe(localId);
676
+ }
636
677
  }
637
678
  }
638
679
 
@@ -905,13 +946,13 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
905
946
  public getPendingBlobs(): IPendingBlobs {
906
947
  const blobs = {};
907
948
  for (const [key, entry] of this.pendingBlobs) {
908
- blobs[key] = entry.minTTLInSeconds
909
- ? {
910
- blob: bufferToString(entry.blob, "base64"),
911
- uploadTime: entry.uploadTime,
912
- minTTLInSeconds: entry.minTTLInSeconds,
913
- }
914
- : { blob: bufferToString(entry.blob, "base64") };
949
+ blobs[key] = {
950
+ blob: bufferToString(entry.blob, "base64"),
951
+ attached: entry.attached,
952
+ acked: entry.acked,
953
+ minTTLInSeconds: entry.minTTLInSeconds,
954
+ uploadTime: entry.uploadTime,
955
+ };
915
956
  }
916
957
  return blobs;
917
958
  }
@@ -187,7 +187,16 @@ class OpPerfTelemetry {
187
187
 
188
188
  private recordPingTime(latency: number) {
189
189
  this.pingLatency = latency;
190
- // logging one in every 1000 pongs, including the first time, if it is a "write" client.
190
+
191
+ // Log if latency is longer than 1 min
192
+ if (latency > 1000 * 60) {
193
+ this.logger.sendErrorEvent({
194
+ eventName: "LatencyTooLong",
195
+ duration: latency,
196
+ });
197
+ }
198
+
199
+ // logging one in every 100 pongs, including the first time, if it is a "write" client.
191
200
  if (this.pongCount % 100 === 0 && this.deltaManager.active) {
192
201
  this.logger.sendPerformanceEvent({
193
202
  eventName: "DeltaLatency",
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ITelemetryBaseLogger, ITelemetryGenericEvent } from "@fluidframework/common-definitions";
6
5
  import {
6
+ ITelemetryBaseLogger,
7
+ ITelemetryGenericEvent,
7
8
  FluidObject,
8
9
  IFluidHandle,
9
10
  IFluidHandleContext,
@@ -28,11 +29,11 @@ import {
28
29
  import {
29
30
  assert,
30
31
  delay,
31
- LazyPromise,
32
32
  Trace,
33
33
  TypedEventEmitter,
34
34
  unreachableCase,
35
35
  } from "@fluidframework/common-utils";
36
+ import { LazyPromise } from "@fluidframework/core-utils";
36
37
  import {
37
38
  ChildLogger,
38
39
  raiseConnectedEvent,
@@ -182,6 +183,7 @@ import {
182
183
  getLongStack,
183
184
  } from "./opLifecycle";
184
185
  import { DeltaManagerSummarizerProxy } from "./deltaManagerSummarizerProxy";
186
+ import { IBatchMetadata } from "./metadata";
185
187
 
186
188
  export enum ContainerMessageType {
187
189
  // An op to be delivered to store
@@ -436,24 +438,9 @@ export interface IContainerRuntimeOptions {
436
438
  * By default, the feature is disabled. If enabled from options, the `Fluid.ContainerRuntime.DisableGroupedBatching`
437
439
  * flag can be used to disable it at runtime.
438
440
  *
439
- * For safety, {@link IContainerRuntimeOptions#enableBatchRebasing} needs to also be enabled to ensure
440
- * consistency across clients.
441
- *
442
441
  * @experimental Not ready for use.
443
442
  */
444
443
  readonly enableGroupedBatching?: boolean;
445
- /**
446
- * Configures if the runtime should rebase a batch of ops when it detects op reentrancy,
447
- * when an op is created as the result of processing another op. Usually this is the case
448
- * when changes are made to a DDS inside a DDS 'onChanged' event handler. This means that the
449
- * reentrant op will have a different reference sequence number than the rest of the ops in
450
- * the batch, resulting in a different view of the state of the data model. Therefore all ops
451
- * must be resubmitted and rebased to the current reference sequence number to be in agreement
452
- * about the state of the data model.
453
- *
454
- * @experimental Not ready for use.
455
- */
456
- readonly enableBatchRebasing?: boolean;
457
444
  }
458
445
 
459
446
  /**
@@ -701,7 +688,6 @@ export class ContainerRuntime
701
688
  chunkSizeInBytes = defaultChunkSizeInBytes,
702
689
  enableOpReentryCheck = false,
703
690
  enableGroupedBatching = false,
704
- enableBatchRebasing = false,
705
691
  } = runtimeOptions;
706
692
 
707
693
  const registry = new FluidDataStoreRegistry(registryEntries);
@@ -800,7 +786,6 @@ export class ContainerRuntime
800
786
  enableRuntimeIdCompressor,
801
787
  enableOpReentryCheck,
802
788
  enableGroupedBatching,
803
- enableBatchRebasing,
804
789
  },
805
790
  containerScope,
806
791
  logger,
@@ -855,6 +840,11 @@ export class ContainerRuntime
855
840
  }
856
841
 
857
842
  public get closeFn(): (error?: ICriticalContainerError) => void {
843
+ if (this._summarizer !== undefined) {
844
+ // In cases of summarizer, we want to dispose instead since consumer doesn't interact with this container
845
+ return this.disposeFn;
846
+ }
847
+
858
848
  // Also call disposeFn to retain functionality of runtime being disposed on close
859
849
  return (error?: ICriticalContainerError) => {
860
850
  this.context.closeFn(error);
@@ -1347,9 +1337,6 @@ export class ContainerRuntime
1347
1337
  const disablePartialFlush = this.mc.config.getBoolean(
1348
1338
  "Fluid.ContainerRuntime.DisablePartialFlush",
1349
1339
  );
1350
- const enableBatchRebasing =
1351
- runtimeOptions.enableBatchRebasing &&
1352
- this.mc.config.getBoolean("Fluid.ContainerRuntime.DisableBatchRebasing") !== true;
1353
1340
  this.outbox = new Outbox({
1354
1341
  shouldSend: () => this.canSendOps(),
1355
1342
  pendingStateManager: this.pendingStateManager,
@@ -1360,7 +1347,7 @@ export class ContainerRuntime
1360
1347
  compressionOptions,
1361
1348
  maxBatchSizeInBytes: runtimeOptions.maxBatchSizeInBytes,
1362
1349
  disablePartialFlush: disablePartialFlush === true,
1363
- enableBatchRebasing,
1350
+ enableGroupedBatching: this.groupedBatchingEnabled,
1364
1351
  },
1365
1352
  logger: this.mc.logger,
1366
1353
  groupingManager: opGroupingManager,
@@ -1531,7 +1518,6 @@ export class ContainerRuntime
1531
1518
  idCompressorEnabled: this.idCompressorEnabled,
1532
1519
  summaryStateUpdateMethod: this.summaryStateUpdateMethod,
1533
1520
  closeSummarizerDelayOverride,
1534
- enableBatchRebasing,
1535
1521
  }),
1536
1522
  telemetryDocumentId: this.telemetryDocumentId,
1537
1523
  groupedBatchingEnabled: this.groupedBatchingEnabled,
@@ -2064,7 +2050,7 @@ export class ContainerRuntime
2064
2050
  local,
2065
2051
  type: message.type,
2066
2052
  contentType: typeof message.contents,
2067
- batch: message.metadata?.batch,
2053
+ batch: (message.metadata as IBatchMetadata | undefined)?.batch,
2068
2054
  compression: message.compression,
2069
2055
  },
2070
2056
  );
@@ -3127,6 +3113,9 @@ export class ContainerRuntime
3127
3113
  this.disableAttachReorder !== true
3128
3114
  ) {
3129
3115
  this.outbox.submitAttach(message);
3116
+ } else if (type === ContainerMessageType.BlobAttach) {
3117
+ // BlobAttach ops must have their metadata visible and cannot be grouped (see opGroupingManager.ts)
3118
+ this.outbox.submitBlobAttach(message);
3130
3119
  } else {
3131
3120
  this.outbox.submit(message);
3132
3121
  }
@@ -3,13 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryProperties } from "@fluidframework/common-definitions";
7
6
  import {
8
7
  IDisposable,
9
8
  FluidObject,
10
9
  IRequest,
11
10
  IResponse,
12
11
  IFluidHandle,
12
+ ITelemetryProperties,
13
13
  } from "@fluidframework/core-interfaces";
14
14
  import {
15
15
  IAudience,
@@ -17,7 +17,8 @@ import {
17
17
  AttachState,
18
18
  ILoaderOptions,
19
19
  } from "@fluidframework/container-definitions";
20
- import { assert, Deferred, LazyPromise, TypedEventEmitter } from "@fluidframework/common-utils";
20
+ import { assert, Deferred, TypedEventEmitter } from "@fluidframework/common-utils";
21
+ import { LazyPromise } from "@fluidframework/core-utils";
21
22
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
22
23
  import { BlobTreeEntry, readAndParse } from "@fluidframework/driver-utils";
23
24
  import {
@@ -396,7 +397,7 @@ export abstract class FluidDataStoreContext
396
397
  packageName: packagePathToTelemetryProperty(this.pkg),
397
398
  });
398
399
  this.channelDeferred?.reject(errorWrapped);
399
- this.logger.sendErrorEvent({ eventName: "RealizeError" }, errorWrapped);
400
+ this.mc.logger.sendErrorEvent({ eventName: "RealizeError" }, errorWrapped);
400
401
  });
401
402
  }
402
403
  return this.channelDeferred.promise;
@@ -786,7 +787,7 @@ export abstract class FluidDataStoreContext
786
787
  this.channelDeferred.resolve(this.channel);
787
788
  } catch (error) {
788
789
  this.channelDeferred?.reject(error);
789
- this.logger.sendErrorEvent(
790
+ this.mc.logger.sendErrorEvent(
790
791
  {
791
792
  eventName: "BindRuntimeError",
792
793
  fluidDataStoreId: {
@@ -4,8 +4,9 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
7
+ import { assert, Deferred } from "@fluidframework/common-utils";
8
+ import { Lazy } from "@fluidframework/core-utils";
7
9
  import { IDisposable } from "@fluidframework/core-interfaces";
8
- import { assert, Deferred, Lazy } from "@fluidframework/common-utils";
9
10
  import { ChildLogger, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
10
11
  import { FluidDataStoreContext, LocalFluidDataStoreContext } from "./dataStoreContext";
11
12