@fluidframework/container-runtime 2.0.0-internal.2.2.1 → 2.0.0-internal.2.3.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.
- package/.eslintrc.js +19 -8
- package/dist/batchTracker.d.ts +1 -2
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/batchTracker.js.map +1 -1
- package/dist/blobManager.d.ts +45 -34
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/blobManager.js +135 -102
- package/dist/blobManager.js.map +1 -1
- package/dist/containerRuntime.d.ts +54 -8
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +143 -72
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +1 -1
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +6 -8
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +12 -9
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +41 -35
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +41 -20
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +205 -150
- package/dist/garbageCollection.js.map +1 -1
- package/dist/garbageCollectionConstants.d.ts +7 -3
- package/dist/garbageCollectionConstants.d.ts.map +1 -1
- package/dist/garbageCollectionConstants.js +10 -8
- package/dist/garbageCollectionConstants.js.map +1 -1
- package/dist/garbageCollectionTombstoneUtils.d.ts +14 -0
- package/dist/garbageCollectionTombstoneUtils.d.ts.map +1 -0
- package/dist/garbageCollectionTombstoneUtils.js +23 -0
- package/dist/garbageCollectionTombstoneUtils.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/opLifecycle/batchManager.d.ts +13 -1
- package/dist/opLifecycle/batchManager.d.ts.map +1 -1
- package/dist/opLifecycle/batchManager.js +35 -1
- package/dist/opLifecycle/batchManager.js.map +1 -1
- package/dist/opLifecycle/definitions.d.ts +25 -1
- package/dist/opLifecycle/definitions.d.ts.map +1 -1
- package/dist/opLifecycle/definitions.js.map +1 -1
- package/dist/opLifecycle/index.d.ts +2 -2
- package/dist/opLifecycle/index.d.ts.map +1 -1
- package/dist/opLifecycle/index.js +2 -1
- package/dist/opLifecycle/index.js.map +1 -1
- package/dist/opLifecycle/opCompressor.d.ts +1 -1
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opCompressor.js +24 -10
- package/dist/opLifecycle/opCompressor.js.map +1 -1
- package/dist/opLifecycle/opDecompressor.d.ts +2 -1
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/dist/opLifecycle/opDecompressor.js +30 -17
- package/dist/opLifecycle/opDecompressor.js.map +1 -1
- package/dist/opLifecycle/opSplitter.d.ts +34 -2
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
- package/dist/opLifecycle/opSplitter.js +114 -5
- package/dist/opLifecycle/opSplitter.js.map +1 -1
- package/dist/opLifecycle/outbox.d.ts +5 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -1
- package/dist/opLifecycle/outbox.js +24 -14
- package/dist/opLifecycle/outbox.js.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/dist/opLifecycle/remoteMessageProcessor.js +17 -2
- package/dist/opLifecycle/remoteMessageProcessor.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/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +0 -1
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/scheduleManager.d.ts +0 -1
- package/dist/scheduleManager.d.ts.map +1 -1
- package/dist/scheduleManager.js +9 -20
- package/dist/scheduleManager.js.map +1 -1
- package/dist/summarizer.d.ts +0 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +2 -1
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +1 -0
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +1 -2
- package/dist/summaryFormat.js.map +1 -1
- package/lib/batchTracker.d.ts +1 -2
- package/lib/batchTracker.d.ts.map +1 -1
- package/lib/batchTracker.js.map +1 -1
- package/lib/blobManager.d.ts +45 -34
- package/lib/blobManager.d.ts.map +1 -1
- package/lib/blobManager.js +137 -104
- package/lib/blobManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +54 -8
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +140 -69
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +1 -1
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +7 -9
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +12 -9
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +44 -38
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +41 -20
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +201 -146
- package/lib/garbageCollection.js.map +1 -1
- package/lib/garbageCollectionConstants.d.ts +7 -3
- package/lib/garbageCollectionConstants.d.ts.map +1 -1
- package/lib/garbageCollectionConstants.js +9 -7
- package/lib/garbageCollectionConstants.js.map +1 -1
- package/lib/garbageCollectionTombstoneUtils.d.ts +14 -0
- package/lib/garbageCollectionTombstoneUtils.d.ts.map +1 -0
- package/lib/garbageCollectionTombstoneUtils.js +19 -0
- package/lib/garbageCollectionTombstoneUtils.js.map +1 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/opLifecycle/batchManager.d.ts +13 -1
- package/lib/opLifecycle/batchManager.d.ts.map +1 -1
- package/lib/opLifecycle/batchManager.js +35 -1
- package/lib/opLifecycle/batchManager.js.map +1 -1
- package/lib/opLifecycle/definitions.d.ts +25 -1
- package/lib/opLifecycle/definitions.d.ts.map +1 -1
- package/lib/opLifecycle/definitions.js.map +1 -1
- package/lib/opLifecycle/index.d.ts +2 -2
- package/lib/opLifecycle/index.d.ts.map +1 -1
- package/lib/opLifecycle/index.js +1 -1
- package/lib/opLifecycle/index.js.map +1 -1
- package/lib/opLifecycle/opCompressor.d.ts +1 -1
- package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opCompressor.js +24 -10
- package/lib/opLifecycle/opCompressor.js.map +1 -1
- package/lib/opLifecycle/opDecompressor.d.ts +2 -1
- package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
- package/lib/opLifecycle/opDecompressor.js +30 -17
- package/lib/opLifecycle/opDecompressor.js.map +1 -1
- package/lib/opLifecycle/opSplitter.d.ts +34 -2
- package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
- package/lib/opLifecycle/opSplitter.js +112 -4
- package/lib/opLifecycle/opSplitter.js.map +1 -1
- package/lib/opLifecycle/outbox.d.ts +5 -0
- package/lib/opLifecycle/outbox.d.ts.map +1 -1
- package/lib/opLifecycle/outbox.js +24 -14
- package/lib/opLifecycle/outbox.js.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
- package/lib/opLifecycle/remoteMessageProcessor.js +17 -2
- package/lib/opLifecycle/remoteMessageProcessor.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/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +0 -1
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/scheduleManager.d.ts +0 -1
- package/lib/scheduleManager.d.ts.map +1 -1
- package/lib/scheduleManager.js +9 -20
- package/lib/scheduleManager.js.map +1 -1
- package/lib/summarizer.d.ts +0 -1
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +2 -1
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +1 -0
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +1 -2
- package/lib/summaryFormat.js.map +1 -1
- package/package.json +20 -19
- package/src/batchTracker.ts +1 -1
- package/src/blobManager.ts +159 -111
- package/src/containerRuntime.ts +202 -73
- package/src/dataStoreContext.ts +15 -16
- package/src/dataStores.ts +61 -45
- package/src/garbageCollection.ts +258 -183
- package/src/garbageCollectionConstants.ts +10 -7
- package/src/garbageCollectionTombstoneUtils.ts +28 -0
- package/src/index.ts +2 -5
- package/src/opLifecycle/batchManager.ts +59 -1
- package/src/opLifecycle/definitions.ts +27 -1
- package/src/opLifecycle/index.ts +2 -1
- package/src/opLifecycle/opCompressor.ts +29 -12
- package/src/opLifecycle/opDecompressor.ts +39 -18
- package/src/opLifecycle/opSplitter.ts +141 -7
- package/src/opLifecycle/outbox.ts +32 -16
- package/src/opLifecycle/remoteMessageProcessor.ts +19 -3
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +0 -1
- package/src/scheduleManager.ts +19 -30
- package/src/summarizer.ts +1 -1
- package/src/summarizerTypes.ts +1 -0
- package/src/summaryFormat.ts +1 -2
package/lib/dataStores.js
CHANGED
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
import { DataCorruptionError, extractSafePropertiesFromMessage } from "@fluidframework/container-utils";
|
|
6
6
|
import { FluidObjectHandle } from "@fluidframework/datastore";
|
|
7
7
|
import { channelsTreeName, CreateSummarizerNodeSource, } from "@fluidframework/runtime-definitions";
|
|
8
|
-
import { convertSnapshotTreeToSummaryTree, convertToSummaryTree, create404Response, createResponseError, responseToException,
|
|
8
|
+
import { convertSnapshotTreeToSummaryTree, convertToSummaryTree, create404Response, createResponseError, responseToException, SummaryTreeBuilder, } from "@fluidframework/runtime-utils";
|
|
9
9
|
import { ChildLogger, loggerToMonitoringContext, LoggingError, TelemetryDataTag } from "@fluidframework/telemetry-utils";
|
|
10
10
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
11
11
|
import { BlobCacheStorageService, buildSnapshotTree } from "@fluidframework/driver-utils";
|
|
12
12
|
import { assert, Lazy, LazyPromise } from "@fluidframework/common-utils";
|
|
13
13
|
import { v4 as uuid } from "uuid";
|
|
14
|
-
import { GCDataBuilder, unpackChildNodesUsedRoutes } from "@fluidframework/garbage-collector";
|
|
14
|
+
import { GCDataBuilder, unpackChildNodesGCDetails, unpackChildNodesUsedRoutes } from "@fluidframework/garbage-collector";
|
|
15
15
|
import { DataStoreContexts } from "./dataStoreContexts";
|
|
16
|
+
import { defaultRuntimeHeaderData, TombstoneResponseHeaderKey } from "./containerRuntime";
|
|
16
17
|
import { RemoteFluidDataStoreContext, LocalFluidDataStoreContext, createAttributesBlob, LocalDetachedFluidDataStoreContext, } from "./dataStoreContext";
|
|
17
18
|
import { nonDataStorePaths, rootHasIsolatedChannels } from "./summaryFormat";
|
|
18
19
|
import { isDataStoreAliasMessage } from "./dataStore";
|
|
19
20
|
import { GCNodeType } from "./garbageCollection";
|
|
20
|
-
import {
|
|
21
|
+
import { throwOnTombstoneLoadKey } from "./garbageCollectionConstants";
|
|
21
22
|
import { summarizerClientType } from "./summarizerClientElection";
|
|
23
|
+
import { sendGCTombstoneEvent } from "./garbageCollectionTombstoneUtils";
|
|
22
24
|
/**
|
|
23
25
|
* This class encapsulates data store handling. Currently it is only used by the container runtime,
|
|
24
26
|
* but eventually could be hosted on any channel once we formalize the channel api boundary.
|
|
@@ -46,7 +48,8 @@ export class DataStores {
|
|
|
46
48
|
this.mc = loggerToMonitoringContext(ChildLogger.create(baseLogger));
|
|
47
49
|
this.containerRuntimeHandle = new FluidObjectHandle(this.runtime, "/", this.runtime.IFluidHandleContext);
|
|
48
50
|
const baseGCDetailsP = new LazyPromise(async () => {
|
|
49
|
-
|
|
51
|
+
const baseGCDetails = await getBaseGCDetails();
|
|
52
|
+
return unpackChildNodesGCDetails(baseGCDetails);
|
|
50
53
|
});
|
|
51
54
|
// Returns the base GC details for the data store with the given id.
|
|
52
55
|
const dataStoreBaseGCDetails = async (dataStoreId) => {
|
|
@@ -54,8 +57,8 @@ export class DataStores {
|
|
|
54
57
|
return baseGCDetails.get(dataStoreId);
|
|
55
58
|
};
|
|
56
59
|
// Tombstone should only throw when the feature flag is enabled and the client isn't a summarizer
|
|
57
|
-
this.
|
|
58
|
-
this.mc.config.getBoolean(
|
|
60
|
+
this.throwOnTombstoneLoad =
|
|
61
|
+
this.mc.config.getBoolean(throwOnTombstoneLoadKey) === true &&
|
|
59
62
|
this.runtime.clientDetails.type !== summarizerClientType;
|
|
60
63
|
// Extract stores stored inside the snapshot
|
|
61
64
|
const fluidDataStores = new Map();
|
|
@@ -288,26 +291,25 @@ export class DataStores {
|
|
|
288
291
|
// being used.
|
|
289
292
|
this.gcNodeUpdated(`/${envelope.address}`, message.timestamp, context.isLoaded ? context.packagePath : undefined);
|
|
290
293
|
}
|
|
291
|
-
async getDataStore(id,
|
|
292
|
-
const
|
|
294
|
+
async getDataStore(id, requestHeaderData) {
|
|
295
|
+
const headerData = Object.assign(Object.assign({}, defaultRuntimeHeaderData), requestHeaderData);
|
|
296
|
+
const context = await this.contexts.getBoundOrRemoted(id, headerData.wait);
|
|
293
297
|
const request = { url: id };
|
|
294
298
|
if (context === undefined) {
|
|
295
299
|
// The requested data store does not exits. Throw a 404 response exception.
|
|
296
300
|
throw responseToException(create404Response(request), request);
|
|
297
301
|
}
|
|
298
302
|
if (context.tombstoned) {
|
|
303
|
+
const shouldFail = this.throwOnTombstoneLoad && !headerData.allowTombstone;
|
|
299
304
|
// The requested data store is removed by gc. Create a 404 gc response exception.
|
|
300
|
-
const error = responseToException(createResponseError(404, "
|
|
301
|
-
|
|
302
|
-
this.mc.logger.sendErrorEvent({
|
|
305
|
+
const error = responseToException(createResponseError(404, "DataStore was deleted", request, { [TombstoneResponseHeaderKey]: true }), request);
|
|
306
|
+
sendGCTombstoneEvent(this.mc, {
|
|
303
307
|
eventName: "GC_Tombstone_DataStore_Requested",
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}, error);
|
|
308
|
-
|
|
309
|
-
// throwOnTombstoneUsage is set.
|
|
310
|
-
if (this.throwOnTombstoneUsage) {
|
|
308
|
+
category: shouldFail ? "error" : "generic",
|
|
309
|
+
isSummarizerClient: this.runtime.clientDetails.type === summarizerClientType,
|
|
310
|
+
headers: JSON.stringify(requestHeaderData),
|
|
311
|
+
}, context.isLoaded ? context.packagePath : undefined, error);
|
|
312
|
+
if (shouldFail) {
|
|
311
313
|
throw error;
|
|
312
314
|
}
|
|
313
315
|
}
|
|
@@ -462,10 +464,6 @@ export class DataStores {
|
|
|
462
464
|
// Verify that the used routes are correct.
|
|
463
465
|
for (const [id] of usedDataStoreRoutes) {
|
|
464
466
|
assert(this.contexts.has(id), 0x167 /* "Used route does not belong to any known data store" */);
|
|
465
|
-
// Revive datastores regardless of whether or not tombstone the tombstone flag is flipped
|
|
466
|
-
const dataStore = this.contexts.get(id);
|
|
467
|
-
assert(dataStore !== undefined, 0x46e /* No data store retrieved with specified id */);
|
|
468
|
-
dataStore.setTombstone(false /* tombstone */);
|
|
469
467
|
}
|
|
470
468
|
// Update the used routes in each data store. Used routes is empty for unused data stores.
|
|
471
469
|
for (const [contextId, context] of this.contexts) {
|
|
@@ -473,13 +471,10 @@ export class DataStores {
|
|
|
473
471
|
}
|
|
474
472
|
}
|
|
475
473
|
/**
|
|
476
|
-
* This is called to update objects whose routes are unused. The unused objects are
|
|
477
|
-
* tombstones.
|
|
474
|
+
* This is called to update objects whose routes are unused. The unused objects are deleted.
|
|
478
475
|
* @param unusedRoutes - The routes that are unused in all data stores in this Container.
|
|
479
|
-
* @param tombstone - if true, the objects corresponding to unused routes are marked tombstones. Otherwise, they
|
|
480
|
-
* are deleted.
|
|
481
476
|
*/
|
|
482
|
-
updateUnusedRoutes(unusedRoutes
|
|
477
|
+
updateUnusedRoutes(unusedRoutes) {
|
|
483
478
|
for (const route of unusedRoutes) {
|
|
484
479
|
const pathParts = route.split("/");
|
|
485
480
|
// Delete data store only if its route (/datastoreId) is in unusedRoutes. We don't want to delete a data
|
|
@@ -489,23 +484,34 @@ export class DataStores {
|
|
|
489
484
|
}
|
|
490
485
|
const dataStoreId = pathParts[1];
|
|
491
486
|
assert(this.contexts.has(dataStoreId), 0x2d7 /* No data store with specified id */);
|
|
492
|
-
/**
|
|
493
|
-
* When running GC in tombstone mode, datastore contexts are tombstoned. Tombstoned datastore contexts
|
|
494
|
-
* enable testing scenarios with accessing deleted content without actually deleting content from
|
|
495
|
-
* summaries.
|
|
496
|
-
*/
|
|
497
|
-
if (tombstone) {
|
|
498
|
-
const dataStore = this.contexts.get(dataStoreId);
|
|
499
|
-
assert(dataStore !== undefined, 0x442 /* No data store retrieved with specified id */);
|
|
500
|
-
dataStore.setTombstone(true /* tombstone */);
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
487
|
// Delete the contexts of unused data stores.
|
|
504
488
|
this.contexts.delete(dataStoreId);
|
|
505
489
|
// Delete the summarizer node of the unused data stores.
|
|
506
490
|
this.deleteChildSummarizerNodeFn(dataStoreId);
|
|
507
491
|
}
|
|
508
492
|
}
|
|
493
|
+
/**
|
|
494
|
+
* This is called to update objects whose routes are tombstones. Tombstoned datastore contexts enable testing
|
|
495
|
+
* scenarios with accessing deleted content without actually deleting content from summaries.
|
|
496
|
+
* @param tombstonedRoutes - The routes that are tombstones in all data stores in this Container.
|
|
497
|
+
*/
|
|
498
|
+
updateTombstonedRoutes(tombstonedRoutes) {
|
|
499
|
+
const tombstonedDataStoresSet = new Set();
|
|
500
|
+
for (const route of tombstonedRoutes) {
|
|
501
|
+
const pathParts = route.split("/");
|
|
502
|
+
// Tombstone data store only if its route (/datastoreId) is directly in tombstoneRoutes.
|
|
503
|
+
if (pathParts.length > 2) {
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
const dataStoreId = pathParts[1];
|
|
507
|
+
assert(this.contexts.has(dataStoreId), 0x510 /* No data store with specified id */);
|
|
508
|
+
tombstonedDataStoresSet.add(dataStoreId);
|
|
509
|
+
}
|
|
510
|
+
// Update the used routes in each data store. Used routes is empty for unused data stores.
|
|
511
|
+
for (const [contextId, context] of this.contexts) {
|
|
512
|
+
context.setTombstone(tombstonedDataStoresSet.has(contextId));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
509
515
|
/**
|
|
510
516
|
* Returns the outbound routes of this channel. Only root data stores are considered referenced and their paths are
|
|
511
517
|
* part of outbound routes.
|
package/lib/dataStores.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataStores.js","sourceRoot":"","sources":["../src/dataStores.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAExG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK9D,OAAO,EAEH,gBAAgB,EAGhB,0BAA0B,GAW7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,gCAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,8BAA8B,EAC9B,kBAAkB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,YAAY,EAAqB,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC5I,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,E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AAC,GAAG,CAAC,EAAE;gBAClC,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;aAChC;SACJ;QACD,uCACO,QAAQ,KACX,KAAK,EAAE,eAAe,IACxB;KACL;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, IDisposable } from \"@fluidframework/common-definitions\";\nimport { DataCorruptionError, extractSafePropertiesFromMessage } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport {\n ISequencedDocumentMessage,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n AliasResult,\n channelsTreeName,\n CreateChildSummarizerNodeFn,\n CreateChildSummarizerNodeParam,\n CreateSummarizerNodeSource,\n IAttachMessage,\n IEnvelope,\n IFluidDataStoreContextDetached,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n IInboundSignalMessage,\n InboundAttachMessage,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n convertSnapshotTreeToSummaryTree,\n convertToSummaryTree,\n create404Response,\n createResponseError,\n responseToException,\n packagePathToTelemetryProperty,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, loggerToMonitoringContext, LoggingError, MonitoringContext, TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { BlobCacheStorageService, buildSnapshotTree } from \"@fluidframework/driver-utils\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/common-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport { GCDataBuilder, unpackChildNodesUsedRoutes } from \"@fluidframework/garbage-collector\";\nimport { DataStoreContexts } from \"./dataStoreContexts\";\nimport { ContainerRuntime } from \"./containerRuntime\";\nimport {\n FluidDataStoreContext,\n RemoteFluidDataStoreContext,\n LocalFluidDataStoreContext,\n createAttributesBlob,\n LocalDetachedFluidDataStoreContext,\n} from \"./dataStoreContext\";\nimport { IContainerRuntimeMetadata, nonDataStorePaths, rootHasIsolatedChannels } from \"./summaryFormat\";\nimport { IDataStoreAliasMessage, isDataStoreAliasMessage } from \"./dataStore\";\nimport { GCNodeType } from \"./garbageCollection\";\nimport { throwOnTombstoneUsageKey } from \"./garbageCollectionConstants\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\n\ntype PendingAliasResolve = (success: boolean) => void;\n\n/**\n * This class encapsulates data store handling. Currently it is only used by the container runtime,\n * but eventually could be hosted on any channel once we formalize the channel api boundary.\n */\nexport class DataStores implements IDisposable {\n // Stores tracked by the Domain\n private readonly pendingAttach = new Map<string, IAttachMessage>();\n // 0.24 back-compat attachingBeforeSummary\n public readonly attachOpFiredForDataStore = new Set<string>();\n\n private readonly mc: MonitoringContext;\n\n private readonly disposeOnce = new Lazy<void>(() => this.contexts.dispose());\n\n public readonly containerLoadStats: {\n // number of dataStores during loadContainer\n readonly containerLoadDataStoreCount: number;\n // number of unreferenced dataStores during loadContainer\n readonly referencedDataStoreCount: number;\n };\n\n // Stores the ids of new data stores between two GC runs. This is used to notify the garbage collector of new\n // root data stores that are added.\n private dataStoresSinceLastGC: string[] = [];\n /** If true, throw an error when a tombstone data store is retrieved. */\n private readonly throwOnTombstoneUsage: boolean;\n // The handle to the container runtime. This is used mainly for GC purposes to represent outbound reference from\n // the container runtime to other nodes.\n private readonly containerRuntimeHandle: IFluidHandle;\n private readonly pendingAliasMap: Map<string, Promise<AliasResult>> = new Map<string, Promise<AliasResult>>();\n\n constructor(\n private readonly baseSnapshot: ISnapshotTree | undefined,\n private readonly runtime: ContainerRuntime,\n private readonly submitAttachFn: (attachContent: any) => void,\n private readonly getCreateChildSummarizerNodeFn:\n (id: string, createParam: CreateChildSummarizerNodeParam) => CreateChildSummarizerNodeFn,\n private readonly deleteChildSummarizerNodeFn: (id: string) => void,\n baseLogger: ITelemetryBaseLogger,\n getBaseGCDetails: () => Promise<Map<string, IGarbageCollectionDetailsBase>>,\n private readonly gcNodeUpdated: (\n nodePath: string, timestampMs: number, packagePath?: readonly string[]) => void,\n private readonly aliasMap: Map<string, string>,\n private readonly contexts: DataStoreContexts = new DataStoreContexts(baseLogger),\n ) {\n this.mc = loggerToMonitoringContext(ChildLogger.create(baseLogger));\n this.containerRuntimeHandle = new FluidObjectHandle(this.runtime, \"/\", this.runtime.IFluidHandleContext);\n\n const baseGCDetailsP = new LazyPromise(async () => {\n return getBaseGCDetails();\n });\n // Returns the base GC details for the data store with the given id.\n const dataStoreBaseGCDetails = async (dataStoreId: string) => {\n const baseGCDetails = await baseGCDetailsP;\n return baseGCDetails.get(dataStoreId);\n };\n // Tombstone should only throw when the feature flag is enabled and the client isn't a summarizer\n this.throwOnTombstoneUsage =\n this.mc.config.getBoolean(throwOnTombstoneUsageKey) === true &&\n this.runtime.clientDetails.type !== summarizerClientType;\n\n // Extract stores stored inside the snapshot\n const fluidDataStores = new Map<string, ISnapshotTree>();\n if (baseSnapshot) {\n for (const [key, value] of Object.entries(baseSnapshot.trees)) {\n fluidDataStores.set(key, value);\n }\n }\n\n let unreferencedDataStoreCount = 0;\n // Create a context for each of them\n for (const [key, value] of fluidDataStores) {\n let dataStoreContext: FluidDataStoreContext;\n\n // counting number of unreferenced data stores\n if (value.unreferenced) {\n unreferencedDataStoreCount++;\n }\n // If we have a detached container, then create local data store contexts.\n if (this.runtime.attachState !== AttachState.Detached) {\n dataStoreContext = new RemoteFluidDataStoreContext({\n id: key,\n snapshotTree: value,\n getBaseGCDetails: async () => dataStoreBaseGCDetails(key),\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n key,\n { type: CreateSummarizerNodeSource.FromSummary },\n ),\n });\n } else {\n if (typeof value !== \"object\") {\n throw new LoggingError(\"Snapshot should be there to load from!!\");\n }\n const snapshotTree = value;\n dataStoreContext = new LocalFluidDataStoreContext({\n id: key,\n pkg: undefined,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n key,\n { type: CreateSummarizerNodeSource.FromSummary },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(key),\n snapshotTree,\n isRootDataStore: undefined,\n });\n }\n this.contexts.addBoundOrRemoted(dataStoreContext);\n }\n this.containerLoadStats = {\n containerLoadDataStoreCount: fluidDataStores.size,\n referencedDataStoreCount: fluidDataStores.size - unreferencedDataStoreCount,\n };\n }\n\n public get aliases(): ReadonlyMap<string, string> {\n return this.aliasMap;\n }\n\n public get pendingAliases(): Map<string, Promise<AliasResult>> {\n return this.pendingAliasMap;\n }\n\n public async waitIfPendingAlias(maybeAlias: string): Promise<AliasResult> {\n const pendingAliasPromise = this.pendingAliases.get(maybeAlias);\n return pendingAliasPromise === undefined ? \"Success\" : pendingAliasPromise;\n }\n\n public processAttachMessage(message: ISequencedDocumentMessage, local: boolean) {\n const attachMessage = message.contents as InboundAttachMessage;\n\n this.dataStoresSinceLastGC.push(attachMessage.id);\n\n // The local object has already been attached\n if (local) {\n assert(this.pendingAttach.has(attachMessage.id),\n 0x15e /* \"Local object does not have matching attach message id\" */);\n this.contexts.get(attachMessage.id)?.emit(\"attached\");\n this.pendingAttach.delete(attachMessage.id);\n return;\n }\n\n // If a non-local operation then go and create the object, otherwise mark it as officially attached.\n if (this.alreadyProcessed(attachMessage.id)) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n const error = new DataCorruptionError(\n // pre-0.58 error message: duplicateDataStoreCreatedWithExistingId\n \"Duplicate DataStore created with existing id\",\n {\n ...extractSafePropertiesFromMessage(message),\n dataStoreId: {\n value: attachMessage.id,\n tag: TelemetryDataTag.CodeArtifact,\n },\n },\n );\n throw error;\n }\n\n const flatBlobs = new Map<string, ArrayBufferLike>();\n let snapshotTree: ISnapshotTree | undefined;\n if (attachMessage.snapshot) {\n snapshotTree = buildSnapshotTree(attachMessage.snapshot.entries, flatBlobs);\n }\n\n // Include the type of attach message which is the pkg of the store to be\n // used by RemoteFluidDataStoreContext in case it is not in the snapshot.\n const pkg = [attachMessage.type];\n const remoteFluidDataStoreContext = new RemoteFluidDataStoreContext({\n id: attachMessage.id,\n snapshotTree,\n // New data stores begin with empty GC details since GC hasn't run on them yet.\n getBaseGCDetails: async () => { return {}; },\n runtime: this.runtime,\n storage: new BlobCacheStorageService(this.runtime.storage, flatBlobs),\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n attachMessage.id,\n {\n type: CreateSummarizerNodeSource.FromAttach,\n sequenceNumber: message.sequenceNumber,\n snapshot: attachMessage.snapshot ?? {\n entries: [createAttributesBlob(\n pkg,\n true /* isRootDataStore */,\n )],\n },\n },\n ),\n pkg,\n });\n\n this.contexts.addBoundOrRemoted(remoteFluidDataStoreContext);\n }\n\n public processAliasMessage(\n message: ISequencedDocumentMessage,\n localOpMetadata: unknown,\n local: boolean,\n ): void {\n const aliasMessage = message.contents as IDataStoreAliasMessage;\n if (!isDataStoreAliasMessage(aliasMessage)) {\n throw new DataCorruptionError(\n \"malformedDataStoreAliasMessage\",\n {\n ...extractSafePropertiesFromMessage(message),\n },\n );\n }\n\n const resolve = localOpMetadata as PendingAliasResolve;\n const aliasResult = this.processAliasMessageCore(aliasMessage);\n if (local) {\n resolve(aliasResult);\n }\n }\n\n public processAliasMessageCore(aliasMessage: IDataStoreAliasMessage): boolean {\n if (this.alreadyProcessed(aliasMessage.alias)) {\n return false;\n }\n\n const context = this.contexts.get(aliasMessage.internalId);\n if (context === undefined) {\n this.mc.logger.sendErrorEvent({\n eventName: \"AliasFluidDataStoreNotFound\",\n fluidDataStoreId: aliasMessage.internalId,\n });\n return false;\n }\n\n const handle = new FluidObjectHandle(\n context,\n aliasMessage.internalId,\n this.runtime.IFluidHandleContext,\n );\n this.runtime.addedGCOutboundReference(this.containerRuntimeHandle, handle);\n\n this.aliasMap.set(aliasMessage.alias, context.id);\n context.setInMemoryRoot();\n return true;\n }\n\n private alreadyProcessed(id: string): boolean {\n return this.aliasMap.get(id) !== undefined || this.contexts.get(id) !== undefined;\n }\n\n /**\n * Make the data stores locally visible in the container graph by moving the data store context from unbound to\n * bound list. This data store can now be reached from the root.\n * @param id - The id of the data store context to make visible.\n */\n private makeDataStoreLocallyVisible(id: string): void {\n const localContext = this.contexts.getUnbound(id);\n assert(!!localContext, 0x15f /* \"Could not find unbound context to bind\" */);\n\n /**\n * If the container is not detached, it is globally visible to all clients. This data store should also be\n * globally visible. Move it to attaching state and send an \"attach\" op for it.\n * If the container is detached, this data store will be part of the summary that makes the container attached.\n */\n if (this.runtime.attachState !== AttachState.Detached) {\n localContext.emit(\"attaching\");\n const message = localContext.generateAttachMessage();\n\n this.pendingAttach.set(id, message);\n this.submitAttachFn(message);\n this.attachOpFiredForDataStore.add(id);\n }\n\n this.contexts.bind(id);\n }\n\n public createDetachedDataStoreCore(\n pkg: Readonly<string[]>,\n isRoot: boolean,\n id = uuid()): IFluidDataStoreContextDetached {\n assert(!id.includes(\"/\"), 0x30c /* Id cannot contain slashes */);\n\n const context = new LocalDetachedFluidDataStoreContext({\n id,\n pkg,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n id,\n { type: CreateSummarizerNodeSource.Local },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(id),\n snapshotTree: undefined,\n isRootDataStore: isRoot,\n });\n this.contexts.addUnbound(context);\n return context;\n }\n\n public _createFluidDataStoreContext(pkg: string[], id: string, props?: any) {\n assert(!id.includes(\"/\"), 0x30d /* Id cannot contain slashes */);\n const context = new LocalFluidDataStoreContext({\n id,\n pkg,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n id,\n { type: CreateSummarizerNodeSource.Local },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(id),\n snapshotTree: undefined,\n isRootDataStore: false,\n createProps: props,\n });\n this.contexts.addUnbound(context);\n return context;\n }\n\n public get disposed() { return this.disposeOnce.evaluated; }\n public readonly dispose = () => this.disposeOnce.value;\n\n public resubmitDataStoreOp(content: any, localOpMetadata: unknown) {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x160 /* \"There should be a store context for the op\" */);\n context.reSubmit(envelope.contents, localOpMetadata);\n }\n\n public rollbackDataStoreOp(content: any, localOpMetadata: unknown) {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x2e8 /* \"There should be a store context for the op\" */);\n context.rollback(envelope.contents, localOpMetadata);\n }\n\n public async applyStashedOp(content: any): Promise<unknown> {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x161 /* \"There should be a store context for the op\" */);\n return context.applyStashedOp(envelope.contents);\n }\n\n public async applyStashedAttachOp(message: IAttachMessage) {\n this.pendingAttach.set(message.id, message);\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.processAttachMessage({ contents: message } as ISequencedDocumentMessage, false);\n }\n\n public processFluidDataStoreOp(message: ISequencedDocumentMessage, local: boolean, localMessageMetadata: unknown) {\n const envelope = message.contents as IEnvelope;\n const transformed = { ...message, contents: envelope.contents };\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x162 /* \"There should be a store context for the op\" */);\n context.process(transformed, local, localMessageMetadata);\n\n // Notify that a GC node for the data store changed. This is used to detect if a deleted data store is\n // being used.\n this.gcNodeUpdated(\n `/${envelope.address}`,\n message.timestamp,\n context.isLoaded ? context.packagePath : undefined,\n );\n }\n\n public async getDataStore(id: string, wait: boolean, viaHandle: boolean): Promise<FluidDataStoreContext> {\n const context = await this.contexts.getBoundOrRemoted(id, wait);\n const request = { url: id };\n if (context === undefined) {\n // The requested data store does not exits. Throw a 404 response exception.\n throw responseToException(create404Response(request), request);\n }\n\n if (context.tombstoned) {\n // The requested data store is removed by gc. Create a 404 gc response exception.\n const error = responseToException(createResponseError(404, \"Datastore removed by gc\", request), request);\n // Note: if a user writes a request to look like it's viaHandle, we will also send this telemetry event\n this.mc.logger.sendErrorEvent({\n eventName: \"GC_Tombstone_DataStore_Requested\",\n url: request.url,\n pkg: packagePathToTelemetryProperty(context.isLoaded ? context.packagePath : undefined),\n viaHandle,\n }, error);\n // Always log an error when tombstoned data store is used. However, throw an error only if\n // throwOnTombstoneUsage is set.\n if (this.throwOnTombstoneUsage) {\n throw error;\n }\n }\n\n return context;\n }\n\n public processSignal(address: string, message: IInboundSignalMessage, local: boolean) {\n const context = this.contexts.get(address);\n if (!context) {\n // Attach message may not have been processed yet\n assert(!local, 0x163 /* \"Missing datastore for local signal\" */);\n this.mc.logger.sendTelemetryEvent({\n eventName: \"SignalFluidDataStoreNotFound\",\n fluidDataStoreId: {\n value: address,\n tag: TelemetryDataTag.CodeArtifact,\n },\n });\n return;\n }\n\n context.processSignal(message, local);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n for (const [fluidDataStore, context] of this.contexts) {\n try {\n context.setConnectionState(connected, clientId);\n } catch (error) {\n this.mc.logger.sendErrorEvent({\n eventName: \"SetConnectionStateError\",\n clientId,\n fluidDataStore,\n }, error);\n }\n }\n }\n\n public setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n const eventName = attachState === AttachState.Attaching ? \"attaching\" : \"attached\";\n for (const [, context] of this.contexts) {\n // Fire only for bounded stores.\n if (!this.contexts.isNotBound(context.id)) {\n context.emit(eventName);\n }\n }\n }\n\n public get size(): number {\n return this.contexts.size;\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats> {\n const summaryBuilder = new SummaryTreeBuilder();\n\n // Iterate over each store and ask it to snapshot\n await Promise.all(Array.from(this.contexts)\n .filter(([_, context]) => {\n // Summarizer works only with clients with no local changes!\n assert(context.attachState !== AttachState.Attaching,\n 0x165 /* \"Summarizer cannot work if client has local changes\" */);\n return context.attachState === AttachState.Attached;\n }).map(async ([contextId, context]) => {\n const contextSummary = await context.summarize(fullTree, trackState, telemetryContext);\n summaryBuilder.addWithStats(contextId, contextSummary);\n }));\n\n return summaryBuilder.getSummaryTree();\n }\n\n public createSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n // Attaching graph of some stores can cause other stores to get bound too.\n // So keep taking summary until no new stores get bound.\n let notBoundContextsLength: number;\n do {\n const builderTree = builder.summary.tree;\n notBoundContextsLength = this.contexts.notBoundLength();\n // Iterate over each data store and ask it to snapshot\n Array.from(this.contexts)\n .filter(([key, _]) =>\n // Take summary of bounded data stores only, make sure we haven't summarized them already\n // and no attach op has been fired for that data store because for loader versions <= 0.24\n // we set attach state as \"attaching\" before taking createNew summary.\n !(this.contexts.isNotBound(key)\n || builderTree[key]\n || this.attachOpFiredForDataStore.has(key)),\n )\n .map(([key, value]) => {\n let dataStoreSummary: ISummarizeResult;\n if (value.isLoaded) {\n const snapshot = value.generateAttachMessage().snapshot;\n dataStoreSummary = convertToSummaryTree(snapshot, true);\n } else {\n // If this data store is not yet loaded, then there should be no changes in the snapshot from\n // which it was created as it is detached container. So just use the previous snapshot.\n assert(!!this.baseSnapshot,\n 0x166 /* \"BaseSnapshot should be there as detached container loaded from snapshot\" */);\n dataStoreSummary = convertSnapshotTreeToSummaryTree(this.baseSnapshot.trees[key]);\n }\n builder.addWithStats(key, dataStoreSummary);\n });\n } while (notBoundContextsLength !== this.contexts.notBoundLength());\n\n return builder.getSummaryTree();\n }\n\n /**\n * Before GC runs, called by the garbage collector to update any pending GC state.\n * The garbage collector needs to know all outbound references that are added. Since root data stores are not\n * explicitly marked as referenced, notify GC of new root data stores that were added since the last GC run.\n */\n public async updateStateBeforeGC(): Promise<void> {\n for (const id of this.dataStoresSinceLastGC) {\n const context = this.contexts.get(id);\n assert(context !== undefined, 0x2b6 /* Missing data store context */);\n if (await context.isRoot()) {\n // A root data store is basically a reference from the container runtime to the data store.\n const handle = new FluidObjectHandle(context, id, this.runtime.IFluidHandleContext);\n this.runtime.addedGCOutboundReference(this.containerRuntimeHandle, handle);\n }\n }\n this.dataStoresSinceLastGC = [];\n }\n\n /**\n * Generates data used for garbage collection. It does the following:\n *\n * 1. Calls into each child data store context to get its GC data.\n *\n * 2. Prefixes the child context's id to the GC nodes in the child's GC data. This makes sure that the node can be\n * identified as belonging to the child.\n *\n * 3. Adds a GC node for this channel to the nodes received from the children. All these nodes together represent\n * the GC data of this channel.\n *\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n const builder = new GCDataBuilder();\n // Iterate over each store and get their GC data.\n await Promise.all(Array.from(this.contexts)\n .filter(([_, context]) => {\n // Get GC data only for attached contexts. Detached contexts are not connected in the GC reference\n // graph so any references they might have won't be connected as well.\n return context.attachState === AttachState.Attached;\n }).map(async ([contextId, context]) => {\n const contextGCData = await context.getGCData(fullGC);\n // Prefix the child's id to the ids of its GC nodes so they can be identified as belonging to the child.\n // This also gradually builds the id of each node to be a path from the root.\n builder.prefixAndAddNodes(contextId, contextGCData.gcNodes);\n }));\n\n // Get the outbound routes and add a GC node for this channel.\n builder.addNode(\"/\", await this.getOutboundRoutes());\n return builder.getGCData();\n }\n\n /**\n * After GC has run, called to notify this Container's data stores of routes that are used in it.\n * @param usedRoutes - The routes that are used in all data stores in this Container.\n */\n public updateUsedRoutes(usedRoutes: string[]) {\n // Get a map of data store ids to routes used in it.\n const usedDataStoreRoutes = unpackChildNodesUsedRoutes(usedRoutes);\n\n // Verify that the used routes are correct.\n for (const [id] of usedDataStoreRoutes) {\n assert(this.contexts.has(id), 0x167 /* \"Used route does not belong to any known data store\" */);\n\n // Revive datastores regardless of whether or not tombstone the tombstone flag is flipped\n const dataStore = this.contexts.get(id);\n assert(dataStore !== undefined, 0x46e /* No data store retrieved with specified id */);\n dataStore.setTombstone(false /* tombstone */);\n }\n\n // Update the used routes in each data store. Used routes is empty for unused data stores.\n for (const [contextId, context] of this.contexts) {\n context.updateUsedRoutes(usedDataStoreRoutes.get(contextId) ?? []);\n }\n }\n\n /**\n * This is called to update objects whose routes are unused. The unused objects are either deleted or marked as\n * tombstones.\n * @param unusedRoutes - The routes that are unused in all data stores in this Container.\n * @param tombstone - if true, the objects corresponding to unused routes are marked tombstones. Otherwise, they\n * are deleted.\n */\n public updateUnusedRoutes(unusedRoutes: string[], tombstone: boolean) {\n for (const route of unusedRoutes) {\n const pathParts = route.split(\"/\");\n // Delete data store only if its route (/datastoreId) is in unusedRoutes. We don't want to delete a data\n // store based on its DDS being unused.\n if (pathParts.length > 2) {\n continue;\n }\n const dataStoreId = pathParts[1];\n assert(this.contexts.has(dataStoreId), 0x2d7 /* No data store with specified id */);\n\n /**\n * When running GC in tombstone mode, datastore contexts are tombstoned. Tombstoned datastore contexts\n * enable testing scenarios with accessing deleted content without actually deleting content from\n * summaries.\n */\n if (tombstone) {\n const dataStore = this.contexts.get(dataStoreId);\n assert(dataStore !== undefined, 0x442 /* No data store retrieved with specified id */);\n dataStore.setTombstone(true /* tombstone */);\n continue;\n }\n\n // Delete the contexts of unused data stores.\n this.contexts.delete(dataStoreId);\n // Delete the summarizer node of the unused data stores.\n this.deleteChildSummarizerNodeFn(dataStoreId);\n }\n }\n\n /**\n * Returns the outbound routes of this channel. Only root data stores are considered referenced and their paths are\n * part of outbound routes.\n */\n private async getOutboundRoutes(): Promise<string[]> {\n const outboundRoutes: string[] = [];\n for (const [contextId, context] of this.contexts) {\n const isRootDataStore = await context.isRoot();\n if (isRootDataStore) {\n outboundRoutes.push(`/${contextId}`);\n }\n }\n return outboundRoutes;\n }\n\n /**\n * Called by GC to retrieve the package path of a data store node with the given path.\n */\n public async getDataStorePackagePath(nodePath: string): Promise<readonly string[] | undefined> {\n // If the node belongs to a data store, return its package path. For DDSes, we return the package path of the\n // data store that contains it.\n const context = this.contexts.get(nodePath.split(\"/\")[1]);\n return (await context?.getInitialSnapshotDetails())?.pkg;\n }\n\n /**\n * Called by GC to determine if a node is for a data store or for an object within a data store (for e.g. DDS).\n * @returns the GC node type if the node belongs to a data store or object within data store, undefined otherwise.\n */\n public getGCNodeType(nodePath: string): GCNodeType | undefined {\n const pathParts = nodePath.split(\"/\");\n if (!this.contexts.has(pathParts[1])) {\n return undefined;\n }\n\n // Data stores paths are of the format \"/dataStoreId\".\n // Sub data store paths are of the format \"/dataStoreId/subPath/...\".\n if (pathParts.length === 2) {\n return GCNodeType.DataStore;\n }\n return GCNodeType.SubDataStore;\n }\n}\n\nexport function getSummaryForDatastores(\n snapshot: ISnapshotTree | undefined,\n metadata?: IContainerRuntimeMetadata,\n): ISnapshotTree | undefined {\n if (!snapshot) {\n return undefined;\n }\n\n if (rootHasIsolatedChannels(metadata)) {\n const datastoresSnapshot = snapshot.trees[channelsTreeName];\n assert(!!datastoresSnapshot, 0x168 /* Expected tree in snapshot not found */);\n return datastoresSnapshot;\n } else {\n // back-compat: strip out all non-datastore paths before giving to DataStores object.\n const datastoresTrees: ISnapshotTree[\"trees\"] = {};\n for (const [key, value] of Object.entries(snapshot.trees)) {\n if (!nonDataStorePaths.includes(key)) {\n datastoresTrees[key] = value;\n }\n }\n return {\n ...snapshot,\n trees: datastoresTrees,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dataStores.js","sourceRoot":"","sources":["../src/dataStores.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAExG,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAK9D,OAAO,EAEH,gBAAgB,EAGhB,0BAA0B,GAW7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO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. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger, IDisposable } from \"@fluidframework/common-definitions\";\nimport { DataCorruptionError, extractSafePropertiesFromMessage } from \"@fluidframework/container-utils\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport {\n ISequencedDocumentMessage,\n ISnapshotTree,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n AliasResult,\n channelsTreeName,\n CreateChildSummarizerNodeFn,\n CreateChildSummarizerNodeParam,\n CreateSummarizerNodeSource,\n IAttachMessage,\n IEnvelope,\n IFluidDataStoreContextDetached,\n IGarbageCollectionData,\n IGarbageCollectionDetailsBase,\n IInboundSignalMessage,\n InboundAttachMessage,\n ISummarizeResult,\n ISummaryTreeWithStats,\n ITelemetryContext,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n convertSnapshotTreeToSummaryTree,\n convertToSummaryTree,\n create404Response,\n createResponseError,\n responseToException,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport { ChildLogger, loggerToMonitoringContext, LoggingError, MonitoringContext, TelemetryDataTag } from \"@fluidframework/telemetry-utils\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { BlobCacheStorageService, buildSnapshotTree } from \"@fluidframework/driver-utils\";\nimport { assert, Lazy, LazyPromise } from \"@fluidframework/common-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport { GCDataBuilder, unpackChildNodesGCDetails, unpackChildNodesUsedRoutes } from \"@fluidframework/garbage-collector\";\nimport { DataStoreContexts } from \"./dataStoreContexts\";\nimport { ContainerRuntime, defaultRuntimeHeaderData, RuntimeHeaderData, TombstoneResponseHeaderKey } from \"./containerRuntime\";\nimport {\n FluidDataStoreContext,\n RemoteFluidDataStoreContext,\n LocalFluidDataStoreContext,\n createAttributesBlob,\n LocalDetachedFluidDataStoreContext,\n} from \"./dataStoreContext\";\nimport { IContainerRuntimeMetadata, nonDataStorePaths, rootHasIsolatedChannels } from \"./summaryFormat\";\nimport { IDataStoreAliasMessage, isDataStoreAliasMessage } from \"./dataStore\";\nimport { GCNodeType } from \"./garbageCollection\";\nimport { throwOnTombstoneLoadKey } from \"./garbageCollectionConstants\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\nimport { sendGCTombstoneEvent } from \"./garbageCollectionTombstoneUtils\";\n\ntype PendingAliasResolve = (success: boolean) => void;\n\n/**\n * This class encapsulates data store handling. Currently it is only used by the container runtime,\n * but eventually could be hosted on any channel once we formalize the channel api boundary.\n */\nexport class DataStores implements IDisposable {\n // Stores tracked by the Domain\n private readonly pendingAttach = new Map<string, IAttachMessage>();\n // 0.24 back-compat attachingBeforeSummary\n public readonly attachOpFiredForDataStore = new Set<string>();\n\n private readonly mc: MonitoringContext;\n\n private readonly disposeOnce = new Lazy<void>(() => this.contexts.dispose());\n\n public readonly containerLoadStats: {\n // number of dataStores during loadContainer\n readonly containerLoadDataStoreCount: number;\n // number of unreferenced dataStores during loadContainer\n readonly referencedDataStoreCount: number;\n };\n\n // Stores the ids of new data stores between two GC runs. This is used to notify the garbage collector of new\n // root data stores that are added.\n private dataStoresSinceLastGC: string[] = [];\n /** If true, throw an error when a tombstone data store is retrieved. */\n private readonly throwOnTombstoneLoad: boolean;\n // The handle to the container runtime. This is used mainly for GC purposes to represent outbound reference from\n // the container runtime to other nodes.\n private readonly containerRuntimeHandle: IFluidHandle;\n private readonly pendingAliasMap: Map<string, Promise<AliasResult>> = new Map<string, Promise<AliasResult>>();\n\n constructor(\n private readonly baseSnapshot: ISnapshotTree | undefined,\n private readonly runtime: ContainerRuntime,\n private readonly submitAttachFn: (attachContent: any) => void,\n private readonly getCreateChildSummarizerNodeFn:\n (id: string, createParam: CreateChildSummarizerNodeParam) => CreateChildSummarizerNodeFn,\n private readonly deleteChildSummarizerNodeFn: (id: string) => void,\n baseLogger: ITelemetryBaseLogger,\n getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase>,\n private readonly gcNodeUpdated: (\n nodePath: string, timestampMs: number, packagePath?: readonly string[]) => void,\n private readonly aliasMap: Map<string, string>,\n private readonly contexts: DataStoreContexts = new DataStoreContexts(baseLogger),\n ) {\n this.mc = loggerToMonitoringContext(ChildLogger.create(baseLogger));\n this.containerRuntimeHandle = new FluidObjectHandle(this.runtime, \"/\", this.runtime.IFluidHandleContext);\n\n const baseGCDetailsP = new LazyPromise(async () => {\n const baseGCDetails = await getBaseGCDetails();\n return unpackChildNodesGCDetails(baseGCDetails);\n });\n // Returns the base GC details for the data store with the given id.\n const dataStoreBaseGCDetails = async (dataStoreId: string) => {\n const baseGCDetails = await baseGCDetailsP;\n return baseGCDetails.get(dataStoreId);\n };\n // Tombstone should only throw when the feature flag is enabled and the client isn't a summarizer\n this.throwOnTombstoneLoad =\n this.mc.config.getBoolean(throwOnTombstoneLoadKey) === true &&\n this.runtime.clientDetails.type !== summarizerClientType;\n\n // Extract stores stored inside the snapshot\n const fluidDataStores = new Map<string, ISnapshotTree>();\n if (baseSnapshot) {\n for (const [key, value] of Object.entries(baseSnapshot.trees)) {\n fluidDataStores.set(key, value);\n }\n }\n\n let unreferencedDataStoreCount = 0;\n // Create a context for each of them\n for (const [key, value] of fluidDataStores) {\n let dataStoreContext: FluidDataStoreContext;\n\n // counting number of unreferenced data stores\n if (value.unreferenced) {\n unreferencedDataStoreCount++;\n }\n // If we have a detached container, then create local data store contexts.\n if (this.runtime.attachState !== AttachState.Detached) {\n dataStoreContext = new RemoteFluidDataStoreContext({\n id: key,\n snapshotTree: value,\n getBaseGCDetails: async () => dataStoreBaseGCDetails(key),\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n key,\n { type: CreateSummarizerNodeSource.FromSummary },\n ),\n });\n } else {\n if (typeof value !== \"object\") {\n throw new LoggingError(\"Snapshot should be there to load from!!\");\n }\n const snapshotTree = value;\n dataStoreContext = new LocalFluidDataStoreContext({\n id: key,\n pkg: undefined,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n key,\n { type: CreateSummarizerNodeSource.FromSummary },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(key),\n snapshotTree,\n isRootDataStore: undefined,\n });\n }\n this.contexts.addBoundOrRemoted(dataStoreContext);\n }\n this.containerLoadStats = {\n containerLoadDataStoreCount: fluidDataStores.size,\n referencedDataStoreCount: fluidDataStores.size - unreferencedDataStoreCount,\n };\n }\n\n public get aliases(): ReadonlyMap<string, string> {\n return this.aliasMap;\n }\n\n public get pendingAliases(): Map<string, Promise<AliasResult>> {\n return this.pendingAliasMap;\n }\n\n public async waitIfPendingAlias(maybeAlias: string): Promise<AliasResult> {\n const pendingAliasPromise = this.pendingAliases.get(maybeAlias);\n return pendingAliasPromise === undefined ? \"Success\" : pendingAliasPromise;\n }\n\n public processAttachMessage(message: ISequencedDocumentMessage, local: boolean) {\n const attachMessage = message.contents as InboundAttachMessage;\n\n this.dataStoresSinceLastGC.push(attachMessage.id);\n\n // The local object has already been attached\n if (local) {\n assert(this.pendingAttach.has(attachMessage.id),\n 0x15e /* \"Local object does not have matching attach message id\" */);\n this.contexts.get(attachMessage.id)?.emit(\"attached\");\n this.pendingAttach.delete(attachMessage.id);\n return;\n }\n\n // If a non-local operation then go and create the object, otherwise mark it as officially attached.\n if (this.alreadyProcessed(attachMessage.id)) {\n // TODO: dataStoreId may require a different tag from PackageData #7488\n const error = new DataCorruptionError(\n // pre-0.58 error message: duplicateDataStoreCreatedWithExistingId\n \"Duplicate DataStore created with existing id\",\n {\n ...extractSafePropertiesFromMessage(message),\n dataStoreId: {\n value: attachMessage.id,\n tag: TelemetryDataTag.CodeArtifact,\n },\n },\n );\n throw error;\n }\n\n const flatBlobs = new Map<string, ArrayBufferLike>();\n let snapshotTree: ISnapshotTree | undefined;\n if (attachMessage.snapshot) {\n snapshotTree = buildSnapshotTree(attachMessage.snapshot.entries, flatBlobs);\n }\n\n // Include the type of attach message which is the pkg of the store to be\n // used by RemoteFluidDataStoreContext in case it is not in the snapshot.\n const pkg = [attachMessage.type];\n const remoteFluidDataStoreContext = new RemoteFluidDataStoreContext({\n id: attachMessage.id,\n snapshotTree,\n // New data stores begin with empty GC details since GC hasn't run on them yet.\n getBaseGCDetails: async () => { return {}; },\n runtime: this.runtime,\n storage: new BlobCacheStorageService(this.runtime.storage, flatBlobs),\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n attachMessage.id,\n {\n type: CreateSummarizerNodeSource.FromAttach,\n sequenceNumber: message.sequenceNumber,\n snapshot: attachMessage.snapshot ?? {\n entries: [createAttributesBlob(\n pkg,\n true /* isRootDataStore */,\n )],\n },\n },\n ),\n pkg,\n });\n\n this.contexts.addBoundOrRemoted(remoteFluidDataStoreContext);\n }\n\n public processAliasMessage(\n message: ISequencedDocumentMessage,\n localOpMetadata: unknown,\n local: boolean,\n ): void {\n const aliasMessage = message.contents as IDataStoreAliasMessage;\n if (!isDataStoreAliasMessage(aliasMessage)) {\n throw new DataCorruptionError(\n \"malformedDataStoreAliasMessage\",\n {\n ...extractSafePropertiesFromMessage(message),\n },\n );\n }\n\n const resolve = localOpMetadata as PendingAliasResolve;\n const aliasResult = this.processAliasMessageCore(aliasMessage);\n if (local) {\n resolve(aliasResult);\n }\n }\n\n public processAliasMessageCore(aliasMessage: IDataStoreAliasMessage): boolean {\n if (this.alreadyProcessed(aliasMessage.alias)) {\n return false;\n }\n\n const context = this.contexts.get(aliasMessage.internalId);\n if (context === undefined) {\n this.mc.logger.sendErrorEvent({\n eventName: \"AliasFluidDataStoreNotFound\",\n fluidDataStoreId: aliasMessage.internalId,\n });\n return false;\n }\n\n const handle = new FluidObjectHandle(\n context,\n aliasMessage.internalId,\n this.runtime.IFluidHandleContext,\n );\n this.runtime.addedGCOutboundReference(this.containerRuntimeHandle, handle);\n\n this.aliasMap.set(aliasMessage.alias, context.id);\n context.setInMemoryRoot();\n return true;\n }\n\n private alreadyProcessed(id: string): boolean {\n return this.aliasMap.get(id) !== undefined || this.contexts.get(id) !== undefined;\n }\n\n /**\n * Make the data stores locally visible in the container graph by moving the data store context from unbound to\n * bound list. This data store can now be reached from the root.\n * @param id - The id of the data store context to make visible.\n */\n private makeDataStoreLocallyVisible(id: string): void {\n const localContext = this.contexts.getUnbound(id);\n assert(!!localContext, 0x15f /* \"Could not find unbound context to bind\" */);\n\n /**\n * If the container is not detached, it is globally visible to all clients. This data store should also be\n * globally visible. Move it to attaching state and send an \"attach\" op for it.\n * If the container is detached, this data store will be part of the summary that makes the container attached.\n */\n if (this.runtime.attachState !== AttachState.Detached) {\n localContext.emit(\"attaching\");\n const message = localContext.generateAttachMessage();\n\n this.pendingAttach.set(id, message);\n this.submitAttachFn(message);\n this.attachOpFiredForDataStore.add(id);\n }\n\n this.contexts.bind(id);\n }\n\n public createDetachedDataStoreCore(\n pkg: Readonly<string[]>,\n isRoot: boolean,\n id = uuid()): IFluidDataStoreContextDetached {\n assert(!id.includes(\"/\"), 0x30c /* Id cannot contain slashes */);\n\n const context = new LocalDetachedFluidDataStoreContext({\n id,\n pkg,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n id,\n { type: CreateSummarizerNodeSource.Local },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(id),\n snapshotTree: undefined,\n isRootDataStore: isRoot,\n });\n this.contexts.addUnbound(context);\n return context;\n }\n\n public _createFluidDataStoreContext(pkg: string[], id: string, props?: any) {\n assert(!id.includes(\"/\"), 0x30d /* Id cannot contain slashes */);\n const context = new LocalFluidDataStoreContext({\n id,\n pkg,\n runtime: this.runtime,\n storage: this.runtime.storage,\n scope: this.runtime.scope,\n createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(\n id,\n { type: CreateSummarizerNodeSource.Local },\n ),\n makeLocallyVisibleFn: () => this.makeDataStoreLocallyVisible(id),\n snapshotTree: undefined,\n isRootDataStore: false,\n createProps: props,\n });\n this.contexts.addUnbound(context);\n return context;\n }\n\n public get disposed() { return this.disposeOnce.evaluated; }\n public readonly dispose = () => this.disposeOnce.value;\n\n public resubmitDataStoreOp(content: any, localOpMetadata: unknown) {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x160 /* \"There should be a store context for the op\" */);\n context.reSubmit(envelope.contents, localOpMetadata);\n }\n\n public rollbackDataStoreOp(content: any, localOpMetadata: unknown) {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x2e8 /* \"There should be a store context for the op\" */);\n context.rollback(envelope.contents, localOpMetadata);\n }\n\n public async applyStashedOp(content: any): Promise<unknown> {\n const envelope = content as IEnvelope;\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x161 /* \"There should be a store context for the op\" */);\n return context.applyStashedOp(envelope.contents);\n }\n\n public async applyStashedAttachOp(message: IAttachMessage) {\n this.pendingAttach.set(message.id, message);\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n this.processAttachMessage({ contents: message } as ISequencedDocumentMessage, false);\n }\n\n public processFluidDataStoreOp(message: ISequencedDocumentMessage, local: boolean, localMessageMetadata: unknown) {\n const envelope = message.contents as IEnvelope;\n const transformed = { ...message, contents: envelope.contents };\n const context = this.contexts.get(envelope.address);\n assert(!!context, 0x162 /* \"There should be a store context for the op\" */);\n context.process(transformed, local, localMessageMetadata);\n\n // Notify that a GC node for the data store changed. This is used to detect if a deleted data store is\n // being used.\n this.gcNodeUpdated(\n `/${envelope.address}`,\n message.timestamp,\n context.isLoaded ? context.packagePath : undefined,\n );\n }\n\n public async getDataStore(id: string, requestHeaderData: RuntimeHeaderData): Promise<FluidDataStoreContext> {\n const headerData = { ...defaultRuntimeHeaderData, ...requestHeaderData };\n\n const context = await this.contexts.getBoundOrRemoted(id, headerData.wait);\n const request = { url: id };\n if (context === undefined) {\n // The requested data store does not exits. Throw a 404 response exception.\n throw responseToException(create404Response(request), request);\n }\n\n if (context.tombstoned) {\n const shouldFail = this.throwOnTombstoneLoad && !headerData.allowTombstone;\n\n // The requested data store is removed by gc. Create a 404 gc response exception.\n const error = responseToException(createResponseError(\n 404,\n \"DataStore was deleted\",\n request,\n { [TombstoneResponseHeaderKey]: true },\n ), request);\n sendGCTombstoneEvent(\n this.mc,\n {\n eventName: \"GC_Tombstone_DataStore_Requested\",\n category: shouldFail ? \"error\" : \"generic\",\n isSummarizerClient: this.runtime.clientDetails.type === summarizerClientType,\n headers: JSON.stringify(requestHeaderData),\n },\n context.isLoaded ? context.packagePath : undefined,\n error,\n );\n\n if (shouldFail) {\n throw error;\n }\n }\n\n return context;\n }\n\n public processSignal(address: string, message: IInboundSignalMessage, local: boolean) {\n const context = this.contexts.get(address);\n if (!context) {\n // Attach message may not have been processed yet\n assert(!local, 0x163 /* \"Missing datastore for local signal\" */);\n this.mc.logger.sendTelemetryEvent({\n eventName: \"SignalFluidDataStoreNotFound\",\n fluidDataStoreId: {\n value: address,\n tag: TelemetryDataTag.CodeArtifact,\n },\n });\n return;\n }\n\n context.processSignal(message, local);\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n for (const [fluidDataStore, context] of this.contexts) {\n try {\n context.setConnectionState(connected, clientId);\n } catch (error) {\n this.mc.logger.sendErrorEvent({\n eventName: \"SetConnectionStateError\",\n clientId,\n fluidDataStore,\n }, error);\n }\n }\n }\n\n public setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n const eventName = attachState === AttachState.Attaching ? \"attaching\" : \"attached\";\n for (const [, context] of this.contexts) {\n // Fire only for bounded stores.\n if (!this.contexts.isNotBound(context.id)) {\n context.emit(eventName);\n }\n }\n }\n\n public get size(): number {\n return this.contexts.size;\n }\n\n public async summarize(\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ): Promise<ISummaryTreeWithStats> {\n const summaryBuilder = new SummaryTreeBuilder();\n\n // Iterate over each store and ask it to snapshot\n await Promise.all(Array.from(this.contexts)\n .filter(([_, context]) => {\n // Summarizer works only with clients with no local changes!\n assert(context.attachState !== AttachState.Attaching,\n 0x165 /* \"Summarizer cannot work if client has local changes\" */);\n return context.attachState === AttachState.Attached;\n }).map(async ([contextId, context]) => {\n const contextSummary = await context.summarize(fullTree, trackState, telemetryContext);\n summaryBuilder.addWithStats(contextId, contextSummary);\n }));\n\n return summaryBuilder.getSummaryTree();\n }\n\n public createSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n const builder = new SummaryTreeBuilder();\n // Attaching graph of some stores can cause other stores to get bound too.\n // So keep taking summary until no new stores get bound.\n let notBoundContextsLength: number;\n do {\n const builderTree = builder.summary.tree;\n notBoundContextsLength = this.contexts.notBoundLength();\n // Iterate over each data store and ask it to snapshot\n Array.from(this.contexts)\n .filter(([key, _]) =>\n // Take summary of bounded data stores only, make sure we haven't summarized them already\n // and no attach op has been fired for that data store because for loader versions <= 0.24\n // we set attach state as \"attaching\" before taking createNew summary.\n !(this.contexts.isNotBound(key)\n || builderTree[key]\n || this.attachOpFiredForDataStore.has(key)),\n )\n .map(([key, value]) => {\n let dataStoreSummary: ISummarizeResult;\n if (value.isLoaded) {\n const snapshot = value.generateAttachMessage().snapshot;\n dataStoreSummary = convertToSummaryTree(snapshot, true);\n } else {\n // If this data store is not yet loaded, then there should be no changes in the snapshot from\n // which it was created as it is detached container. So just use the previous snapshot.\n assert(!!this.baseSnapshot,\n 0x166 /* \"BaseSnapshot should be there as detached container loaded from snapshot\" */);\n dataStoreSummary = convertSnapshotTreeToSummaryTree(this.baseSnapshot.trees[key]);\n }\n builder.addWithStats(key, dataStoreSummary);\n });\n } while (notBoundContextsLength !== this.contexts.notBoundLength());\n\n return builder.getSummaryTree();\n }\n\n /**\n * Before GC runs, called by the garbage collector to update any pending GC state.\n * The garbage collector needs to know all outbound references that are added. Since root data stores are not\n * explicitly marked as referenced, notify GC of new root data stores that were added since the last GC run.\n */\n public async updateStateBeforeGC(): Promise<void> {\n for (const id of this.dataStoresSinceLastGC) {\n const context = this.contexts.get(id);\n assert(context !== undefined, 0x2b6 /* Missing data store context */);\n if (await context.isRoot()) {\n // A root data store is basically a reference from the container runtime to the data store.\n const handle = new FluidObjectHandle(context, id, this.runtime.IFluidHandleContext);\n this.runtime.addedGCOutboundReference(this.containerRuntimeHandle, handle);\n }\n }\n this.dataStoresSinceLastGC = [];\n }\n\n /**\n * Generates data used for garbage collection. It does the following:\n *\n * 1. Calls into each child data store context to get its GC data.\n *\n * 2. Prefixes the child context's id to the GC nodes in the child's GC data. This makes sure that the node can be\n * identified as belonging to the child.\n *\n * 3. Adds a GC node for this channel to the nodes received from the children. All these nodes together represent\n * the GC data of this channel.\n *\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n const builder = new GCDataBuilder();\n // Iterate over each store and get their GC data.\n await Promise.all(Array.from(this.contexts)\n .filter(([_, context]) => {\n // Get GC data only for attached contexts. Detached contexts are not connected in the GC reference\n // graph so any references they might have won't be connected as well.\n return context.attachState === AttachState.Attached;\n }).map(async ([contextId, context]) => {\n const contextGCData = await context.getGCData(fullGC);\n // Prefix the child's id to the ids of its GC nodes so they can be identified as belonging to the child.\n // This also gradually builds the id of each node to be a path from the root.\n builder.prefixAndAddNodes(contextId, contextGCData.gcNodes);\n }));\n\n // Get the outbound routes and add a GC node for this channel.\n builder.addNode(\"/\", await this.getOutboundRoutes());\n return builder.getGCData();\n }\n\n /**\n * After GC has run, called to notify this Container's data stores of routes that are used in it.\n * @param usedRoutes - The routes that are used in all data stores in this Container.\n */\n public updateUsedRoutes(usedRoutes: string[]) {\n // Get a map of data store ids to routes used in it.\n const usedDataStoreRoutes = unpackChildNodesUsedRoutes(usedRoutes);\n\n // Verify that the used routes are correct.\n for (const [id] of usedDataStoreRoutes) {\n assert(this.contexts.has(id), 0x167 /* \"Used route does not belong to any known data store\" */);\n }\n\n // Update the used routes in each data store. Used routes is empty for unused data stores.\n for (const [contextId, context] of this.contexts) {\n context.updateUsedRoutes(usedDataStoreRoutes.get(contextId) ?? []);\n }\n }\n\n /**\n * This is called to update objects whose routes are unused. The unused objects are deleted.\n * @param unusedRoutes - The routes that are unused in all data stores in this Container.\n */\n public updateUnusedRoutes(unusedRoutes: string[]) {\n for (const route of unusedRoutes) {\n const pathParts = route.split(\"/\");\n // Delete data store only if its route (/datastoreId) is in unusedRoutes. We don't want to delete a data\n // store based on its DDS being unused.\n if (pathParts.length > 2) {\n continue;\n }\n const dataStoreId = pathParts[1];\n assert(this.contexts.has(dataStoreId), 0x2d7 /* No data store with specified id */);\n // Delete the contexts of unused data stores.\n this.contexts.delete(dataStoreId);\n // Delete the summarizer node of the unused data stores.\n this.deleteChildSummarizerNodeFn(dataStoreId);\n }\n }\n\n /**\n * This is called to update objects whose routes are tombstones. Tombstoned datastore contexts enable testing\n * scenarios with accessing deleted content without actually deleting content from summaries.\n * @param tombstonedRoutes - The routes that are tombstones in all data stores in this Container.\n */\n public updateTombstonedRoutes(tombstonedRoutes: string[]) {\n const tombstonedDataStoresSet: Set<string> = new Set();\n for (const route of tombstonedRoutes) {\n const pathParts = route.split(\"/\");\n // Tombstone data store only if its route (/datastoreId) is directly in tombstoneRoutes.\n if (pathParts.length > 2) {\n continue;\n }\n const dataStoreId = pathParts[1];\n assert(this.contexts.has(dataStoreId), 0x510 /* No data store with specified id */);\n tombstonedDataStoresSet.add(dataStoreId);\n }\n\n // Update the used routes in each data store. Used routes is empty for unused data stores.\n for (const [contextId, context] of this.contexts) {\n context.setTombstone(tombstonedDataStoresSet.has(contextId));\n }\n }\n\n /**\n * Returns the outbound routes of this channel. Only root data stores are considered referenced and their paths are\n * part of outbound routes.\n */\n private async getOutboundRoutes(): Promise<string[]> {\n const outboundRoutes: string[] = [];\n for (const [contextId, context] of this.contexts) {\n const isRootDataStore = await context.isRoot();\n if (isRootDataStore) {\n outboundRoutes.push(`/${contextId}`);\n }\n }\n return outboundRoutes;\n }\n\n /**\n * Called by GC to retrieve the package path of a data store node with the given path.\n */\n public async getDataStorePackagePath(nodePath: string): Promise<readonly string[] | undefined> {\n // If the node belongs to a data store, return its package path. For DDSes, we return the package path of the\n // data store that contains it.\n const context = this.contexts.get(nodePath.split(\"/\")[1]);\n return (await context?.getInitialSnapshotDetails())?.pkg;\n }\n\n /**\n * Called by GC to determine if a node is for a data store or for an object within a data store (for e.g. DDS).\n * @returns the GC node type if the node belongs to a data store or object within data store, undefined otherwise.\n */\n public getGCNodeType(nodePath: string): GCNodeType | undefined {\n const pathParts = nodePath.split(\"/\");\n if (!this.contexts.has(pathParts[1])) {\n return undefined;\n }\n\n // Data stores paths are of the format \"/dataStoreId\".\n // Sub data store paths are of the format \"/dataStoreId/subPath/...\".\n if (pathParts.length === 2) {\n return GCNodeType.DataStore;\n }\n return GCNodeType.SubDataStore;\n }\n}\n\nexport function getSummaryForDatastores(\n snapshot: ISnapshotTree | undefined,\n metadata?: IContainerRuntimeMetadata,\n): ISnapshotTree | undefined {\n if (!snapshot) {\n return undefined;\n }\n\n if (rootHasIsolatedChannels(metadata)) {\n const datastoresSnapshot = snapshot.trees[channelsTreeName];\n assert(!!datastoresSnapshot, 0x168 /* Expected tree in snapshot not found */);\n return datastoresSnapshot;\n } else {\n // back-compat: strip out all non-datastore paths before giving to DataStores object.\n const datastoresTrees: ISnapshotTree[\"trees\"] = {};\n for (const [key, value] of Object.entries(snapshot.trees)) {\n if (!nonDataStorePaths.includes(key)) {\n datastoresTrees[key] = value;\n }\n }\n return {\n ...snapshot,\n trees: datastoresTrees,\n };\n }\n}\n"]}
|
|
@@ -48,7 +48,9 @@ export interface IGarbageCollectionRuntime {
|
|
|
48
48
|
/** After GC has run, called to notify the runtime of routes that are used in it. */
|
|
49
49
|
updateUsedRoutes(usedRoutes: string[]): void;
|
|
50
50
|
/** After GC has run, called to notify the runtime of routes that are unused in it. */
|
|
51
|
-
updateUnusedRoutes(unusedRoutes: string[]
|
|
51
|
+
updateUnusedRoutes(unusedRoutes: string[]): void;
|
|
52
|
+
/** Called to notify the runtime of routes that are tombstones. */
|
|
53
|
+
updateTombstonedRoutes(tombstoneRoutes: string[]): void;
|
|
52
54
|
/** Returns a referenced timestamp to be used to track unreferenced nodes. */
|
|
53
55
|
getCurrentReferenceTimestampMs(): number | undefined;
|
|
54
56
|
/** Returns the type of the GC node. */
|
|
@@ -75,10 +77,10 @@ export interface IGarbageCollector {
|
|
|
75
77
|
summarize(fullTree: boolean, trackState: boolean, telemetryContext?: ITelemetryContext): ISummarizeResult | undefined;
|
|
76
78
|
/** Returns the garbage collector specific metadata to be written into the summary. */
|
|
77
79
|
getMetadata(): IGCMetadata;
|
|
78
|
-
/** Returns
|
|
79
|
-
getBaseGCDetails(): Promise<
|
|
80
|
+
/** Returns the GC details generated from the base snapshot. */
|
|
81
|
+
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
80
82
|
/** Called when the latest summary of the system has been refreshed. */
|
|
81
|
-
|
|
83
|
+
refreshLatestSummary(result: RefreshSummaryResult, proposalHandle: string | undefined, summaryRefSeq: number, readAndParseBlob: ReadAndParseBlob): Promise<void>;
|
|
82
84
|
/** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */
|
|
83
85
|
nodeUpdated(nodePath: string, reason: "Loaded" | "Changed", timestampMs?: number, packagePath?: readonly string[], requestHeaders?: IRequestHeader): void;
|
|
84
86
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
@@ -171,11 +173,13 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
171
173
|
*
|
|
172
174
|
* 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.
|
|
173
175
|
*
|
|
174
|
-
* 3.
|
|
176
|
+
* 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
|
|
175
177
|
*
|
|
176
|
-
*
|
|
178
|
+
* 4. The GC version in the latest summary is different from the current GC version. This can happen if:
|
|
177
179
|
*
|
|
178
|
-
*
|
|
180
|
+
* 4.1. The summary this client loaded with has data from a different GC version.
|
|
181
|
+
*
|
|
182
|
+
* 4.2. This client's latest summary was updated from a snapshot that has a different GC version.
|
|
179
183
|
*/
|
|
180
184
|
get summaryStateNeedsReset(): boolean;
|
|
181
185
|
/**
|
|
@@ -203,7 +207,7 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
203
207
|
private readonly tombstoneMode;
|
|
204
208
|
private readonly mc;
|
|
205
209
|
/**
|
|
206
|
-
* Tells whether the
|
|
210
|
+
* Tells whether the GC state needs to be reset. This can happen under 3 conditions:
|
|
207
211
|
*
|
|
208
212
|
* 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after
|
|
209
213
|
* it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.
|
|
@@ -211,13 +215,16 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
211
215
|
* 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on
|
|
212
216
|
* a document and the first time GC is enabled after is was disabled before.
|
|
213
217
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
218
|
+
* 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
|
|
219
|
+
*
|
|
220
|
+
* Note that the state will be reset only once for the first summary generated after this returns true. After that,
|
|
221
|
+
* this will return false.
|
|
216
222
|
*/
|
|
217
|
-
private
|
|
223
|
+
private get gcStateNeedsReset();
|
|
224
|
+
private wasGCRunInLatestSummary;
|
|
218
225
|
private readonly currentGCVersion;
|
|
219
226
|
private latestSummaryGCVersion;
|
|
220
|
-
private
|
|
227
|
+
private gcDataFromLastRun;
|
|
221
228
|
private readonly newReferencesSinceLastRun;
|
|
222
229
|
private tombstones;
|
|
223
230
|
/**
|
|
@@ -263,6 +270,15 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
263
270
|
* in use or not.
|
|
264
271
|
*/
|
|
265
272
|
initializeBaseState(): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* Update state from the given snapshot data. This is done during load and during refreshing state from a snapshot.
|
|
275
|
+
* All current tracking is reset and updated from the data in the snapshot.
|
|
276
|
+
* @param snapshotData - The snapshot data to update state from. If this is undefined, all GC state and tracking
|
|
277
|
+
* is reset.
|
|
278
|
+
* @param currentReferenceTimestampMs - The current reference timestamp for marking unreferenced nodes' unreferenced
|
|
279
|
+
* timestamp.
|
|
280
|
+
*/
|
|
281
|
+
private updateStateFromSnapshotData;
|
|
266
282
|
/**
|
|
267
283
|
* Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this
|
|
268
284
|
* to initialize the base state for non-summarizer clients so that they can track inactive / sweep ready nodes.
|
|
@@ -302,15 +318,15 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
302
318
|
private buildGCSummaryTree;
|
|
303
319
|
getMetadata(): IGCMetadata;
|
|
304
320
|
/**
|
|
305
|
-
* Returns a
|
|
306
|
-
*
|
|
321
|
+
* Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes
|
|
322
|
+
* in the container.
|
|
307
323
|
*/
|
|
308
|
-
getBaseGCDetails(): Promise<
|
|
324
|
+
getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
|
|
309
325
|
/**
|
|
310
|
-
* Called
|
|
311
|
-
*
|
|
326
|
+
* Called to refresh the latest summary state. This happens when either a pending summary is acked or a snapshot
|
|
327
|
+
* is downloaded and should be used to update the state.
|
|
312
328
|
*/
|
|
313
|
-
|
|
329
|
+
refreshLatestSummary(result: RefreshSummaryResult, proposalHandle: string | undefined, summaryRefSeq: number, readAndParseBlob: ReadAndParseBlob): Promise<void>;
|
|
314
330
|
/**
|
|
315
331
|
* Called when a node with the given id is updated. If the node is inactive, log an error.
|
|
316
332
|
* @param nodePath - The id of the node that changed.
|
|
@@ -341,8 +357,13 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
341
357
|
private updateCurrentState;
|
|
342
358
|
/**
|
|
343
359
|
* Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in
|
|
344
|
-
* time.
|
|
345
|
-
*
|
|
360
|
+
* time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be
|
|
361
|
+
* updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of
|
|
362
|
+
* these objects while there can be in-memory referenced to it:
|
|
363
|
+
* 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is
|
|
364
|
+
* added, the object may have been accessed and in-memory reference to it added.
|
|
365
|
+
* 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were
|
|
366
|
+
* unreferenced, they could have been accessed and in-memory reference to them added.
|
|
346
367
|
*
|
|
347
368
|
* This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.
|
|
348
369
|
* If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAAE,aAAa,EAAe,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAIH,sBAAsB,EACtB,6BAA6B,EAG7B,gBAAgB,EAChB,iBAAiB,EAIpB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAGH,gBAAgB,EAChB,oBAAoB,EAEvB,MAAM,+BAA+B,CAAC;AAUvC,OAAO,EAAE,iBAAiB,EAAkB,MAA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