@fluidframework/container-runtime 2.0.0-internal.1.0.0.83139 → 2.0.0-internal.1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.mocharc.js +12 -0
  2. package/dist/batchTracker.js +1 -1
  3. package/dist/batchTracker.js.map +1 -1
  4. package/dist/blobManager.d.ts +7 -1
  5. package/dist/blobManager.d.ts.map +1 -1
  6. package/dist/blobManager.js +34 -17
  7. package/dist/blobManager.js.map +1 -1
  8. package/dist/containerRuntime.d.ts +3 -104
  9. package/dist/containerRuntime.d.ts.map +1 -1
  10. package/dist/containerRuntime.js +83 -395
  11. package/dist/containerRuntime.js.map +1 -1
  12. package/dist/dataStore.d.ts +1 -1
  13. package/dist/dataStore.d.ts.map +1 -1
  14. package/dist/dataStore.js +2 -3
  15. package/dist/dataStore.js.map +1 -1
  16. package/dist/dataStoreContext.d.ts +3 -5
  17. package/dist/dataStoreContext.d.ts.map +1 -1
  18. package/dist/dataStoreContext.js +13 -23
  19. package/dist/dataStoreContext.js.map +1 -1
  20. package/dist/dataStores.d.ts +1 -1
  21. package/dist/dataStores.d.ts.map +1 -1
  22. package/dist/dataStores.js +3 -8
  23. package/dist/dataStores.js.map +1 -1
  24. package/dist/garbageCollection.d.ts +37 -6
  25. package/dist/garbageCollection.d.ts.map +1 -1
  26. package/dist/garbageCollection.js +61 -65
  27. package/dist/garbageCollection.js.map +1 -1
  28. package/dist/index.d.ts +2 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/packageVersion.d.ts +1 -1
  33. package/dist/packageVersion.d.ts.map +1 -1
  34. package/dist/packageVersion.js +1 -1
  35. package/dist/packageVersion.js.map +1 -1
  36. package/dist/pendingStateManager.d.ts.map +1 -1
  37. package/dist/pendingStateManager.js +15 -2
  38. package/dist/pendingStateManager.js.map +1 -1
  39. package/dist/runningSummarizer.js +1 -1
  40. package/dist/runningSummarizer.js.map +1 -1
  41. package/dist/scheduleManager.d.ts +28 -0
  42. package/dist/scheduleManager.d.ts.map +1 -0
  43. package/dist/scheduleManager.js +235 -0
  44. package/dist/scheduleManager.js.map +1 -0
  45. package/dist/summarizer.d.ts.map +1 -1
  46. package/dist/summarizer.js +20 -1
  47. package/dist/summarizer.js.map +1 -1
  48. package/dist/summaryCollection.js +1 -1
  49. package/dist/summaryCollection.js.map +1 -1
  50. package/dist/summaryGenerator.js +1 -1
  51. package/dist/summaryGenerator.js.map +1 -1
  52. package/dist/summaryManager.d.ts.map +1 -1
  53. package/dist/summaryManager.js +20 -5
  54. package/dist/summaryManager.js.map +1 -1
  55. package/lib/batchTracker.js +1 -1
  56. package/lib/batchTracker.js.map +1 -1
  57. package/lib/blobManager.d.ts +7 -1
  58. package/lib/blobManager.d.ts.map +1 -1
  59. package/lib/blobManager.js +35 -18
  60. package/lib/blobManager.js.map +1 -1
  61. package/lib/containerRuntime.d.ts +3 -104
  62. package/lib/containerRuntime.d.ts.map +1 -1
  63. package/lib/containerRuntime.js +84 -395
  64. package/lib/containerRuntime.js.map +1 -1
  65. package/lib/dataStore.d.ts +1 -1
  66. package/lib/dataStore.d.ts.map +1 -1
  67. package/lib/dataStore.js +2 -3
  68. package/lib/dataStore.js.map +1 -1
  69. package/lib/dataStoreContext.d.ts +3 -5
  70. package/lib/dataStoreContext.d.ts.map +1 -1
  71. package/lib/dataStoreContext.js +13 -23
  72. package/lib/dataStoreContext.js.map +1 -1
  73. package/lib/dataStores.d.ts +1 -1
  74. package/lib/dataStores.d.ts.map +1 -1
  75. package/lib/dataStores.js +3 -8
  76. package/lib/dataStores.js.map +1 -1
  77. package/lib/garbageCollection.d.ts +37 -6
  78. package/lib/garbageCollection.d.ts.map +1 -1
  79. package/lib/garbageCollection.js +47 -52
  80. package/lib/garbageCollection.js.map +1 -1
  81. package/lib/index.d.ts +2 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +2 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/packageVersion.d.ts +1 -1
  86. package/lib/packageVersion.d.ts.map +1 -1
  87. package/lib/packageVersion.js +1 -1
  88. package/lib/packageVersion.js.map +1 -1
  89. package/lib/pendingStateManager.d.ts.map +1 -1
  90. package/lib/pendingStateManager.js +15 -2
  91. package/lib/pendingStateManager.js.map +1 -1
  92. package/lib/runningSummarizer.js +1 -1
  93. package/lib/runningSummarizer.js.map +1 -1
  94. package/lib/scheduleManager.d.ts +28 -0
  95. package/lib/scheduleManager.d.ts.map +1 -0
  96. package/lib/scheduleManager.js +231 -0
  97. package/lib/scheduleManager.js.map +1 -0
  98. package/lib/summarizer.d.ts.map +1 -1
  99. package/lib/summarizer.js +22 -3
  100. package/lib/summarizer.js.map +1 -1
  101. package/lib/summaryCollection.js +1 -1
  102. package/lib/summaryCollection.js.map +1 -1
  103. package/lib/summaryGenerator.js +1 -1
  104. package/lib/summaryGenerator.js.map +1 -1
  105. package/lib/summaryManager.d.ts.map +1 -1
  106. package/lib/summaryManager.js +20 -5
  107. package/lib/summaryManager.js.map +1 -1
  108. package/package.json +32 -19
  109. package/src/batchTracker.ts +1 -1
  110. package/src/blobManager.ts +43 -17
  111. package/src/containerRuntime.ts +113 -547
  112. package/src/dataStore.ts +1 -4
  113. package/src/dataStoreContext.ts +10 -25
  114. package/src/dataStores.ts +13 -19
  115. package/src/garbageCollection.ts +64 -69
  116. package/src/index.ts +1 -2
  117. package/src/packageVersion.ts +1 -1
  118. package/src/pendingStateManager.ts +18 -2
  119. package/src/runningSummarizer.ts +1 -1
  120. package/src/scheduleManager.ts +294 -0
  121. package/src/summarizer.ts +28 -3
  122. package/src/summaryCollection.ts +1 -1
  123. package/src/summaryGenerator.ts +1 -1
  124. package/src/summaryManager.ts +20 -5
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ScheduleManager = void 0;
4
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
5
+ const common_utils_1 = require("@fluidframework/common-utils");
6
+ const driver_utils_1 = require("@fluidframework/driver-utils");
7
+ const container_utils_1 = require("@fluidframework/container-utils");
8
+ const deltaScheduler_1 = require("./deltaScheduler");
9
+ const packageVersion_1 = require("./packageVersion");
10
+ const connectionTelemetry_1 = require("./connectionTelemetry");
11
+ /**
12
+ * This class has the following responsibilities:
13
+ * 1. It tracks batches as we process ops and raises "batchBegin" and "batchEnd" events.
14
+ * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)
15
+ * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch
16
+ * unless all ops of the batch are in.
17
+ */
18
+ class ScheduleManager {
19
+ constructor(deltaManager, emitter, logger) {
20
+ this.deltaManager = deltaManager;
21
+ this.emitter = emitter;
22
+ this.logger = logger;
23
+ this.hitError = false;
24
+ this.deltaScheduler = new deltaScheduler_1.DeltaScheduler(this.deltaManager, telemetry_utils_1.ChildLogger.create(this.logger, "DeltaScheduler"));
25
+ void new ScheduleManagerCore(deltaManager, logger);
26
+ }
27
+ beforeOpProcessing(message) {
28
+ var _a;
29
+ if (this.batchClientId !== message.clientId) {
30
+ (0, common_utils_1.assert)(this.batchClientId === undefined, 0x2a2 /* "Batch is interrupted by other client op. Should be caught by trackPending()" */);
31
+ // This could be the beginning of a new batch or an individual message.
32
+ this.emitter.emit("batchBegin", message);
33
+ this.deltaScheduler.batchBegin(message);
34
+ const batch = (_a = message === null || message === void 0 ? void 0 : message.metadata) === null || _a === void 0 ? void 0 : _a.batch;
35
+ if (batch) {
36
+ this.batchClientId = message.clientId;
37
+ }
38
+ else {
39
+ this.batchClientId = undefined;
40
+ }
41
+ }
42
+ }
43
+ afterOpProcessing(error, message) {
44
+ var _a;
45
+ // If this is no longer true, we need to revisit what we do where we set this.hitError.
46
+ (0, common_utils_1.assert)(!this.hitError, 0x2a3 /* "container should be closed on any error" */);
47
+ if (error) {
48
+ // We assume here that loader will close container and stop processing all future ops.
49
+ // This is implicit dependency. If this flow changes, this code might no longer be correct.
50
+ this.hitError = true;
51
+ this.batchClientId = undefined;
52
+ this.emitter.emit("batchEnd", error, message);
53
+ this.deltaScheduler.batchEnd(message);
54
+ return;
55
+ }
56
+ const batch = (_a = message === null || message === void 0 ? void 0 : message.metadata) === null || _a === void 0 ? void 0 : _a.batch;
57
+ // If no batchClientId has been set then we're in an individual batch. Else, if we get
58
+ // batch end metadata, this is end of the current batch.
59
+ if (this.batchClientId === undefined || batch === false) {
60
+ this.batchClientId = undefined;
61
+ this.emitter.emit("batchEnd", undefined, message);
62
+ this.deltaScheduler.batchEnd(message);
63
+ return;
64
+ }
65
+ }
66
+ }
67
+ exports.ScheduleManager = ScheduleManager;
68
+ /**
69
+ * This class controls pausing and resuming of inbound queue to ensure that we never
70
+ * start processing ops in a batch IF we do not have all ops in the batch.
71
+ */
72
+ class ScheduleManagerCore {
73
+ constructor(deltaManager, logger) {
74
+ this.deltaManager = deltaManager;
75
+ this.logger = logger;
76
+ this.localPaused = false;
77
+ this.timePaused = 0;
78
+ this.batchCount = 0;
79
+ // Listen for delta manager sends and add batch metadata to messages
80
+ this.deltaManager.on("prepareSend", (messages) => {
81
+ if (messages.length === 0) {
82
+ return;
83
+ }
84
+ // First message will have the batch flag set to true if doing a batched send
85
+ const firstMessageMetadata = messages[0].metadata;
86
+ if (!(firstMessageMetadata === null || firstMessageMetadata === void 0 ? void 0 : firstMessageMetadata.batch)) {
87
+ return;
88
+ }
89
+ // If the batch contains only a single op, clear the batch flag.
90
+ if (messages.length === 1) {
91
+ delete firstMessageMetadata.batch;
92
+ return;
93
+ }
94
+ // Set the batch flag to false on the last message to indicate the end of the send batch
95
+ const lastMessage = messages[messages.length - 1];
96
+ lastMessage.metadata = Object.assign(Object.assign({}, lastMessage.metadata), { batch: false });
97
+ });
98
+ // Listen for updates and peek at the inbound
99
+ this.deltaManager.inbound.on("push", (message) => {
100
+ this.trackPending(message);
101
+ });
102
+ // Start with baseline - empty inbound queue.
103
+ (0, common_utils_1.assert)(!this.localPaused, 0x293 /* "initial state" */);
104
+ const allPending = this.deltaManager.inbound.toArray();
105
+ for (const pending of allPending) {
106
+ this.trackPending(pending);
107
+ }
108
+ // We are intentionally directly listening to the "op" to inspect system ops as well.
109
+ // If we do not observe system ops, we are likely to hit 0x296 assert when system ops
110
+ // precedes start of incomplete batch.
111
+ this.deltaManager.on("op", (message) => this.afterOpProcessing(message.sequenceNumber));
112
+ }
113
+ /**
114
+ * The only public function in this class - called when we processed an op,
115
+ * to make decision if op processing should be paused or not after that.
116
+ */
117
+ afterOpProcessing(sequenceNumber) {
118
+ (0, common_utils_1.assert)(!this.localPaused, 0x294 /* "can't have op processing paused if we are processing an op" */);
119
+ // If the inbound queue is ever empty, nothing to do!
120
+ if (this.deltaManager.inbound.length === 0) {
121
+ (0, common_utils_1.assert)(this.pauseSequenceNumber === undefined, 0x295 /* "there should be no pending batch if we have no ops" */);
122
+ return;
123
+ }
124
+ // The queue is
125
+ // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:
126
+ // - here (processing ops until reaching start of incomplete batch)
127
+ // - in trackPending(), when queue was empty and start of batch showed up.
128
+ // 2. resumed when batch end comes in (in trackPending())
129
+ // do we have incomplete batch to worry about?
130
+ if (this.pauseSequenceNumber !== undefined) {
131
+ (0, common_utils_1.assert)(sequenceNumber < this.pauseSequenceNumber, 0x296 /* "we should never start processing incomplete batch!" */);
132
+ // If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!
133
+ if (sequenceNumber + 1 === this.pauseSequenceNumber) {
134
+ this.pauseQueue();
135
+ }
136
+ }
137
+ }
138
+ pauseQueue() {
139
+ (0, common_utils_1.assert)(!this.localPaused, 0x297 /* "always called from resumed state" */);
140
+ this.localPaused = true;
141
+ this.timePaused = common_utils_1.performance.now();
142
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
143
+ this.deltaManager.inbound.pause();
144
+ }
145
+ resumeQueue(startBatch, messageEndBatch) {
146
+ const endBatch = messageEndBatch.sequenceNumber;
147
+ const duration = this.localPaused ? (common_utils_1.performance.now() - this.timePaused) : undefined;
148
+ this.batchCount++;
149
+ if (this.batchCount % 1000 === 1) {
150
+ this.logger.sendTelemetryEvent({
151
+ eventName: "BatchStats",
152
+ sequenceNumber: endBatch,
153
+ length: endBatch - startBatch + 1,
154
+ msnDistance: endBatch - messageEndBatch.minimumSequenceNumber,
155
+ duration,
156
+ batchCount: this.batchCount,
157
+ interrupted: this.localPaused,
158
+ });
159
+ }
160
+ // Return early if no change in value
161
+ if (!this.localPaused) {
162
+ return;
163
+ }
164
+ this.localPaused = false;
165
+ // Random round number - we want to know when batch waiting paused op processing.
166
+ if (duration !== undefined && duration > connectionTelemetry_1.latencyThreshold) {
167
+ this.logger.sendErrorEvent({
168
+ eventName: "MaxBatchWaitTimeExceeded",
169
+ duration,
170
+ sequenceNumber: endBatch,
171
+ length: endBatch - startBatch,
172
+ });
173
+ }
174
+ this.deltaManager.inbound.resume();
175
+ }
176
+ /**
177
+ * Called for each incoming op (i.e. inbound "push" notification)
178
+ */
179
+ trackPending(message) {
180
+ (0, common_utils_1.assert)(this.deltaManager.inbound.length !== 0, 0x298 /* "we have something in the queue that generates this event" */);
181
+ (0, common_utils_1.assert)((this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined), 0x299 /* "non-synchronized state" */);
182
+ const metadata = message.metadata;
183
+ const batchMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.batch;
184
+ // Protocol messages are never part of a runtime batch of messages
185
+ if (!(0, driver_utils_1.isUnpackedRuntimeMessage)(message)) {
186
+ // Protocol messages should never show up in the middle of the batch!
187
+ (0, common_utils_1.assert)(this.currentBatchClientId === undefined, 0x29a /* "System message in the middle of batch!" */);
188
+ (0, common_utils_1.assert)(batchMetadata === undefined, 0x29b /* "system op in a batch?" */);
189
+ (0, common_utils_1.assert)(!this.localPaused, 0x29c /* "we should be processing ops when there is no active batch" */);
190
+ return;
191
+ }
192
+ if (this.currentBatchClientId === undefined && batchMetadata === undefined) {
193
+ (0, common_utils_1.assert)(!this.localPaused, 0x29d /* "we should be processing ops when there is no active batch" */);
194
+ return;
195
+ }
196
+ // If the client ID changes then we can move the pause point. If it stayed the same then we need to check.
197
+ // If batchMetadata is not undefined then if it's true we've begun a new batch - if false we've ended
198
+ // the previous one
199
+ if (this.currentBatchClientId !== undefined || batchMetadata === false) {
200
+ if (this.currentBatchClientId !== message.clientId) {
201
+ // "Batch not closed, yet message from another client!"
202
+ throw new container_utils_1.DataCorruptionError("OpBatchIncomplete", Object.assign({ runtimeVersion: packageVersion_1.pkgVersion, batchClientId: this.currentBatchClientId }, (0, container_utils_1.extractSafePropertiesFromMessage)(message)));
203
+ }
204
+ }
205
+ // The queue is
206
+ // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:
207
+ // - in afterOpProcessing() - processing ops until reaching start of incomplete batch
208
+ // - here (batchMetadata == false below), when queue was empty and start of batch showed up.
209
+ // 2. resumed when batch end comes in (batchMetadata === true case below)
210
+ if (batchMetadata) {
211
+ (0, common_utils_1.assert)(this.currentBatchClientId === undefined, 0x29e /* "there can't be active batch" */);
212
+ (0, common_utils_1.assert)(!this.localPaused, 0x29f /* "we should be processing ops when there is no active batch" */);
213
+ this.pauseSequenceNumber = message.sequenceNumber;
214
+ this.currentBatchClientId = message.clientId;
215
+ // Start of the batch
216
+ // Only pause processing if queue has no other ops!
217
+ // If there are any other ops in the queue, processing will be stopped when they are processed!
218
+ if (this.deltaManager.inbound.length === 1) {
219
+ this.pauseQueue();
220
+ }
221
+ }
222
+ else if (batchMetadata === false) {
223
+ (0, common_utils_1.assert)(this.pauseSequenceNumber !== undefined, 0x2a0 /* "batch presence was validated above" */);
224
+ // Batch is complete, we can process it!
225
+ this.resumeQueue(this.pauseSequenceNumber, message);
226
+ this.pauseSequenceNumber = undefined;
227
+ this.currentBatchClientId = undefined;
228
+ }
229
+ else {
230
+ // Continuation of current batch. Do nothing
231
+ (0, common_utils_1.assert)(this.currentBatchClientId !== undefined, 0x2a1 /* "logic error" */);
232
+ }
233
+ }
234
+ }
235
+ //# sourceMappingURL=scheduleManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduleManager.js","sourceRoot":"","sources":["../src/scheduleManager.ts"],"names":[],"mappings":";;;AAQA,qEAA8D;AAC9D,+DAAmE;AACnE,+DAAwE;AACxE,qEAAwG;AACxG,qDAAkD;AAClD,qDAA8C;AAC9C,+DAAyD;AAMzD;;;;;;GAMG;AACH,MAAa,eAAe;IAKxB,YACqB,YAAwE,EACxE,OAAqB,EACrB,MAAwB;QAFxB,iBAAY,GAAZ,YAAY,CAA4D;QACxE,YAAO,GAAP,OAAO,CAAc;QACrB,WAAM,GAAN,MAAM,CAAkB;QALrC,aAAQ,GAAG,KAAK,CAAC;QAOrB,IAAI,CAAC,cAAc,GAAG,IAAI,+BAAc,CACpC,IAAI,CAAC,YAAY,EACjB,6BAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAC,CACpD,CAAC;QACF,KAAK,IAAI,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAEM,kBAAkB,CAAC,OAAkC;;QACxD,IAAI,IAAI,CAAC,aAAa,KAAK,OAAO,CAAC,QAAQ,EAAE;YACzC,IAAA,qBAAM,EAAC,IAAI,CAAC,aAAa,KAAK,SAAS,EACnC,KAAK,CAAC,mFAAmF,CAAC,CAAC;YAE/F,uEAAuE;YACvE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACzC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAExC,MAAM,KAAK,GAAG,MAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAoC,0CAAE,KAAK,CAAC;YACpE,IAAI,KAAK,EAAE;gBACP,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;aACzC;iBAAM;gBACH,IAA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CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;YACnG,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;YAClD,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,QAAQ,CAAC;YAC7C,qBAAqB;YACrB,mDAAmD;YACnD,+FAA+F;YAC/F,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxC,IAAI,CAAC,UAAU,EAAE,CAAC;aACrB;SACJ;aAAM,IAAI,aAAa,KAAK,KAAK,EAAE;YAChC,IAAA,qBAAM,EAAC,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;YACjG,wCAAwC;YACxC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;YACpD,IAAI,CAAC,mBAAmB,GAAG,SAAS,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,SAAS,CAAC;SACzC;aAAM;YACH,4CAA4C;YAC5C,IAAA,qBAAM,EAAC,IAAI,CAAC,oBAAoB,KAAK,SAAS,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;SAC9E;IACL,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { IDocumentMessage, ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { isUnpackedRuntimeMessage } from \"@fluidframework/driver-utils\";\nimport { DataCorruptionError, extractSafePropertiesFromMessage } from \"@fluidframework/container-utils\";\nimport { DeltaScheduler } from \"./deltaScheduler\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { latencyThreshold } from \"./connectionTelemetry\";\n\ntype IRuntimeMessageMetadata = undefined | {\n batch?: boolean;\n};\n\n/**\n * This class has the following responsibilities:\n * 1. It tracks batches as we process ops and raises \"batchBegin\" and \"batchEnd\" events.\n * As part of it, it validates batch correctness (i.e. no system ops in the middle of batch)\n * 2. It creates instance of ScheduleManagerCore that ensures we never start processing ops from batch\n * unless all ops of the batch are in.\n */\nexport class ScheduleManager {\n private readonly deltaScheduler: DeltaScheduler;\n private batchClientId: string | undefined;\n private hitError = false;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly emitter: EventEmitter,\n private readonly logger: ITelemetryLogger,\n ) {\n this.deltaScheduler = new DeltaScheduler(\n this.deltaManager,\n ChildLogger.create(this.logger, \"DeltaScheduler\"),\n );\n void new ScheduleManagerCore(deltaManager, logger);\n }\n\n public beforeOpProcessing(message: ISequencedDocumentMessage) {\n if (this.batchClientId !== message.clientId) {\n assert(this.batchClientId === undefined,\n 0x2a2 /* \"Batch is interrupted by other client op. Should be caught by trackPending()\" */);\n\n // This could be the beginning of a new batch or an individual message.\n this.emitter.emit(\"batchBegin\", message);\n this.deltaScheduler.batchBegin(message);\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n if (batch) {\n this.batchClientId = message.clientId;\n } else {\n this.batchClientId = undefined;\n }\n }\n }\n\n public afterOpProcessing(error: any | undefined, message: ISequencedDocumentMessage) {\n // If this is no longer true, we need to revisit what we do where we set this.hitError.\n assert(!this.hitError, 0x2a3 /* \"container should be closed on any error\" */);\n\n if (error) {\n // We assume here that loader will close container and stop processing all future ops.\n // This is implicit dependency. If this flow changes, this code might no longer be correct.\n this.hitError = true;\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", error, message);\n this.deltaScheduler.batchEnd(message);\n return;\n }\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n // If no batchClientId has been set then we're in an individual batch. Else, if we get\n // batch end metadata, this is end of the current batch.\n if (this.batchClientId === undefined || batch === false) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", undefined, message);\n this.deltaScheduler.batchEnd(message);\n return;\n }\n }\n}\n\n/**\n * This class controls pausing and resuming of inbound queue to ensure that we never\n * start processing ops in a batch IF we do not have all ops in the batch.\n */\nclass ScheduleManagerCore {\n private pauseSequenceNumber: number | undefined;\n private currentBatchClientId: string | undefined;\n private localPaused = false;\n private timePaused = 0;\n private batchCount = 0;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly logger: ITelemetryLogger,\n ) {\n // Listen for delta manager sends and add batch metadata to messages\n this.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n if (messages.length === 0) {\n return;\n }\n\n // First message will have the batch flag set to true if doing a batched send\n const firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n if (!firstMessageMetadata?.batch) {\n return;\n }\n\n // If the batch contains only a single op, clear the batch flag.\n if (messages.length === 1) {\n delete firstMessageMetadata.batch;\n return;\n }\n\n // Set the batch flag to false on the last message to indicate the end of the send batch\n const lastMessage = messages[messages.length - 1];\n lastMessage.metadata = { ...lastMessage.metadata, batch: false };\n });\n\n // Listen for updates and peek at the inbound\n this.deltaManager.inbound.on(\n \"push\",\n (message: ISequencedDocumentMessage) => {\n this.trackPending(message);\n });\n\n // Start with baseline - empty inbound queue.\n assert(!this.localPaused, 0x293 /* \"initial state\" */);\n\n const allPending = this.deltaManager.inbound.toArray();\n for (const pending of allPending) {\n this.trackPending(pending);\n }\n\n // We are intentionally directly listening to the \"op\" to inspect system ops as well.\n // If we do not observe system ops, we are likely to hit 0x296 assert when system ops\n // precedes start of incomplete batch.\n this.deltaManager.on(\"op\", (message) => this.afterOpProcessing(message.sequenceNumber));\n }\n\n /**\n * The only public function in this class - called when we processed an op,\n * to make decision if op processing should be paused or not after that.\n */\n public afterOpProcessing(sequenceNumber: number) {\n assert(!this.localPaused, 0x294 /* \"can't have op processing paused if we are processing an op\" */);\n\n // If the inbound queue is ever empty, nothing to do!\n if (this.deltaManager.inbound.length === 0) {\n assert(this.pauseSequenceNumber === undefined,\n 0x295 /* \"there should be no pending batch if we have no ops\" */);\n return;\n }\n\n // The queue is\n // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n // - here (processing ops until reaching start of incomplete batch)\n // - in trackPending(), when queue was empty and start of batch showed up.\n // 2. resumed when batch end comes in (in trackPending())\n\n // do we have incomplete batch to worry about?\n if (this.pauseSequenceNumber !== undefined) {\n assert(sequenceNumber < this.pauseSequenceNumber,\n 0x296 /* \"we should never start processing incomplete batch!\" */);\n // If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!\n if (sequenceNumber + 1 === this.pauseSequenceNumber) {\n this.pauseQueue();\n }\n }\n }\n\n private pauseQueue() {\n assert(!this.localPaused, 0x297 /* \"always called from resumed state\" */);\n this.localPaused = true;\n this.timePaused = performance.now();\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.deltaManager.inbound.pause();\n }\n\n private resumeQueue(startBatch: number, messageEndBatch: ISequencedDocumentMessage) {\n const endBatch = messageEndBatch.sequenceNumber;\n const duration = this.localPaused ? (performance.now() - this.timePaused) : undefined;\n\n this.batchCount++;\n if (this.batchCount % 1000 === 1) {\n this.logger.sendTelemetryEvent({\n eventName: \"BatchStats\",\n sequenceNumber: endBatch,\n length: endBatch - startBatch + 1,\n msnDistance: endBatch - messageEndBatch.minimumSequenceNumber,\n duration,\n batchCount: this.batchCount,\n interrupted: this.localPaused,\n });\n }\n\n // Return early if no change in value\n if (!this.localPaused) {\n return;\n }\n\n this.localPaused = false;\n\n // Random round number - we want to know when batch waiting paused op processing.\n if (duration !== undefined && duration > latencyThreshold) {\n this.logger.sendErrorEvent({\n eventName: \"MaxBatchWaitTimeExceeded\",\n duration,\n sequenceNumber: endBatch,\n length: endBatch - startBatch,\n });\n }\n this.deltaManager.inbound.resume();\n }\n\n /**\n * Called for each incoming op (i.e. inbound \"push\" notification)\n */\n private trackPending(message: ISequencedDocumentMessage) {\n assert(this.deltaManager.inbound.length !== 0,\n 0x298 /* \"we have something in the queue that generates this event\" */);\n\n assert((this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined),\n 0x299 /* \"non-synchronized state\" */);\n\n const metadata = message.metadata as IRuntimeMessageMetadata;\n const batchMetadata = metadata?.batch;\n\n // Protocol messages are never part of a runtime batch of messages\n if (!isUnpackedRuntimeMessage(message)) {\n // Protocol messages should never show up in the middle of the batch!\n assert(this.currentBatchClientId === undefined, 0x29a /* \"System message in the middle of batch!\" */);\n assert(batchMetadata === undefined, 0x29b /* \"system op in a batch?\" */);\n assert(!this.localPaused, 0x29c /* \"we should be processing ops when there is no active batch\" */);\n return;\n }\n\n if (this.currentBatchClientId === undefined && batchMetadata === undefined) {\n assert(!this.localPaused, 0x29d /* \"we should be processing ops when there is no active batch\" */);\n return;\n }\n\n // If the client ID changes then we can move the pause point. If it stayed the same then we need to check.\n // If batchMetadata is not undefined then if it's true we've begun a new batch - if false we've ended\n // the previous one\n if (this.currentBatchClientId !== undefined || batchMetadata === false) {\n if (this.currentBatchClientId !== message.clientId) {\n // \"Batch not closed, yet message from another client!\"\n throw new DataCorruptionError(\n \"OpBatchIncomplete\",\n {\n runtimeVersion: pkgVersion,\n batchClientId: this.currentBatchClientId,\n ...extractSafePropertiesFromMessage(message),\n });\n }\n }\n\n // The queue is\n // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:\n // - in afterOpProcessing() - processing ops until reaching start of incomplete batch\n // - here (batchMetadata == false below), when queue was empty and start of batch showed up.\n // 2. resumed when batch end comes in (batchMetadata === true case below)\n\n if (batchMetadata) {\n assert(this.currentBatchClientId === undefined, 0x29e /* \"there can't be active batch\" */);\n assert(!this.localPaused, 0x29f /* \"we should be processing ops when there is no active batch\" */);\n this.pauseSequenceNumber = message.sequenceNumber;\n this.currentBatchClientId = message.clientId;\n // Start of the batch\n // Only pause processing if queue has no other ops!\n // If there are any other ops in the queue, processing will be stopped when they are processed!\n if (this.deltaManager.inbound.length === 1) {\n this.pauseQueue();\n }\n } else if (batchMetadata === false) {\n assert(this.pauseSequenceNumber !== undefined, 0x2a0 /* \"batch presence was validated above\" */);\n // Batch is complete, we can process it!\n this.resumeQueue(this.pauseSequenceNumber, message);\n this.pauseSequenceNumber = undefined;\n this.currentBatchClientId = undefined;\n } else {\n // Continuation of current batch. Do nothing\n assert(this.currentBatchClientId !== undefined, 0x2a1 /* \"logic error\" */);\n }\n }\n}\n"]}
@@ -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,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAiB,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EACH,WAAW,EACX,4BAA4B,EAC5B,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,MAAM,EAAE,OAAO;IAL5B,QAAQ,CAAC,SAAS,sBAAoB;IACtC,QAAQ,CAAC,QAA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AAE,OAAO,EACf,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAuBzB,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAWnE;;;;OAIG;IACI,IAAI,CAAC,MAAM,EAAE,oBAAoB;IAIjC,KAAK;YAOE,OAAO;IAgDrB;;;;;OAKG;WACW,2BAA2B,CAAC,UAAU,EAAE,oBAAoB,GAAG,OAAO;IAIpF;;;;;;;;OAQG;YACW,KAAK;IA8DnB;;;;;OAKG;IACI,OAAO;IAWd,SAAgB,iBAAiB,EAAE,WAAW,CAAC,mBAAmB,CAAC,CA+CjE;IAEF,SAAgB,gBAAgB,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAK/D;YAEY,iBAAiB;CAqDlC"}
@@ -300,7 +300,26 @@ class Summarizer extends events_1.EventEmitter {
300
300
  // Make sure we block any summarizer from being executed/enqueued while
301
301
  // executing the refreshLatestSummaryAck.
302
302
  // https://dev.azure.com/fluidframework/internal/_workitems/edit/779
303
- await this.runningSummarizer.lockedRefreshSummaryAckAction(async () => this.internalsProvider.refreshLatestSummaryAck(summaryOpHandle, summaryAckHandle, refSequenceNumber, summaryLogger));
303
+ await this.runningSummarizer.lockedRefreshSummaryAckAction(async () => this.internalsProvider.refreshLatestSummaryAck(summaryOpHandle, summaryAckHandle, refSequenceNumber, summaryLogger).catch(async (error) => {
304
+ // If the error is 404, so maybe the fetched version no longer exists on server. We just
305
+ // ignore this error in that case, as that means we will have another summaryAck for the
306
+ // latest version with which we will refresh the state. However in case of single commit
307
+ // summary, we might me missing a summary ack, so in that case we are still fine as the
308
+ // code in `submitSummary` function in container runtime, will refresh the latest state
309
+ // by calling `refreshLatestSummaryAckFromServer` and we will be fine.
310
+ if ((0, telemetry_utils_1.isFluidError)(error)
311
+ && error.errorType === driver_definitions_1.DriverErrorType.fileNotFoundOrAccessDeniedError) {
312
+ summaryLogger.sendTelemetryEvent({
313
+ eventName: "HandleSummaryAckErrorIgnored",
314
+ referenceSequenceNumber: refSequenceNumber,
315
+ proposalHandle: summaryOpHandle,
316
+ ackHandle: summaryAckHandle,
317
+ }, error);
318
+ }
319
+ else {
320
+ throw error;
321
+ }
322
+ }));
304
323
  }
305
324
  catch (error) {
306
325
  summaryLogger.sendErrorEvent({
@@ -1 +1 @@
1
- {"version":3,"file":"summarizer.js","sourceRoot":"","sources":["../src/summarizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mCAAsC;AACtC,+DAAwD;AAExD,iFAA8E;AAC9E,qEAA6D;AAC7D,2EAAkE;AAClE,iEAAmE;AACnE,qEAA8G;AAS9G,yEAAkE;AAElE,yDAAsD;AACtD,2DAAwD;AAQxD,iEAAgE;AAChE,yDAA4D;AAG5D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAa,kBAAmB,SAAQ,8BAAY;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,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9E,OAAO,IAAA,iCAAe,EAAqB,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;CACJ;AAfD,gDAeC;AAEM,MAAM,wBAAwB,GACjC,CAAC,YAAoB,EAAE,MAAe,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAD/E,QAAA,wBAAwB,4BACuD;AAE5F;;;;GAIG;AACH,MAAa,UAAW,SAAQ,qBAAY;IAcxC,YACI,GAAW;IAC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GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACtD,MAAM,gBAAgB,GAAG,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACxD,uEAAuE;gBACvE,yCAAyC;gBACzC,oEAAoE;gBACpE,MAAM,IAAI,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,KAAK,IAAI,EAAE,CAClE,IAAI,CAAC,iBAAiB,CAAC,uBAAuB,CAC1C,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,CAChB,CAAC,CAAC;aACV;YAAC,OAAO,KAAK,EAAE;gBACZ,aAAa,CAAC,cAAc,CAAC;oBACzB,SAAS,EAAE,uBAAuB;oBAClC,uBAAuB,EAAE,iBAAiB;oBAC1C,MAAM,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,0CAAE,QAAQ,0CAAE,MAAM;oBACxC,SAAS,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,QAAQ,0CAAE,MAAM;iBAC/C,EAAE,KAAK,CAAC,CAAC;aACb;YACD,iBAAiB,EAAE,CAAC;SACvB;IACL,CAAC;CACJ;AA5UD,gCA4UC","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 { ISummaryConfiguration } from \"./containerRuntime\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { IAckedSummary, SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorMessage: string, logged: boolean) => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n } finally {\n this.close();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n public close() {\n // This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n // unless stop() was called earlier\n this.dispose();\n this.runtime.closeFn();\n }\n\n private async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(\n !runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason));\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Should we try to run a last summary for the given stop reason?\n * Currently only allows \"parentNotConnected\"\n * @param stopReason - SummarizerStopReason\n * @returns - true if the stop reason can run a last summary\n */\n public static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n return stopReason === \"parentNotConnected\";\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n config: JSON.stringify(this.configurationGetter()),\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorMessage: string) => {\n if (!this._disposed) {\n this.logger.sendErrorEvent({ eventName: \"summarizingError\" },\n createSummarizingWarning(errorMessage, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n this.runtime,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // 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);\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.close();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n } catch (error) {\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n let ack: IAckedSummary | undefined;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n // Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n // we record undefined, not previous handles.\n ack = undefined;\n ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n const summaryOpHandle = ack.summaryOp.contents.handle;\n const summaryAckHandle = ack.summaryAck.contents.handle;\n // Make sure we block any summarizer from being executed/enqueued while\n // executing the refreshLatestSummaryAck.\n // https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n await this.runningSummarizer.lockedRefreshSummaryAckAction(async () =>\n this.internalsProvider.refreshLatestSummaryAck(\n summaryOpHandle,\n summaryAckHandle,\n refSequenceNumber,\n summaryLogger,\n ));\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n handle: ack?.summaryOp?.contents?.handle,\n ackHandle: ack?.summaryAck?.contents?.hand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C,oEAAoE;gBACpE,MAAM,IAAI,CAAC,iBAAiB,CAAC,6BAA6B,CAAC,KAAK,IAAI,EAAE,CAClE,IAAI,CAAC,iBAAiB,CAAC,uBAAuB,CAC1C,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,CAChB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;oBACpB,wFAAwF;oBACxF,wFAAwF;oBACxF,wFAAwF;oBACxF,uFAAuF;oBACvF,uFAAuF;oBACvF,sEAAsE;oBACtE,IAAI,IAAA,8BAAY,EAAC,KAAK,CAAC;2BAChB,KAAK,CAAC,SAAS,KAAK,oCAAe,CAAC,+BAA+B,EAAE;wBACxE,aAAa,CAAC,kBAAkB,CAAC;4BAC7B,SAAS,EAAE,8BAA8B;4BACzC,uBAAuB,EAAE,iBAAiB;4BAC1C,cAAc,EAAE,eAAe;4BAC/B,SAAS,EAAE,gBAAgB;yBAC9B,EAAE,KAAK,CAAC,CAAC;qBACb;yBAAM;wBACH,MAAM,KAAK,CAAC;qBACf;gBACL,CAAC,CAAC,CACL,CAAC;aACL;YAAC,OAAO,KAAK,EAAE;gBACZ,aAAa,CAAC,cAAc,CAAC;oBACzB,SAAS,EAAE,uBAAuB;oBAClC,uBAAuB,EAAE,iBAAiB;oBAC1C,MAAM,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,SAAS,0CAAE,QAAQ,0CAAE,MAAM;oBACxC,SAAS,EAAE,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,0CAAE,QAAQ,0CAAE,MAAM;iBAC/C,EAAE,KAAK,CAAC,CAAC;aACb;YACD,iBAAiB,EAAE,CAAC;SACvB;IACL,CAAC;CACJ;AA/VD,gCA+VC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { Deferred } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ILoader, LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { DriverErrorType, DriverHeader } from \"@fluidframework/driver-definitions\";\nimport { requestFluidObject } from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n IFluidErrorBase,\n isFluidError,\n LoggingError,\n wrapErrorAndLog,\n} from \"@fluidframework/telemetry-utils\";\nimport {\n FluidObject,\n IFluidHandleContext,\n IFluidHandle,\n IRequest,\n} from \"@fluidframework/core-interfaces\";\nimport { ISummaryConfiguration } from \"./containerRuntime\";\nimport { ICancellableSummarizerController } from \"./runWhileConnectedCoordinator\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { IAckedSummary, SummaryCollection } from \"./summaryCollection\";\nimport { SummarizerHandle } from \"./summarizerHandle\";\nimport { RunningSummarizer } from \"./runningSummarizer\";\nimport {\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerRuntime,\n ISummarizingWarning,\n SummarizerStopReason,\n} from \"./summarizerTypes\";\nimport { SummarizeHeuristicData } from \"./summarizerHeuristics\";\nimport { SummarizeResultBuilder } from \"./summaryGenerator\";\nimport { IConnectableRuntime } from \".\";\n\nconst summarizingError = \"summarizingError\";\n\nexport class SummarizingWarning extends LoggingError implements ISummarizingWarning, IFluidErrorBase {\n readonly errorType = summarizingError;\n readonly canRetry = true;\n\n constructor(\n errorMessage: string,\n readonly logged: boolean = false,\n ) {\n super(errorMessage);\n }\n\n static wrap(error: any, logged: boolean = false, logger: ITelemetryLogger) {\n const newErrorFn = (errMsg: string) => new SummarizingWarning(errMsg, logged);\n return wrapErrorAndLog<SummarizingWarning>(error, newErrorFn, logger);\n }\n}\n\nexport const createSummarizingWarning =\n (errorMessage: string, logged: boolean) => new SummarizingWarning(errorMessage, logged);\n\n/**\n * Summarizer is responsible for coordinating when to generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\nexport class Summarizer extends EventEmitter implements ISummarizer {\n public get IFluidLoadable() { return this; }\n public get ISummarizer() { return this; }\n\n private readonly logger: ITelemetryLogger;\n private runningSummarizer?: RunningSummarizer;\n private _disposed: boolean = false;\n private starting: boolean = false;\n\n private readonly innerHandle: IFluidHandle<this>;\n\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n constructor(\n url: string,\n /** Reference to runtime that created this object.\n * i.e. runtime with clientType === \"summarizer\"\n */\n private readonly runtime: ISummarizerRuntime,\n private readonly configurationGetter: () => ISummaryConfiguration,\n /** Represents an object that can generate summary.\n * In practical terms, it's same runtime (this.runtime) with clientType === \"summarizer\".\n */\n private readonly internalsProvider: ISummarizerInternalsProvider,\n handleContext: IFluidHandleContext,\n public readonly summaryCollection: SummaryCollection,\n private readonly runCoordinatorCreateFn:\n (runtime: IConnectableRuntime) => Promise<ICancellableSummarizerController>,\n ) {\n super();\n this.logger = ChildLogger.create(this.runtime.logger, \"Summarizer\");\n this.innerHandle = new SummarizerHandle(this, url, handleContext);\n }\n\n /**\n * Creates a Summarizer and its underlying client.\n * Note that different implementations of ILoader will handle the URL differently.\n * ILoader provided by a ContainerRuntime is a RelativeLoader, which will treat URL's\n * starting with \"/\" as relative to the Container. The general ILoader\n * interface will expect an absolute URL and will not handle \"/\".\n * @param loader - the loader that resolves the request\n * @param url - the URL used to resolve the container\n */\n public static async create(\n loader: ILoader,\n url: string): Promise<ISummarizer> {\n const request: IRequest = {\n headers: {\n [LoaderHeader.cache]: false,\n [LoaderHeader.clientDetails]: {\n capabilities: { interactive: false },\n type: summarizerClientType,\n },\n [DriverHeader.summarizingClient]: true,\n [LoaderHeader.reconnect]: false,\n },\n url,\n };\n\n const resolvedContainer = await loader.resolve(request);\n const fluidObject =\n await requestFluidObject<FluidObject<ISummarizer>>(resolvedContainer, { url: \"_summarizer\" });\n if (fluidObject.ISummarizer === undefined) {\n throw new UsageError(\"Fluid object does not implement ISummarizer\");\n }\n return fluidObject.ISummarizer;\n }\n\n public async run(onBehalfOf: string): Promise<SummarizerStopReason> {\n try {\n return await this.runCore(onBehalfOf);\n } catch (error) {\n this.stop(\"summarizerException\");\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n } finally {\n this.close();\n }\n }\n\n /**\n * Stops the summarizer from running. This will complete\n * the run promise, and also close the container.\n * @param reason - reason code for stopping\n */\n public stop(reason: SummarizerStopReason) {\n this.stopDeferred.resolve(reason);\n }\n\n public close() {\n // This will result in \"summarizerClientDisconnected\" stop reason recorded in telemetry,\n // unless stop() was called earlier\n this.dispose();\n this.runtime.closeFn();\n }\n\n private async runCore(onBehalfOf: string): Promise<SummarizerStopReason> {\n const runCoordinator: ICancellableSummarizerController = await this.runCoordinatorCreateFn(this.runtime);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopP = Promise.race([runCoordinator.waitCancelled, this.stopDeferred.promise]);\n void stopP.then((reason) => {\n this.logger.sendTelemetryEvent({\n eventName: \"StoppingSummarizer\",\n onBehalfOf,\n reason,\n });\n });\n\n if (runCoordinator.cancelled) {\n return runCoordinator.waitCancelled;\n }\n\n const runningSummarizer = await this.start(onBehalfOf, runCoordinator);\n\n // Wait for either external signal to cancel, or loss of connectivity.\n const stopReason = await stopP;\n\n // There are two possible approaches here:\n // 1. Propagate cancellation from this.stopDeferred to runCoordinator. This will ensure that we move to the exit\n // faster, including breaking out of the RunningSummarizer.trySummarize() faster.\n // We could create new coordinator and pass it to waitStop() -> trySummarizeOnce(\"lastSummary\") flow.\n // The con of this approach is that we might cancel active summary, and lastSummary will fail because it\n // did not wait for ack/nack from previous summary. Plus we disregard any 429 kind of info from service\n // that way (i.e. trySummarize() loop might have been waiting for 5 min because storage told us so).\n // In general, it's more wasted resources.\n // 2. We can not do it and make waitStop() do last summary only if there was no active summary. This ensures\n // that client behaves properly (from server POV) and we do not waste resources. But, it may mean we wait\n // substantially longer for trySummarize() retries to play out and thus this summary loop may run into\n // conflict with new summarizer client starting on different client.\n // As of now, #2 is implemented. It's more forward looking, as issue #7279 suggests changing design for new\n // summarizer client to not be created until current summarizer fully moves to exit, and that would reduce\n // cons of #2 substantially.\n\n // Cleanup after running\n await runningSummarizer.waitStop(\n !runCoordinator.cancelled && Summarizer.stopReasonCanRunLastSummary(stopReason));\n\n // Propagate reason and ensure that if someone is waiting for cancellation token, they are moving to exit\n runCoordinator.stop(stopReason);\n\n return stopReason;\n }\n\n /**\n * Should we try to run a last summary for the given stop reason?\n * Currently only allows \"parentNotConnected\"\n * @param stopReason - SummarizerStopReason\n * @returns - true if the stop reason can run a last summary\n */\n public static stopReasonCanRunLastSummary(stopReason: SummarizerStopReason): boolean {\n return stopReason === \"parentNotConnected\";\n }\n\n /**\n * Put the summarizer in a started state, including creating and initializing the RunningSummarizer.\n * The start request can come either from the SummaryManager (in the auto-summarize case) or from the user\n * (in the on-demand case).\n * @param onBehalfOf - ID of the client that requested that the summarizer start\n * @param runCoordinator - cancellation token\n * @param newConfig - Summary configuration to override the existing config when invoking the RunningSummarizer.\n * @returns - Promise that is fulfilled when the RunningSummarizer is ready\n */\n private async start(\n onBehalfOf: string,\n runCoordinator: ICancellableSummarizerController): Promise<RunningSummarizer> {\n if (this.runningSummarizer) {\n if (this.runningSummarizer.disposed) {\n throw new UsageError(\"Starting a disposed summarizer\");\n }\n return this.runningSummarizer;\n }\n if (this.starting) {\n throw new UsageError(\"Attempting to start a summarizer that is already starting\");\n }\n this.starting = true;\n // Initialize values and first ack (time is not exact)\n this.logger.sendTelemetryEvent({\n eventName: \"RunningSummarizer\",\n onBehalfOf,\n initSummarySeqNumber: this.runtime.deltaManager.initialSequenceNumber,\n config: JSON.stringify(this.configurationGetter()),\n });\n\n // Summarizing container ID (with clientType === \"summarizer\")\n const clientId = this.runtime.clientId;\n if (clientId === undefined) {\n throw new UsageError(\"clientId should be defined if connected.\");\n }\n\n const runningSummarizer = await RunningSummarizer.start(\n this.logger,\n this.summaryCollection.createWatcher(clientId),\n this.configurationGetter(),\n async (...args) => this.internalsProvider.submitSummary(...args), // submitSummaryCallback\n new SummarizeHeuristicData(\n this.runtime.deltaManager.lastSequenceNumber,\n { /** summary attempt baseline for heuristics */\n refSequenceNumber: this.runtime.deltaManager.initialSequenceNumber,\n summaryTime: Date.now(),\n } as const,\n ),\n (errorMessage: string) => {\n if (!this._disposed) {\n this.logger.sendErrorEvent({ eventName: \"summarizingError\" },\n createSummarizingWarning(errorMessage, true));\n }\n },\n this.summaryCollection,\n runCoordinator /* cancellationToken */,\n (reason) => runCoordinator.stop(reason), /* stopSummarizerCallback */\n this.runtime,\n );\n this.runningSummarizer = runningSummarizer;\n this.starting = false;\n\n // Handle summary acks\n // Note: no exceptions are thrown from handleSummaryAcks handler as it handles all exceptions\n this.handleSummaryAcks().catch((error) => {\n this.logger.sendErrorEvent({ eventName: \"HandleSummaryAckFatalError\" }, error);\n });\n\n return runningSummarizer;\n }\n\n /**\n * Disposes of resources after running. This cleanup will\n * clear any outstanding timers and reset some of the state\n * properties.\n * Called by ContainerRuntime when it is disposed, as well as at the end the run().\n */\n public dispose() {\n // Given that the call can come from own ContainerRuntime, ensure that we stop all the processes.\n this.stop(\"summarizerClientDisconnected\");\n\n this._disposed = true;\n if (this.runningSummarizer) {\n this.runningSummarizer.dispose();\n this.runningSummarizer = undefined;\n }\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n try {\n if (this._disposed || this.runningSummarizer?.disposed) {\n throw new UsageError(\"Summarizer is already disposed.\");\n }\n if (this.runtime.summarizerClientId !== undefined &&\n this.runtime.summarizerClientId !== this.runtime.clientId) {\n // If there is an elected summarizer, and it's not this one, don't allow on-demand summary.\n // This is to prevent the on-demand summary and heuristic-based summary from stepping on\n // each other.\n throw new UsageError(\"On-demand summary attempted while an elected summarizer is present\");\n }\n const builder = new SummarizeResultBuilder();\n if (this.runningSummarizer) {\n // Summarizer is already running. Go ahead and start.\n return this.runningSummarizer.summarizeOnDemand(builder, ...args);\n }\n\n // Summarizer isn't running, so we need to start it, which is an async operation.\n // Manage the promise related to creating the cancellation token here.\n // The promises related to starting, summarizing,\n // and submitting are communicated to the caller through the results builder.\n const coordinatorCreateP = this.runCoordinatorCreateFn(this.runtime);\n\n coordinatorCreateP.then((runCoordinator) => {\n // 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);\n startP.then(async (runningSummarizer) => {\n // Successfully started the summarizer. Run it.\n runningSummarizer.summarizeOnDemand(builder, ...args);\n // Wait for a command to stop or loss of connectivity before tearing down the summarizer and client.\n const stopReason = await Promise.race([this.stopDeferred.promise, runCoordinator.waitCancelled]);\n await runningSummarizer.waitStop(false);\n runCoordinator.stop(stopReason);\n this.close();\n }).catch((reason) => {\n builder.fail(\"Failed to start summarizer\", reason);\n });\n }).catch((reason) => {\n builder.fail(\"Failed to create cancellation token\", reason);\n });\n\n return builder.build();\n } catch (error) {\n throw SummarizingWarning.wrap(error, false /* logged */, this.logger);\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this._disposed || this.runningSummarizer === undefined || this.runningSummarizer.disposed) {\n throw new UsageError(\"Summarizer is not running or already disposed.\");\n }\n return this.runningSummarizer.enqueueSummarize(...args);\n };\n\n private async handleSummaryAcks() {\n let refSequenceNumber = this.runtime.deltaManager.initialSequenceNumber;\n let ack: IAckedSummary | undefined;\n while (this.runningSummarizer) {\n const summaryLogger = this.runningSummarizer.tryGetCorrelatedLogger(refSequenceNumber) ?? this.logger;\n try {\n // Initialize ack with undefined if exception happens inside of waitSummaryAck on second iteration,\n // we record undefined, not previous handles.\n ack = undefined;\n ack = await this.summaryCollection.waitSummaryAck(refSequenceNumber);\n refSequenceNumber = ack.summaryOp.referenceSequenceNumber;\n const summaryOpHandle = ack.summaryOp.contents.handle;\n const summaryAckHandle = ack.summaryAck.contents.handle;\n // Make sure we block any summarizer from being executed/enqueued while\n // executing the refreshLatestSummaryAck.\n // https://dev.azure.com/fluidframework/internal/_workitems/edit/779\n await this.runningSummarizer.lockedRefreshSummaryAckAction(async () =>\n this.internalsProvider.refreshLatestSummaryAck(\n summaryOpHandle,\n summaryAckHandle,\n refSequenceNumber,\n summaryLogger,\n ).catch(async (error) => {\n // If the error is 404, so maybe the fetched version no longer exists on server. We just\n // ignore this error in that case, as that means we will have another summaryAck for the\n // latest version with which we will refresh the state. However in case of single commit\n // summary, we might me missing a summary ack, so in that case we are still fine as the\n // code in `submitSummary` function in container runtime, will refresh the latest state\n // by calling `refreshLatestSummaryAckFromServer` and we will be fine.\n if (isFluidError(error)\n && error.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError) {\n summaryLogger.sendTelemetryEvent({\n eventName: \"HandleSummaryAckErrorIgnored\",\n referenceSequenceNumber: refSequenceNumber,\n proposalHandle: summaryOpHandle,\n ackHandle: summaryAckHandle,\n }, error);\n } else {\n throw error;\n }\n }),\n );\n } catch (error) {\n summaryLogger.sendErrorEvent({\n eventName: \"HandleSummaryAckError\",\n referenceSequenceNumber: refSequenceNumber,\n handle: ack?.summaryOp?.contents?.handle,\n ackHandle: ack?.summaryAck?.contents?.handle,\n }, error);\n }\n refSequenceNumber++;\n }\n }\n}\n"]}
@@ -255,7 +255,7 @@ class SummaryCollection extends common_utils_1.TypedEventEmitter {
255
255
  // from. i.e. initialSequenceNumber > summarySequenceNumber.
256
256
  // We really don't care about it for now, since it is older than
257
257
  // the one we loaded from.
258
- if (seq >= this.deltaManager.initialSequenceNumber) {
258
+ if (seq > this.deltaManager.initialSequenceNumber) {
259
259
  // Potential causes for it to be later than our initialSequenceNumber
260
260
  // are that the summaryOp was nacked then acked, double-acked, or
261
261
  // the summarySequenceNumber is incorrect.
@@ -1 +1 @@
1
- {"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../src/summaryCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;A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C,IAAI,OAAO,EAAE;YACT,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACpB,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,kCAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SAC1C;IACL,CAAC;CACJ;AAxMD,8CAwMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, IEvent, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Deferred, assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISummaryAck,\n ISummaryContent,\n ISummaryNack,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Interface for summary op messages with typed contents.\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n type: MessageType.Summarize;\n contents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n type: MessageType.SummaryAck;\n contents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n type: MessageType.SummaryNack;\n contents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n */\nexport interface ISummary {\n readonly clientId: string;\n readonly clientSequenceNumber: number;\n waitBroadcast(): Promise<ISummaryOpMessage>;\n waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n */\nexport interface IAckedSummary {\n readonly summaryOp: ISummaryOpMessage;\n readonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n Local = 0,\n Broadcast = 1,\n Acked = 2,\n Nacked = -1,\n}\n\nclass Summary implements ISummary {\n public static createLocal(clientId: string, clientSequenceNumber: number) {\n return new Summary(clientId, clientSequenceNumber);\n }\n public static createFromOp(op: ISummaryOpMessage) {\n const summary = new Summary(op.clientId, op.clientSequenceNumber);\n summary.broadcast(op);\n return summary;\n }\n\n private state = SummaryState.Local;\n\n private _summaryOp?: ISummaryOpMessage;\n private _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n private readonly defSummaryOp = new Deferred<void>();\n private readonly defSummaryAck = new Deferred<void>();\n\n public get summaryOp() { return this._summaryOp; }\n public get summaryAckNack() { return this._summaryAckNack; }\n\n private constructor(\n public readonly clientId: string,\n public readonly clientSequenceNumber: number) { }\n\n public hasBeenAcked(): this is IAckedSummary {\n return this.state === SummaryState.Acked;\n }\n\n public broadcast(op: ISummaryOpMessage) {\n assert(this.state === SummaryState.Local, 0x175 /* \"Can only broadcast if summarizer starts in local state\" */);\n this._summaryOp = op;\n this.defSummaryOp.resolve();\n this.state = SummaryState.Broadcast;\n return true;\n }\n\n public ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n assert(this.state === SummaryState.Broadcast,\n 0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */);\n this._summaryAckNack = op;\n this.defSummaryAck.resolve();\n this.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n return true;\n }\n\n public async waitBroadcast(): Promise<ISummaryOpMessage> {\n await this.defSummaryOp.promise;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._summaryOp!;\n }\n\n public async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n await this.defSummaryAck.promise;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._summaryAckNack!;\n }\n}\n\n/**\n * Watches summaries created by a specific client.\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n watchSummary(clientSequenceNumber: number): ISummary;\n waitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n // key: clientSeqNum\n private readonly localSummaries = new Map<number, Summary>();\n private _disposed = false;\n\n public get disposed() { return this._disposed; }\n\n public constructor(\n public readonly clientId: string,\n private readonly summaryCollection: SummaryCollection,\n ) { }\n\n /**\n * Watches for a specific sent summary op.\n * @param clientSequenceNumber - client sequence number of sent summary op\n */\n public watchSummary(clientSequenceNumber: number): ISummary {\n let summary = this.localSummaries.get(clientSequenceNumber);\n if (!summary) {\n summary = Summary.createLocal(this.clientId, clientSequenceNumber);\n this.localSummaries.set(summary.clientSequenceNumber, summary);\n }\n return summary;\n }\n\n /**\n * Waits until all of the pending summaries in the underlying SummaryCollection\n * are acked/nacked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n public waitFlushed() {\n return this.summaryCollection.waitFlushed();\n }\n\n /**\n * Gets a watched summary or returns undefined if not watched.\n * @param clientSequenceNumber - client sequence number of sent summary op\n */\n public tryGetSummary(clientSequenceNumber: number) {\n return this.localSummaries.get(clientSequenceNumber);\n }\n\n /**\n * Starts watching a summary made by this client.\n * @param summary - summary to start watching\n */\n public setSummary(summary: Summary) {\n this.localSummaries.set(summary.clientSequenceNumber, summary);\n }\n\n public dispose() {\n this.summaryCollection.removeWatcher(this.clientId);\n this._disposed = true;\n }\n}\n\nexport type OpActionEventName = MessageType.Summarize | MessageType.SummaryAck | MessageType.SummaryNack | \"default\";\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\nexport interface ISummaryCollectionOpEvents extends IEvent {\n (event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n // key: clientId\n private readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n // key: summarySeqNum\n private readonly pendingSummaries = new Map<number, Summary>();\n private refreshWaitNextAck = new Deferred<void>();\n\n private lastSummaryTimestamp: number | undefined;\n private maxAckWaitTime: number | undefined;\n private pendingAckTimerTimeoutCallback: (() => void) | undefined;\n private lastAck: IAckedSummary | undefined;\n\n public get latestAck(): IAckedSummary | undefined { return this.lastAck; }\n\n public emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n return super.emit(event, ...args);\n }\n\n public get opsSinceLastAck() {\n return this.deltaManager.lastSequenceNumber -\n (this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber);\n }\n\n public addOpListener(listener: () => void) {\n this.deltaManager.on(\"op\", listener);\n }\n\n public removeOpListener(listener: () => void) {\n this.deltaManager.off(\"op\", listener);\n }\n\n public constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly logger: ITelemetryLogger,\n ) {\n super();\n this.deltaManager.on(\n \"op\",\n (op) => this.handleOp(op));\n }\n\n /**\n * Creates and returns a summary watcher for a specific client.\n * This will allow for local sent summaries to be better tracked.\n * @param clientId - client id for watcher\n */\n public createWatcher(clientId: string): IClientSummaryWatcher {\n const watcher = new ClientSummaryWatcher(clientId, this);\n this.summaryWatchers.set(clientId, watcher);\n return watcher;\n }\n\n public removeWatcher(clientId: string) {\n this.summaryWatchers.delete(clientId);\n }\n\n public setPendingAckTimerTimeoutCallback(maxAckWaitTime: number, timeoutCallback: () => void) {\n this.maxAckWaitTime = maxAckWaitTime;\n this.pendingAckTimerTimeoutCallback = timeoutCallback;\n }\n\n public unsetPendingAckTimerTimeoutCallback() {\n this.maxAckWaitTime = undefined;\n this.pendingAckTimerTimeoutCallback = undefined;\n }\n\n /**\n * Returns a promise that resolves once all pending summary ops\n * have been acked or nacked.\n */\n public async waitFlushed(): Promise<IAckedSummary | undefined> {\n while (this.pendingSummaries.size > 0) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const promises = Array.from(this.pendingSummaries, ([, summary]) => summary.waitAckNack());\n await Promise.all(promises);\n }\n return this.lastAck;\n }\n\n /**\n * Returns a promise that resolves once a summary is acked that has a reference\n * sequence number greater than or equal to the passed in sequence number.\n * @param referenceSequenceNumber - reference sequence number to wait for\n * @returns The latest acked summary\n */\n public async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n while (!this.lastAck || this.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber) {\n await this.refreshWaitNextAck.promise;\n }\n return this.lastAck;\n }\n\n /**\n * Handler for ops; only handles ops relating to summaries.\n * @param op - op message to handle\n */\n private handleOp(op: ISequencedDocumentMessage) {\n switch (op.type) {\n case MessageType.Summarize: {\n this.handleSummaryOp(op as ISummaryOpMessage);\n return;\n }\n case MessageType.SummaryAck: {\n this.handleSummaryAck(op as ISummaryAckMessage);\n return;\n }\n case MessageType.SummaryNack: {\n this.handleSummaryNack(op as ISummaryNackMessage);\n return;\n }\n default: {\n // If the difference between timestamp of current op and last summary op is greater than\n // the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n // immediately as we have already waited for maxAckWaitTime.\n const lastOpTimestamp = op.timestamp;\n if (this.lastSummaryTimestamp !== undefined &&\n this.maxAckWaitTime !== undefined &&\n lastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n ) {\n this.pendingAckTimerTimeoutCallback?.();\n }\n this.emit(\"default\", op);\n\n return;\n }\n }\n }\n\n private handleSummaryOp(op: ISummaryOpMessage) {\n let summary: Summary | undefined;\n\n // Check if summary already being watched, broadcast if so\n const watcher = this.summaryWatchers.get(op.clientId);\n if (watcher) {\n summary = watcher.tryGetSummary(op.clientSequenceNumber);\n if (summary) {\n summary.broadcast(op);\n }\n }\n\n // If not watched, create from op\n if (!summary) {\n summary = Summary.createFromOp(op);\n if (watcher) {\n watcher.setSummary(summary);\n }\n }\n this.pendingSummaries.set(op.sequenceNumber, summary);\n this.lastSummaryTimestamp = op.timestamp;\n this.emit(MessageType.Summarize, op);\n }\n\n private handleSummaryAck(op: ISummaryAckMessage) {\n const seq = op.contents.summaryProposal.summarySequenceNumber;\n const summary = this.pendingSummaries.get(seq);\n if (!summary || summary.summaryOp === undefined) {\n // Summary ack without an op should be rare. We could fetch the\n // reference sequence number from the snapshot, but instead we\n // will not emit this ack. It should be the case that the summary\n // op that this ack is for is earlier than this file was loaded\n // from. i.e. initialSequenceNumber > summarySequenceNumber.\n // We really don't care about it for now, since it is older than\n // the one we loaded from.\n if (seq >= this.deltaManager.initialSequenceNumber) {\n // Potential causes for it to be later than our initialSequenceNumber\n // are that the summaryOp was nacked then acked, double-acked, or\n // the summarySequenceNumber is incorrect.\n this.logger.sendTelemetryEvent({\n eventName: \"SummaryAckWithoutOp\",\n sequenceNumber: op.sequenceNumber, // summary ack seq #\n summarySequenceNumber: seq, // missing summary seq #\n initialSequenceNumber: this.deltaManager.initialSequenceNumber,\n });\n }\n return;\n }\n summary.ackNack(op);\n this.pendingSummaries.delete(seq);\n\n // Track latest ack\n if (!this.lastAck || seq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber) {\n this.lastAck = {\n summaryOp: summary.summaryOp,\n summaryAck: op,\n };\n this.refreshWaitNextAck.resolve();\n this.refreshWaitNextAck = new Deferred<void>();\n this.emit(MessageType.SummaryAck, op);\n }\n }\n\n private handleSummaryNack(op: ISummaryNackMessage) {\n const seq = op.contents.summaryProposal.summarySequenceNumber;\n const summary = this.pendingSummaries.get(seq);\n if (summary) {\n summary.ackNack(op);\n this.pendingSummaries.delete(seq);\n this.emit(MessageType.SummaryNack, op);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"summaryCollection.js","sourceRoot":"","sources":["../src/summaryCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAmF;AAEnF,+EAO8C;AA6C9C,IAAK,YAKJ;AALD,WAAK,YAAY;IACb,iDAAS,CAAA;IACT,yDAAa,CAAA;IACb,iDAAS,CAAA;IACT,oDAAW,CAAA;AACf,CAAC,EALI,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CAAC,kCAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SAC1C;IACL,CAAC;CACJ;AAxMD,8CAwMC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable, IEvent, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { Deferred, assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport {\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISummaryAck,\n ISummaryContent,\n ISummaryNack,\n MessageType,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Interface for summary op messages with typed contents.\n */\nexport interface ISummaryOpMessage extends ISequencedDocumentMessage {\n type: MessageType.Summarize;\n contents: ISummaryContent;\n}\n\n/**\n * Interface for summary ack messages with typed contents.\n */\nexport interface ISummaryAckMessage extends ISequencedDocumentMessage {\n type: MessageType.SummaryAck;\n contents: ISummaryAck;\n}\n\n/**\n * Interface for summary nack messages with typed contents.\n */\nexport interface ISummaryNackMessage extends ISequencedDocumentMessage {\n type: MessageType.SummaryNack;\n contents: ISummaryNack;\n}\n\n/**\n * A single summary which can be tracked as it goes through its life cycle.\n * The life cycle is: Local to Broadcast to Acked/Nacked.\n */\nexport interface ISummary {\n readonly clientId: string;\n readonly clientSequenceNumber: number;\n waitBroadcast(): Promise<ISummaryOpMessage>;\n waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage>;\n}\n\n/**\n * A single summary which has already been acked by the server.\n */\nexport interface IAckedSummary {\n readonly summaryOp: ISummaryOpMessage;\n readonly summaryAck: ISummaryAckMessage;\n}\n\nenum SummaryState {\n Local = 0,\n Broadcast = 1,\n Acked = 2,\n Nacked = -1,\n}\n\nclass Summary implements ISummary {\n public static createLocal(clientId: string, clientSequenceNumber: number) {\n return new Summary(clientId, clientSequenceNumber);\n }\n public static createFromOp(op: ISummaryOpMessage) {\n const summary = new Summary(op.clientId, op.clientSequenceNumber);\n summary.broadcast(op);\n return summary;\n }\n\n private state = SummaryState.Local;\n\n private _summaryOp?: ISummaryOpMessage;\n private _summaryAckNack?: ISummaryAckMessage | ISummaryNackMessage;\n\n private readonly defSummaryOp = new Deferred<void>();\n private readonly defSummaryAck = new Deferred<void>();\n\n public get summaryOp() { return this._summaryOp; }\n public get summaryAckNack() { return this._summaryAckNack; }\n\n private constructor(\n public readonly clientId: string,\n public readonly clientSequenceNumber: number) { }\n\n public hasBeenAcked(): this is IAckedSummary {\n return this.state === SummaryState.Acked;\n }\n\n public broadcast(op: ISummaryOpMessage) {\n assert(this.state === SummaryState.Local, 0x175 /* \"Can only broadcast if summarizer starts in local state\" */);\n this._summaryOp = op;\n this.defSummaryOp.resolve();\n this.state = SummaryState.Broadcast;\n return true;\n }\n\n public ackNack(op: ISummaryAckMessage | ISummaryNackMessage) {\n assert(this.state === SummaryState.Broadcast,\n 0x176 /* \"Can only ack/nack if summarizer is in broadcasting state\" */);\n this._summaryAckNack = op;\n this.defSummaryAck.resolve();\n this.state = op.type === MessageType.SummaryAck ? SummaryState.Acked : SummaryState.Nacked;\n return true;\n }\n\n public async waitBroadcast(): Promise<ISummaryOpMessage> {\n await this.defSummaryOp.promise;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._summaryOp!;\n }\n\n public async waitAckNack(): Promise<ISummaryAckMessage | ISummaryNackMessage> {\n await this.defSummaryAck.promise;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._summaryAckNack!;\n }\n}\n\n/**\n * Watches summaries created by a specific client.\n */\nexport interface IClientSummaryWatcher extends IDisposable {\n watchSummary(clientSequenceNumber: number): ISummary;\n waitFlushed(): Promise<IAckedSummary | undefined>;\n}\n\n/**\n * This class watches summaries created by a specific client.\n * It should be created and managed from a SummaryCollection.\n */\nclass ClientSummaryWatcher implements IClientSummaryWatcher {\n // key: clientSeqNum\n private readonly localSummaries = new Map<number, Summary>();\n private _disposed = false;\n\n public get disposed() { return this._disposed; }\n\n public constructor(\n public readonly clientId: string,\n private readonly summaryCollection: SummaryCollection,\n ) { }\n\n /**\n * Watches for a specific sent summary op.\n * @param clientSequenceNumber - client sequence number of sent summary op\n */\n public watchSummary(clientSequenceNumber: number): ISummary {\n let summary = this.localSummaries.get(clientSequenceNumber);\n if (!summary) {\n summary = Summary.createLocal(this.clientId, clientSequenceNumber);\n this.localSummaries.set(summary.clientSequenceNumber, summary);\n }\n return summary;\n }\n\n /**\n * Waits until all of the pending summaries in the underlying SummaryCollection\n * are acked/nacked.\n */\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n public waitFlushed() {\n return this.summaryCollection.waitFlushed();\n }\n\n /**\n * Gets a watched summary or returns undefined if not watched.\n * @param clientSequenceNumber - client sequence number of sent summary op\n */\n public tryGetSummary(clientSequenceNumber: number) {\n return this.localSummaries.get(clientSequenceNumber);\n }\n\n /**\n * Starts watching a summary made by this client.\n * @param summary - summary to start watching\n */\n public setSummary(summary: Summary) {\n this.localSummaries.set(summary.clientSequenceNumber, summary);\n }\n\n public dispose() {\n this.summaryCollection.removeWatcher(this.clientId);\n this._disposed = true;\n }\n}\n\nexport type OpActionEventName = MessageType.Summarize | MessageType.SummaryAck | MessageType.SummaryNack | \"default\";\nexport type OpActionEventListener = (op: ISequencedDocumentMessage) => void;\nexport interface ISummaryCollectionOpEvents extends IEvent {\n (event: OpActionEventName, listener: OpActionEventListener);\n}\n\n/**\n * Data structure that looks at the op stream to track summaries as they\n * are broadcast, acked and nacked.\n * It provides functionality for watching specific summaries.\n */\nexport class SummaryCollection extends TypedEventEmitter<ISummaryCollectionOpEvents> {\n // key: clientId\n private readonly summaryWatchers = new Map<string, ClientSummaryWatcher>();\n // key: summarySeqNum\n private readonly pendingSummaries = new Map<number, Summary>();\n private refreshWaitNextAck = new Deferred<void>();\n\n private lastSummaryTimestamp: number | undefined;\n private maxAckWaitTime: number | undefined;\n private pendingAckTimerTimeoutCallback: (() => void) | undefined;\n private lastAck: IAckedSummary | undefined;\n\n public get latestAck(): IAckedSummary | undefined { return this.lastAck; }\n\n public emit(event: OpActionEventName, ...args: Parameters<OpActionEventListener>): boolean {\n return super.emit(event, ...args);\n }\n\n public get opsSinceLastAck() {\n return this.deltaManager.lastSequenceNumber -\n (this.lastAck?.summaryAck.sequenceNumber ?? this.deltaManager.initialSequenceNumber);\n }\n\n public addOpListener(listener: () => void) {\n this.deltaManager.on(\"op\", listener);\n }\n\n public removeOpListener(listener: () => void) {\n this.deltaManager.off(\"op\", listener);\n }\n\n public constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly logger: ITelemetryLogger,\n ) {\n super();\n this.deltaManager.on(\n \"op\",\n (op) => this.handleOp(op));\n }\n\n /**\n * Creates and returns a summary watcher for a specific client.\n * This will allow for local sent summaries to be better tracked.\n * @param clientId - client id for watcher\n */\n public createWatcher(clientId: string): IClientSummaryWatcher {\n const watcher = new ClientSummaryWatcher(clientId, this);\n this.summaryWatchers.set(clientId, watcher);\n return watcher;\n }\n\n public removeWatcher(clientId: string) {\n this.summaryWatchers.delete(clientId);\n }\n\n public setPendingAckTimerTimeoutCallback(maxAckWaitTime: number, timeoutCallback: () => void) {\n this.maxAckWaitTime = maxAckWaitTime;\n this.pendingAckTimerTimeoutCallback = timeoutCallback;\n }\n\n public unsetPendingAckTimerTimeoutCallback() {\n this.maxAckWaitTime = undefined;\n this.pendingAckTimerTimeoutCallback = undefined;\n }\n\n /**\n * Returns a promise that resolves once all pending summary ops\n * have been acked or nacked.\n */\n public async waitFlushed(): Promise<IAckedSummary | undefined> {\n while (this.pendingSummaries.size > 0) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const promises = Array.from(this.pendingSummaries, ([, summary]) => summary.waitAckNack());\n await Promise.all(promises);\n }\n return this.lastAck;\n }\n\n /**\n * Returns a promise that resolves once a summary is acked that has a reference\n * sequence number greater than or equal to the passed in sequence number.\n * @param referenceSequenceNumber - reference sequence number to wait for\n * @returns The latest acked summary\n */\n public async waitSummaryAck(referenceSequenceNumber: number): Promise<IAckedSummary> {\n while (!this.lastAck || this.lastAck.summaryOp.referenceSequenceNumber < referenceSequenceNumber) {\n await this.refreshWaitNextAck.promise;\n }\n return this.lastAck;\n }\n\n /**\n * Handler for ops; only handles ops relating to summaries.\n * @param op - op message to handle\n */\n private handleOp(op: ISequencedDocumentMessage) {\n switch (op.type) {\n case MessageType.Summarize: {\n this.handleSummaryOp(op as ISummaryOpMessage);\n return;\n }\n case MessageType.SummaryAck: {\n this.handleSummaryAck(op as ISummaryAckMessage);\n return;\n }\n case MessageType.SummaryNack: {\n this.handleSummaryNack(op as ISummaryNackMessage);\n return;\n }\n default: {\n // If the difference between timestamp of current op and last summary op is greater than\n // the maxAckWaitTime, then we need to inform summarizer to not wait and summarize\n // immediately as we have already waited for maxAckWaitTime.\n const lastOpTimestamp = op.timestamp;\n if (this.lastSummaryTimestamp !== undefined &&\n this.maxAckWaitTime !== undefined &&\n lastOpTimestamp - this.lastSummaryTimestamp >= this.maxAckWaitTime\n ) {\n this.pendingAckTimerTimeoutCallback?.();\n }\n this.emit(\"default\", op);\n\n return;\n }\n }\n }\n\n private handleSummaryOp(op: ISummaryOpMessage) {\n let summary: Summary | undefined;\n\n // Check if summary already being watched, broadcast if so\n const watcher = this.summaryWatchers.get(op.clientId);\n if (watcher) {\n summary = watcher.tryGetSummary(op.clientSequenceNumber);\n if (summary) {\n summary.broadcast(op);\n }\n }\n\n // If not watched, create from op\n if (!summary) {\n summary = Summary.createFromOp(op);\n if (watcher) {\n watcher.setSummary(summary);\n }\n }\n this.pendingSummaries.set(op.sequenceNumber, summary);\n this.lastSummaryTimestamp = op.timestamp;\n this.emit(MessageType.Summarize, op);\n }\n\n private handleSummaryAck(op: ISummaryAckMessage) {\n const seq = op.contents.summaryProposal.summarySequenceNumber;\n const summary = this.pendingSummaries.get(seq);\n if (!summary || summary.summaryOp === undefined) {\n // Summary ack without an op should be rare. We could fetch the\n // reference sequence number from the snapshot, but instead we\n // will not emit this ack. It should be the case that the summary\n // op that this ack is for is earlier than this file was loaded\n // from. i.e. initialSequenceNumber > summarySequenceNumber.\n // We really don't care about it for now, since it is older than\n // the one we loaded from.\n if (seq > this.deltaManager.initialSequenceNumber) {\n // Potential causes for it to be later than our initialSequenceNumber\n // are that the summaryOp was nacked then acked, double-acked, or\n // the summarySequenceNumber is incorrect.\n this.logger.sendTelemetryEvent({\n eventName: \"SummaryAckWithoutOp\",\n sequenceNumber: op.sequenceNumber, // summary ack seq #\n summarySequenceNumber: seq, // missing summary seq #\n initialSequenceNumber: this.deltaManager.initialSequenceNumber,\n });\n }\n return;\n }\n summary.ackNack(op);\n this.pendingSummaries.delete(seq);\n\n // Track latest ack\n if (!this.lastAck || seq > this.lastAck.summaryAck.contents.summaryProposal.summarySequenceNumber) {\n this.lastAck = {\n summaryOp: summary.summaryOp,\n summaryAck: op,\n };\n this.refreshWaitNextAck.resolve();\n this.refreshWaitNextAck = new Deferred<void>();\n this.emit(MessageType.SummaryAck, op);\n }\n }\n\n private handleSummaryNack(op: ISummaryNackMessage) {\n const seq = op.contents.summaryProposal.summarySequenceNumber;\n const summary = this.pendingSummaries.get(seq);\n if (summary) {\n summary.ackNack(op);\n this.pendingSummaries.delete(seq);\n this.emit(MessageType.SummaryNack, op);\n }\n }\n}\n"]}
@@ -253,7 +253,7 @@ class SummaryGenerator {
253
253
  case "generate": return Object.assign(Object.assign(Object.assign({}, initialProps), summaryData.summaryStats), { generateDuration: summaryData.generateDuration });
254
254
  case "upload": return Object.assign(Object.assign(Object.assign({}, initialProps), summaryData.summaryStats), { generateDuration: summaryData.generateDuration, handle: summaryData.handle, uploadDuration: summaryData.uploadDuration });
255
255
  case "submit": return Object.assign(Object.assign(Object.assign({}, initialProps), summaryData.summaryStats), { generateDuration: summaryData.generateDuration, handle: summaryData.handle, uploadDuration: summaryData.uploadDuration, clientSequenceNumber: summaryData.clientSequenceNumber, hasMissingOpData: this.heuristicData.hasMissingOpData, opsSizesSinceLastSummary: this.heuristicData.totalOpsSize, nonRuntimeOpsSinceLastSummary: this.heuristicData.numNonRuntimeOps });
256
- default: (0, common_utils_1.assert)(true, "Unexpected summary stage");
256
+ default: (0, common_utils_1.assert)(true, 0x397 /* Unexpected summary stage */);
257
257
  }
258
258
  return initialProps;
259
259
  }