@fluidframework/container-runtime 0.57.0 → 0.58.0-55983

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 (112) hide show
  1. package/dist/batchTracker.d.ts +26 -0
  2. package/dist/batchTracker.d.ts.map +1 -0
  3. package/dist/batchTracker.js +59 -0
  4. package/dist/batchTracker.js.map +1 -0
  5. package/dist/containerRuntime.d.ts +10 -5
  6. package/dist/containerRuntime.d.ts.map +1 -1
  7. package/dist/containerRuntime.js +113 -35
  8. package/dist/containerRuntime.js.map +1 -1
  9. package/dist/dataStore.d.ts +1 -36
  10. package/dist/dataStore.d.ts.map +1 -1
  11. package/dist/dataStore.js +5 -27
  12. package/dist/dataStore.js.map +1 -1
  13. package/dist/dataStoreContext.d.ts +1 -7
  14. package/dist/dataStoreContext.d.ts.map +1 -1
  15. package/dist/dataStoreContext.js +11 -7
  16. package/dist/dataStoreContext.js.map +1 -1
  17. package/dist/dataStores.js +1 -1
  18. package/dist/dataStores.js.map +1 -1
  19. package/dist/garbageCollection.d.ts +1 -0
  20. package/dist/garbageCollection.d.ts.map +1 -1
  21. package/dist/garbageCollection.js +6 -4
  22. package/dist/garbageCollection.js.map +1 -1
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +1 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/packageVersion.d.ts +1 -1
  28. package/dist/packageVersion.d.ts.map +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/dist/pendingStateManager.d.ts.map +1 -1
  32. package/dist/pendingStateManager.js +1 -6
  33. package/dist/pendingStateManager.js.map +1 -1
  34. package/dist/runningSummarizer.d.ts +1 -1
  35. package/dist/runningSummarizer.d.ts.map +1 -1
  36. package/dist/runningSummarizer.js +1 -1
  37. package/dist/runningSummarizer.js.map +1 -1
  38. package/dist/summarizer.d.ts +3 -4
  39. package/dist/summarizer.d.ts.map +1 -1
  40. package/dist/summarizer.js +8 -9
  41. package/dist/summarizer.js.map +1 -1
  42. package/dist/summaryGenerator.d.ts +1 -1
  43. package/dist/summaryGenerator.d.ts.map +1 -1
  44. package/dist/summaryGenerator.js +1 -1
  45. package/dist/summaryGenerator.js.map +1 -1
  46. package/dist/summaryManager.d.ts +2 -6
  47. package/dist/summaryManager.d.ts.map +1 -1
  48. package/dist/summaryManager.js +4 -10
  49. package/dist/summaryManager.js.map +1 -1
  50. package/lib/batchTracker.d.ts +26 -0
  51. package/lib/batchTracker.d.ts.map +1 -0
  52. package/lib/batchTracker.js +54 -0
  53. package/lib/batchTracker.js.map +1 -0
  54. package/lib/containerRuntime.d.ts +10 -5
  55. package/lib/containerRuntime.d.ts.map +1 -1
  56. package/lib/containerRuntime.js +114 -36
  57. package/lib/containerRuntime.js.map +1 -1
  58. package/lib/dataStore.d.ts +1 -36
  59. package/lib/dataStore.d.ts.map +1 -1
  60. package/lib/dataStore.js +4 -26
  61. package/lib/dataStore.js.map +1 -1
  62. package/lib/dataStoreContext.d.ts +1 -7
  63. package/lib/dataStoreContext.d.ts.map +1 -1
  64. package/lib/dataStoreContext.js +12 -8
  65. package/lib/dataStoreContext.js.map +1 -1
  66. package/lib/dataStores.js +1 -1
  67. package/lib/dataStores.js.map +1 -1
  68. package/lib/garbageCollection.d.ts +1 -0
  69. package/lib/garbageCollection.d.ts.map +1 -1
  70. package/lib/garbageCollection.js +4 -2
  71. package/lib/garbageCollection.js.map +1 -1
  72. package/lib/index.d.ts +0 -1
  73. package/lib/index.d.ts.map +1 -1
  74. package/lib/index.js +0 -1
  75. package/lib/index.js.map +1 -1
  76. package/lib/packageVersion.d.ts +1 -1
  77. package/lib/packageVersion.d.ts.map +1 -1
  78. package/lib/packageVersion.js +1 -1
  79. package/lib/packageVersion.js.map +1 -1
  80. package/lib/pendingStateManager.d.ts.map +1 -1
  81. package/lib/pendingStateManager.js +1 -6
  82. package/lib/pendingStateManager.js.map +1 -1
  83. package/lib/runningSummarizer.d.ts +1 -1
  84. package/lib/runningSummarizer.d.ts.map +1 -1
  85. package/lib/runningSummarizer.js +1 -1
  86. package/lib/runningSummarizer.js.map +1 -1
  87. package/lib/summarizer.d.ts +3 -4
  88. package/lib/summarizer.d.ts.map +1 -1
  89. package/lib/summarizer.js +8 -9
  90. package/lib/summarizer.js.map +1 -1
  91. package/lib/summaryGenerator.d.ts +1 -1
  92. package/lib/summaryGenerator.d.ts.map +1 -1
  93. package/lib/summaryGenerator.js +1 -1
  94. package/lib/summaryGenerator.js.map +1 -1
  95. package/lib/summaryManager.d.ts +2 -6
  96. package/lib/summaryManager.d.ts.map +1 -1
  97. package/lib/summaryManager.js +5 -11
  98. package/lib/summaryManager.js.map +1 -1
  99. package/package.json +16 -16
  100. package/src/batchTracker.ts +80 -0
  101. package/src/containerRuntime.ts +151 -38
  102. package/src/dataStore.ts +6 -42
  103. package/src/dataStoreContext.ts +12 -15
  104. package/src/dataStores.ts +1 -1
  105. package/src/garbageCollection.ts +11 -10
  106. package/src/index.ts +0 -1
  107. package/src/packageVersion.ts +1 -1
  108. package/src/pendingStateManager.ts +4 -8
  109. package/src/runningSummarizer.ts +3 -3
  110. package/src/summarizer.ts +8 -8
  111. package/src/summaryGenerator.ts +2 -2
  112. package/src/summaryManager.ts +5 -20
@@ -1 +1 @@
1
- {"version":3,"file":"pendingStateManager.js","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAoB,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA8C9F;;;;;;;;GAQG;AACH,MAAM,OAAO,mBAAm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,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;qBACjC;oBACD,MAAM;gBACV;oBACI,MAAM;aACb;YACD,kBAAkB,EAAE,CAAC;SACxB;QAED,wBAAwB;QACxB,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport { assert, Lazy } from \"@fluidframework/common-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport Deque from \"double-ended-queue\";\nimport { ContainerRuntime, ContainerMessageType, isRuntimeMessage } from \"./containerRuntime\";\n\n/**\n * This represents a message that has been submitted and is added to the pending queue when `submit` is called on the\n * ContainerRuntime. This message has either not been ack'd by the server or has not been submitted to the server yet.\n */\nexport interface IPendingMessage {\n type: \"message\";\n messageType: ContainerMessageType;\n clientSequenceNumber: number;\n referenceSequenceNumber: number;\n content: any;\n localOpMetadata: unknown;\n opMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * This represents a FlushMode update and is added to the pending queue when `setFlushMode` is called on the\n * ContainerRuntime and the FlushMode changes.\n */\nexport interface IPendingFlushMode {\n type: \"flushMode\";\n flushMode: FlushMode;\n}\n\n/**\n * This represents a manual flush and is added to the pending queue when `flush` is called on the ContainerRuntime to\n * flush any pending messages. This is applicable only when the FlushMode is Manual.\n */\nexport interface IPendingFlush {\n type: \"flush\";\n}\n\nexport type IPendingState = IPendingMessage | IPendingFlushMode | IPendingFlush;\n\nexport interface IPendingLocalState {\n /**\n * client ID we most recently connected with, or undefined if we never connected\n */\n clientId?: string;\n /**\n * list of pending states, including ops and batch information\n */\n pendingStates: IPendingState[];\n}\n\n/**\n * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been\n * acknowledged by the server. It also maintains the batch information for both automatically and manually flushed\n * batches along with the messages.\n * When the Container reconnects, it replays the pending states, which includes setting the FlushMode, manual flushing\n * of messages and triggering resubmission of unacked ops.\n *\n * It verifies that all the ops are acked, are received in the right order and batch information is correct.\n */\nexport class PendingStateManager implements IDisposable {\n private readonly pendingStates = new Deque<IPendingState>();\n private readonly initialStates: Deque<IPendingState>;\n private readonly previousClientIds = new Set<string>();\n private readonly firstStashedCSN: number = -1;\n private readonly disposeOnce = new Lazy<void>(() => {\n this.initialStates.clear();\n this.pendingStates.clear();\n });\n\n // Maintains the count of messages that are currently unacked.\n private pendingMessagesCount: number = 0;\n\n // Indicates whether we are processing a batch.\n private isProcessingBatch: boolean = false;\n\n // This stores the first message in the batch that we are processing. This is used to verify that we get\n // the correct batch metadata.\n private pendingBatchBeginMessage: ISequencedDocumentMessage | undefined;\n\n private clientId: string | undefined;\n\n private get connected(): boolean {\n return this.containerRuntime.connected;\n }\n\n /**\n * Called to check if there are any pending messages in the pending state queue.\n * @returns A boolean indicating whether there are messages or not.\n */\n public hasPendingMessages(): boolean {\n return this.pendingMessagesCount !== 0;\n }\n\n public getLocalState(): IPendingLocalState | undefined {\n if (this.hasPendingMessages()) {\n return {\n clientId: this.clientId,\n pendingStates: this.pendingStates.toArray().map(\n // delete localOpMetadata since it may not be serializable\n // and will be regenerated by applyStashedOp()\n (state) => state.type === \"message\" ? {...state, localOpMetadata: undefined } : state),\n };\n }\n }\n\n constructor(\n private readonly containerRuntime: ContainerRuntime,\n private readonly applyStashedOp: (type, content) => Promise<unknown>,\n initialState: IPendingLocalState | undefined,\n ) {\n this.initialStates = new Deque<IPendingState>(initialState?.pendingStates ?? []);\n\n if (initialState) {\n if (initialState?.clientId) {\n this.previousClientIds.add(initialState.clientId);\n }\n // get stashed op count and client sequence number of first op\n const messages = initialState.pendingStates\n .filter((state) => state.type === \"message\") as IPendingMessage[];\n this.firstStashedCSN = messages[0].clientSequenceNumber;\n }\n }\n\n public get disposed() { return this.disposeOnce.evaluated; }\n public readonly dispose = () => this.disposeOnce.value;\n\n /**\n * Called when a message is submitted locally. Adds the message and the associated details to the pending state\n * queue.\n * @param type - The container message type.\n * @param clientSequenceNumber - The clientSequenceNumber associated with the message.\n * @param content - The message content.\n * @param localOpMetadata - The local metadata associated with the message.\n */\n public onSubmitMessage(\n type: ContainerMessageType,\n clientSequenceNumber: number,\n referenceSequenceNumber: number,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) {\n const pendingMessage: IPendingMessage = {\n type: \"message\",\n messageType: type,\n clientSequenceNumber,\n referenceSequenceNumber,\n content,\n localOpMetadata,\n opMetadata,\n };\n\n this.pendingStates.push(pendingMessage);\n\n this.pendingMessagesCount++;\n }\n\n /**\n * Called when the FlushMode is updated. Adds the FlushMode to the pending state queue.\n * @param flushMode - The flushMode that was updated.\n */\n public onFlushModeUpdated(flushMode: FlushMode) {\n if (flushMode === FlushMode.Immediate) {\n const previousState = this.pendingStates.peekBack();\n\n // We don't have to track a previous \"flush\" state because FlushMode.Immediate flushes the messages. So,\n // just tracking this FlushMode.Immediate is enough.\n if (previousState?.type === \"flush\") {\n this.pendingStates.removeBack();\n }\n\n // If no messages were sent between FlushMode.TurnBased and FlushMode.Immediate,\n // then we do not have to track both these states.\n // Remove FlushMode.TurnBased from the pending queue and return.\n if (previousState?.type === \"flushMode\" && previousState.flushMode === FlushMode.TurnBased) {\n this.pendingStates.removeBack();\n return;\n }\n }\n\n const pendingFlushMode: IPendingFlushMode = {\n type: \"flushMode\",\n flushMode,\n };\n this.pendingStates.push(pendingFlushMode);\n }\n\n /**\n * Called when flush() is called on the ContainerRuntime to manually flush messages.\n */\n public onFlush() {\n // If the FlushMode is Immediate, we should not track this flush call as it is only applicable when FlushMode\n // is TurnBased.\n if (this.containerRuntime.flushMode === FlushMode.Immediate) {\n return;\n }\n\n // If the previous state is not a message, we don't have to track this flush call as there is nothing to flush.\n const previousState = this.pendingStates.peekBack();\n if (previousState?.type !== \"message\") {\n return;\n }\n\n // Note that because of the checks above and the checks in onFlushModeUpdated(), we can be sure that a \"flush\"\n // state always has a \"message\" before and after it. So, it marks the end of a batch and the beginning of a\n // new one.\n const pendingFlush: IPendingFlush = {\n type: \"flush\",\n };\n this.pendingStates.push(pendingFlush);\n }\n\n /**\n * Applies stashed ops at their reference sequence number so they are ready to be ACKed or resubmitted\n */\n public async applyStashedOpsAt(seqNum: number) {\n // apply stashed ops at sequence number\n while (!this.initialStates.isEmpty()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const nextState = this.initialStates.peekFront()!;\n if (nextState.type === \"message\") {\n if (nextState.referenceSequenceNumber > seqNum) {\n break; // nothing left to do at this sequence number\n } else if (nextState.referenceSequenceNumber > 0 && nextState.referenceSequenceNumber < seqNum) {\n throw new Error(\"loaded from snapshot too recent to apply stashed ops\");\n }\n\n // applyStashedOp will cause the DDS to behave as if it has sent the op but not actually send it\n const localOpMetadata = await this.applyStashedOp(nextState.messageType, nextState.content);\n nextState.localOpMetadata = localOpMetadata;\n }\n\n // then we push onto pendingStates which will cause PendingStateManager to resubmit when we connect\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.pendingStates.push(this.initialStates.shift()!);\n }\n }\n\n /**\n * Processes a local message once it's ack'd by the server to verify that there was no data corruption and that\n * the batch information was preserved for batch messages. Also process remote messages that might have been\n * sent from a previous container.\n * @param message - The messsage that got ack'd and needs to be processed.\n */\n public processMessage(message: ISequencedDocumentMessage, local: boolean) {\n // Do not process chunked ops until all pieces are available.\n if (message.type === ContainerMessageType.ChunkedOp) {\n return { localAck: false, localOpMetadata: undefined };\n }\n\n if (local) {\n return { localAck: false, localOpMetadata: this.processPendingLocalMessage(message) };\n } else {\n return this.processRemoteMessage(message);\n }\n }\n\n /**\n * Listens for ACKs of stashed ops\n */\n private processRemoteMessage(message: ISequencedDocumentMessage) {\n if (!isRuntimeMessage(message)) {\n return { localAck: false, localOpMetadata: undefined };\n }\n\n // this message was a pending op that was actually sent successfully\n const isOriginalClientId = message.clientId === Array.from(this.previousClientIds)[0] &&\n message.clientSequenceNumber >= this.firstStashedCSN;\n // this message is a pending or stashed op that was resubmitted\n const isNewClientId = Array.from(this.previousClientIds).indexOf(message.clientId) > 0;\n\n // if this is an ack for a stashed op, dequeue one message.\n // we should have seen its ref seq num by now and the DDS should be ready for it to be ACKed\n if (isOriginalClientId || isNewClientId) {\n assert(this.clientId === undefined, 0x28b /* \"multiple clients connected with stashed ops\" */);\n while (!this.pendingStates.isEmpty()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const nextState = this.pendingStates.shift()!;\n // if it's not a message just drop it and keep looking\n if (nextState.type === \"message\") {\n this.assertOpMatch(nextState, message, isOriginalClientId);\n return { localAck: true, localOpMetadata: nextState.localOpMetadata };\n }\n }\n }\n\n if (message.type === ContainerMessageType.Rejoin && this.previousClientIds.has(message.contents?.clientId)) {\n this.previousClientIds.add(message.clientId);\n }\n\n return { localAck: false, localOpMetadata: undefined };\n }\n\n private assertOpMatch(state: IPendingMessage, message: ISequencedDocumentMessage, isOriginalClientId: boolean) {\n assert(message.type === state.messageType, 0x28c /* \"different message type\" */);\n assert(message.clientSequenceNumber === state.clientSequenceNumber || !isOriginalClientId,\n 0x28d /* \"client sequence number doesn't match\" */);\n switch(message.type) {\n case ContainerMessageType.Attach:\n assert(message.contents.id === state.content.id, 0x28e /* \"datastore ID doesn't match\" */);\n break;\n case ContainerMessageType.FluidDataStoreOp:\n assert(message.contents.address === state.content.address, 0x28f /* \"address doesn't match\" */);\n break;\n case ContainerMessageType.BlobAttach:\n // todo: assert we have blob storage, assert blob IDs match, remove blob from blob storage since it made\n // it through successfully\n break;\n case ContainerMessageType.Rejoin:\n default:\n throw new Error(`${message.type} not expected`);\n }\n }\n\n /**\n * Processes a local message once its ack'd by the server. It verifies that there was no data corruption and that\n * the batch information was preserved for batch messages.\n * @param message - The messsage that got ack'd and needs to be processed.\n */\n private processPendingLocalMessage(message: ISequencedDocumentMessage): unknown {\n // Pre-processing part - This may be the start of a batch.\n this.maybeProcessBatchBegin(message);\n\n // Get the next state from the pending queue and verify that it is of type \"message\".\n const pendingState = this.peekNextPendingState();\n assert(pendingState.type === \"message\", 0x169 /* \"No pending message found for this remote message\" */);\n this.pendingStates.shift();\n\n // Processing part - Verify that there has been no data corruption.\n // The clientSequenceNumber of the incoming message must match that of the pending message.\n if (pendingState.clientSequenceNumber !== message.clientSequenceNumber) {\n // Close the container because this could indicate data corruption.\n const error = new DataProcessingError(\n \"unexpectedAckReceived\",\n \"unexpectedAckReceived\",\n {\n clientId: message.clientId,\n sequenceNumber: message.sequenceNumber,\n clientSequenceNumber: message.clientSequenceNumber,\n expectedClientSequenceNumber: pendingState.clientSequenceNumber,\n },\n );\n\n this.containerRuntime.closeFn(error);\n return;\n }\n\n this.pendingMessagesCount--;\n\n // Post-processing part - If we are processing a batch then this could be the last message in the batch.\n if (this.isProcessingBatch) {\n this.maybeProcessBatchEnd(message);\n }\n\n return pendingState.localOpMetadata;\n }\n\n /**\n * This message could be the first message in batch. If so, set batch state marking the beginning of a batch.\n * @param message - The message that is being processed.\n */\n private maybeProcessBatchBegin(message: ISequencedDocumentMessage) {\n const pendingState = this.peekNextPendingState();\n if (pendingState.type !== \"flush\" && pendingState.type !== \"flushMode\") {\n return;\n }\n\n // If the pending state is of type \"flushMode\", it must be Manual since Automatic flush mode is processed\n // after a message is processed and not before.\n if (pendingState.type === \"flushMode\") {\n assert(pendingState.flushMode === FlushMode.TurnBased,\n 0x16a /* \"Flush mode should be manual when processing batch begin\" */);\n }\n\n // We should not already be processing a batch and there should be no pending batch begin message.\n assert(!this.isProcessingBatch && this.pendingBatchBeginMessage === undefined,\n 0x16b /* \"The pending batch state indicates we are already processing a batch\" */);\n\n // Set the pending batch state indicating we have started processing a batch.\n this.pendingBatchBeginMessage = message;\n this.isProcessingBatch = true;\n\n // Remove this pending state from the queue as we have processed it.\n this.pendingStates.shift();\n }\n\n private maybeProcessBatchEnd(message: ISequencedDocumentMessage) {\n const nextPendingState = this.peekNextPendingState();\n if (nextPendingState.type !== \"flush\" && nextPendingState.type !== \"flushMode\") {\n return;\n }\n\n // If the next pending state is of type \"flushMode\", it must be Immediate and if so, we need to remove it from\n // the queue.\n // Note that we do not remove the type \"flush\" from the queue because it indicates the end of one batch and the\n // beginning of a new one. So, it will removed when the next batch begin is processed.\n if (nextPendingState.type === \"flushMode\") {\n assert(nextPendingState.flushMode === FlushMode.Immediate,\n 0x16c /* \"Flush mode is set to TurnBased in the middle of processing a batch\" */);\n this.pendingStates.shift();\n }\n\n // There should be a pending batch begin message.\n assert(this.pendingBatchBeginMessage !== undefined, 0x16d /* \"There is no pending batch begin message\" */);\n\n // Get the batch begin metadata from the first message in the batch.\n const batchBeginMetadata = this.pendingBatchBeginMessage.metadata?.batch;\n\n // There could be just a single message in the batch. If so, it should not have any batch metadata. If there\n // are multiple messages in the batch, verify that we got the correct batch begin and end metadata.\n if (this.pendingBatchBeginMessage === message) {\n assert(batchBeginMetadata === undefined,\n 0x16e /* \"Batch with single message should not have batch metadata\" */);\n } else {\n // Get the batch metadata from the last message in the batch.\n const batchEndMetadata = message.metadata?.batch;\n assert(batchBeginMetadata === true, 0x16f /* \"Did not receive batch begin metadata\" */);\n assert(batchEndMetadata === false, 0x170 /* \"Did not receive batch end metadata\" */);\n }\n\n // Clear the pending batch state now that we have processed the entire batch.\n this.pendingBatchBeginMessage = undefined;\n this.isProcessingBatch = false;\n }\n\n /**\n * Returns the next pending state from the pending state queue.\n */\n private peekNextPendingState(): IPendingState {\n const nextPendingState = this.pendingStates.peekFront();\n assert(!!nextPendingState, 0x171 /* \"No pending state found for the remote message\" */);\n return nextPendingState;\n }\n\n /**\n * Called when the Container's connection state changes. If the Container gets connected, it replays all the pending\n * states in its queue. This includes setting the FlushMode and triggering resubmission of unacked ops.\n */\n public replayPendingStates() {\n assert(this.connected, 0x172 /* \"The connection state is not consistent with the runtime\" */);\n\n // This assert suggests we are about to send same ops twice, which will result in data loss.\n assert(this.clientId !== this.containerRuntime.clientId,\n 0x173 /* \"replayPendingStates called twice for same clientId!\" */);\n this.clientId = this.containerRuntime.clientId;\n\n assert(this.initialStates.isEmpty(), 0x174 /* \"initial states should be empty before replaying pending\" */);\n\n let pendingStatesCount = this.pendingStates.length;\n if (pendingStatesCount === 0) {\n return;\n }\n\n // Reset the pending message count because all these messages will be removed from the queue.\n this.pendingMessagesCount = 0;\n\n // Save the current FlushMode so that we can revert it back after replaying the states.\n const savedFlushMode = this.containerRuntime.flushMode;\n\n // Process exactly `pendingStatesCount` items in the queue as it represents the number of states that were\n // pending when we connected. This is important because the `reSubmitFn` might add more items in the queue\n // which must not be replayed.\n while (pendingStatesCount > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const pendingState = this.pendingStates.shift()!;\n switch (pendingState.type) {\n case \"message\":\n {\n this.containerRuntime.reSubmitFn(\n pendingState.messageType,\n pendingState.content,\n pendingState.localOpMetadata,\n pendingState.opMetadata);\n }\n break;\n case \"flushMode\":\n {\n this.containerRuntime.setFlushMode(pendingState.flushMode);\n }\n break;\n case \"flush\":\n {\n this.containerRuntime.flush();\n }\n break;\n default:\n break;\n }\n pendingStatesCount--;\n }\n\n // Revert the FlushMode.\n this.containerRuntime.setFlushMode(savedFlushMode);\n }\n}\n"]}
1
+ {"version":3,"file":"pendingStateManager.js","sourceRoot":"","sources":["../src/pendingStateManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAItE,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAChE,OAAO,KAAK,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAoB,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AA8C9F;;;;;;;;GAQG;A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YACD,kBAAkB,EAAE,CAAC;SACxB;QAED,wBAAwB;QACxB,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport { assert, Lazy } from \"@fluidframework/common-utils\";\nimport { DataProcessingError } from \"@fluidframework/container-utils\";\nimport {\n ISequencedDocumentMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { FlushMode } from \"@fluidframework/runtime-definitions\";\nimport Deque from \"double-ended-queue\";\nimport { ContainerRuntime, ContainerMessageType, isRuntimeMessage } from \"./containerRuntime\";\n\n/**\n * This represents a message that has been submitted and is added to the pending queue when `submit` is called on the\n * ContainerRuntime. This message has either not been ack'd by the server or has not been submitted to the server yet.\n */\nexport interface IPendingMessage {\n type: \"message\";\n messageType: ContainerMessageType;\n clientSequenceNumber: number;\n referenceSequenceNumber: number;\n content: any;\n localOpMetadata: unknown;\n opMetadata: Record<string, unknown> | undefined;\n}\n\n/**\n * This represents a FlushMode update and is added to the pending queue when `setFlushMode` is called on the\n * ContainerRuntime and the FlushMode changes.\n */\nexport interface IPendingFlushMode {\n type: \"flushMode\";\n flushMode: FlushMode;\n}\n\n/**\n * This represents a manual flush and is added to the pending queue when `flush` is called on the ContainerRuntime to\n * flush any pending messages. This is applicable only when the FlushMode is Manual.\n */\nexport interface IPendingFlush {\n type: \"flush\";\n}\n\nexport type IPendingState = IPendingMessage | IPendingFlushMode | IPendingFlush;\n\nexport interface IPendingLocalState {\n /**\n * client ID we most recently connected with, or undefined if we never connected\n */\n clientId?: string;\n /**\n * list of pending states, including ops and batch information\n */\n pendingStates: IPendingState[];\n}\n\n/**\n * PendingStateManager is responsible for maintaining the messages that have not been sent or have not yet been\n * acknowledged by the server. It also maintains the batch information for both automatically and manually flushed\n * batches along with the messages.\n * When the Container reconnects, it replays the pending states, which includes setting the FlushMode, manual flushing\n * of messages and triggering resubmission of unacked ops.\n *\n * It verifies that all the ops are acked, are received in the right order and batch information is correct.\n */\nexport class PendingStateManager implements IDisposable {\n private readonly pendingStates = new Deque<IPendingState>();\n private readonly initialStates: Deque<IPendingState>;\n private readonly previousClientIds = new Set<string>();\n private readonly firstStashedCSN: number = -1;\n private readonly disposeOnce = new Lazy<void>(() => {\n this.initialStates.clear();\n this.pendingStates.clear();\n });\n\n // Maintains the count of messages that are currently unacked.\n private pendingMessagesCount: number = 0;\n\n // Indicates whether we are processing a batch.\n private isProcessingBatch: boolean = false;\n\n // This stores the first message in the batch that we are processing. This is used to verify that we get\n // the correct batch metadata.\n private pendingBatchBeginMessage: ISequencedDocumentMessage | undefined;\n\n private clientId: string | undefined;\n\n private get connected(): boolean {\n return this.containerRuntime.connected;\n }\n\n /**\n * Called to check if there are any pending messages in the pending state queue.\n * @returns A boolean indicating whether there are messages or not.\n */\n public hasPendingMessages(): boolean {\n return this.pendingMessagesCount !== 0;\n }\n\n public getLocalState(): IPendingLocalState | undefined {\n if (this.hasPendingMessages()) {\n return {\n clientId: this.clientId,\n pendingStates: this.pendingStates.toArray().map(\n // delete localOpMetadata since it may not be serializable\n // and will be regenerated by applyStashedOp()\n (state) => state.type === \"message\" ? {...state, localOpMetadata: undefined } : state),\n };\n }\n }\n\n constructor(\n private readonly containerRuntime: ContainerRuntime,\n private readonly applyStashedOp: (type, content) => Promise<unknown>,\n initialState: IPendingLocalState | undefined,\n ) {\n this.initialStates = new Deque<IPendingState>(initialState?.pendingStates ?? []);\n\n if (initialState) {\n if (initialState?.clientId) {\n this.previousClientIds.add(initialState.clientId);\n }\n // get stashed op count and client sequence number of first op\n const messages = initialState.pendingStates\n .filter((state) => state.type === \"message\") as IPendingMessage[];\n this.firstStashedCSN = messages[0].clientSequenceNumber;\n }\n }\n\n public get disposed() { return this.disposeOnce.evaluated; }\n public readonly dispose = () => this.disposeOnce.value;\n\n /**\n * Called when a message is submitted locally. Adds the message and the associated details to the pending state\n * queue.\n * @param type - The container message type.\n * @param clientSequenceNumber - The clientSequenceNumber associated with the message.\n * @param content - The message content.\n * @param localOpMetadata - The local metadata associated with the message.\n */\n public onSubmitMessage(\n type: ContainerMessageType,\n clientSequenceNumber: number,\n referenceSequenceNumber: number,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) {\n const pendingMessage: IPendingMessage = {\n type: \"message\",\n messageType: type,\n clientSequenceNumber,\n referenceSequenceNumber,\n content,\n localOpMetadata,\n opMetadata,\n };\n\n this.pendingStates.push(pendingMessage);\n\n this.pendingMessagesCount++;\n }\n\n /**\n * Called when the FlushMode is updated. Adds the FlushMode to the pending state queue.\n * @param flushMode - The flushMode that was updated.\n */\n public onFlushModeUpdated(flushMode: FlushMode) {\n if (flushMode === FlushMode.Immediate) {\n const previousState = this.pendingStates.peekBack();\n\n // We don't have to track a previous \"flush\" state because FlushMode.Immediate flushes the messages. So,\n // just tracking this FlushMode.Immediate is enough.\n if (previousState?.type === \"flush\") {\n this.pendingStates.removeBack();\n }\n\n // If no messages were sent between FlushMode.TurnBased and FlushMode.Immediate,\n // then we do not have to track both these states.\n // Remove FlushMode.TurnBased from the pending queue and return.\n if (previousState?.type === \"flushMode\" && previousState.flushMode === FlushMode.TurnBased) {\n this.pendingStates.removeBack();\n return;\n }\n }\n\n const pendingFlushMode: IPendingFlushMode = {\n type: \"flushMode\",\n flushMode,\n };\n this.pendingStates.push(pendingFlushMode);\n }\n\n /**\n * Called when flush() is called on the ContainerRuntime to manually flush messages.\n */\n public onFlush() {\n // If the FlushMode is Immediate, we should not track this flush call as it is only applicable when FlushMode\n // is TurnBased.\n if (this.containerRuntime.flushMode === FlushMode.Immediate) {\n return;\n }\n\n // If the previous state is not a message, we don't have to track this flush call as there is nothing to flush.\n const previousState = this.pendingStates.peekBack();\n if (previousState?.type !== \"message\") {\n return;\n }\n\n // Note that because of the checks above and the checks in onFlushModeUpdated(), we can be sure that a \"flush\"\n // state always has a \"message\" before and after it. So, it marks the end of a batch and the beginning of a\n // new one.\n const pendingFlush: IPendingFlush = {\n type: \"flush\",\n };\n this.pendingStates.push(pendingFlush);\n }\n\n /**\n * Applies stashed ops at their reference sequence number so they are ready to be ACKed or resubmitted\n */\n public async applyStashedOpsAt(seqNum: number) {\n // apply stashed ops at sequence number\n while (!this.initialStates.isEmpty()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const nextState = this.initialStates.peekFront()!;\n if (nextState.type === \"message\") {\n if (nextState.referenceSequenceNumber > seqNum) {\n break; // nothing left to do at this sequence number\n } else if (nextState.referenceSequenceNumber > 0 && nextState.referenceSequenceNumber < seqNum) {\n throw new Error(\"loaded from snapshot too recent to apply stashed ops\");\n }\n\n // applyStashedOp will cause the DDS to behave as if it has sent the op but not actually send it\n const localOpMetadata = await this.applyStashedOp(nextState.messageType, nextState.content);\n nextState.localOpMetadata = localOpMetadata;\n }\n\n // then we push onto pendingStates which will cause PendingStateManager to resubmit when we connect\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.pendingStates.push(this.initialStates.shift()!);\n }\n }\n\n /**\n * Processes a local message once it's ack'd by the server to verify that there was no data corruption and that\n * the batch information was preserved for batch messages. Also process remote messages that might have been\n * sent from a previous container.\n * @param message - The messsage that got ack'd and needs to be processed.\n */\n public processMessage(message: ISequencedDocumentMessage, local: boolean) {\n // Do not process chunked ops until all pieces are available.\n if (message.type === ContainerMessageType.ChunkedOp) {\n return { localAck: false, localOpMetadata: undefined };\n }\n\n if (local) {\n return { localAck: false, localOpMetadata: this.processPendingLocalMessage(message) };\n } else {\n return this.processRemoteMessage(message);\n }\n }\n\n /**\n * Listens for ACKs of stashed ops\n */\n private processRemoteMessage(message: ISequencedDocumentMessage) {\n if (!isRuntimeMessage(message)) {\n return { localAck: false, localOpMetadata: undefined };\n }\n\n // this message was a pending op that was actually sent successfully\n const isOriginalClientId = message.clientId === Array.from(this.previousClientIds)[0] &&\n message.clientSequenceNumber >= this.firstStashedCSN;\n // this message is a pending or stashed op that was resubmitted\n const isNewClientId = Array.from(this.previousClientIds).indexOf(message.clientId) > 0;\n\n // if this is an ack for a stashed op, dequeue one message.\n // we should have seen its ref seq num by now and the DDS should be ready for it to be ACKed\n if (isOriginalClientId || isNewClientId) {\n assert(this.clientId === undefined, 0x28b /* \"multiple clients connected with stashed ops\" */);\n while (!this.pendingStates.isEmpty()) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const nextState = this.pendingStates.shift()!;\n // if it's not a message just drop it and keep looking\n if (nextState.type === \"message\") {\n this.assertOpMatch(nextState, message, isOriginalClientId);\n return { localAck: true, localOpMetadata: nextState.localOpMetadata };\n }\n }\n }\n\n if (message.type === ContainerMessageType.Rejoin && this.previousClientIds.has(message.contents?.clientId)) {\n this.previousClientIds.add(message.clientId);\n }\n\n return { localAck: false, localOpMetadata: undefined };\n }\n\n private assertOpMatch(state: IPendingMessage, message: ISequencedDocumentMessage, isOriginalClientId: boolean) {\n assert(message.type === state.messageType, 0x28c /* \"different message type\" */);\n assert(message.clientSequenceNumber === state.clientSequenceNumber || !isOriginalClientId,\n 0x28d /* \"client sequence number doesn't match\" */);\n switch(message.type) {\n case ContainerMessageType.Attach:\n assert(message.contents.id === state.content.id, 0x28e /* \"datastore ID doesn't match\" */);\n break;\n case ContainerMessageType.FluidDataStoreOp:\n assert(message.contents.address === state.content.address, 0x28f /* \"address doesn't match\" */);\n break;\n case ContainerMessageType.BlobAttach:\n // todo: assert we have blob storage, assert blob IDs match, remove blob from blob storage since it made\n // it through successfully\n break;\n case ContainerMessageType.Rejoin:\n default:\n throw new Error(`${message.type} not expected`);\n }\n }\n\n /**\n * Processes a local message once its ack'd by the server. It verifies that there was no data corruption and that\n * the batch information was preserved for batch messages.\n * @param message - The messsage that got ack'd and needs to be processed.\n */\n private processPendingLocalMessage(message: ISequencedDocumentMessage): unknown {\n // Pre-processing part - This may be the start of a batch.\n this.maybeProcessBatchBegin(message);\n\n // Get the next state from the pending queue and verify that it is of type \"message\".\n const pendingState = this.peekNextPendingState();\n assert(pendingState.type === \"message\", 0x169 /* \"No pending message found for this remote message\" */);\n this.pendingStates.shift();\n\n // Processing part - Verify that there has been no data corruption.\n // The clientSequenceNumber of the incoming message must match that of the pending message.\n if (pendingState.clientSequenceNumber !== message.clientSequenceNumber) {\n // Close the container because this could indicate data corruption.\n const error = DataProcessingError.create(\n \"pending local message clientSequenceNumber mismatch\",\n \"unexpectedAckReceived\",\n message,\n { expectedClientSequenceNumber: pendingState.clientSequenceNumber },\n );\n\n this.containerRuntime.closeFn(error);\n return;\n }\n\n this.pendingMessagesCount--;\n\n // Post-processing part - If we are processing a batch then this could be the last message in the batch.\n if (this.isProcessingBatch) {\n this.maybeProcessBatchEnd(message);\n }\n\n return pendingState.localOpMetadata;\n }\n\n /**\n * This message could be the first message in batch. If so, set batch state marking the beginning of a batch.\n * @param message - The message that is being processed.\n */\n private maybeProcessBatchBegin(message: ISequencedDocumentMessage) {\n const pendingState = this.peekNextPendingState();\n if (pendingState.type !== \"flush\" && pendingState.type !== \"flushMode\") {\n return;\n }\n\n // If the pending state is of type \"flushMode\", it must be Manual since Automatic flush mode is processed\n // after a message is processed and not before.\n if (pendingState.type === \"flushMode\") {\n assert(pendingState.flushMode === FlushMode.TurnBased,\n 0x16a /* \"Flush mode should be manual when processing batch begin\" */);\n }\n\n // We should not already be processing a batch and there should be no pending batch begin message.\n assert(!this.isProcessingBatch && this.pendingBatchBeginMessage === undefined,\n 0x16b /* \"The pending batch state indicates we are already processing a batch\" */);\n\n // Set the pending batch state indicating we have started processing a batch.\n this.pendingBatchBeginMessage = message;\n this.isProcessingBatch = true;\n\n // Remove this pending state from the queue as we have processed it.\n this.pendingStates.shift();\n }\n\n private maybeProcessBatchEnd(message: ISequencedDocumentMessage) {\n const nextPendingState = this.peekNextPendingState();\n if (nextPendingState.type !== \"flush\" && nextPendingState.type !== \"flushMode\") {\n return;\n }\n\n // If the next pending state is of type \"flushMode\", it must be Immediate and if so, we need to remove it from\n // the queue.\n // Note that we do not remove the type \"flush\" from the queue because it indicates the end of one batch and the\n // beginning of a new one. So, it will removed when the next batch begin is processed.\n if (nextPendingState.type === \"flushMode\") {\n assert(nextPendingState.flushMode === FlushMode.Immediate,\n 0x16c /* \"Flush mode is set to TurnBased in the middle of processing a batch\" */);\n this.pendingStates.shift();\n }\n\n // There should be a pending batch begin message.\n assert(this.pendingBatchBeginMessage !== undefined, 0x16d /* \"There is no pending batch begin message\" */);\n\n // Get the batch begin metadata from the first message in the batch.\n const batchBeginMetadata = this.pendingBatchBeginMessage.metadata?.batch;\n\n // There could be just a single message in the batch. If so, it should not have any batch metadata. If there\n // are multiple messages in the batch, verify that we got the correct batch begin and end metadata.\n if (this.pendingBatchBeginMessage === message) {\n assert(batchBeginMetadata === undefined,\n 0x16e /* \"Batch with single message should not have batch metadata\" */);\n } else {\n // Get the batch metadata from the last message in the batch.\n const batchEndMetadata = message.metadata?.batch;\n assert(batchBeginMetadata === true, 0x16f /* \"Did not receive batch begin metadata\" */);\n assert(batchEndMetadata === false, 0x170 /* \"Did not receive batch end metadata\" */);\n }\n\n // Clear the pending batch state now that we have processed the entire batch.\n this.pendingBatchBeginMessage = undefined;\n this.isProcessingBatch = false;\n }\n\n /**\n * Returns the next pending state from the pending state queue.\n */\n private peekNextPendingState(): IPendingState {\n const nextPendingState = this.pendingStates.peekFront();\n assert(!!nextPendingState, 0x171 /* \"No pending state found for the remote message\" */);\n return nextPendingState;\n }\n\n /**\n * Called when the Container's connection state changes. If the Container gets connected, it replays all the pending\n * states in its queue. This includes setting the FlushMode and triggering resubmission of unacked ops.\n */\n public replayPendingStates() {\n assert(this.connected, 0x172 /* \"The connection state is not consistent with the runtime\" */);\n\n // This assert suggests we are about to send same ops twice, which will result in data loss.\n assert(this.clientId !== this.containerRuntime.clientId,\n 0x173 /* \"replayPendingStates called twice for same clientId!\" */);\n this.clientId = this.containerRuntime.clientId;\n\n assert(this.initialStates.isEmpty(), 0x174 /* \"initial states should be empty before replaying pending\" */);\n\n let pendingStatesCount = this.pendingStates.length;\n if (pendingStatesCount === 0) {\n return;\n }\n\n // Reset the pending message count because all these messages will be removed from the queue.\n this.pendingMessagesCount = 0;\n\n // Save the current FlushMode so that we can revert it back after replaying the states.\n const savedFlushMode = this.containerRuntime.flushMode;\n\n // Process exactly `pendingStatesCount` items in the queue as it represents the number of states that were\n // pending when we connected. This is important because the `reSubmitFn` might add more items in the queue\n // which must not be replayed.\n while (pendingStatesCount > 0) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const pendingState = this.pendingStates.shift()!;\n switch (pendingState.type) {\n case \"message\":\n {\n this.containerRuntime.reSubmitFn(\n pendingState.messageType,\n pendingState.content,\n pendingState.localOpMetadata,\n pendingState.opMetadata);\n }\n break;\n case \"flushMode\":\n {\n this.containerRuntime.setFlushMode(pendingState.flushMode);\n }\n break;\n case \"flush\":\n {\n this.containerRuntime.flush();\n }\n break;\n default:\n break;\n }\n pendingStatesCount--;\n }\n\n // Revert the FlushMode.\n this.containerRuntime.setFlushMode(savedFlushMode);\n }\n}\n"]}
@@ -23,7 +23,7 @@ export declare class RunningSummarizer implements IDisposable {
23
23
  private readonly summaryCollection;
24
24
  private readonly cancellationToken;
25
25
  private readonly stopSummarizerCallback;
26
- static start(logger: ITelemetryLogger, summaryWatcher: IClientSummaryWatcher, configuration: ISummaryConfiguration, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, heuristicData: ISummarizeHeuristicData, raiseSummarizingError: (errorCode: string) => void, summaryCollection: SummaryCollection, cancellationToken: ISummaryCancellationToken, stopSummarizerCallback: (reason: SummarizerStopReason) => void, options?: Readonly<Partial<ISummarizerOptions>>): Promise<RunningSummarizer>;
26
+ static start(logger: ITelemetryLogger, summaryWatcher: IClientSummaryWatcher, configuration: ISummaryConfiguration, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, heuristicData: ISummarizeHeuristicData, raiseSummarizingError: (errorMessage: string) => void, summaryCollection: SummaryCollection, cancellationToken: ISummaryCancellationToken, stopSummarizerCallback: (reason: SummarizerStopReason) => void, options?: Readonly<Partial<ISummarizerOptions>>): Promise<RunningSummarizer>;
27
27
  get disposed(): boolean;
28
28
  private stopping;
29
29
  private _disposed;
@@ -1 +1 @@
1
- {"version":3,"file":"runningSummarizer.d.ts","sourceRoot":"","sources":["../src/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,CAAC;AAGzG,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EAExB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACH,wBAAwB,EAExB,uBAAuB,EAEvB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAGH,sBAAsB,EAEzB,MAAM,oBAAoB,CAAC;AAI5B;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IAqD7C,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,sBAAsB;WA3DvB,KAAK,CACrB,MAAM,EAAE,gBAAgB,EACxB,cAAc,EAAE,qBAAqB,EACrC,aAAa,EAAE,qBAAqB,EACpC,qBAAqB,EAA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uBjC;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAwBxB,oCAAoC;IACpC,OAAO,CAAC,YAAY;IAoFpB,8DAA8D;IACvD,iBAAiB,CACpB,cAAc,oCAAuD,EACrE,EACI,MAAM,EACN,GAAG,OAAO,EACb,EAAE,yBAAyB,GAAG,iBAAiB;IAmBpD,6DAA6D;IACtD,gBAAgB,CAAC,EACpB,MAAM,EACN,mBAAuB,EACvB,QAAgB,EAChB,GAAG,OAAO,EACb,EAAE,wBAAwB,GAAG,sBAAsB;IA8BpD,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,sBAAsB;CAMjC"}
@@ -64,7 +64,7 @@ export class RunningSummarizer {
64
64
  // configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides
65
65
  const maxAckWaitTime = Math.min(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);
66
66
  this.pendingAckTimer = new PromiseTimer(maxAckWaitTime, () => {
67
- this.raiseSummarizingError("summaryAckWaitTimeout");
67
+ this.raiseSummarizingError("Pending summary ack not received in time");
68
68
  // Note: summarizeCount (from ChildLogger definition) may be 0,
69
69
  // since this code path is hit when RunningSummarizer first starts up,
70
70
  // before this instance has kicked off a new summarize run.
@@ -1 +1 @@
1
- {"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../src/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAGH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAgBlE,OAAO,EACH,SAAS,EAET,sBAAsB,EACtB,gBAAgB,GACnB,MA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EO,qBAAqB;QACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;SAChB;QACD,IACI,IAAI,CAAC,eAAe,KAAK,SAAS;eAC/B,IAAI,CAAC,aAAa,CAAC,oBAAoB,GAAG,IAAI,CAAC,eAAe,CAAC,mBAAmB;eAClF,IAAI,CAAC,eAAe,KAAK,SAAS,EACvC;YACE,uFAAuF;YACvF,OAAO,KAAK,CAAC;SAChB;QACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QACjE,+FAA+F;QAC/F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACjC,IAAI,CAAC,gBAAgB,CACjB,EAAE,eAAe,EAAE,mBAAmB,MAAM,EAAE,EAAE,EAChD,OAAO,EACP,IAAI,CAAC,iBAAiB,EACtB,cAAc,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,sBAAsB;QAC1B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;YAC7F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SACpC;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport {\n ISequencedDocumentMessage,\n ISummaryConfiguration,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n IEnqueueSummarizeOptions,\n ISummarizeOptions,\n ISummarizeHeuristicData,\n ISummarizeHeuristicRunner,\n ISummarizerOptions,\n IOnDemandSummarizeOptions,\n EnqueueSummarizeResult,\n SummarizerStopReason,\n ISubmitSummaryOptions,\n SubmitSummaryResult,\n ISummaryCancellationToken,\n ISummarizeResults,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n raceTimer,\n SummarizeReason,\n SummarizeResultBuilder,\n SummaryGenerator,\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 public static async start(\n logger: ITelemetryLogger,\n summaryWatcher: IClientSummaryWatcher,\n configuration: ISummaryConfiguration,\n submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n heuristicData: ISummarizeHeuristicData,\n raiseSummarizingError: (errorCode: string) => void,\n summaryCollection: SummaryCollection,\n cancellationToken: ISummaryCancellationToken,\n stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n options?: Readonly<Partial<ISummarizerOptions>>,\n ): Promise<RunningSummarizer> {\n const summarizer = new RunningSummarizer(\n logger,\n summaryWatcher,\n configuration,\n submitSummaryCallback,\n heuristicData,\n raiseSummarizingError,\n summaryCollection,\n cancellationToken,\n stopSummarizerCallback,\n options);\n\n await summarizer.waitStart();\n\n // Run the heuristics after starting\n summarizer.heuristicRunner?.run();\n return summarizer;\n }\n\n public get disposed() { return this._disposed; }\n\n private stopping = false;\n private _disposed = false;\n private summarizingLock: Promise<void> | undefined;\n private tryWhileSummarizing = false;\n private readonly pendingAckTimer: PromiseTimer;\n private heuristicRunner?: ISummarizeHeuristicRunner;\n private readonly generator: SummaryGenerator;\n private readonly logger: ITelemetryLogger;\n private enqueuedSummary: {\n reason: SummarizeReason;\n afterSequenceNumber: number;\n options: ISummarizeOptions;\n readonly resultsBuilder: SummarizeResultBuilder;\n } | undefined;\n private summarizeCount = 0;\n private totalSuccessfulAttempts = 0;\n\n private constructor(\n baseLogger: ITelemetryLogger,\n private readonly summaryWatcher: IClientSummaryWatcher,\n private readonly configuration: ISummaryConfiguration,\n private readonly submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n private readonly heuristicData: ISummarizeHeuristicData,\n private readonly raiseSummarizingError: (errorCode: string) => void,\n private readonly summaryCollection: SummaryCollection,\n private readonly cancellationToken: ISummaryCancellationToken,\n private readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n { disableHeuristics = false }: Readonly<Partial<ISummarizerOptions>> = {},\n ) {\n this.logger = ChildLogger.create(\n baseLogger, \"Running\",\n {\n all: {\n summarizeCount: () => this.summarizeCount,\n summarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n },\n },\n );\n\n if (!disableHeuristics) {\n this.heuristicRunner = new SummarizeHeuristicRunner(\n heuristicData,\n configuration,\n (reason) => this.trySummarize(reason));\n }\n\n // Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n // configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n const maxAckWaitTime = Math.min(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\n\n this.pendingAckTimer = new PromiseTimer(\n maxAckWaitTime,\n () => {\n this.raiseSummarizingError(\"summaryAckWaitTimeout\");\n // Note: summarizeCount (from ChildLogger definition) may be 0,\n // since this code path is hit when RunningSummarizer first starts up,\n // before this instance has kicked off a new summarize run.\n this.logger.sendErrorEvent({\n eventName: \"SummaryAckWaitTimeout\",\n maxAckWaitTime,\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n timePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n });\n });\n // Set up pending ack timeout by op timestamp differences for previous summaries.\n summaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n if (this.pendingAckTimer.hasTimer) {\n this.logger.sendTelemetryEvent({\n eventName: \"MissingSummaryAckFoundByOps\",\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n });\n this.pendingAckTimer.clear();\n }\n });\n\n this.generator = new SummaryGenerator(\n this.pendingAckTimer,\n this.heuristicData,\n this.submitSummaryCallback,\n this.raiseSummarizingError,\n () => { this.totalSuccessfulAttempts++; },\n this.summaryWatcher,\n this.logger,\n );\n }\n\n public dispose(): void {\n this.summaryWatcher.dispose();\n this.heuristicRunner?.dispose();\n this.heuristicRunner = undefined;\n this.generator.dispose();\n this.pendingAckTimer.clear();\n this.disposeEnqueuedSummary();\n this._disposed = true;\n this.stopping = true;\n }\n\n /**\n * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n * If some other Summarizer code wants that event on their logs they can get it here,\n * but only if they're logging about that same summary.\n * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n */\n public tryGetCorrelatedLogger = (summaryOpRefSeq) =>\n this.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n ? this.logger\n : undefined;\n\n public handleSystemOp(op: ISequencedDocumentMessage) {\n switch (op.type) {\n case MessageType.ClientLeave:\n case MessageType.ClientJoin:\n case MessageType.Propose: {\n // Synchronously handle quorum ops like regular ops\n this.handleOp(undefined, op);\n return;\n }\n default: {\n return;\n }\n }\n }\n\n public handleOp(error: any, { sequenceNumber, type, clientId, contents }: ISequencedDocumentMessage) {\n if (error !== undefined) {\n return;\n }\n this.heuristicData.lastOpSequenceNumber = sequenceNumber;\n\n // Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n if (!this.tryRunEnqueuedSummary()) {\n this.heuristicRunner?.run();\n }\n }\n\n public async waitStop(allowLastSummary: boolean): Promise<void> {\n if (this.stopping) {\n return;\n }\n\n this.stopping = true;\n\n this.disposeEnqueuedSummary();\n\n // This will try to run lastSummary if needed.\n if (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n if (this.summarizingLock === undefined) {\n this.trySummarizeOnce(\n // summarizeProps\n { summarizeReason: \"lastSummary\" },\n // ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n {});\n }\n }\n\n // Note that trySummarizeOnce() call above returns right away, without waiting.\n // So we need to wait for its completion, otherwise it would be destroyed right away.\n // That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n // submit summary. We should reconsider this flow and make summarizer move to exit faster.\n // This resolves when the current pending summary gets an ack or fails.\n await this.summarizingLock;\n }\n\n private async waitStart() {\n // Wait no longer than ack timeout for all pending\n const waitStartResult = await raceTimer(\n this.summaryWatcher.waitFlushed(),\n this.pendingAckTimer.start(),\n );\n this.pendingAckTimer.clear();\n\n // Remove pending ack wait timeout by op timestamp comparison, because\n // it has race conditions with summaries submitted by this same client.\n this.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n if (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n this.heuristicData.initialize({\n refSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n summaryTime: waitStartResult.value.summaryOp.timestamp,\n summarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n });\n }\n }\n\n /**\n * Runs single summary action that prevents any other concurrent actions.\n * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n * @param action - action to perform.\n * @returns - result of action.\n */\n private async lockedSummaryAction<T>(action: () => Promise<T>) {\n assert (this.summarizingLock === undefined, 0x25b /* \"Caller is responsible for checking lock\" */);\n\n const summarizingLock = new Deferred<void>();\n this.summarizingLock = summarizingLock.promise;\n\n this.summarizeCount++;\n\n return action().finally(() => {\n summarizingLock.resolve();\n this.summarizingLock = undefined;\n\n const retry = this.tryWhileSummarizing;\n this.tryWhileSummarizing = false;\n\n // After summarizing, we should check to see if we need to summarize again.\n // Rerun the heuristics and check for enqueued summaries.\n if (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n this.heuristicRunner?.run();\n }\n });\n }\n\n /**\n * Runs single summarize attempt\n * @param summarizeProps - props to log with each telemetry event associated with this attempt\n * @param options - summary options\n * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n * @param resultsBuilder - optional, result builder to use.\n * @returns ISummarizeResult - result of running a summary.\n */\n private trySummarizeOnce(\n summarizeProps: ITelemetryProperties,\n options: ISummarizeOptions,\n cancellationToken = this.cancellationToken,\n resultsBuilder = new SummarizeResultBuilder()): ISummarizeResults\n {\n this.lockedSummaryAction(async () => {\n const summarizeResult = this.generator.summarize(\n summarizeProps,\n options,\n cancellationToken,\n resultsBuilder);\n // ensure we wait till the end of the process\n return summarizeResult.receivedSummaryAckOrNack;\n }).catch((error) => {\n // SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n // on resultsBuilder\n // We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n // and take a appropriate action.\n });\n\n return resultsBuilder.build();\n }\n\n /** Heuristics summarize attempt. */\n private trySummarize(\n summarizeReason: SummarizeReason,\n cancellationToken = this.cancellationToken): void\n {\n if (this.summarizingLock !== undefined) {\n // lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n // if it's still needed\n this.tryWhileSummarizing = true;\n return;\n }\n\n this.lockedSummaryAction(async () => {\n const attempts: (ISummarizeOptions & { delaySeconds?: number })[] = [\n { refreshLatestAck: false, fullTree: false },\n { refreshLatestAck: true, fullTree: false },\n { refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },\n { refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },\n ];\n let overrideDelaySeconds: number | undefined;\n let summaryAttempts = 0;\n let summaryAttemptsPerPhase = 0;\n\n let lastResult: { message: string; error: any; } | undefined;\n\n for (let summaryAttemptPhase = 0; summaryAttemptPhase < attempts.length;) {\n if (this.cancellationToken.cancelled) {\n return;\n }\n\n summaryAttempts++;\n summaryAttemptsPerPhase++;\n\n const { delaySeconds: regularDelaySeconds = 0, ...options } = attempts[summaryAttemptPhase];\n const delaySeconds = overrideDelaySeconds ?? regularDelaySeconds;\n\n const summarizeProps: ITelemetryProperties = {\n summarizeReason,\n summaryAttempts,\n summaryAttemptsPerPhase,\n summaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n ...options,\n };\n\n if (delaySeconds > 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"SummarizeAttemptDelay\",\n duration: delaySeconds,\n reason: overrideDelaySeconds !== undefined ? \"nack with retryAfter\" : undefined,\n ...summarizeProps,\n });\n await delay(delaySeconds * 1000);\n }\n // Note: no need to account for cancellationToken.waitCancelled here, as\n // this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n const resultSummarize = this.generator.summarize(summarizeProps, options, cancellationToken);\n const result = await resultSummarize.receivedSummaryAckOrNack;\n\n if (result.success) {\n this.totalSuccessfulAttempts++;\n return;\n }\n // Check for retryDelay that can come from summaryNack or upload summary flow.\n // Retry the same step only once per retryAfter response.\n overrideDelaySeconds = result.retryAfterSeconds;\n if (overrideDelaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n summaryAttemptPhase++;\n summaryAttemptsPerPhase = 0;\n }\n lastResult = result;\n }\n\n // If all attempts failed, log error (with last attempt info) and close the summarizer container\n this.logger.sendErrorEvent({\n eventName: \"FailToSummarize\",\n summarizeReason,\n message: lastResult?.message,\n }, lastResult?.error);\n\n this.stopSummarizerCallback(\"failToSummarize\");\n }).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n });\n }\n\n /** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n public summarizeOnDemand(\n resultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n {\n reason,\n ...options\n }: IOnDemandSummarizeOptions): ISummarizeResults {\n if (this.stopping) {\n resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n return resultsBuilder.build();\n }\n // Check for concurrent summary attempts. If one is found,\n // return a promise that caller can await before trying again.\n if (this.summarizingLock !== undefined) {\n // The heuristics are blocking concurrent summarize attempts.\n throw new UsageError(\"Attempted to run an already-running summarizer on demand\");\n }\n const result = this.trySummarizeOnce(\n { summarizeReason: `onDemand/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return result;\n }\n\n /** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n public enqueueSummarize({\n reason,\n afterSequenceNumber = 0,\n override = false,\n ...options\n }: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n const onDemandReason = `enqueue;${reason}` as const;\n let overridden = false;\n if (this.enqueuedSummary !== undefined) {\n if (!override) {\n return { alreadyEnqueued: true };\n }\n // Override existing enqueued summarize attempt.\n this.enqueuedSummary.resultsBuilder.fail(\n \"Aborted; overridden by another enqueue summarize attempt\",\n undefined,\n );\n this.enqueuedSummary = undefined;\n overridden = true;\n }\n this.enqueuedSummary = {\n reason: onDemandReason,\n afterSequenceNumber,\n options,\n resultsBuilder: new SummarizeResultBuilder(),\n };\n const results = this.enqueuedSummary.resultsBuilder.build();\n this.tryRunEnqueuedSummary();\n return overridden ? {\n ...results,\n alreadyEnqueued: true,\n overridden: true,\n } : results;\n }\n\n private tryRunEnqueuedSummary() {\n if (this.stopping) {\n this.disposeEnqueuedSummary();\n return false;\n }\n if (\n this.enqueuedSummary === undefined\n || this.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber\n || this.summarizingLock !== undefined\n ) {\n // If no enqueued summary is ready or a summary is already in progress, take no action.\n return false;\n }\n const { reason, resultsBuilder, options } = this.enqueuedSummary;\n // Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n this.enqueuedSummary = undefined;\n this.trySummarizeOnce(\n { summarizeReason: `enqueuedSummary/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return true;\n }\n\n private disposeEnqueuedSummary() {\n if (this.enqueuedSummary !== undefined) {\n this.enqueuedSummary.resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n this.enqueuedSummary = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"runningSummarizer.js","sourceRoot":"","sources":["../src/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;AAGH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAGH,WAAW,GACd,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAgBlE,OAAO,EACH,SAAS,EAET,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,uBAAuB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAE7D;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAmD1B,YACI,UAA4B,EACX,cAAqC,EACrC,aAAoC,EACpC,qBAAuF,EACvF,aAAsC,EACtC,qBAAqD,EACrD,iBAAoC,EACpC,iBAA4C,EAC5C,sBAA8D,EAC/E,EAAE,iBAAiB,GAAG,KAAK,KAA4C,EAAE;QARxD,mBAAc,GAAd,cAAc,CAAuB;QACrC,kBAAa,GAAb,aAAa,CAAuB;QACpC,0BAAqB,GAArB,qBAAqB,CAAkE;QACvF,kBAAa,GAAb,aAAa,CAAyB;QACtC,0BAAqB,GAArB,qBAAqB,CAAgC;QACrD,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,sBAAiB,GAAjB,iBAAiB,CAA2B;QAC5C,2BAA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B,EACtB,cAAc,CAAC,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,sBAAsB;QAC1B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;YAC7F,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SACpC;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, delay, Deferred, PromiseTimer } from \"@fluidframework/common-utils\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport {\n ISequencedDocumentMessage,\n ISummaryConfiguration,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { SummarizeHeuristicRunner } from \"./summarizerHeuristics\";\nimport {\n IEnqueueSummarizeOptions,\n ISummarizeOptions,\n ISummarizeHeuristicData,\n ISummarizeHeuristicRunner,\n ISummarizerOptions,\n IOnDemandSummarizeOptions,\n EnqueueSummarizeResult,\n SummarizerStopReason,\n ISubmitSummaryOptions,\n SubmitSummaryResult,\n ISummaryCancellationToken,\n ISummarizeResults,\n} from \"./summarizerTypes\";\nimport { IClientSummaryWatcher, SummaryCollection } from \"./summaryCollection\";\nimport {\n raceTimer,\n SummarizeReason,\n SummarizeResultBuilder,\n SummaryGenerator,\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 public static async start(\n logger: ITelemetryLogger,\n summaryWatcher: IClientSummaryWatcher,\n configuration: ISummaryConfiguration,\n submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n heuristicData: ISummarizeHeuristicData,\n raiseSummarizingError: (errorMessage: string) => void,\n summaryCollection: SummaryCollection,\n cancellationToken: ISummaryCancellationToken,\n stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n options?: Readonly<Partial<ISummarizerOptions>>,\n ): Promise<RunningSummarizer> {\n const summarizer = new RunningSummarizer(\n logger,\n summaryWatcher,\n configuration,\n submitSummaryCallback,\n heuristicData,\n raiseSummarizingError,\n summaryCollection,\n cancellationToken,\n stopSummarizerCallback,\n options);\n\n await summarizer.waitStart();\n\n // Run the heuristics after starting\n summarizer.heuristicRunner?.run();\n return summarizer;\n }\n\n public get disposed() { return this._disposed; }\n\n private stopping = false;\n private _disposed = false;\n private summarizingLock: Promise<void> | undefined;\n private tryWhileSummarizing = false;\n private readonly pendingAckTimer: PromiseTimer;\n private heuristicRunner?: ISummarizeHeuristicRunner;\n private readonly generator: SummaryGenerator;\n private readonly logger: ITelemetryLogger;\n private enqueuedSummary: {\n reason: SummarizeReason;\n afterSequenceNumber: number;\n options: ISummarizeOptions;\n readonly resultsBuilder: SummarizeResultBuilder;\n } | undefined;\n private summarizeCount = 0;\n private totalSuccessfulAttempts = 0;\n\n private constructor(\n baseLogger: ITelemetryLogger,\n private readonly summaryWatcher: IClientSummaryWatcher,\n private readonly configuration: ISummaryConfiguration,\n private readonly submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>,\n private readonly heuristicData: ISummarizeHeuristicData,\n private readonly raiseSummarizingError: (errorMessage: string) => void,\n private readonly summaryCollection: SummaryCollection,\n private readonly cancellationToken: ISummaryCancellationToken,\n private readonly stopSummarizerCallback: (reason: SummarizerStopReason) => void,\n { disableHeuristics = false }: Readonly<Partial<ISummarizerOptions>> = {},\n ) {\n this.logger = ChildLogger.create(\n baseLogger, \"Running\",\n {\n all: {\n summarizeCount: () => this.summarizeCount,\n summarizerSuccessfulAttempts: () => this.totalSuccessfulAttempts,\n },\n },\n );\n\n if (!disableHeuristics) {\n this.heuristicRunner = new SummarizeHeuristicRunner(\n heuristicData,\n configuration,\n (reason) => this.trySummarize(reason));\n }\n\n // Cap the maximum amount of time client will wait for a summarize op ack to maxSummarizeAckWaitTime\n // configuration.maxAckWaitTime is composed from defaults, server values, and runtime overrides\n const maxAckWaitTime = Math.min(this.configuration.maxAckWaitTime, maxSummarizeAckWaitTime);\n\n this.pendingAckTimer = new PromiseTimer(\n maxAckWaitTime,\n () => {\n this.raiseSummarizingError(\"Pending summary ack not received in time\");\n // Note: summarizeCount (from ChildLogger definition) may be 0,\n // since this code path is hit when RunningSummarizer first starts up,\n // before this instance has kicked off a new summarize run.\n this.logger.sendErrorEvent({\n eventName: \"SummaryAckWaitTimeout\",\n maxAckWaitTime,\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n timePending: Date.now() - this.heuristicData.lastAttempt.summaryTime,\n });\n });\n // Set up pending ack timeout by op timestamp differences for previous summaries.\n summaryCollection.setPendingAckTimerTimeoutCallback(maxAckWaitTime, () => {\n if (this.pendingAckTimer.hasTimer) {\n this.logger.sendTelemetryEvent({\n eventName: \"MissingSummaryAckFoundByOps\",\n referenceSequenceNumber: this.heuristicData.lastAttempt.refSequenceNumber,\n summarySequenceNumber: this.heuristicData.lastAttempt.summarySequenceNumber,\n });\n this.pendingAckTimer.clear();\n }\n });\n\n this.generator = new SummaryGenerator(\n this.pendingAckTimer,\n this.heuristicData,\n this.submitSummaryCallback,\n this.raiseSummarizingError,\n () => { this.totalSuccessfulAttempts++; },\n this.summaryWatcher,\n this.logger,\n );\n }\n\n public dispose(): void {\n this.summaryWatcher.dispose();\n this.heuristicRunner?.dispose();\n this.heuristicRunner = undefined;\n this.generator.dispose();\n this.pendingAckTimer.clear();\n this.disposeEnqueuedSummary();\n this._disposed = true;\n this.stopping = true;\n }\n\n /**\n * RunningSummarizer's logger includes the sequenced index of the current summary on each event.\n * If some other Summarizer code wants that event on their logs they can get it here,\n * but only if they're logging about that same summary.\n * @param summaryOpRefSeq - RefSeq number of the summary op, to ensure the log correlation will be correct\n */\n public tryGetCorrelatedLogger = (summaryOpRefSeq) =>\n this.heuristicData.lastAttempt.refSequenceNumber === summaryOpRefSeq\n ? this.logger\n : undefined;\n\n public handleSystemOp(op: ISequencedDocumentMessage) {\n switch (op.type) {\n case MessageType.ClientLeave:\n case MessageType.ClientJoin:\n case MessageType.Propose: {\n // Synchronously handle quorum ops like regular ops\n this.handleOp(undefined, op);\n return;\n }\n default: {\n return;\n }\n }\n }\n\n public handleOp(error: any, { sequenceNumber, type, clientId, contents }: ISequencedDocumentMessage) {\n if (error !== undefined) {\n return;\n }\n this.heuristicData.lastOpSequenceNumber = sequenceNumber;\n\n // Check for enqueued on-demand summaries; Intentionally do nothing otherwise\n if (!this.tryRunEnqueuedSummary()) {\n this.heuristicRunner?.run();\n }\n }\n\n public async waitStop(allowLastSummary: boolean): Promise<void> {\n if (this.stopping) {\n return;\n }\n\n this.stopping = true;\n\n this.disposeEnqueuedSummary();\n\n // This will try to run lastSummary if needed.\n if (allowLastSummary && this.heuristicRunner?.shouldRunLastSummary()) {\n if (this.summarizingLock === undefined) {\n this.trySummarizeOnce(\n // summarizeProps\n { summarizeReason: \"lastSummary\" },\n // ISummarizeOptions, using defaults: { refreshLatestAck: false, fullTree: false }\n {});\n }\n }\n\n // Note that trySummarizeOnce() call above returns right away, without waiting.\n // So we need to wait for its completion, otherwise it would be destroyed right away.\n // That said, if summary lock was taken upfront, this wait might wait on multiple retries to\n // submit summary. We should reconsider this flow and make summarizer move to exit faster.\n // This resolves when the current pending summary gets an ack or fails.\n await this.summarizingLock;\n }\n\n private async waitStart() {\n // Wait no longer than ack timeout for all pending\n const waitStartResult = await raceTimer(\n this.summaryWatcher.waitFlushed(),\n this.pendingAckTimer.start(),\n );\n this.pendingAckTimer.clear();\n\n // Remove pending ack wait timeout by op timestamp comparison, because\n // it has race conditions with summaries submitted by this same client.\n this.summaryCollection.unsetPendingAckTimerTimeoutCallback();\n\n if (waitStartResult.result === \"done\" && waitStartResult.value !== undefined) {\n this.heuristicData.initialize({\n refSequenceNumber: waitStartResult.value.summaryOp.referenceSequenceNumber,\n summaryTime: waitStartResult.value.summaryOp.timestamp,\n summarySequenceNumber: waitStartResult.value.summaryOp.sequenceNumber,\n });\n }\n }\n\n /**\n * Runs single summary action that prevents any other concurrent actions.\n * Assumes that caller checked upfront for lack of concurrent action (this.summarizingLock)\n * before calling this API. I.e. caller is responsible for either erroring out or waiting on this promise.\n * @param action - action to perform.\n * @returns - result of action.\n */\n private async lockedSummaryAction<T>(action: () => Promise<T>) {\n assert (this.summarizingLock === undefined, 0x25b /* \"Caller is responsible for checking lock\" */);\n\n const summarizingLock = new Deferred<void>();\n this.summarizingLock = summarizingLock.promise;\n\n this.summarizeCount++;\n\n return action().finally(() => {\n summarizingLock.resolve();\n this.summarizingLock = undefined;\n\n const retry = this.tryWhileSummarizing;\n this.tryWhileSummarizing = false;\n\n // After summarizing, we should check to see if we need to summarize again.\n // Rerun the heuristics and check for enqueued summaries.\n if (!this.stopping && !this.tryRunEnqueuedSummary() && retry) {\n this.heuristicRunner?.run();\n }\n });\n }\n\n /**\n * Runs single summarize attempt\n * @param summarizeProps - props to log with each telemetry event associated with this attempt\n * @param options - summary options\n * @param cancellationToken - cancellation token to use to be able to cancel this summary, if needed\n * @param resultsBuilder - optional, result builder to use.\n * @returns ISummarizeResult - result of running a summary.\n */\n private trySummarizeOnce(\n summarizeProps: ITelemetryProperties,\n options: ISummarizeOptions,\n cancellationToken = this.cancellationToken,\n resultsBuilder = new SummarizeResultBuilder()): ISummarizeResults\n {\n this.lockedSummaryAction(async () => {\n const summarizeResult = this.generator.summarize(\n summarizeProps,\n options,\n cancellationToken,\n resultsBuilder);\n // ensure we wait till the end of the process\n return summarizeResult.receivedSummaryAckOrNack;\n }).catch((error) => {\n // SummaryGenerator.summarize() does not throw exceptions - it converts them to failed result\n // on resultsBuilder\n // We do not care about exceptions on receivedSummaryAckOrNack - caller should check results\n // and take a appropriate action.\n });\n\n return resultsBuilder.build();\n }\n\n /** Heuristics summarize attempt. */\n private trySummarize(\n summarizeReason: SummarizeReason,\n cancellationToken = this.cancellationToken): void\n {\n if (this.summarizingLock !== undefined) {\n // lockedSummaryAction() will retry heuristic-based summary at the end of current attempt\n // if it's still needed\n this.tryWhileSummarizing = true;\n return;\n }\n\n this.lockedSummaryAction(async () => {\n const attempts: (ISummarizeOptions & { delaySeconds?: number })[] = [\n { refreshLatestAck: false, fullTree: false },\n { refreshLatestAck: true, fullTree: false },\n { refreshLatestAck: true, fullTree: false, delaySeconds: 2 * 60 },\n { refreshLatestAck: true, fullTree: true, delaySeconds: 10 * 60 },\n ];\n let overrideDelaySeconds: number | undefined;\n let summaryAttempts = 0;\n let summaryAttemptsPerPhase = 0;\n\n let lastResult: { message: string; error: any; } | undefined;\n\n for (let summaryAttemptPhase = 0; summaryAttemptPhase < attempts.length;) {\n if (this.cancellationToken.cancelled) {\n return;\n }\n\n summaryAttempts++;\n summaryAttemptsPerPhase++;\n\n const { delaySeconds: regularDelaySeconds = 0, ...options } = attempts[summaryAttemptPhase];\n const delaySeconds = overrideDelaySeconds ?? regularDelaySeconds;\n\n const summarizeProps: ITelemetryProperties = {\n summarizeReason,\n summaryAttempts,\n summaryAttemptsPerPhase,\n summaryAttemptPhase: summaryAttemptPhase + 1, // make everything 1-based\n ...options,\n };\n\n if (delaySeconds > 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"SummarizeAttemptDelay\",\n duration: delaySeconds,\n reason: overrideDelaySeconds !== undefined ? \"nack with retryAfter\" : undefined,\n ...summarizeProps,\n });\n await delay(delaySeconds * 1000);\n }\n // Note: no need to account for cancellationToken.waitCancelled here, as\n // this is accounted SummaryGenerator.summarizeCore that controls receivedSummaryAckOrNack.\n const resultSummarize = this.generator.summarize(summarizeProps, options, cancellationToken);\n const result = await resultSummarize.receivedSummaryAckOrNack;\n\n if (result.success) {\n this.totalSuccessfulAttempts++;\n return;\n }\n // Check for retryDelay that can come from summaryNack or upload summary flow.\n // Retry the same step only once per retryAfter response.\n overrideDelaySeconds = result.retryAfterSeconds;\n if (overrideDelaySeconds === undefined || summaryAttemptsPerPhase > 1) {\n summaryAttemptPhase++;\n summaryAttemptsPerPhase = 0;\n }\n lastResult = result;\n }\n\n // If all attempts failed, log error (with last attempt info) and close the summarizer container\n this.logger.sendErrorEvent({\n eventName: \"FailToSummarize\",\n summarizeReason,\n message: lastResult?.message,\n }, lastResult?.error);\n\n this.stopSummarizerCallback(\"failToSummarize\");\n }).catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"UnexpectedSummarizeError\" }, error);\n });\n }\n\n /** {@inheritdoc (ISummarizer:interface).summarizeOnDemand} */\n public summarizeOnDemand(\n resultsBuilder: SummarizeResultBuilder = new SummarizeResultBuilder(),\n {\n reason,\n ...options\n }: IOnDemandSummarizeOptions): ISummarizeResults {\n if (this.stopping) {\n resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n return resultsBuilder.build();\n }\n // Check for concurrent summary attempts. If one is found,\n // return a promise that caller can await before trying again.\n if (this.summarizingLock !== undefined) {\n // The heuristics are blocking concurrent summarize attempts.\n throw new UsageError(\"Attempted to run an already-running summarizer on demand\");\n }\n const result = this.trySummarizeOnce(\n { summarizeReason: `onDemand/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return result;\n }\n\n /** {@inheritdoc (ISummarizer:interface).enqueueSummarize} */\n public enqueueSummarize({\n reason,\n afterSequenceNumber = 0,\n override = false,\n ...options\n }: IEnqueueSummarizeOptions): EnqueueSummarizeResult {\n const onDemandReason = `enqueue;${reason}` as const;\n let overridden = false;\n if (this.enqueuedSummary !== undefined) {\n if (!override) {\n return { alreadyEnqueued: true };\n }\n // Override existing enqueued summarize attempt.\n this.enqueuedSummary.resultsBuilder.fail(\n \"Aborted; overridden by another enqueue summarize attempt\",\n undefined,\n );\n this.enqueuedSummary = undefined;\n overridden = true;\n }\n this.enqueuedSummary = {\n reason: onDemandReason,\n afterSequenceNumber,\n options,\n resultsBuilder: new SummarizeResultBuilder(),\n };\n const results = this.enqueuedSummary.resultsBuilder.build();\n this.tryRunEnqueuedSummary();\n return overridden ? {\n ...results,\n alreadyEnqueued: true,\n overridden: true,\n } : results;\n }\n\n private tryRunEnqueuedSummary() {\n if (this.stopping) {\n this.disposeEnqueuedSummary();\n return false;\n }\n if (\n this.enqueuedSummary === undefined\n || this.heuristicData.lastOpSequenceNumber < this.enqueuedSummary.afterSequenceNumber\n || this.summarizingLock !== undefined\n ) {\n // If no enqueued summary is ready or a summary is already in progress, take no action.\n return false;\n }\n const { reason, resultsBuilder, options } = this.enqueuedSummary;\n // Set to undefined first, so that subsequent enqueue attempt while summarize will occur later.\n this.enqueuedSummary = undefined;\n this.trySummarizeOnce(\n { summarizeReason: `enqueuedSummary/${reason}` },\n options,\n this.cancellationToken,\n resultsBuilder);\n return true;\n }\n\n private disposeEnqueuedSummary() {\n if (this.enqueuedSummary !== undefined) {\n this.enqueuedSummary.resultsBuilder.fail(\"RunningSummarizer stopped or disposed\", undefined);\n this.enqueuedSummary = undefined;\n }\n }\n}\n"]}
@@ -14,14 +14,13 @@ import { SummaryCollection } from "./summaryCollection";
14
14
  import { ISummarizer, ISummarizerInternalsProvider, ISummarizerOptions, ISummarizerRuntime, ISummarizingWarning, SummarizerStopReason } from "./summarizerTypes";
15
15
  import { IConnectableRuntime } from ".";
16
16
  export declare class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {
17
- readonly fluidErrorCode: string;
18
17
  readonly logged: boolean;
19
18
  readonly errorType = "summarizingError";
20
19
  readonly canRetry = true;
21
- constructor(errorMessage: string, fluidErrorCode: string, logged?: boolean);
22
- static wrap(error: any, errorCode: string, logged: boolean | undefined, logger: ITelemetryLogger): SummarizingWarning;
20
+ constructor(errorMessage: string, logged?: boolean);
21
+ static wrap(error: any, logged: boolean | undefined, logger: ITelemetryLogger): SummarizingWarning;
23
22
  }
24
- export declare const createSummarizingWarning: (errorCode: string, logged: boolean) => SummarizingWarning;
23
+ export declare const createSummarizingWarning: (errorMessage: string, logged: boolean) => SummarizingWarning;
25
24
  /**
26
25
  * Summarizer is responsible for coordinating when to generate and send summaries.
27
26
  * It is the main entry point for summary work.
@@ -1 +1 @@
1
- {"version":3,"file":"summarizer.d.ts","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,OAAO,EAAgB,MAAM,uCAAuC,CAAC;AAI9E,OAAO,EAAe,eAAe,EAAE,YAAY,EAAmB,MAAM,iCAAiC,CAAC;AAC9G,OAAO,EAEH,mBAAmB,EACnB,YAAY,EAEf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEH,qBAAqB,EACxB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EACH,WAAW,EACX,4BAA4B,EAC5B,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,GAAG,CAAC;AAIxC,qBAAa,kBAAmB,SAAQ,YAAa,YAAW,mBAAmB,EAAE,eAAe;IAM5F,QAAQ,CAAC,cAAc,EAAE,MAAM;IAC/B,QAAQ,CAAC,MAAM,EAAE,OAAO;IAN5B,QAAQ,CAAC,SAAS,sBAAoB;IACtC,QAAQ,CAAC,QAAQ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,iBAAiB,EAAE,4BAA4B,EAChE,aAAa,EAAE,mBAAmB,EAClB,iBAAiB,EAAE,iBAAiB,EACnC,sBAAsB,EACnC,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,gCAAgC,CAAC;IAOnF;;;;;;;;OAQG;WACiB,MAAM,CACtB,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBzB,GAAG,CACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAYnF;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,oBAAoB;YAI1B,OAAO;IAiDrB;;;;;;;;OAQG;YACW,KAAK;IAqEnB;;;;;OAKG;IACI,OAAO;IAiBd,SAAgB,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAiDjE;IAEF,SAAgB,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAK/D;YAEY,iBAAiB;CAuBlC"}
package/lib/summarizer.js CHANGED
@@ -16,19 +16,18 @@ import { SummarizeHeuristicData } from "./summarizerHeuristics";
16
16
  import { SummarizeResultBuilder } from "./summaryGenerator";
17
17
  const summarizingError = "summarizingError";
18
18
  export class SummarizingWarning extends LoggingError {
19
- constructor(errorMessage, fluidErrorCode, logged = false) {
19
+ constructor(errorMessage, logged = false) {
20
20
  super(errorMessage);
21
- this.fluidErrorCode = fluidErrorCode;
22
21
  this.logged = logged;
23
22
  this.errorType = summarizingError;
24
23
  this.canRetry = true;
25
24
  }
26
- static wrap(error, errorCode, logged = false, logger) {
27
- const newErrorFn = (errMsg) => new SummarizingWarning(errMsg, errorCode, logged);
25
+ static wrap(error, logged = false, logger) {
26
+ const newErrorFn = (errMsg) => new SummarizingWarning(errMsg, logged);
28
27
  return wrapErrorAndLog(error, newErrorFn, logger);
29
28
  }
30
29
  }
31
- export const createSummarizingWarning = (errorCode, logged) => new SummarizingWarning(errorCode, errorCode, logged);
30
+ export const createSummarizingWarning = (errorMessage, logged) => new SummarizingWarning(errorMessage, logged);
32
31
  /**
33
32
  * Summarizer is responsible for coordinating when to generate and send summaries.
34
33
  * It is the main entry point for summary work.
@@ -98,7 +97,7 @@ export class Summarizer extends EventEmitter {
98
97
  return builder.build();
99
98
  }
100
99
  catch (error) {
101
- throw SummarizingWarning.wrap(error, "summarizerRun", false /* logged */, this.logger);
100
+ throw SummarizingWarning.wrap(error, false /* logged */, this.logger);
102
101
  }
103
102
  };
104
103
  this.enqueueSummarize = (...args) => {
@@ -148,7 +147,7 @@ export class Summarizer extends EventEmitter {
148
147
  }
149
148
  catch (error) {
150
149
  this.stop("summarizerException");
151
- throw SummarizingWarning.wrap(error, "summarizerRun", false /* logged */, this.logger);
150
+ throw SummarizingWarning.wrap(error, false /* logged */, this.logger);
152
151
  }
153
152
  finally {
154
153
  this.dispose();
@@ -236,9 +235,9 @@ export class Summarizer extends EventEmitter {
236
235
  new SummarizeHeuristicData(this.runtime.deltaManager.lastSequenceNumber, {
237
236
  refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,
238
237
  summaryTime: Date.now(),
239
- }), (errorCode) => {
238
+ }), (errorMessage) => {
240
239
  if (!this._disposed) {
241
- this.emit("summarizingError", createSummarizingWarning(errorCode, true));
240
+ this.logger.sendErrorEvent({ eventName: "summarizingError" }, createSummarizingWarning(errorMessage, true));
242
241
  }
243
242
  }, this.summaryCollection, runCoordinator /* cancellationToken */, (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */ options);
244
243
  this.runningSummarizer = runningSummarizer;
@@ -1 +1 @@
1
- {"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AA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,IAAI,CAAC,UAAU,EAAE;YACjB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SAC5D;IACL,CAAC;IA4DO,KAAK,CAAC,iBAAiB;;QAC3B,IAAI,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,qBAAqB,CAAC;QACxE,OAAO,IAAI,CAAC,iBAAiB,EAAE;YAC3B,MAAM,aAAa,SAAG,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,mCAAI,IAAI,CAAC,MAAM,CAAC;YACtG,IAAI;gBACA,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;gBAC3E,iBAAiB,GAAG,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC;gBAE1D,MAAM,IAAI,CAAC,iBAAiB,CAAC,uBAAuB,CAChD,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAC7B,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,EAC9B,iBAAiB,EACjB,aAAa,CAChB,CAAC;aACL;YAAC,OAAO,KAAK,EAAE;gBACZ,aAAa,CAAC,cAAc,CAAC;oBACzB,SAAS,EAAE,uBAAuB;oBAClC,uBAAuB,EAAE,iBAAiB;iBAC7C,EAAE,KAAK,CAAC,CAAC;aACb;YACD,iBAAiB,EAAE,CAAC;SACvB;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { Deferred } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ILoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, IFluidErrorBase, LoggingError, wrapErrorAndLog } from \"@fluidframework/telemetry-utils\";\nimport {\n FluidObject,\n IFluidHandleContext,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport {\n ISequencedDocumentMessage,\n ISummaryConfiguration,\n} from \"@fluidframework/protocol-definitions\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerOptions,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly fluidErrorCode: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, errorCode: string, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, errorCode, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorCode: string, logged: boolean) => new SummarizingWarning(errorCode, errorCode, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private systemOpListener?: (op: ISequencedDocumentMessage) => void;\n private opListener?: (error: any, op: ISequencedDocumentMessage) => void;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(\n onBehalfOf: string,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf, options);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, \"summarizerRun\", false /* logged */, this.logger);\n } finally {\n this.dispose();\n this.runtime.closeFn();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n private async runCore(\n onBehalfOf: string,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator, options);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(!runCoordinator.cancelled /* allowLastSummary */);\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param options - options to forward to the RunningSummarizer\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorCode: string) => {\n if (!this._disposed) {\n this.emit(\"summarizingError\", createSummarizingWarning(errorCode, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n options,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n // Listen for ops\n this.systemOpListener = (op: ISequencedDocumentMessage) => runningSummarizer.handleSystemOp(op);\n this.runtime.deltaManager.inbound.on(\"op\", this.systemOpListener);\n\n this.opListener = (error: any, op: ISequencedDocumentMessage) => runningSummarizer.handleOp(error, op);\n this.runtime.on(\"batchEnd\", this.opListener);\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n if (this.systemOpListener) {\n this.runtime.deltaManager.inbound.off(\"op\", this.systemOpListener);\n }\n if (this.opListener) {\n this.runtime.removeListener(\"batchEnd\", this.opListener);\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // Successully created the cancellation token. Start the summarizer.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const startP = this.start(this.runtime.clientId!, runCoordinator, { disableHeuristics: true });\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.dispose();\n this.runtime.closeFn();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n }\n catch (error) {\n throw SummarizingWarning.wrap(error, \"summarizerRun\", false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n const ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\n await this.internalsProvider.refreshLatestSummaryAck(\n ack.summaryOp.contents.handle,\n ack.summaryAck.contents.handle,\n refSequenceNumber,\n summaryLogger,\n );\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n }, error);\n }\n refSequenceNumber++;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAW,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAmB,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAY9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AASxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAIhD,YACI,YAAoB,EACX,SAAkB,KAAK;QAEhC,KAAK,CAAC,YAAY,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAAiB;QAL3B,cAAS,GAAG,gBAAgB,CAAC;QAC7B,aAAQ,GAAG,IAAI,CAAC;IAOzB,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,KAAU,EAAE,SAAkB,KAAK,EAAE,MAAwB;QACrE,MAAM,UAAU,GA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and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { Deferred } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ILoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverHeader } from \"@fluidframework/driver-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, IFluidErrorBase, LoggingError, wrapErrorAndLog } from \"@fluidframework/telemetry-utils\";\nimport {\n FluidObject,\n IFluidHandleContext,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport {\n ISequencedDocumentMessage,\n ISummaryConfiguration,\n} from \"@fluidframework/protocol-definitions\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerOptions,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorMessage: string, logged: boolean) => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private systemOpListener?: (op: ISequencedDocumentMessage) => void;\n private opListener?: (error: any, op: ISequencedDocumentMessage) => void;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(\n onBehalfOf: string,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf, options);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n } finally {\n this.dispose();\n this.runtime.closeFn();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n private async runCore(\n onBehalfOf: string,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator, options);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(!runCoordinator.cancelled /* allowLastSummary */);\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param options - options to forward to the RunningSummarizer\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController,\n options?: Readonly<Partial<ISummarizerOptions>>): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorMessage: string) => {\n if (!this._disposed) {\n this.logger.sendErrorEvent({ eventName: \"summarizingError\" },\n createSummarizingWarning(errorMessage, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n options,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n // Listen for ops\n this.systemOpListener = (op: ISequencedDocumentMessage) => runningSummarizer.handleSystemOp(op);\n this.runtime.deltaManager.inbound.on(\"op\", this.systemOpListener);\n\n this.opListener = (error: any, op: ISequencedDocumentMessage) => runningSummarizer.handleOp(error, op);\n this.runtime.on(\"batchEnd\", this.opListener);\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n if (this.systemOpListener) {\n this.runtime.deltaManager.inbound.off(\"op\", this.systemOpListener);\n }\n if (this.opListener) {\n this.runtime.removeListener(\"batchEnd\", this.opListener);\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // Successully created the cancellation token. Start the summarizer.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const startP = this.start(this.runtime.clientId!, runCoordinator, { disableHeuristics: true });\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.dispose();\n this.runtime.closeFn();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n }\n catch (error) {\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n const ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n\n await this.internalsProvider.refreshLatestSummaryAck(\n ack.summaryOp.contents.handle,\n ack.summaryAck.contents.handle,\n refSequenceNumber,\n summaryLogger,\n );\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n }, error);\n }\n refSequenceNumber++;\n }\n }\n}\n"]}
@@ -71,7 +71,7 @@ export declare class SummaryGenerator {
71
71
  private readonly summaryWatcher;
72
72
  private readonly logger;
73
73
  private readonly summarizeTimer;
74
- constructor(pendingAckTimer: IPromiseTimer, heuristicData: ISummarizeHeuristicData, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, raiseSummarizingError: (errorCode: string) => void, successfulSummaryCallback: () => void, summaryWatcher: Pick<IClientSummaryWatcher, "watchSummary">, logger: ITelemetryLogger);
74
+ constructor(pendingAckTimer: IPromiseTimer, heuristicData: ISummarizeHeuristicData, submitSummaryCallback: (options: ISubmitSummaryOptions) => Promise<SubmitSummaryResult>, raiseSummarizingError: (errorMessage: string) => void, successfulSummaryCallback: () => void, summaryWatcher: Pick<IClientSummaryWatcher, "watchSummary">, logger: ITelemetryLogger);
75
75
  /**
76
76
  * Generates summary and listens for broadcast and ack/nack.
77
77
  * Returns true for ack, false for nack, and undefined for failure or timeout.