@fluidframework/container-runtime 2.0.0-internal.3.0.0 → 2.0.0-internal.3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +19 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js +2 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +9 -2
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +80 -33
- package/dist/blobManager.js.map +1 -1
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/connectionTelemetry.js +11 -9
- package/dist/connectionTelemetry.js.map +1 -1
- package/dist/containerHandleContext.d.ts.map +1 -1
- package/dist/containerHandleContext.js +3 -1
- package/dist/containerHandleContext.js.map +1 -1
- package/dist/containerRuntime.d.ts +10 -0
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +140 -72
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/dataStore.js +11 -9
- package/dist/dataStore.js.map +1 -1
- package/dist/dataStoreContext.d.ts +18 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +66 -15
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/dataStoreContexts.js +7 -3
- package/dist/dataStoreContexts.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/dataStoreRegistry.js +3 -1
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/dataStores.d.ts +26 -1
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +103 -18
- package/dist/dataStores.js.map +1 -1
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/deltaScheduler.js +8 -3
- package/dist/deltaScheduler.js.map +1 -1
- package/dist/garbageCollection.d.ts +34 -14
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +188 -93
- package/dist/garbageCollection.js.map +1 -1
- package/dist/garbageCollectionConstants.d.ts +3 -0
- package/dist/garbageCollectionConstants.d.ts.map +1 -1
- package/dist/garbageCollectionConstants.js +6 -1
- package/dist/garbageCollectionConstants.js.map +1 -1
- package/dist/garbageCollectionHelpers.d.ts +26 -0
- package/dist/garbageCollectionHelpers.d.ts.map +1 -0
- package/dist/garbageCollectionHelpers.js +45 -0
- package/dist/garbageCollectionHelpers.js.map +1 -0
- package/dist/gcSweepReadyUsageDetection.d.ts +5 -5
- package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/dist/gcSweepReadyUsageDetection.js +14 -10
- package/dist/gcSweepReadyUsageDetection.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +5 -5
- package/dist/opLifecycle/batchManager.d.ts.map +1 -1
- package/dist/opLifecycle/batchManager.js +19 -12
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/index.d.ts.map +1 -1
- package/dist/opLifecycle/index.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +5 -2
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +4 -1
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +19 -17
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/opProperties.d.ts.map +1 -1
- package/dist/opProperties.js +1 -3
- package/dist/opProperties.js.map +1 -1
- package/dist/orderedClientElection.d.ts.map +1 -1
- package/dist/orderedClientElection.js +10 -4
- package/dist/orderedClientElection.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +7 -0
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +7 -4
- package/dist/pendingStateManager.js.map +1 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/dist/runWhileConnectedCoordinator.js.map +1 -1
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +34 -21
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/scheduleManager.js +3 -2
- package/dist/scheduleManager.js.map +1 -1
- package/dist/serializedSnapshotStorage.d.ts +2 -2
- package/dist/serializedSnapshotStorage.d.ts.map +1 -1
- package/dist/serializedSnapshotStorage.js +5 -3
- package/dist/serializedSnapshotStorage.js.map +1 -1
- package/dist/summarizer.d.ts +2 -2
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +37 -17
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerClientElection.d.ts.map +1 -1
- package/dist/summarizerClientElection.js.map +1 -1
- package/dist/summarizerHandle.d.ts.map +1 -1
- package/dist/summarizerHandle.js.map +1 -1
- package/dist/summarizerHeuristics.d.ts.map +1 -1
- package/dist/summarizerHeuristics.js +6 -9
- package/dist/summarizerHeuristics.js.map +1 -1
- package/dist/summarizerTypes.d.ts +21 -21
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryCollection.d.ts.map +1 -1
- package/dist/summaryCollection.js +18 -8
- package/dist/summaryCollection.js.map +1 -1
- package/dist/summaryFormat.d.ts +22 -0
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +18 -10
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +34 -15
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +21 -9
- package/dist/summaryManager.js.map +1 -1
- package/dist/throttler.d.ts +2 -2
- package/dist/throttler.d.ts.map +1 -1
- package/dist/throttler.js +4 -4
- package/dist/throttler.js.map +1 -1
- package/garbageCollection.md +15 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js +2 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +9 -2
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +82 -35
- package/lib/blobManager.js.map +1 -1
- package/lib/connectionTelemetry.d.ts.map +1 -1
- package/lib/connectionTelemetry.js +11 -9
- package/lib/connectionTelemetry.js.map +1 -1
- package/lib/containerHandleContext.d.ts.map +1 -1
- package/lib/containerHandleContext.js +3 -1
- package/lib/containerHandleContext.js.map +1 -1
- package/lib/containerRuntime.d.ts +10 -0
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +146 -78
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStore.d.ts.map +1 -1
- package/lib/dataStore.js +11 -9
- package/lib/dataStore.js.map +1 -1
- package/lib/dataStoreContext.d.ts +18 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +68 -17
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStoreContexts.d.ts.map +1 -1
- package/lib/dataStoreContexts.js +7 -3
- package/lib/dataStoreContexts.js.map +1 -1
- package/lib/dataStoreRegistry.d.ts.map +1 -1
- package/lib/dataStoreRegistry.js +3 -1
- package/lib/dataStoreRegistry.js.map +1 -1
- package/lib/dataStores.d.ts +26 -1
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +109 -24
- package/lib/dataStores.js.map +1 -1
- package/lib/deltaScheduler.d.ts.map +1 -1
- package/lib/deltaScheduler.js +9 -4
- package/lib/deltaScheduler.js.map +1 -1
- package/lib/garbageCollection.d.ts +34 -14
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +190 -95
- package/lib/garbageCollection.js.map +1 -1
- package/lib/garbageCollectionConstants.d.ts +3 -0
- package/lib/garbageCollectionConstants.d.ts.map +1 -1
- package/lib/garbageCollectionConstants.js +5 -0
- package/lib/garbageCollectionConstants.js.map +1 -1
- package/lib/garbageCollectionHelpers.d.ts +26 -0
- package/lib/garbageCollectionHelpers.d.ts.map +1 -0
- package/lib/garbageCollectionHelpers.js +40 -0
- package/lib/garbageCollectionHelpers.js.map +1 -0
- package/lib/gcSweepReadyUsageDetection.d.ts +5 -5
- package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
- package/lib/gcSweepReadyUsageDetection.js +14 -10
- package/lib/gcSweepReadyUsageDetection.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +5 -5
- package/lib/opLifecycle/batchManager.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +19 -12
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/index.d.ts.map +1 -1
- package/lib/opLifecycle/index.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +5 -2
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +5 -2
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +19 -17
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/opProperties.d.ts.map +1 -1
- package/lib/opProperties.js +1 -3
- package/lib/opProperties.js.map +1 -1
- package/lib/orderedClientElection.d.ts.map +1 -1
- package/lib/orderedClientElection.js +10 -4
- package/lib/orderedClientElection.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +7 -0
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +7 -4
- package/lib/pendingStateManager.js.map +1 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +1 -1
- package/lib/runWhileConnectedCoordinator.js.map +1 -1
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +35 -22
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/scheduleManager.js +3 -2
- package/lib/scheduleManager.js.map +1 -1
- package/lib/serializedSnapshotStorage.d.ts +2 -2
- package/lib/serializedSnapshotStorage.d.ts.map +1 -1
- package/lib/serializedSnapshotStorage.js +5 -3
- package/lib/serializedSnapshotStorage.js.map +1 -1
- package/lib/summarizer.d.ts +2 -2
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +37 -17
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerClientElection.d.ts.map +1 -1
- package/lib/summarizerClientElection.js.map +1 -1
- package/lib/summarizerHandle.d.ts.map +1 -1
- package/lib/summarizerHandle.js.map +1 -1
- package/lib/summarizerHeuristics.d.ts.map +1 -1
- package/lib/summarizerHeuristics.js +6 -9
- package/lib/summarizerHeuristics.js.map +1 -1
- package/lib/summarizerTypes.d.ts +21 -21
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryCollection.d.ts.map +1 -1
- package/lib/summaryCollection.js +18 -8
- package/lib/summaryCollection.js.map +1 -1
- package/lib/summaryFormat.d.ts +22 -0
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +20 -12
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +34 -15
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +21 -9
- package/lib/summaryManager.js.map +1 -1
- package/lib/throttler.d.ts +2 -2
- package/lib/throttler.d.ts.map +1 -1
- package/lib/throttler.js +4 -4
- package/lib/throttler.js.map +1 -1
- package/package.json +121 -149
- package/prettier.config.cjs +1 -1
- package/src/batchTracker.ts +54 -49
- package/src/blobManager.ts +793 -672
- package/src/connectionTelemetry.ts +280 -249
- package/src/containerHandleContext.ts +27 -29
- package/src/containerRuntime.ts +3168 -2940
- package/src/dataStore.ts +172 -159
- package/src/dataStoreContext.ts +1098 -996
- package/src/dataStoreContexts.ts +178 -161
- package/src/dataStoreRegistry.ts +25 -20
- package/src/dataStores.ts +884 -728
- package/src/deltaScheduler.ts +158 -150
- package/src/garbageCollection.ts +1883 -1692
- package/src/garbageCollectionConstants.ts +6 -0
- package/src/garbageCollectionHelpers.ts +61 -0
- package/src/gcSweepReadyUsageDetection.ts +89 -83
- package/src/index.ts +67 -66
- package/src/opLifecycle/README.md +152 -0
- package/src/opLifecycle/batchManager.ts +145 -141
- package/src/opLifecycle/definitions.ts +29 -29
- package/src/opLifecycle/index.ts +5 -5
- package/src/opLifecycle/opCompressor.ts +54 -53
- package/src/opLifecycle/opDecompressor.ts +100 -81
- package/src/opLifecycle/opSplitter.ts +214 -188
- package/src/opLifecycle/outbox.ts +204 -194
- package/src/opLifecycle/remoteMessageProcessor.ts +62 -62
- package/src/opProperties.ts +11 -9
- package/src/orderedClientElection.ts +489 -457
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +384 -338
- package/src/runWhileConnectedCoordinator.ts +78 -71
- package/src/runningSummarizer.ts +619 -581
- package/src/scheduleManager.ts +299 -269
- package/src/serializedSnapshotStorage.ts +126 -112
- package/src/summarizer.ts +417 -381
- package/src/summarizerClientElection.ts +107 -100
- package/src/summarizerHandle.ts +11 -9
- package/src/summarizerHeuristics.ts +183 -186
- package/src/summarizerTypes.ts +344 -330
- package/src/summaryCollection.ts +378 -349
- package/src/summaryFormat.ts +170 -126
- package/src/summaryGenerator.ts +465 -406
- package/src/summaryManager.ts +377 -348
- package/src/throttler.ts +131 -122
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
- package/dist/garbageCollectionTombstoneUtils.d.ts +0 -14
- package/dist/garbageCollectionTombstoneUtils.d.ts.map +0 -1
- package/dist/garbageCollectionTombstoneUtils.js +0 -23
- package/dist/garbageCollectionTombstoneUtils.js.map +0 -1
- package/lib/garbageCollectionTombstoneUtils.d.ts +0 -14
- package/lib/garbageCollectionTombstoneUtils.d.ts.map +0 -1
- package/lib/garbageCollectionTombstoneUtils.js +0 -19
- package/lib/garbageCollectionTombstoneUtils.js.map +0 -1
- package/src/garbageCollectionTombstoneUtils.ts +0 -28
package/dist/containerRuntime.js
CHANGED
|
@@ -33,6 +33,8 @@ const batchTracker_1 = require("./batchTracker");
|
|
|
33
33
|
const serializedSnapshotStorage_1 = require("./serializedSnapshotStorage");
|
|
34
34
|
const scheduleManager_1 = require("./scheduleManager");
|
|
35
35
|
const opLifecycle_1 = require("./opLifecycle");
|
|
36
|
+
const garbageCollectionHelpers_1 = require("./garbageCollectionHelpers");
|
|
37
|
+
const garbageCollectionConstants_1 = require("./garbageCollectionConstants");
|
|
36
38
|
var ContainerMessageType;
|
|
37
39
|
(function (ContainerMessageType) {
|
|
38
40
|
// An op to be delivered to store
|
|
@@ -138,8 +140,7 @@ function getDeviceSpec() {
|
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
|
-
catch (_a) {
|
|
142
|
-
}
|
|
143
|
+
catch (_a) { }
|
|
143
144
|
return {};
|
|
144
145
|
}
|
|
145
146
|
exports.getDeviceSpec = getDeviceSpec;
|
|
@@ -152,7 +153,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
152
153
|
* @internal
|
|
153
154
|
*/
|
|
154
155
|
constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, requestHandler, summaryConfiguration) {
|
|
155
|
-
var _a, _b, _c, _d, _e, _f;
|
|
156
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
156
157
|
if (summaryConfiguration === void 0) { summaryConfiguration = Object.assign(Object.assign({}, exports.DefaultSummaryConfiguration), (_a = runtimeOptions.summaryOptions) === null || _a === void 0 ? void 0 : _a.summaryConfigOverrides); }
|
|
157
158
|
super();
|
|
158
159
|
this.context = context;
|
|
@@ -235,28 +236,39 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
235
236
|
this.nextSummaryNumber = loadSummaryNumber + 1;
|
|
236
237
|
this.messageAtLastSummary = metadata === null || metadata === void 0 ? void 0 : metadata.message;
|
|
237
238
|
this._connected = this.context.connected;
|
|
239
|
+
this.gcTombstoneEnforcementAllowed = (0, garbageCollectionHelpers_1.shouldAllowGcTombstoneEnforcement)((_c = metadata === null || metadata === void 0 ? void 0 : metadata.gcFeatureMatrix) === null || _c === void 0 ? void 0 : _c.tombstoneGeneration /* persisted */, this.runtimeOptions.gcOptions[garbageCollectionConstants_1.gcTombstoneGenerationOptionName] /* current */);
|
|
238
240
|
this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.logger, "ContainerRuntime"));
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
this.mc.logger.sendTelemetryEvent({
|
|
242
|
+
eventName: "GCFeatureMatrix",
|
|
243
|
+
metadataValue: JSON.stringify(metadata === null || metadata === void 0 ? void 0 : metadata.gcFeatureMatrix),
|
|
244
|
+
inputs: JSON.stringify({
|
|
245
|
+
gcOptions_gcTombstoneGeneration: this.runtimeOptions.gcOptions[garbageCollectionConstants_1.gcTombstoneGenerationOptionName],
|
|
246
|
+
}),
|
|
247
|
+
});
|
|
248
|
+
const opSplitter = new opLifecycle_1.OpSplitter(chunks, this.context.submitBatchFn, this.mc.config.getBoolean("Fluid.ContainerRuntime.DisableCompressionChunking") === true
|
|
249
|
+
? Number.POSITIVE_INFINITY
|
|
250
|
+
: runtimeOptions.chunkSizeInBytes, runtimeOptions.maxBatchSizeInBytes, this.mc.logger);
|
|
241
251
|
this.remoteMessageProcessor = new opLifecycle_1.RemoteMessageProcessor(opSplitter, new opLifecycle_1.OpDecompressor());
|
|
242
252
|
this.handleContext = new containerHandleContext_1.ContainerFluidHandleContext("", this);
|
|
243
253
|
if (this.summaryConfiguration.state === "enabled") {
|
|
244
254
|
this.validateSummaryHeuristicConfiguration(this.summaryConfiguration);
|
|
245
255
|
}
|
|
246
|
-
this.enableOpReentryCheck =
|
|
247
|
-
|
|
248
|
-
|
|
256
|
+
this.enableOpReentryCheck =
|
|
257
|
+
runtimeOptions.enableOpReentryCheck === true &&
|
|
258
|
+
// Allow for a break-glass config to override the options
|
|
259
|
+
this.mc.config.getBoolean("Fluid.ContainerRuntime.DisableOpReentryCheck") !== true;
|
|
249
260
|
this.summariesDisabled = this.isSummariesDisabled();
|
|
250
261
|
this.heuristicsDisabled = this.isHeuristicsDisabled();
|
|
251
262
|
this.maxOpsSinceLastSummary = this.getMaxOpsSinceLastSummary();
|
|
252
263
|
this.initialSummarizerDelayMs = this.getInitialSummarizerDelayMs();
|
|
253
264
|
this.maxConsecutiveReconnects =
|
|
254
|
-
(
|
|
265
|
+
(_d = this.mc.config.getNumber(maxConsecutiveReconnectsKey)) !== null && _d !== void 0 ? _d : this.defaultMaxConsecutiveReconnects;
|
|
255
266
|
this._flushMode = runtimeOptions.flushMode;
|
|
256
267
|
const pendingRuntimeState = context.pendingLocalState;
|
|
257
|
-
const baseSnapshot = (
|
|
258
|
-
const maxSnapshotCacheDurationMs = (
|
|
259
|
-
if (maxSnapshotCacheDurationMs !== undefined &&
|
|
268
|
+
const baseSnapshot = (_e = pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.baseSnapshot) !== null && _e !== void 0 ? _e : context.baseSnapshot;
|
|
269
|
+
const maxSnapshotCacheDurationMs = (_g = (_f = this._storage) === null || _f === void 0 ? void 0 : _f.policies) === null || _g === void 0 ? void 0 : _g.maximumCacheDurationMs;
|
|
270
|
+
if (maxSnapshotCacheDurationMs !== undefined &&
|
|
271
|
+
maxSnapshotCacheDurationMs > 5 * 24 * 60 * 60 * 1000) {
|
|
260
272
|
// This is a runtime enforcement of what's already explicit in the policy's type itself,
|
|
261
273
|
// which dictates the value is either undefined or exactly 5 days in ms.
|
|
262
274
|
// As long as the actual value is less than 5 days, the assumptions GC makes here are valid.
|
|
@@ -301,12 +313,15 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
301
313
|
if (baseSnapshot) {
|
|
302
314
|
this.summarizerNode.updateBaseSummaryState(baseSnapshot);
|
|
303
315
|
}
|
|
304
|
-
this.dataStores = new dataStores_1.DataStores((0, dataStores_1.getSummaryForDatastores)(baseSnapshot, metadata), this, (attachMsg) => this.submit(ContainerMessageType.Attach, attachMsg), (id, createParam) => (summarizeInternal, getGCDataFn, getBaseGCDetailsFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn, getBaseGCDetailsFn), (id) => this.summarizerNode.deleteChild(id), this.mc.logger, async () => this.garbageCollector.getBaseGCDetails(), (path, timestampMs, packagePath) => this.garbageCollector.nodeUpdated(path, "Changed", timestampMs, packagePath), new Map(dataStoreAliasMap));
|
|
316
|
+
this.dataStores = new dataStores_1.DataStores((0, dataStores_1.getSummaryForDatastores)(baseSnapshot, metadata), this, (attachMsg) => this.submit(ContainerMessageType.Attach, attachMsg), (id, createParam) => (summarizeInternal, getGCDataFn, getBaseGCDetailsFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn, getBaseGCDetailsFn), (id) => this.summarizerNode.deleteChild(id), this.mc.logger, async () => this.garbageCollector.getBaseGCDetails(), (path, timestampMs, packagePath) => this.garbageCollector.nodeUpdated(path, "Changed", timestampMs, packagePath), (path) => this.garbageCollector.isNodeDeleted(path), new Map(dataStoreAliasMap));
|
|
305
317
|
this.blobManager = new blobManager_1.BlobManager(this.handleContext, blobManagerSnapshot, () => this.storage, (localId, blobId) => {
|
|
306
318
|
if (!this.disposed) {
|
|
307
|
-
this.submit(ContainerMessageType.BlobAttach, undefined, undefined, {
|
|
319
|
+
this.submit(ContainerMessageType.BlobAttach, undefined, undefined, {
|
|
320
|
+
localId,
|
|
321
|
+
blobId,
|
|
322
|
+
});
|
|
308
323
|
}
|
|
309
|
-
}, (blobPath) => this.garbageCollector.nodeUpdated(blobPath, "Loaded"), (fromPath, toPath) => this.garbageCollector.addedOutboundReference(fromPath, toPath), this, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pendingAttachmentBlobs, () => this.getCurrentReferenceTimestampMs());
|
|
324
|
+
}, (blobPath) => this.garbageCollector.nodeUpdated(blobPath, "Loaded"), (fromPath, toPath) => this.garbageCollector.addedOutboundReference(fromPath, toPath), (blobPath) => this.garbageCollector.isNodeDeleted(blobPath), this, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pendingAttachmentBlobs, () => this.getCurrentReferenceTimestampMs());
|
|
310
325
|
this.scheduleManager = new scheduleManager_1.ScheduleManager(context.deltaManager, this, () => this.clientId, telemetry_utils_1.ChildLogger.create(this.logger, "ScheduleManager"));
|
|
311
326
|
this.pendingStateManager = new pendingStateManager_1.PendingStateManager({
|
|
312
327
|
applyStashedOp: this.applyStashedOp.bind(this),
|
|
@@ -317,11 +332,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
317
332
|
rollback: this.rollback.bind(this),
|
|
318
333
|
orderSequentially: this.orderSequentially.bind(this),
|
|
319
334
|
}, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pending);
|
|
320
|
-
const compressionOptions = this.mc.config.getBoolean("Fluid.ContainerRuntime.DisableCompression") === true
|
|
321
|
-
{
|
|
335
|
+
const compressionOptions = this.mc.config.getBoolean("Fluid.ContainerRuntime.DisableCompression") === true
|
|
336
|
+
? {
|
|
322
337
|
minimumBatchSizeInBytes: Number.POSITIVE_INFINITY,
|
|
323
|
-
compressionAlgorithm: CompressionAlgorithms.lz4
|
|
324
|
-
}
|
|
338
|
+
compressionAlgorithm: CompressionAlgorithms.lz4,
|
|
339
|
+
}
|
|
340
|
+
: runtimeOptions.compressionOptions;
|
|
325
341
|
this.outbox = new opLifecycle_1.Outbox({
|
|
326
342
|
shouldSend: () => this.canSendOps(),
|
|
327
343
|
pendingStateManager: this.pendingStateManager,
|
|
@@ -339,8 +355,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
339
355
|
this.remoteMessageProcessor.clearPartialMessagesFor(clientId);
|
|
340
356
|
});
|
|
341
357
|
this.summaryCollection = new summaryCollection_1.SummaryCollection(this.deltaManager, this.logger);
|
|
342
|
-
this.dirtyContainer =
|
|
343
|
-
|
|
358
|
+
this.dirtyContainer =
|
|
359
|
+
this.context.attachState !== container_definitions_1.AttachState.Attached ||
|
|
360
|
+
this.pendingStateManager.hasPendingMessages();
|
|
344
361
|
this.context.updateDirtyContainerState(this.dirtyContainer);
|
|
345
362
|
if (this.summariesDisabled) {
|
|
346
363
|
this.mc.logger.sendTelemetryEvent({ eventName: "SummariesDisabled" });
|
|
@@ -408,8 +425,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
408
425
|
(0, connectionTelemetry_1.ReportOpPerfTelemetry)(this.context.clientId, this.deltaManager, this.logger);
|
|
409
426
|
(0, batchTracker_1.BindBatchTracker)(this, this.logger);
|
|
410
427
|
}
|
|
411
|
-
get IContainerRuntime() {
|
|
412
|
-
|
|
428
|
+
get IContainerRuntime() {
|
|
429
|
+
return this;
|
|
430
|
+
}
|
|
431
|
+
get IFluidRouter() {
|
|
432
|
+
return this;
|
|
433
|
+
}
|
|
413
434
|
/**
|
|
414
435
|
* @deprecated - use loadRuntime instead.
|
|
415
436
|
* Load the stores from a snapshot and returns the runtime.
|
|
@@ -450,7 +471,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
450
471
|
*/
|
|
451
472
|
static async loadRuntime(params) {
|
|
452
473
|
var _a, _b, _c, _d;
|
|
453
|
-
const { context, registryEntries, existing, requestHandler, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime } = params;
|
|
474
|
+
const { context, registryEntries, existing, requestHandler, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime, } = params;
|
|
454
475
|
// If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
|
|
455
476
|
// back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
|
|
456
477
|
const backCompatContext = context;
|
|
@@ -462,13 +483,15 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
462
483
|
});
|
|
463
484
|
const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, enableOfflineLoad = false, compressionOptions = {
|
|
464
485
|
minimumBatchSizeInBytes: Number.POSITIVE_INFINITY,
|
|
465
|
-
compressionAlgorithm: CompressionAlgorithms.lz4
|
|
486
|
+
compressionAlgorithm: CompressionAlgorithms.lz4,
|
|
466
487
|
}, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, chunkSizeInBytes = Number.POSITIVE_INFINITY, enableOpReentryCheck = false, } = runtimeOptions;
|
|
467
488
|
const pendingRuntimeState = context.pendingLocalState;
|
|
468
489
|
const baseSnapshot = (_b = pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.baseSnapshot) !== null && _b !== void 0 ? _b : context.baseSnapshot;
|
|
469
|
-
const storage = !pendingRuntimeState
|
|
470
|
-
context.storage
|
|
471
|
-
new serializedSnapshotStorage_1.SerializedSnapshotStorage(() => {
|
|
490
|
+
const storage = !pendingRuntimeState
|
|
491
|
+
? context.storage
|
|
492
|
+
: new serializedSnapshotStorage_1.SerializedSnapshotStorage(() => {
|
|
493
|
+
return context.storage;
|
|
494
|
+
}, pendingRuntimeState.snapshotBlobs);
|
|
472
495
|
const registry = new dataStoreRegistry_1.FluidDataStoreRegistry(registryEntries);
|
|
473
496
|
const tryFetchBlob = async (blobName) => {
|
|
474
497
|
const blobId = baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.blobs[blobName];
|
|
@@ -499,7 +522,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
499
522
|
if (!pendingRuntimeState && runtimeSequenceNumber !== undefined) {
|
|
500
523
|
const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;
|
|
501
524
|
// Unless bypass is explicitly set, then take action when sequence numbers mismatch.
|
|
502
|
-
if (loadSequenceNumberVerification !== "bypass" &&
|
|
525
|
+
if (loadSequenceNumberVerification !== "bypass" &&
|
|
526
|
+
runtimeSequenceNumber !== protocolSequenceNumber) {
|
|
503
527
|
// "Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber"
|
|
504
528
|
const error = new container_utils_1.DataCorruptionError(
|
|
505
529
|
// pre-0.58 error message: SummaryMetadataMismatch
|
|
@@ -606,7 +630,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
606
630
|
var _a;
|
|
607
631
|
return (_a = this.summarizerClientElection) === null || _a === void 0 ? void 0 : _a.electedClientId;
|
|
608
632
|
}
|
|
609
|
-
get disposed() {
|
|
633
|
+
get disposed() {
|
|
634
|
+
return this._disposed;
|
|
635
|
+
}
|
|
610
636
|
get summarizer() {
|
|
611
637
|
(0, common_utils_1.assert)(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
|
|
612
638
|
return this._summarizer;
|
|
@@ -716,7 +742,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
716
742
|
status: 200,
|
|
717
743
|
mimeType: "fluid/object",
|
|
718
744
|
value: blob,
|
|
719
|
-
}
|
|
745
|
+
}
|
|
746
|
+
: (0, runtime_utils_1.create404Response)(request);
|
|
720
747
|
}
|
|
721
748
|
else if (requestParser.pathParts.length > 0) {
|
|
722
749
|
const dataStore = await this.getDataStoreFromRequest(id, request);
|
|
@@ -759,7 +786,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
759
786
|
* This is a workaround to handle scenarios where a data store shared with an external app is deleted
|
|
760
787
|
* and marked as unreferenced by GC. Returning an error will fail to load the data store for the app.
|
|
761
788
|
*/
|
|
762
|
-
if (((_d = request.headers) === null || _d === void 0 ? void 0 : _d[RuntimeHeaders.externalRequest]) &&
|
|
789
|
+
if (((_d = request.headers) === null || _d === void 0 ? void 0 : _d[RuntimeHeaders.externalRequest]) &&
|
|
790
|
+
this.garbageCollector.shouldRunGC) {
|
|
763
791
|
// The data store is referenced if used routes in the base summary has a route to self.
|
|
764
792
|
// Older documents may not have used routes in the summary. They are considered referenced.
|
|
765
793
|
const usedRoutes = (await dataStoreContext.getBaseGCDetails()).usedRoutes;
|
|
@@ -933,7 +961,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
933
961
|
if (reconnection) {
|
|
934
962
|
this.consecutiveReconnects++;
|
|
935
963
|
if (!this.shouldContinueReconnecting()) {
|
|
936
|
-
this.closeFn(container_utils_1.DataProcessingError.create("Runtime detected too many reconnects with no progress syncing local ops.
|
|
964
|
+
this.closeFn(container_utils_1.DataProcessingError.create("Runtime detected too many reconnects with no progress syncing local ops.", "setConnectionState", undefined, {
|
|
937
965
|
dataLoss: 1,
|
|
938
966
|
attempts: this.consecutiveReconnects,
|
|
939
967
|
pendingMessages: this.pendingStateManager.pendingMessagesCount,
|
|
@@ -1040,7 +1068,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1040
1068
|
if (message.clientId === this.clientId && this.connected) {
|
|
1041
1069
|
// Check to see if the signal was lost.
|
|
1042
1070
|
if (this._perfSignalData.trackingSignalSequenceNumber !== undefined &&
|
|
1043
|
-
envelope.clientSignalSequenceNumber >
|
|
1071
|
+
envelope.clientSignalSequenceNumber >
|
|
1072
|
+
this._perfSignalData.trackingSignalSequenceNumber) {
|
|
1044
1073
|
this._perfSignalData.signalsLost++;
|
|
1045
1074
|
this._perfSignalData.trackingSignalSequenceNumber = undefined;
|
|
1046
1075
|
this.logger.sendErrorEvent({
|
|
@@ -1051,7 +1080,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1051
1080
|
clientSignalSequenceNumber: envelope.clientSignalSequenceNumber,
|
|
1052
1081
|
});
|
|
1053
1082
|
}
|
|
1054
|
-
else if (envelope.clientSignalSequenceNumber ===
|
|
1083
|
+
else if (envelope.clientSignalSequenceNumber ===
|
|
1084
|
+
this._perfSignalData.trackingSignalSequenceNumber) {
|
|
1055
1085
|
this.sendSignalTelemetryEvent(envelope.clientSignalSequenceNumber);
|
|
1056
1086
|
this._perfSignalData.trackingSignalSequenceNumber = undefined;
|
|
1057
1087
|
}
|
|
@@ -1138,7 +1168,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1138
1168
|
return this.dataStores.createDetachedDataStoreCore(pkg, false);
|
|
1139
1169
|
}
|
|
1140
1170
|
async _createDataStoreWithProps(pkg, props, id = (0, uuid_1.v4)()) {
|
|
1141
|
-
const fluidDataStore = await this.dataStores
|
|
1171
|
+
const fluidDataStore = await this.dataStores
|
|
1172
|
+
._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id, props)
|
|
1173
|
+
.realize();
|
|
1142
1174
|
return (0, dataStore_1.channelToDataStore)(fluidDataStore, id, this, this.dataStores, this.mc.logger);
|
|
1143
1175
|
}
|
|
1144
1176
|
async _createDataStore(pkg, id = (0, uuid_1.v4)(), props) {
|
|
@@ -1275,7 +1307,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1275
1307
|
}
|
|
1276
1308
|
const telemetryContext = new runtime_utils_1.TelemetryContext();
|
|
1277
1309
|
const { stats, summary } = await this.summarizerNode.summarize(fullTree, trackState, telemetryContext);
|
|
1278
|
-
this.logger.sendTelemetryEvent({
|
|
1310
|
+
this.logger.sendTelemetryEvent({
|
|
1311
|
+
eventName: "SummarizeTelemetry",
|
|
1312
|
+
details: telemetryContext.serialize(),
|
|
1313
|
+
});
|
|
1279
1314
|
(0, common_utils_1.assert)(summary.type === protocol_definitions_1.SummaryType.Tree, 0x12f /* "Container Runtime's summarize should always return a tree" */);
|
|
1280
1315
|
return { stats, summary, gcStats };
|
|
1281
1316
|
}
|
|
@@ -1326,6 +1361,18 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1326
1361
|
this.blobManager.updateUnusedRoutes(blobManagerRoutes);
|
|
1327
1362
|
this.dataStores.updateUnusedRoutes(dataStoreRoutes);
|
|
1328
1363
|
}
|
|
1364
|
+
/**
|
|
1365
|
+
* This is called to delete objects from the runtime
|
|
1366
|
+
* @param unusedRoutes - object routes and sub routes that can be deleted
|
|
1367
|
+
* @returns - routes of objects deleted from the runtime
|
|
1368
|
+
*/
|
|
1369
|
+
deleteUnusedNodes(unusedRoutes) {
|
|
1370
|
+
const { dataStoreRoutes } = this.getDataStoreAndBlobManagerRoutes(unusedRoutes);
|
|
1371
|
+
const deletedRoutes = [];
|
|
1372
|
+
const deletedDataStoreRoutes = this.dataStores.deleteUnusedNodes(dataStoreRoutes);
|
|
1373
|
+
deletedRoutes.push(...deletedDataStoreRoutes);
|
|
1374
|
+
return deletedRoutes;
|
|
1375
|
+
}
|
|
1329
1376
|
/**
|
|
1330
1377
|
* This is called to update objects that are tombstones.
|
|
1331
1378
|
* @param tombstonedRoutes - Data store and attachment blob routes that are tombstones in this Container.
|
|
@@ -1441,8 +1488,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1441
1488
|
// We might need to catch up to the latest summary's reference sequence number before pausing.
|
|
1442
1489
|
await this.waitForDeltaManagerToCatchup(latestSnapshotRefSeq, summaryNumberLogger);
|
|
1443
1490
|
}
|
|
1491
|
+
const shouldPauseInboundSignal = this.mc.config.getBoolean("Fluid.ContainerRuntime.SubmitSummary.disableInboundSignalPause") !== true;
|
|
1444
1492
|
try {
|
|
1445
1493
|
await this.deltaManager.inbound.pause();
|
|
1494
|
+
if (shouldPauseInboundSignal) {
|
|
1495
|
+
await this.deltaManager.inboundSignal.pause();
|
|
1496
|
+
}
|
|
1446
1497
|
const summaryRefSeqNum = this.deltaManager.lastSequenceNumber;
|
|
1447
1498
|
const minimumSequenceNumber = this.deltaManager.minimumSequenceNumber;
|
|
1448
1499
|
const message = `Summary @${summaryRefSeqNum}:${this.deltaManager.minimumSequenceNumber}`;
|
|
@@ -1543,8 +1594,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1543
1594
|
// latestSnapshotVersionId from storage and it does not match with the lastAck ackHandle, then use
|
|
1544
1595
|
// the one fetched from storage as parent as that is the latest.
|
|
1545
1596
|
let summaryContext;
|
|
1546
|
-
if ((lastAck === null || lastAck === void 0 ? void 0 : lastAck.summaryAck.contents.handle) !== latestSnapshotVersionId
|
|
1547
|
-
|
|
1597
|
+
if ((lastAck === null || lastAck === void 0 ? void 0 : lastAck.summaryAck.contents.handle) !== latestSnapshotVersionId &&
|
|
1598
|
+
latestSnapshotVersionId !== undefined) {
|
|
1548
1599
|
summaryContext = {
|
|
1549
1600
|
proposalHandle: undefined,
|
|
1550
1601
|
ackHandle: latestSnapshotVersionId,
|
|
@@ -1601,6 +1652,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1601
1652
|
this.summarizerNode.clearSummary();
|
|
1602
1653
|
// Restart the delta manager
|
|
1603
1654
|
this.deltaManager.inbound.resume();
|
|
1655
|
+
if (shouldPauseInboundSignal) {
|
|
1656
|
+
this.deltaManager.inboundSignal.resume();
|
|
1657
|
+
}
|
|
1604
1658
|
}
|
|
1605
1659
|
}
|
|
1606
1660
|
hasPendingMessages() {
|
|
@@ -1649,7 +1703,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1649
1703
|
const deserializedContent = { type, contents };
|
|
1650
1704
|
const serializedContent = JSON.stringify(deserializedContent);
|
|
1651
1705
|
if (this.deltaManager.readOnlyInfo.readonly) {
|
|
1652
|
-
this.logger.sendTelemetryEvent({
|
|
1706
|
+
this.logger.sendTelemetryEvent({
|
|
1707
|
+
eventName: "SubmitOpInReadonly",
|
|
1708
|
+
connected: this.connected,
|
|
1709
|
+
});
|
|
1653
1710
|
}
|
|
1654
1711
|
const message = {
|
|
1655
1712
|
contents: serializedContent,
|
|
@@ -1679,7 +1736,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1679
1736
|
// issue than sending.
|
|
1680
1737
|
// Please note that this does not change file format, so it can be disabled in the future if this
|
|
1681
1738
|
// optimization no longer makes sense (for example, batch compression may make it less appealing).
|
|
1682
|
-
if (this.currentlyBatching() &&
|
|
1739
|
+
if (this.currentlyBatching() &&
|
|
1740
|
+
type === ContainerMessageType.Attach &&
|
|
1683
1741
|
this.mc.config.getBoolean("Fluid.ContainerRuntime.disableAttachOpReorder") !== true) {
|
|
1684
1742
|
this.outbox.submitAttach(message);
|
|
1685
1743
|
}
|
|
@@ -1692,10 +1750,14 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1692
1750
|
else if (!this.flushMicroTaskExists) {
|
|
1693
1751
|
this.flushMicroTaskExists = true;
|
|
1694
1752
|
// Queue a microtask to detect the end of the turn and force a flush.
|
|
1695
|
-
Promise.resolve()
|
|
1753
|
+
Promise.resolve()
|
|
1754
|
+
.then(() => {
|
|
1696
1755
|
this.flushMicroTaskExists = false;
|
|
1697
1756
|
this.flush();
|
|
1698
|
-
})
|
|
1757
|
+
})
|
|
1758
|
+
.catch((error) => {
|
|
1759
|
+
this.closeFn(error);
|
|
1760
|
+
});
|
|
1699
1761
|
}
|
|
1700
1762
|
}
|
|
1701
1763
|
catch (error) {
|
|
@@ -1809,14 +1871,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1809
1871
|
// The call to fetch the snapshot is very expensive and not always needed.
|
|
1810
1872
|
// It should only be done by the summarizerNode, if required.
|
|
1811
1873
|
// When fetching from storage we will always get the latest version and do not use the ackHandle.
|
|
1812
|
-
const
|
|
1874
|
+
const fetchLatestSnapshot = async () => {
|
|
1813
1875
|
const fetchResult = await this.fetchLatestSnapshotFromStorage(summaryLogger, {
|
|
1814
|
-
eventName: "
|
|
1876
|
+
eventName: "RefreshLatestSummaryAckFetch",
|
|
1815
1877
|
ackHandle,
|
|
1816
|
-
summaryRefSeq,
|
|
1817
|
-
|
|
1818
|
-
});
|
|
1819
|
-
const latestSnapshotRefSeq = await (0, runtime_utils_1.seqFromTree)(fetchResult.snapshotTree, readAndParseBlob);
|
|
1878
|
+
targetSequenceNumber: summaryRefSeq,
|
|
1879
|
+
}, readAndParseBlob);
|
|
1820
1880
|
/**
|
|
1821
1881
|
* If the fetched snapshot is older than the one for which the ack was received, close the container.
|
|
1822
1882
|
* This should never happen because an ack should be sent after the latest summary is updated in the server.
|
|
@@ -1827,29 +1887,26 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1827
1887
|
* such cases, the file will be rolled back along with the ack and we will eventually reach a consistent
|
|
1828
1888
|
* state.
|
|
1829
1889
|
*/
|
|
1830
|
-
if (latestSnapshotRefSeq < summaryRefSeq) {
|
|
1890
|
+
if (fetchResult.latestSnapshotRefSeq < summaryRefSeq) {
|
|
1831
1891
|
const error = container_utils_1.DataProcessingError.create("Fetched snapshot is older than the received ack", "RefreshLatestSummaryAck", undefined /* sequencedMessage */, {
|
|
1832
1892
|
ackHandle,
|
|
1833
1893
|
summaryRefSeq,
|
|
1834
|
-
latestSnapshotRefSeq,
|
|
1894
|
+
latestSnapshotRefSeq: fetchResult.latestSnapshotRefSeq,
|
|
1835
1895
|
});
|
|
1836
1896
|
this.closeFn(error);
|
|
1837
1897
|
throw error;
|
|
1838
1898
|
}
|
|
1839
|
-
summaryLogger.sendTelemetryEvent({
|
|
1840
|
-
eventName: "LatestSummaryRetrieved",
|
|
1841
|
-
ackHandle,
|
|
1842
|
-
lastSequenceNumber: latestSnapshotRefSeq,
|
|
1843
|
-
targetSequenceNumber: summaryRefSeq,
|
|
1844
|
-
});
|
|
1845
1899
|
// In case we had to retrieve the latest snapshot and it is different than summaryRefSeq,
|
|
1846
1900
|
// wait for the delta manager to catch up before refreshing the latest Summary.
|
|
1847
|
-
await this.waitForDeltaManagerToCatchup(latestSnapshotRefSeq, summaryLogger);
|
|
1848
|
-
return
|
|
1901
|
+
await this.waitForDeltaManagerToCatchup(fetchResult.latestSnapshotRefSeq, summaryLogger);
|
|
1902
|
+
return {
|
|
1903
|
+
snapshotTree: fetchResult.snapshotTree,
|
|
1904
|
+
snapshotRefSeq: fetchResult.latestSnapshotRefSeq,
|
|
1905
|
+
};
|
|
1849
1906
|
};
|
|
1850
|
-
const result = await this.summarizerNode.refreshLatestSummary(proposalHandle, summaryRefSeq,
|
|
1907
|
+
const result = await this.summarizerNode.refreshLatestSummary(proposalHandle, summaryRefSeq, fetchLatestSnapshot, readAndParseBlob, summaryLogger);
|
|
1851
1908
|
// Notify the garbage collector so it can update its latest summary state.
|
|
1852
|
-
await this.garbageCollector.refreshLatestSummary(
|
|
1909
|
+
await this.garbageCollector.refreshLatestSummary(proposalHandle, result, readAndParseBlob);
|
|
1853
1910
|
}
|
|
1854
1911
|
/**
|
|
1855
1912
|
* Fetches the latest snapshot from storage and uses it to refresh SummarizerNode's
|
|
@@ -1858,18 +1915,20 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1858
1915
|
* @returns downloaded snapshot's reference sequence number
|
|
1859
1916
|
*/
|
|
1860
1917
|
async refreshLatestSummaryAckFromServer(summaryLogger) {
|
|
1861
|
-
const { snapshotTree, versionId } = await this.fetchLatestSnapshotFromStorage(summaryLogger, {
|
|
1862
|
-
eventName: "RefreshLatestSummaryGetSnapshot",
|
|
1863
|
-
fetchLatest: true,
|
|
1864
|
-
});
|
|
1865
1918
|
const readAndParseBlob = async (id) => (0, driver_utils_1.readAndParse)(this.storage, id);
|
|
1866
|
-
const latestSnapshotRefSeq = await
|
|
1867
|
-
|
|
1919
|
+
const { snapshotTree, versionId, latestSnapshotRefSeq } = await this.fetchLatestSnapshotFromStorage(summaryLogger, {
|
|
1920
|
+
eventName: "RefreshLatestSummaryFromServerFetch",
|
|
1921
|
+
}, readAndParseBlob);
|
|
1922
|
+
const fetchLatestSnapshot = {
|
|
1923
|
+
snapshotTree,
|
|
1924
|
+
snapshotRefSeq: latestSnapshotRefSeq,
|
|
1925
|
+
};
|
|
1926
|
+
const result = await this.summarizerNode.refreshLatestSummary(undefined /* proposalHandle */, latestSnapshotRefSeq, async () => fetchLatestSnapshot, readAndParseBlob, summaryLogger);
|
|
1868
1927
|
// Notify the garbage collector so it can update its latest summary state.
|
|
1869
|
-
await this.garbageCollector.refreshLatestSummary(
|
|
1928
|
+
await this.garbageCollector.refreshLatestSummary(undefined /* proposalHandle */, result, readAndParseBlob);
|
|
1870
1929
|
return { latestSnapshotRefSeq, latestSnapshotVersionId: versionId };
|
|
1871
1930
|
}
|
|
1872
|
-
async fetchLatestSnapshotFromStorage(logger, event) {
|
|
1931
|
+
async fetchLatestSnapshotFromStorage(logger, event, readAndParseBlob) {
|
|
1873
1932
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, event, async (perfEvent) => {
|
|
1874
1933
|
const stats = {};
|
|
1875
1934
|
const trace = common_utils_1.Trace.start();
|
|
@@ -1879,20 +1938,29 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1879
1938
|
const maybeSnapshot = await this.storage.getSnapshotTree(versions[0]);
|
|
1880
1939
|
(0, common_utils_1.assert)(!!maybeSnapshot, 0x138 /* "Failed to get snapshot from storage" */);
|
|
1881
1940
|
stats.getSnapshotDuration = trace.trace().duration;
|
|
1941
|
+
const latestSnapshotRefSeq = await (0, runtime_utils_1.seqFromTree)(maybeSnapshot, readAndParseBlob);
|
|
1942
|
+
stats.snapshotRefSeq = latestSnapshotRefSeq;
|
|
1943
|
+
stats.snapshotVersion = versions[0].id;
|
|
1882
1944
|
perfEvent.end(stats);
|
|
1883
|
-
return {
|
|
1945
|
+
return {
|
|
1946
|
+
snapshotTree: maybeSnapshot,
|
|
1947
|
+
versionId: versions[0].id,
|
|
1948
|
+
latestSnapshotRefSeq,
|
|
1949
|
+
};
|
|
1884
1950
|
});
|
|
1885
1951
|
}
|
|
1886
1952
|
notifyAttaching(snapshot) {
|
|
1887
1953
|
var _a;
|
|
1888
1954
|
if ((_a = this.mc.config.getBoolean("enableOfflineLoad")) !== null && _a !== void 0 ? _a : this.runtimeOptions.enableOfflineLoad) {
|
|
1889
|
-
this.baseSnapshotBlobs =
|
|
1955
|
+
this.baseSnapshotBlobs =
|
|
1956
|
+
serializedSnapshotStorage_1.SerializedSnapshotStorage.serializeTreeWithBlobContents(snapshot);
|
|
1890
1957
|
}
|
|
1891
1958
|
}
|
|
1892
1959
|
async initializeBaseSnapshotBlobs() {
|
|
1893
1960
|
var _a;
|
|
1894
1961
|
if (!((_a = this.mc.config.getBoolean("enableOfflineLoad")) !== null && _a !== void 0 ? _a : this.runtimeOptions.enableOfflineLoad) ||
|
|
1895
|
-
this.attachState !== container_definitions_1.AttachState.Attached ||
|
|
1962
|
+
this.attachState !== container_definitions_1.AttachState.Attached ||
|
|
1963
|
+
this.context.pendingLocalState) {
|
|
1896
1964
|
return;
|
|
1897
1965
|
}
|
|
1898
1966
|
(0, common_utils_1.assert)(!!this.context.baseSnapshot, 0x2e5 /* "Must have a base snapshot" */);
|