@fluidframework/container-runtime 2.4.0 → 2.5.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/CHANGELOG.md +18 -0
- package/api-report/container-runtime.legacy.alpha.api.md +3 -1
- package/container-runtime.test-files.tar +0 -0
- package/dist/blobManager/blobManager.d.ts +3 -3
- package/dist/blobManager/blobManager.d.ts.map +1 -1
- package/dist/blobManager/blobManager.js +1 -1
- package/dist/blobManager/blobManager.js.map +1 -1
- package/dist/channelCollection.d.ts +20 -5
- package/dist/channelCollection.d.ts.map +1 -1
- package/dist/channelCollection.js +183 -119
- package/dist/channelCollection.js.map +1 -1
- package/dist/containerRuntime.d.ts +12 -4
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +155 -66
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +15 -3
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +48 -19
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/gc/garbageCollection.d.ts +5 -6
- package/dist/gc/garbageCollection.d.ts.map +1 -1
- package/dist/gc/garbageCollection.js +23 -22
- package/dist/gc/garbageCollection.js.map +1 -1
- package/dist/gc/gcDefinitions.d.ts +2 -2
- package/dist/gc/gcDefinitions.d.ts.map +1 -1
- package/dist/gc/gcDefinitions.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +3 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +9 -0
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +2 -0
- package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/dist/opProperties.js +1 -1
- package/dist/opProperties.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/summary/documentSchema.d.ts +11 -0
- package/dist/summary/documentSchema.d.ts.map +1 -1
- package/dist/summary/documentSchema.js +45 -30
- package/dist/summary/documentSchema.js.map +1 -1
- package/lib/blobManager/blobManager.d.ts +3 -3
- package/lib/blobManager/blobManager.d.ts.map +1 -1
- package/lib/blobManager/blobManager.js +1 -1
- package/lib/blobManager/blobManager.js.map +1 -1
- package/lib/channelCollection.d.ts +20 -5
- package/lib/channelCollection.d.ts.map +1 -1
- package/lib/channelCollection.js +183 -119
- package/lib/channelCollection.js.map +1 -1
- package/lib/containerRuntime.d.ts +12 -4
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +155 -66
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +15 -3
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +48 -19
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/gc/garbageCollection.d.ts +5 -6
- package/lib/gc/garbageCollection.d.ts.map +1 -1
- package/lib/gc/garbageCollection.js +23 -22
- package/lib/gc/garbageCollection.js.map +1 -1
- package/lib/gc/gcDefinitions.d.ts +2 -2
- package/lib/gc/gcDefinitions.d.ts.map +1 -1
- package/lib/gc/gcDefinitions.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +3 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +9 -0
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +2 -0
- package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
- package/lib/opProperties.js +1 -1
- package/lib/opProperties.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/summary/documentSchema.d.ts +11 -0
- package/lib/summary/documentSchema.d.ts.map +1 -1
- package/lib/summary/documentSchema.js +45 -30
- package/lib/summary/documentSchema.js.map +1 -1
- package/package.json +24 -24
- package/src/blobManager/blobManager.ts +2 -2
- package/src/channelCollection.ts +227 -160
- package/src/containerRuntime.ts +197 -80
- package/src/dataStoreContext.ts +66 -23
- package/src/gc/garbageCollection.ts +32 -32
- package/src/gc/gcDefinitions.ts +3 -3
- package/src/opLifecycle/outbox.ts +12 -0
- package/src/opLifecycle/remoteMessageProcessor.ts +3 -0
- package/src/opProperties.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/summary/documentSchema.ts +58 -39
|
@@ -256,87 +256,93 @@ class ChannelCollection {
|
|
|
256
256
|
makeVisibleAndAttachGraph() {
|
|
257
257
|
this.parentContext.makeLocallyVisible();
|
|
258
258
|
}
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
// Allows longitudinal tracking of various state (e.g. foundGCData), and some sampled details
|
|
269
|
-
if (this.shouldSendAttachLog) {
|
|
270
|
-
this.shouldSendAttachLog = false;
|
|
271
|
-
this.mc.logger.sendTelemetryEvent({
|
|
272
|
-
eventName: "dataStoreAttachMessage_sampled",
|
|
273
|
-
...(0, internal_6.tagCodeArtifacts)({ id: attachMessage.id, pkg: attachMessage.type }),
|
|
274
|
-
details: {
|
|
275
|
-
local,
|
|
276
|
-
snapshot: !!attachMessage.snapshot,
|
|
277
|
-
foundGCData,
|
|
278
|
-
},
|
|
279
|
-
...(0, internal_6.extractSafePropertiesFromMessage)(message),
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
// The local object has already been attached
|
|
283
|
-
if (local) {
|
|
284
|
-
(0, internal_1.assert)(this.pendingAttach.has(attachMessage.id), 0x15e /* "Local object does not have matching attach message id" */);
|
|
285
|
-
this.contexts.get(attachMessage.id)?.setAttachState(container_definitions_1.AttachState.Attached);
|
|
286
|
-
this.pendingAttach.delete(attachMessage.id);
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
// If a non-local operation then go and create the object, otherwise mark it as officially attached.
|
|
290
|
-
if (this.alreadyProcessed(attachMessage.id)) {
|
|
291
|
-
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
292
|
-
const error = new internal_6.DataCorruptionError(
|
|
293
|
-
// pre-0.58 error message: duplicateDataStoreCreatedWithExistingId
|
|
294
|
-
"Duplicate DataStore created with existing id", {
|
|
295
|
-
...(0, internal_6.extractSafePropertiesFromMessage)(message),
|
|
296
|
-
...(0, internal_6.tagCodeArtifacts)({ dataStoreId: attachMessage.id }),
|
|
259
|
+
processAttachMessages(messageCollection) {
|
|
260
|
+
const { envelope, messagesContent, local } = messageCollection;
|
|
261
|
+
for (const { contents } of messagesContent) {
|
|
262
|
+
const attachMessage = contents;
|
|
263
|
+
// We need to process the GC Data for both local and remote attach messages
|
|
264
|
+
const foundGCData = (0, internal_5.processAttachMessageGCData)(attachMessage.snapshot, (nodeId, toPath) => {
|
|
265
|
+
// nodeId is the relative path under the node being attached. Always starts with "/", but no trailing "/" after an id
|
|
266
|
+
const fromPath = `/${attachMessage.id}${nodeId === "/" ? "" : nodeId}`;
|
|
267
|
+
this.parentContext.addedGCOutboundRoute(fromPath, toPath, envelope.timestamp);
|
|
297
268
|
});
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
269
|
+
// Only log once per container to avoid noise/cost.
|
|
270
|
+
// Allows longitudinal tracking of various state (e.g. foundGCData), and some sampled details
|
|
271
|
+
if (this.shouldSendAttachLog) {
|
|
272
|
+
this.shouldSendAttachLog = false;
|
|
273
|
+
this.mc.logger.sendTelemetryEvent({
|
|
274
|
+
eventName: "dataStoreAttachMessage_sampled",
|
|
275
|
+
...(0, internal_6.tagCodeArtifacts)({ id: attachMessage.id, pkg: attachMessage.type }),
|
|
276
|
+
details: {
|
|
277
|
+
local,
|
|
278
|
+
snapshot: !!attachMessage.snapshot,
|
|
279
|
+
foundGCData,
|
|
280
|
+
},
|
|
281
|
+
...(0, internal_6.extractSafePropertiesFromMessage)(envelope),
|
|
282
|
+
});
|
|
306
283
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
284
|
+
// The local object has already been attached
|
|
285
|
+
if (local) {
|
|
286
|
+
(0, internal_1.assert)(this.pendingAttach.has(attachMessage.id), 0x15e /* "Local object does not have matching attach message id" */);
|
|
287
|
+
this.contexts.get(attachMessage.id)?.setAttachState(container_definitions_1.AttachState.Attached);
|
|
288
|
+
this.pendingAttach.delete(attachMessage.id);
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
// If a non-local operation then go and create the object, otherwise mark it as officially attached.
|
|
292
|
+
if (this.alreadyProcessed(attachMessage.id)) {
|
|
293
|
+
// TODO: dataStoreId may require a different tag from PackageData #7488
|
|
294
|
+
const error = new internal_6.DataCorruptionError(
|
|
295
|
+
// pre-0.58 error message: duplicateDataStoreCreatedWithExistingId
|
|
296
|
+
"Duplicate DataStore created with existing id", {
|
|
297
|
+
...(0, internal_6.extractSafePropertiesFromMessage)(envelope),
|
|
298
|
+
...(0, internal_6.tagCodeArtifacts)({ dataStoreId: attachMessage.id }),
|
|
299
|
+
});
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
const flatAttachBlobs = new Map();
|
|
303
|
+
let snapshot;
|
|
304
|
+
if (attachMessage.snapshot) {
|
|
305
|
+
snapshot = (0, internal_3.buildSnapshotTree)(attachMessage.snapshot.entries, flatAttachBlobs);
|
|
306
|
+
if ((0, internal_3.isInstanceOfISnapshot)(this.baseSnapshot)) {
|
|
307
|
+
snapshot = { ...this.baseSnapshot, snapshotTree: snapshot };
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// Include the type of attach message which is the pkg of the store to be
|
|
311
|
+
// used by RemoteFluidDataStoreContext in case it is not in the snapshot.
|
|
312
|
+
const pkg = [attachMessage.type];
|
|
313
|
+
const remoteFluidDataStoreContext = new dataStoreContext_js_1.RemoteFluidDataStoreContext({
|
|
314
|
+
id: attachMessage.id,
|
|
315
|
+
snapshot,
|
|
316
|
+
parentContext: this.wrapContextForInnerChannel(attachMessage.id),
|
|
317
|
+
storage: new storageServiceWithAttachBlobs_js_1.StorageServiceWithAttachBlobs(this.parentContext.storage, flatAttachBlobs),
|
|
318
|
+
scope: this.parentContext.scope,
|
|
319
|
+
loadingGroupId: attachMessage.snapshot?.groupId,
|
|
320
|
+
createSummarizerNodeFn: this.parentContext.getCreateChildSummarizerNodeFn(attachMessage.id, {
|
|
321
|
+
type: internal_4.CreateSummarizerNodeSource.FromAttach,
|
|
322
|
+
sequenceNumber: envelope.sequenceNumber,
|
|
323
|
+
snapshot: attachMessage.snapshot ?? {
|
|
324
|
+
entries: [(0, dataStoreContext_js_1.createAttributesBlob)(pkg, true /* isRootDataStore */)],
|
|
325
|
+
},
|
|
326
|
+
}),
|
|
327
|
+
pkg,
|
|
334
328
|
});
|
|
329
|
+
this.contexts.addBoundOrRemoted(remoteFluidDataStoreContext);
|
|
335
330
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
331
|
+
}
|
|
332
|
+
processAliasMessages(messageCollection) {
|
|
333
|
+
const { envelope, messagesContent, local } = messageCollection;
|
|
334
|
+
for (const { contents, localOpMetadata } of messagesContent) {
|
|
335
|
+
const aliasMessage = contents;
|
|
336
|
+
if (!(0, dataStore_js_1.isDataStoreAliasMessage)(aliasMessage)) {
|
|
337
|
+
throw new internal_6.DataCorruptionError("malformedDataStoreAliasMessage", {
|
|
338
|
+
...(0, internal_6.extractSafePropertiesFromMessage)(envelope),
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
const resolve = localOpMetadata;
|
|
342
|
+
const aliasResult = this.processAliasMessageCore(aliasMessage.internalId, aliasMessage.alias, envelope.timestamp);
|
|
343
|
+
if (local) {
|
|
344
|
+
resolve(aliasResult);
|
|
345
|
+
}
|
|
340
346
|
}
|
|
341
347
|
}
|
|
342
348
|
processAliasMessageCore(internalId, alias, messageTimestampMs) {
|
|
@@ -583,58 +589,116 @@ class ChannelCollection {
|
|
|
583
589
|
this.pendingAttach.set(message.id, message);
|
|
584
590
|
}
|
|
585
591
|
}
|
|
586
|
-
|
|
587
|
-
|
|
592
|
+
/**
|
|
593
|
+
* Process messages for this channel collection. The messages here are contiguous messages in a batch.
|
|
594
|
+
* @param messageCollection - The collection of messages to process.
|
|
595
|
+
*/
|
|
596
|
+
processMessages(messageCollection) {
|
|
597
|
+
switch (messageCollection.envelope.type) {
|
|
598
|
+
case messageTypes_js_1.ContainerMessageType.FluidDataStoreOp:
|
|
599
|
+
this.processChannelMessages(messageCollection);
|
|
600
|
+
break;
|
|
588
601
|
case messageTypes_js_1.ContainerMessageType.Attach:
|
|
589
|
-
this.
|
|
590
|
-
|
|
602
|
+
this.processAttachMessages(messageCollection);
|
|
603
|
+
break;
|
|
591
604
|
case messageTypes_js_1.ContainerMessageType.Alias:
|
|
592
|
-
this.
|
|
593
|
-
return;
|
|
594
|
-
case messageTypes_js_1.ContainerMessageType.FluidDataStoreOp: {
|
|
595
|
-
const envelope = message.contents;
|
|
596
|
-
const innerContents = envelope.contents;
|
|
597
|
-
const transformed = {
|
|
598
|
-
...message,
|
|
599
|
-
type: innerContents.type,
|
|
600
|
-
contents: innerContents.content,
|
|
601
|
-
};
|
|
602
|
-
this.processChannelOp(envelope.address, transformed, local, localMessageMetadata);
|
|
603
|
-
// Notify GC of any outbound references that were added by this op.
|
|
604
|
-
detectOutboundReferences(envelope.address, transformed.contents, (fromPath, toPath) => this.parentContext.addedGCOutboundRoute(fromPath, toPath, message.timestamp));
|
|
605
|
+
this.processAliasMessages(messageCollection);
|
|
605
606
|
break;
|
|
606
|
-
}
|
|
607
607
|
default:
|
|
608
608
|
(0, internal_1.assert)(false, 0x8e9 /* unreached */);
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
611
|
+
/**
|
|
612
|
+
* This is still here for back-compat purposes because channel collection implements
|
|
613
|
+
* IFluidDataStoreChannel. Once it is removed from the interface, this method can be removed.
|
|
614
|
+
* Container runtime calls `processMessages` instead.
|
|
615
|
+
*/
|
|
616
|
+
process(message, local, localOpMetadata) {
|
|
617
|
+
this.processMessages({
|
|
618
|
+
envelope: message,
|
|
619
|
+
messagesContent: [
|
|
620
|
+
{
|
|
621
|
+
contents: message.contents,
|
|
622
|
+
localOpMetadata,
|
|
623
|
+
clientSequenceNumber: message.clientSequenceNumber,
|
|
624
|
+
},
|
|
625
|
+
],
|
|
626
|
+
local,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Process channel messages. The messages here are contiguous channel type messages in a batch. Bunch
|
|
631
|
+
* of contiguous messages for a data store should be sent to it together.
|
|
632
|
+
* @param messageCollection - The collection of messages to process.
|
|
633
|
+
*/
|
|
634
|
+
processChannelMessages(messageCollection) {
|
|
635
|
+
const { messagesContent, local } = messageCollection;
|
|
636
|
+
let currentMessageState;
|
|
637
|
+
let currentMessagesContent = [];
|
|
638
|
+
// Helper that sends the current bunch of messages to the data store. It validates that the data stores exists.
|
|
639
|
+
const sendBunchedMessages = () => {
|
|
640
|
+
// Current message state will be undefined for the first message in the list.
|
|
641
|
+
if (currentMessageState === undefined) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const currentContext = this.contexts.get(currentMessageState.address);
|
|
645
|
+
(0, internal_1.assert)(!!currentContext, 0xa66 /* Context not found */);
|
|
646
|
+
currentContext.processMessages({
|
|
647
|
+
envelope: { ...messageCollection.envelope, type: currentMessageState.type },
|
|
648
|
+
messagesContent: currentMessagesContent,
|
|
621
649
|
local,
|
|
622
|
-
messageDetails: JSON.stringify({
|
|
623
|
-
type: message.type,
|
|
624
|
-
contentType: typeof message.contents,
|
|
625
|
-
}),
|
|
626
|
-
...(0, internal_6.tagCodeArtifacts)({ address }),
|
|
627
650
|
});
|
|
651
|
+
currentMessagesContent = [];
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Bunch contiguous messages for the same data store and send them together.
|
|
655
|
+
* This is an optimization mainly for DDSes, where it can process a bunch of ops together. DDSes
|
|
656
|
+
* like merge tree or shared tree can process ops more efficiently when they are bunched together.
|
|
657
|
+
*/
|
|
658
|
+
for (const { contents, ...restOfMessagesContent } of messagesContent) {
|
|
659
|
+
const contentsEnvelope = contents;
|
|
660
|
+
const address = contentsEnvelope.address;
|
|
661
|
+
const context = this.contexts.get(address);
|
|
662
|
+
// If the data store has been deleted, log an error and ignore this message. This helps prevent document
|
|
663
|
+
// corruption in case a deleted data store accidentally submitted an op.
|
|
664
|
+
if (this.checkAndLogIfDeleted(address, context, "Changed", "processFluidDataStoreOp")) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
if (context === undefined) {
|
|
668
|
+
// Former assert 0x162
|
|
669
|
+
throw internal_6.DataProcessingError.create("No context for op", "processFluidDataStoreOp", messageCollection.envelope, {
|
|
670
|
+
local,
|
|
671
|
+
messageDetails: JSON.stringify({
|
|
672
|
+
type: messageCollection.envelope.type,
|
|
673
|
+
contentType: typeof contents,
|
|
674
|
+
}),
|
|
675
|
+
...(0, internal_6.tagCodeArtifacts)({ address }),
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
const { type: contextType, content: contextContents } = contentsEnvelope.contents;
|
|
679
|
+
// If the address or type of the message changes while processing the message, send the current bunch.
|
|
680
|
+
if (currentMessageState?.address !== address ||
|
|
681
|
+
currentMessageState?.type !== contextType) {
|
|
682
|
+
sendBunchedMessages();
|
|
683
|
+
}
|
|
684
|
+
currentMessagesContent.push({
|
|
685
|
+
contents: contextContents,
|
|
686
|
+
...restOfMessagesContent,
|
|
687
|
+
});
|
|
688
|
+
currentMessageState = { address, type: contextType };
|
|
689
|
+
// Notify that a GC node for the data store changed. This is used to detect if a deleted data store is
|
|
690
|
+
// being used.
|
|
691
|
+
this.gcNodeUpdated({
|
|
692
|
+
node: { type: "DataStore", path: `/${address}` },
|
|
693
|
+
reason: "Changed",
|
|
694
|
+
timestampMs: messageCollection.envelope.timestamp,
|
|
695
|
+
packagePath: context.isLoaded ? context.packagePath : undefined,
|
|
696
|
+
});
|
|
697
|
+
detectOutboundReferences(address, contextContents, (fromPath, toPath) => this.parentContext.addedGCOutboundRoute(fromPath, toPath, messageCollection.envelope.timestamp));
|
|
628
698
|
}
|
|
629
|
-
|
|
630
|
-
//
|
|
631
|
-
|
|
632
|
-
this.gcNodeUpdated({
|
|
633
|
-
node: { type: "DataStore", path: `/${address}` },
|
|
634
|
-
reason: "Changed",
|
|
635
|
-
timestampMs: message.timestamp,
|
|
636
|
-
packagePath: context.isLoaded ? context.packagePath : undefined,
|
|
637
|
-
});
|
|
699
|
+
// Process the last bunch of messages, if any. Note that there may not be any messages in case all of them are
|
|
700
|
+
// ignored because the data store is deleted.
|
|
701
|
+
sendBunchedMessages();
|
|
638
702
|
}
|
|
639
703
|
async getDataStore(id, requestHeaderData, originalRequest) {
|
|
640
704
|
const headerData = { ...containerRuntime_js_1.defaultRuntimeHeaderData, ...requestHeaderData };
|