@fluidframework/container-runtime 0.59.2000-61729 → 0.59.2000-63294
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/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +6 -6
- package/dist/containerRuntime.js.map +1 -1
- package/dist/garbageCollection.d.ts +26 -8
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +81 -57
- package/dist/garbageCollection.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 +11 -10
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/summarizer.d.ts +1 -0
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +8 -4
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +47 -1
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryGenerator.d.ts +0 -2
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +15 -15
- package/dist/summaryManager.js.map +1 -1
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +6 -6
- package/lib/containerRuntime.js.map +1 -1
- package/lib/garbageCollection.d.ts +26 -8
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +81 -57
- package/lib/garbageCollection.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 +11 -10
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/summarizer.d.ts +1 -0
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +8 -4
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +47 -1
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryGenerator.d.ts +0 -2
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +15 -15
- package/lib/summaryManager.js.map +1 -1
- package/package.json +35 -59
- package/src/containerRuntime.ts +4 -6
- package/src/garbageCollection.ts +96 -61
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +13 -10
- package/src/summarizer.ts +9 -4
- package/src/summarizerTypes.ts +60 -1
- package/src/summaryGenerator.ts +2 -44
- package/src/summaryManager.ts +17 -19
|
@@ -96,6 +96,19 @@ export interface IGarbageCollector {
|
|
|
96
96
|
/**
|
|
97
97
|
* The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
|
|
98
98
|
* its state across summaries.
|
|
99
|
+
*
|
|
100
|
+
* Node - represented as nodeId, it's a node on the GC graph
|
|
101
|
+
* Outbound Route - a path from one node to another node, think `nodeA` -> `nodeB`
|
|
102
|
+
* Graph - all nodes with their respective routes
|
|
103
|
+
* GC Graph
|
|
104
|
+
*
|
|
105
|
+
* Node
|
|
106
|
+
* NodeId = "datastore1"
|
|
107
|
+
* / \
|
|
108
|
+
* OutboundRoute OutboundRoute
|
|
109
|
+
* / \
|
|
110
|
+
* Node Node
|
|
111
|
+
* NodeId = "dds1" NodeId = "dds2"
|
|
99
112
|
*/
|
|
100
113
|
export declare class GarbageCollector implements IGarbageCollector {
|
|
101
114
|
private readonly runtime;
|
|
@@ -154,8 +167,8 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
154
167
|
private initialStateNeedsReset;
|
|
155
168
|
private readonly currentGCVersion;
|
|
156
169
|
private latestSummaryGCVersion;
|
|
157
|
-
private
|
|
158
|
-
private readonly
|
|
170
|
+
private previousGCDataFromLastRun;
|
|
171
|
+
private readonly newReferencesSinceLastRun;
|
|
159
172
|
private readonly initializeBaseStateP;
|
|
160
173
|
private readonly baseGCDetailsP;
|
|
161
174
|
private readonly deleteTimeoutMs;
|
|
@@ -238,14 +251,19 @@ export declare class GarbageCollector implements IGarbageCollector {
|
|
|
238
251
|
*/
|
|
239
252
|
private updateStateSinceLastRun;
|
|
240
253
|
/**
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
254
|
+
* Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.
|
|
255
|
+
* The principle is that every new reference or outbound route must be notified to GC via the
|
|
256
|
+
* addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.
|
|
257
|
+
*
|
|
258
|
+
* In more simple terms:
|
|
259
|
+
* Missing Explicit References = Current References - Previous References - Explicitly Added References;
|
|
260
|
+
*
|
|
246
261
|
* @param currentGCData - The GC data (reference graph) from the current GC run.
|
|
262
|
+
* @param previousGCData - The GC data (reference graph) from the previous GC run.
|
|
263
|
+
* @param explicitReferences - New references added explicity between the previous and the current run.
|
|
264
|
+
* @returns - a list of missing explicit references
|
|
247
265
|
*/
|
|
248
|
-
private
|
|
266
|
+
private findMissingExplicitReferences;
|
|
249
267
|
/**
|
|
250
268
|
* Generates the stats of a garbage collection run from the given results of the run. Also, logs any pending events
|
|
251
269
|
* in the pendingEventsQueue. This should be called before updating the current state because it generates stats
|
|
@@ -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,EAA8B,MAAM,oCAAoC,CAAC;AAElG,OAAO,EAAE,uB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ature gate key to expire a session after a set period of time.
|
|
32
32
|
const runSessionExpiry = "Fluid.GarbageCollection.RunSessionExpiry";
|
|
33
|
+
// Feature gate key to log error messages if GC reference validation fails.
|
|
34
|
+
const logUnknownOutboundReferencesKey = "Fluid.GarbageCollection.LogUnknownOutboundReferences";
|
|
33
35
|
const defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
34
36
|
exports.defaultSessionExpiryDurationMs = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
35
37
|
/** The types of GC nodes in the GC reference graph. */
|
|
@@ -90,6 +92,19 @@ class UnreferencedStateTracker {
|
|
|
90
92
|
/**
|
|
91
93
|
* The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
|
|
92
94
|
* its state across summaries.
|
|
95
|
+
*
|
|
96
|
+
* Node - represented as nodeId, it's a node on the GC graph
|
|
97
|
+
* Outbound Route - a path from one node to another node, think `nodeA` -> `nodeB`
|
|
98
|
+
* Graph - all nodes with their respective routes
|
|
99
|
+
* GC Graph
|
|
100
|
+
*
|
|
101
|
+
* Node
|
|
102
|
+
* NodeId = "datastore1"
|
|
103
|
+
* / \
|
|
104
|
+
* OutboundRoute OutboundRoute
|
|
105
|
+
* / \
|
|
106
|
+
* Node Node
|
|
107
|
+
* NodeId = "dds1" NodeId = "dds2"
|
|
93
108
|
*/
|
|
94
109
|
class GarbageCollector {
|
|
95
110
|
constructor(runtime, gcOptions,
|
|
@@ -121,7 +136,7 @@ class GarbageCollector {
|
|
|
121
136
|
this.currentGCVersion = GCVersion;
|
|
122
137
|
// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of
|
|
123
138
|
// outbound routes from that node.
|
|
124
|
-
this.
|
|
139
|
+
this.newReferencesSinceLastRun = new Map();
|
|
125
140
|
// Map of node ids to their unreferenced state tracker.
|
|
126
141
|
this.unreferencedNodesState = new Map();
|
|
127
142
|
// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one
|
|
@@ -255,7 +270,7 @@ class GarbageCollector {
|
|
|
255
270
|
}
|
|
256
271
|
gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
|
|
257
272
|
}
|
|
258
|
-
this.
|
|
273
|
+
this.previousGCDataFromLastRun = { gcNodes };
|
|
259
274
|
});
|
|
260
275
|
// Get the GC details for each node from the GC state in the base summary. This is returned in getBaseGCDetails
|
|
261
276
|
// which the caller uses to initialize each node's GC state.
|
|
@@ -367,11 +382,11 @@ class GarbageCollector {
|
|
|
367
382
|
*/
|
|
368
383
|
summarize() {
|
|
369
384
|
var _a;
|
|
370
|
-
if (!this.shouldRunGC || this.
|
|
385
|
+
if (!this.shouldRunGC || this.previousGCDataFromLastRun === undefined) {
|
|
371
386
|
return;
|
|
372
387
|
}
|
|
373
388
|
const gcState = { gcNodes: {} };
|
|
374
|
-
for (const [nodeId, outboundRoutes] of Object.entries(this.
|
|
389
|
+
for (const [nodeId, outboundRoutes] of Object.entries(this.previousGCDataFromLastRun.gcNodes)) {
|
|
375
390
|
gcState.gcNodes[nodeId] = {
|
|
376
391
|
outboundRoutes,
|
|
377
392
|
unreferencedTimestampMs: (_a = this.unreferencedNodesState.get(nodeId)) === null || _a === void 0 ? void 0 : _a.unreferencedTimestampMs,
|
|
@@ -435,9 +450,9 @@ class GarbageCollector {
|
|
|
435
450
|
if (!this.shouldRunGC) {
|
|
436
451
|
return;
|
|
437
452
|
}
|
|
438
|
-
const outboundRoutes = (_a = this.
|
|
453
|
+
const outboundRoutes = (_a = this.newReferencesSinceLastRun.get(fromNodePath)) !== null && _a !== void 0 ? _a : [];
|
|
439
454
|
outboundRoutes.push(toNodePath);
|
|
440
|
-
this.
|
|
455
|
+
this.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);
|
|
441
456
|
// If the node that got referenced is inactive, log an event as that may indicate use-after-delete.
|
|
442
457
|
this.logIfInactive("Revived", toNodePath);
|
|
443
458
|
}
|
|
@@ -467,8 +482,8 @@ class GarbageCollector {
|
|
|
467
482
|
* @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.
|
|
468
483
|
*/
|
|
469
484
|
updateCurrentState(gcData, gcResult, currentReferenceTimestampMs) {
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
485
|
+
this.previousGCDataFromLastRun = garbage_collector_1.cloneGCData(gcData);
|
|
486
|
+
this.newReferencesSinceLastRun.clear();
|
|
472
487
|
// Iterate through the referenced nodes and stop tracking if they were unreferenced before.
|
|
473
488
|
for (const nodeId of gcResult.referencedNodeIds) {
|
|
474
489
|
const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
|
|
@@ -511,12 +526,30 @@ class GarbageCollector {
|
|
|
511
526
|
* If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.
|
|
512
527
|
*/
|
|
513
528
|
updateStateSinceLastRun(currentGCData) {
|
|
514
|
-
// If we haven't run GC before
|
|
515
|
-
if (this.
|
|
529
|
+
// If we haven't run GC before there is nothing to do.
|
|
530
|
+
if (this.previousGCDataFromLastRun === undefined) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
// Find any references that haven't been identified correctly.
|
|
534
|
+
const missingExplicitReferences = this.findMissingExplicitReferences(currentGCData, this.previousGCDataFromLastRun, this.newReferencesSinceLastRun);
|
|
535
|
+
// The following log will be enabled once this issue is resolved:
|
|
536
|
+
// https://github.com/microsoft/FluidFramework/issues/8878.
|
|
537
|
+
if (this.mc.config.getBoolean(logUnknownOutboundReferencesKey) === true
|
|
538
|
+
&& missingExplicitReferences.length > 0) {
|
|
539
|
+
missingExplicitReferences.forEach((missingExplicitReference) => {
|
|
540
|
+
const event = {
|
|
541
|
+
eventName: "gcUnknownOutboundReferences",
|
|
542
|
+
gcNodeId: missingExplicitReference[0],
|
|
543
|
+
gcRoutes: JSON.stringify(missingExplicitReference[1]),
|
|
544
|
+
};
|
|
545
|
+
this.mc.logger.sendPerformanceEvent(event);
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
// No references were added since the last run so we don't have to update reference states of any unreferenced
|
|
549
|
+
// nodes
|
|
550
|
+
if (this.newReferencesSinceLastRun.size === 0) {
|
|
516
551
|
return;
|
|
517
552
|
}
|
|
518
|
-
// Validate that we have identified all references correctly.
|
|
519
|
-
this.validateReferenceCorrectness(currentGCData);
|
|
520
553
|
/**
|
|
521
554
|
* Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and
|
|
522
555
|
* edges that have been added since then. To do this, combine the GC data from the last run and the current
|
|
@@ -532,8 +565,8 @@ class GarbageCollector {
|
|
|
532
565
|
* which is tracked by https://github.com/microsoft/FluidFramework/issues/8470.
|
|
533
566
|
* - A new data store may have "root" DDSs already created and we don't detect them today.
|
|
534
567
|
*/
|
|
535
|
-
const gcDataSuperSet = garbage_collector_1.concatGarbageCollectionData(this.
|
|
536
|
-
this.
|
|
568
|
+
const gcDataSuperSet = garbage_collector_1.concatGarbageCollectionData(this.previousGCDataFromLastRun, currentGCData);
|
|
569
|
+
this.newReferencesSinceLastRun.forEach((outboundRoutes, sourceNodeId) => {
|
|
537
570
|
if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {
|
|
538
571
|
gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;
|
|
539
572
|
}
|
|
@@ -558,53 +591,44 @@ class GarbageCollector {
|
|
|
558
591
|
}
|
|
559
592
|
}
|
|
560
593
|
/**
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
594
|
+
* Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.
|
|
595
|
+
* The principle is that every new reference or outbound route must be notified to GC via the
|
|
596
|
+
* addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.
|
|
597
|
+
*
|
|
598
|
+
* In more simple terms:
|
|
599
|
+
* Missing Explicit References = Current References - Previous References - Explicitly Added References;
|
|
600
|
+
*
|
|
566
601
|
* @param currentGCData - The GC data (reference graph) from the current GC run.
|
|
602
|
+
* @param previousGCData - The GC data (reference graph) from the previous GC run.
|
|
603
|
+
* @param explicitReferences - New references added explicity between the previous and the current run.
|
|
604
|
+
* @returns - a list of missing explicit references
|
|
567
605
|
*/
|
|
568
|
-
|
|
569
|
-
common_utils_1.assert(
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
// Validate that the current reference graph doesn't have references that we are not already aware of. If this
|
|
591
|
-
// happens, it might indicate data corruption since we may delete objects prematurely.
|
|
592
|
-
currentReferences.forEach((route) => {
|
|
593
|
-
// Validate references for data stores only. Currently, layers below data stores don't have GC implemented
|
|
594
|
-
// so there is no guarantee their references will be notified.
|
|
595
|
-
if (this.runtime.getNodeType(route) === exports.GCNodeType.DataStore && !explicitReferences.includes(route)) {
|
|
596
|
-
/**
|
|
597
|
-
* The following log will be enabled once this issue is resolved:
|
|
598
|
-
* https://github.com/microsoft/FluidFramework/issues/8878.
|
|
599
|
-
*/
|
|
600
|
-
// We should ideally throw a data corruption error here. However, send an error for now until we have
|
|
601
|
-
// implemented sweep and have reasonable confidence in the sweep process.
|
|
602
|
-
// this.mc.logger.sendErrorEvent({
|
|
603
|
-
// eventName: "gcUnknownOutboundRoute",
|
|
604
|
-
// route,
|
|
605
|
-
// });
|
|
606
|
+
findMissingExplicitReferences(currentGCData, previousGCData, explicitReferences) {
|
|
607
|
+
common_utils_1.assert(previousGCData !== undefined, 0x2b7);
|
|
608
|
+
const currentGraph = Object.entries(currentGCData.gcNodes);
|
|
609
|
+
const missingExplicitReferences = [];
|
|
610
|
+
currentGraph.forEach(([nodeId, currentOutboundRoutes]) => {
|
|
611
|
+
var _a, _b;
|
|
612
|
+
const previousRoutes = (_a = previousGCData.gcNodes[nodeId]) !== null && _a !== void 0 ? _a : [];
|
|
613
|
+
const explicitRoutes = (_b = explicitReferences.get(nodeId)) !== null && _b !== void 0 ? _b : [];
|
|
614
|
+
const missingExplicitRoutes = [];
|
|
615
|
+
currentOutboundRoutes.forEach((route) => {
|
|
616
|
+
const isBlobOrDataStoreRoute = this.runtime.getNodeType(route) === exports.GCNodeType.Blob ||
|
|
617
|
+
this.runtime.getNodeType(route) === exports.GCNodeType.DataStore;
|
|
618
|
+
// Ignore implicitly added DDS routes to their parent datastores
|
|
619
|
+
const notRouteFromDDSToParentDataStore = !nodeId.startsWith(route);
|
|
620
|
+
if (isBlobOrDataStoreRoute &&
|
|
621
|
+
notRouteFromDDSToParentDataStore &&
|
|
622
|
+
(!previousRoutes.includes(route) && !explicitRoutes.includes(route))) {
|
|
623
|
+
missingExplicitRoutes.push(route);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
if (missingExplicitRoutes.length > 0) {
|
|
627
|
+
missingExplicitReferences.push([nodeId, missingExplicitRoutes]);
|
|
606
628
|
}
|
|
607
629
|
});
|
|
630
|
+
// Ideally missingExplicitReferences should always have a size 0
|
|
631
|
+
return missingExplicitReferences;
|
|
608
632
|
}
|
|
609
633
|
/**
|
|
610
634
|
* Generates the stats of a garbage collection run from the given results of the run. Also, logs any pending events
|