@fluidframework/container-runtime 0.51.0-43124 → 0.51.3
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 +31 -31
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +61 -144
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.js +1 -1
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +3 -5
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +3 -4
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +116 -0
- package/dist/garbageCollection.d.ts.map +1 -0
- package/dist/garbageCollection.js +148 -0
- package/dist/garbageCollection.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/pendingStateManager.d.ts +0 -1
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/pendingStateManager.js +0 -36
- package/dist/pendingStateManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +31 -31
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +62 -145
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.js +1 -1
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +3 -5
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +3 -4
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +116 -0
- package/lib/garbageCollection.d.ts.map +1 -0
- package/lib/garbageCollection.js +144 -0
- package/lib/garbageCollection.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/pendingStateManager.d.ts +0 -1
- package/lib/pendingStateManager.d.ts.map +1 -1
- package/lib/pendingStateManager.js +0 -36
- package/lib/pendingStateManager.js.map +1 -1
- package/package.json +11 -11
- package/src/containerRuntime.ts +89 -188
- package/src/dataStoreContext.ts +1 -1
- package/src/dataStores.ts +5 -5
- package/src/garbageCollection.ts +269 -0
- package/src/index.ts +1 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +0 -43
|
@@ -11,9 +11,10 @@ import { IContainerRuntime, IContainerRuntimeEvents } from "@fluidframework/cont
|
|
|
11
11
|
import { TypedEventEmitter } from "@fluidframework/common-utils";
|
|
12
12
|
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
13
13
|
import { IClientDetails, IDocumentMessage, IQuorum, ISequencedDocumentMessage, ISignalMessage, ISummaryConfiguration, ISummaryTree, ITree, MessageType } from "@fluidframework/protocol-definitions";
|
|
14
|
-
import { FlushMode, IFluidDataStoreContextDetached, IFluidDataStoreRegistry, NamedFluidDataStoreRegistryEntries, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
14
|
+
import { FlushMode, IFluidDataStoreContextDetached, IFluidDataStoreRegistry, IGarbageCollectionData, NamedFluidDataStoreRegistryEntries, ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
|
|
15
15
|
import { IPendingLocalState } from "./pendingStateManager";
|
|
16
16
|
import { SubmitSummaryResult, ISubmitSummaryOptions, ISummarizer, ISummarizerInternalsProvider, ISummarizerOptions, ISummarizerRuntime } from "./summarizerTypes";
|
|
17
|
+
import { IGarbageCollectionRuntime, IGCStats, IUsedStateStats } from "./garbageCollection";
|
|
17
18
|
export declare enum ContainerMessageType {
|
|
18
19
|
FluidDataStoreOp = "component",
|
|
19
20
|
Attach = "attach",
|
|
@@ -31,17 +32,6 @@ export interface ContainerRuntimeMessage {
|
|
|
31
32
|
contents: any;
|
|
32
33
|
type: ContainerMessageType;
|
|
33
34
|
}
|
|
34
|
-
/** The statistics of a garbage collection run */
|
|
35
|
-
export interface IGCStats {
|
|
36
|
-
/** Total number of nodes in the GC graph */
|
|
37
|
-
totalNodes: number;
|
|
38
|
-
/** Number of nodes that have been marked as deleted */
|
|
39
|
-
deletedNodes: number;
|
|
40
|
-
/** Total number of data stores in the GC graph */
|
|
41
|
-
totalDataStores: number;
|
|
42
|
-
/** Number of data stores that have been marked as deleted */
|
|
43
|
-
deletedDataStores: number;
|
|
44
|
-
}
|
|
45
35
|
export interface IGCRuntimeOptions {
|
|
46
36
|
disableGC?: boolean;
|
|
47
37
|
/**
|
|
@@ -130,7 +120,7 @@ export declare const agentSchedulerId = "_scheduler";
|
|
|
130
120
|
* Represents the runtime of the container. Contains helper functions/state of the container.
|
|
131
121
|
* It will define the store level mappings.
|
|
132
122
|
*/
|
|
133
|
-
export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents> implements IContainerRuntime, IRuntime, ISummarizerRuntime, ISummarizerInternalsProvider {
|
|
123
|
+
export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents> implements IContainerRuntime, IGarbageCollectionRuntime, IRuntime, ISummarizerRuntime, ISummarizerInternalsProvider {
|
|
134
124
|
private readonly context;
|
|
135
125
|
private readonly registry;
|
|
136
126
|
private readonly runtimeOptions;
|
|
@@ -202,12 +192,9 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
202
192
|
private readonly scheduleManager;
|
|
203
193
|
private readonly blobManager;
|
|
204
194
|
private readonly pendingStateManager;
|
|
195
|
+
private readonly garbageCollector;
|
|
205
196
|
private readonly chunkMap;
|
|
206
197
|
private readonly dataStores;
|
|
207
|
-
private readonly currentGCVersion;
|
|
208
|
-
private latestSummaryGCVersion;
|
|
209
|
-
private readonly shouldRunGC;
|
|
210
|
-
private readonly shouldRunSweep;
|
|
211
198
|
/**
|
|
212
199
|
* True if generating summaries with isolated channels is
|
|
213
200
|
* explicitly disabled. This only affects how summaries are written,
|
|
@@ -217,8 +204,6 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
217
204
|
/** The message in the metadata of the base summary this container is loaded from. */
|
|
218
205
|
private readonly baseSummaryMessage;
|
|
219
206
|
private static get defaultFlushMode();
|
|
220
|
-
private get gcEnabled();
|
|
221
|
-
get gcTestMode(): boolean;
|
|
222
207
|
private get summarizer();
|
|
223
208
|
private constructor();
|
|
224
209
|
dispose(error?: Error): void;
|
|
@@ -234,7 +219,6 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
234
219
|
* @param request - Request made to the handler.
|
|
235
220
|
*/
|
|
236
221
|
resolveHandle(request: IRequest): Promise<IResponse>;
|
|
237
|
-
private get shouldWriteMetadata();
|
|
238
222
|
private formMetadata;
|
|
239
223
|
/**
|
|
240
224
|
* Retrieves the runtime for a data store if it's referenced as per the initially summary that it is loaded with.
|
|
@@ -304,11 +288,6 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
304
288
|
*/
|
|
305
289
|
createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree;
|
|
306
290
|
getAbsoluteUrl(relativeUrl: string): Promise<string | undefined>;
|
|
307
|
-
/**
|
|
308
|
-
* Runs garbage collection and udpates the reference / used state of the nodes in the container.
|
|
309
|
-
* @returns the number of data stores that have been marked as unreferenced.
|
|
310
|
-
*/
|
|
311
|
-
collectGarbage(logger: ITelemetryLogger, fullGC?: boolean): Promise<IGCStats>;
|
|
312
291
|
private summarizeInternal;
|
|
313
292
|
/**
|
|
314
293
|
* Returns a summary of the runtime at the current sequence number.
|
|
@@ -322,11 +301,36 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
322
301
|
trackState?: boolean;
|
|
323
302
|
/** True to run garbage collection before summarizing; defaults to true */
|
|
324
303
|
runGC?: boolean;
|
|
325
|
-
/** True to generate full GC data
|
|
304
|
+
/** True to generate full GC data */
|
|
326
305
|
fullGC?: boolean;
|
|
327
|
-
/** True to run GC sweep phase after the mark phase
|
|
306
|
+
/** True to run GC sweep phase after the mark phase */
|
|
328
307
|
runSweep?: boolean;
|
|
329
308
|
}): Promise<ISummaryTreeWithStats>;
|
|
309
|
+
/**
|
|
310
|
+
* Implementation of IGarbageCollectionRuntime::getGCData.
|
|
311
|
+
* Generates and returns the GC data for this container.
|
|
312
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data.
|
|
313
|
+
*/
|
|
314
|
+
getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
|
|
315
|
+
/**
|
|
316
|
+
* Implementation of IGarbageCollectionRuntime::updateUsedRoutes.
|
|
317
|
+
* After GC has run, called to notify this container's nodes of routes that are used in it.
|
|
318
|
+
* @param usedRoutes - The routes that are used in all nodes in this Container.
|
|
319
|
+
* @returns the statistics of the used state of the data stores.
|
|
320
|
+
*/
|
|
321
|
+
updateUsedRoutes(usedRoutes: string[]): IUsedStateStats;
|
|
322
|
+
/**
|
|
323
|
+
* Runs garbage collection and udpates the reference / used state of the nodes in the container.
|
|
324
|
+
* @returns the statistics of the garbage collection run.
|
|
325
|
+
*/
|
|
326
|
+
collectGarbage(options: {
|
|
327
|
+
/** Logger to use for logging GC events */
|
|
328
|
+
logger?: ITelemetryLogger;
|
|
329
|
+
/** True to run GC sweep phase after the mark phase */
|
|
330
|
+
runSweep?: boolean;
|
|
331
|
+
/** True to generate full GC data */
|
|
332
|
+
fullGC?: boolean;
|
|
333
|
+
}): Promise<IGCStats>;
|
|
330
334
|
/**
|
|
331
335
|
* Generates the summary tree, uploads it to storage, and then submits the summarize op.
|
|
332
336
|
* This is intended to be called by the summarizer, since it is the implementation of
|
|
@@ -367,10 +371,6 @@ export declare class ContainerRuntime extends TypedEventEmitter<IContainerRuntim
|
|
|
367
371
|
* @returns downloaded snapshot's reference sequence number
|
|
368
372
|
*/
|
|
369
373
|
private refreshLatestSummaryAckFromServer;
|
|
370
|
-
/**
|
|
371
|
-
* Updates the summary GC version as per the metadata blob in given snapshot.
|
|
372
|
-
*/
|
|
373
|
-
private updateSummaryGCVersionFromSnapshot;
|
|
374
374
|
private fetchSnapshotFromStorage;
|
|
375
375
|
getPendingLocalState(): IPendingLocalState | undefined;
|
|
376
376
|
readonly summarizeOnDemand: ISummarizer["summarizeOnDemand"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRuntime.d.ts","sourceRoot":"","sources":["../src/containerRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAA0B,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EACH,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,mBAAmB,EACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EAEb,QAAQ,EACR,gBAAgB,EAChB,uBAAuB,EACvB,WAAW,EACX,cAAc,EACjB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACH,iBAAiB,EACjB,uBAAuB,EAC1B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAGH,iBAAiB,EAEpB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,EAAE,uBAAuB,EAAmB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"containerRuntime.d.ts","sourceRoot":"","sources":["../src/containerRuntime.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAA0B,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EACH,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,S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E,WAAW,CAAC,kBAAkB,CAAC,CAa/D;CACL"}
|
package/dist/containerRuntime.js
CHANGED
|
@@ -10,7 +10,6 @@ const common_utils_1 = require("@fluidframework/common-utils");
|
|
|
10
10
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
11
11
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
12
12
|
const container_utils_1 = require("@fluidframework/container-utils");
|
|
13
|
-
const garbage_collector_1 = require("@fluidframework/garbage-collector");
|
|
14
13
|
const protocol_base_1 = require("@fluidframework/protocol-base");
|
|
15
14
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
16
15
|
const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
|
|
@@ -33,6 +32,7 @@ const orderedClientElection_1 = require("./orderedClientElection");
|
|
|
33
32
|
const summarizerClientElection_1 = require("./summarizerClientElection");
|
|
34
33
|
const throttler_1 = require("./throttler");
|
|
35
34
|
const runWhileConnectedCoordinator_1 = require("./runWhileConnectedCoordinator");
|
|
35
|
+
const garbageCollection_1 = require("./garbageCollection");
|
|
36
36
|
var ContainerMessageType;
|
|
37
37
|
(function (ContainerMessageType) {
|
|
38
38
|
// An op to be delivered to store
|
|
@@ -58,14 +58,6 @@ const DefaultSummaryConfiguration = {
|
|
|
58
58
|
// the min of the two will be chosen
|
|
59
59
|
maxAckWaitTime: 120000,
|
|
60
60
|
};
|
|
61
|
-
/** This is the current version of garbage collection */
|
|
62
|
-
const GCVersion = 1;
|
|
63
|
-
// Local storage key to turn GC on / off.
|
|
64
|
-
const runGCKey = "FluidRunGC";
|
|
65
|
-
// Local storage key to turn GC test mode on / off.
|
|
66
|
-
const gcTestModeKey = "FluidGCTestMode";
|
|
67
|
-
// Local storage key to turn GC sweep on / off.
|
|
68
|
-
const runSweepKey = "FluidRunSweep";
|
|
69
61
|
// Local storage key to set the default flush mode to TurnBased
|
|
70
62
|
const turnBasedFlushModeKey = "FluidFlushModeTurnBased";
|
|
71
63
|
function isRuntimeMessage(message) {
|
|
@@ -256,7 +248,7 @@ exports.agentSchedulerId = "_scheduler";
|
|
|
256
248
|
*/
|
|
257
249
|
class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
258
250
|
constructor(context, registry, metadata, electedSummarizerData, chunks, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, requestHandler, _storage) {
|
|
259
|
-
var _a, _b, _c, _d
|
|
251
|
+
var _a, _b, _c, _d;
|
|
260
252
|
super();
|
|
261
253
|
this.context = context;
|
|
262
254
|
this.registry = registry;
|
|
@@ -279,8 +271,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
279
271
|
this._disposed = false;
|
|
280
272
|
this.dirtyContainer = false;
|
|
281
273
|
this.emitDirtyDocumentEvent = true;
|
|
282
|
-
// The current GC version that this container is running.
|
|
283
|
-
this.currentGCVersion = GCVersion;
|
|
284
274
|
/**
|
|
285
275
|
* Used to apply stashed ops at their reference sequence number.
|
|
286
276
|
* Normal op processing is synchronous, but applying stashed ops is async since the
|
|
@@ -335,31 +325,14 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
335
325
|
}
|
|
336
326
|
};
|
|
337
327
|
this.baseSummaryMessage = metadata === null || metadata === void 0 ? void 0 : metadata.message;
|
|
338
|
-
/**
|
|
339
|
-
* gcFeature in metadata is introduced with v1 in the metadata blob. Forced to 0/disallowed before that.
|
|
340
|
-
* For existing documents, we get this value from the metadata blob.
|
|
341
|
-
* For new documents, we get this value based on the gcAllowed flag in runtimeOptions.
|
|
342
|
-
*/
|
|
343
|
-
const prevSummaryGCVersion = existing ? summaryFormat_1.getGCVersion(metadata) : undefined;
|
|
344
|
-
// Default to false for now.
|
|
345
|
-
this.latestSummaryGCVersion = prevSummaryGCVersion !== null && prevSummaryGCVersion !== void 0 ? prevSummaryGCVersion : (this.runtimeOptions.gcOptions.gcAllowed === true ? this.currentGCVersion : 0);
|
|
346
|
-
// Whether GC should run or not. Can override with localStorage flag.
|
|
347
|
-
this.shouldRunGC = (_a = localStorageFeatureGates_1.getLocalStorageFeatureGate(runGCKey)) !== null && _a !== void 0 ? _a : (
|
|
348
|
-
// GC must be enabled for the document.
|
|
349
|
-
this.gcEnabled
|
|
350
|
-
// Must not be disabled by runtime option.
|
|
351
|
-
&& !this.runtimeOptions.gcOptions.disableGC);
|
|
352
|
-
// Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with
|
|
353
|
-
// localStorage flag.
|
|
354
|
-
this.shouldRunSweep = this.shouldRunGC &&
|
|
355
|
-
((_b = localStorageFeatureGates_1.getLocalStorageFeatureGate(runSweepKey)) !== null && _b !== void 0 ? _b : this.runtimeOptions.gcOptions.runSweep === true);
|
|
356
328
|
// Default to false (enabled).
|
|
357
|
-
this.disableIsolatedChannels = (
|
|
329
|
+
this.disableIsolatedChannels = (_a = this.runtimeOptions.summaryOptions.disableIsolatedChannels) !== null && _a !== void 0 ? _a : false;
|
|
358
330
|
this._connected = this.context.connected;
|
|
359
331
|
this.chunkMap = new Map(chunks);
|
|
360
332
|
this.IFluidHandleContext = new containerHandleContext_1.ContainerFluidHandleContext("", this);
|
|
361
333
|
this.IFluidSerializer = new runtime_utils_1.FluidSerializer(this.IFluidHandleContext);
|
|
362
334
|
this._logger = telemetry_utils_1.ChildLogger.create(this.logger, "ContainerRuntime");
|
|
335
|
+
this.garbageCollector = garbageCollection_1.GarbageCollector.create(this, this.runtimeOptions.gcOptions, (unusedRoutes) => this.dataStores.deleteUnusedRoutes(unusedRoutes), this._logger, existing, metadata);
|
|
363
336
|
const loadedFromSequenceNumber = this.deltaManager.initialSequenceNumber;
|
|
364
337
|
this.summarizerNode = runtime_utils_1.createRootSummarizerNodeWithGC(telemetry_utils_1.ChildLogger.create(this.logger, "SummarizerNode"),
|
|
365
338
|
// Summarize function to call when summarize is called. Summarizer node always tracks summary state.
|
|
@@ -374,8 +347,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
374
347
|
// Must set to true to throw on any data stores failure that was too severe to be handled.
|
|
375
348
|
// We also are not decoding the base summaries at the root.
|
|
376
349
|
throwOnFailure: true,
|
|
377
|
-
// If GC
|
|
378
|
-
gcDisabled: !this.shouldRunGC,
|
|
350
|
+
// If GC should not run, let the summarizer node know so that it does not track GC state.
|
|
351
|
+
gcDisabled: !this.garbageCollector.shouldRunGC,
|
|
379
352
|
// The max duration for which objects can be unreferenced before they are eligible for deletion.
|
|
380
353
|
maxUnreferencedDurationMs: this.runtimeOptions.gcOptions.maxUnreferencedDurationMs,
|
|
381
354
|
});
|
|
@@ -401,7 +374,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
401
374
|
this._logger.sendTelemetryEvent({ eventName: "SummariesDisabled" });
|
|
402
375
|
}
|
|
403
376
|
else {
|
|
404
|
-
const maxOpsSinceLastSummary = (
|
|
377
|
+
const maxOpsSinceLastSummary = (_b = this.runtimeOptions.summaryOptions.maxOpsSinceLastSummary) !== null && _b !== void 0 ? _b : 7000;
|
|
405
378
|
const defaultAction = () => {
|
|
406
379
|
if (this.summaryCollection.opsSinceLastAck > maxOpsSinceLastSummary) {
|
|
407
380
|
this.logger.sendErrorEvent({ eventName: "SummaryStatus:Behind" });
|
|
@@ -421,7 +394,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
421
394
|
const orderedClientLogger = telemetry_utils_1.ChildLogger.create(this.logger, "OrderedClientElection");
|
|
422
395
|
const orderedClientCollection = new orderedClientElection_1.OrderedClientCollection(orderedClientLogger, this.context.deltaManager, this.context.quorum);
|
|
423
396
|
const orderedClientElectionForSummarizer = new orderedClientElection_1.OrderedClientElection(orderedClientLogger, orderedClientCollection, electedSummarizerData !== null && electedSummarizerData !== void 0 ? electedSummarizerData : this.context.deltaManager.lastSequenceNumber, summarizerClientElection_1.SummarizerClientElection.isClientEligible);
|
|
424
|
-
const summarizerClientElectionEnabled = (
|
|
397
|
+
const summarizerClientElectionEnabled = (_c = localStorageFeatureGates_1.getLocalStorageFeatureGate("summarizerClientElection")) !== null && _c !== void 0 ? _c : ((_d = this.runtimeOptions.summaryOptions) === null || _d === void 0 ? void 0 : _d.summarizerClientElection) === true;
|
|
425
398
|
this.summarizerClientElection = new summarizerClientElection_1.SummarizerClientElection(orderedClientLogger, this.summaryCollection, orderedClientElectionForSummarizer, maxOpsSinceLastSummary, summarizerClientElectionEnabled);
|
|
426
399
|
if (this.context.clientDetails.type === summarizerClientElection_1.summarizerClientType) {
|
|
427
400
|
this._summarizer = new summarizer_1.Summarizer("/_summarizer", this /* ISummarizerRuntime */, () => this.summaryConfiguration, this /* ISummarizerInternalsProvider */, this.IFluidHandleContext, this.summaryCollection, async (runtime) => runWhileConnectedCoordinator_1.RunWhileConnectedCoordinator.create(runtime));
|
|
@@ -620,16 +593,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
620
593
|
static get defaultFlushMode() {
|
|
621
594
|
return localStorageFeatureGates_1.getLocalStorageFeatureGate(turnBasedFlushModeKey) ? runtime_definitions_1.FlushMode.TurnBased : runtime_definitions_1.FlushMode.Immediate;
|
|
622
595
|
}
|
|
623
|
-
// Tells whether GC is enabled for this document or not. If the summaryGCVersion is > 0, GC is enabled.
|
|
624
|
-
get gcEnabled() {
|
|
625
|
-
return this.latestSummaryGCVersion > 0;
|
|
626
|
-
}
|
|
627
|
-
// Tells whether this container is running in GC test mode. If so, unreferenced data stores are immediately
|
|
628
|
-
// deleted as soon as GC runs.
|
|
629
|
-
get gcTestMode() {
|
|
630
|
-
var _a, _b;
|
|
631
|
-
return (_a = localStorageFeatureGates_1.getLocalStorageFeatureGate(gcTestModeKey)) !== null && _a !== void 0 ? _a : ((_b = this.runtimeOptions.gcOptions) === null || _b === void 0 ? void 0 : _b.runGCInTestMode) === true;
|
|
632
|
-
}
|
|
633
596
|
get summarizer() {
|
|
634
597
|
common_utils_1.assert(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
|
|
635
598
|
return this._summarizer;
|
|
@@ -722,7 +685,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
722
685
|
}
|
|
723
686
|
else if (requestParser.pathParts.length > 0) {
|
|
724
687
|
/**
|
|
725
|
-
* If GC
|
|
688
|
+
* If GC should run and this an external app request with "externalRequest" header, we need to return
|
|
726
689
|
* an error if the data store being requested is marked as unreferenced as per the data store's initial
|
|
727
690
|
* summary.
|
|
728
691
|
*
|
|
@@ -730,7 +693,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
730
693
|
* and marked as unreferenced by GC. Returning an error will fail to load the data store for the app.
|
|
731
694
|
*/
|
|
732
695
|
const wait = typeof ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.wait) === "boolean" ? request.headers.wait : undefined;
|
|
733
|
-
const dataStore = ((_b = request.headers) === null || _b === void 0 ? void 0 : _b.externalRequest) && this.shouldRunGC
|
|
696
|
+
const dataStore = ((_b = request.headers) === null || _b === void 0 ? void 0 : _b.externalRequest) && this.garbageCollector.shouldRunGC
|
|
734
697
|
? await this.getDataStoreIfInitiallyReferenced(id, wait)
|
|
735
698
|
: await this.getDataStore(id, wait);
|
|
736
699
|
const subRequest = requestParser.createSubRequest(1);
|
|
@@ -745,19 +708,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
745
708
|
return runtime_utils_1.exceptionToResponse(error);
|
|
746
709
|
}
|
|
747
710
|
}
|
|
748
|
-
get shouldWriteMetadata() {
|
|
749
|
-
// We need the metadata blob if either isolated channels are enabled
|
|
750
|
-
// or GC is enabled at the document level.
|
|
751
|
-
return !this.disableIsolatedChannels || this.gcEnabled;
|
|
752
|
-
}
|
|
753
711
|
formMetadata() {
|
|
754
712
|
var _a;
|
|
755
713
|
return {
|
|
756
714
|
summaryFormatVersion: 1,
|
|
757
715
|
disableIsolatedChannels: this.disableIsolatedChannels || undefined,
|
|
758
|
-
|
|
759
|
-
// we always write the current GC version as that is what is used to generate the GC data.
|
|
760
|
-
gcFeature: this.gcEnabled ? this.currentGCVersion : this.latestSummaryGCVersion,
|
|
716
|
+
gcFeature: this.garbageCollector.gcSummaryFeatureVersion,
|
|
761
717
|
// The last message processed at the time of summary. If there are no messages, nothing has changed from
|
|
762
718
|
// the base summary we loaded from. So, use the message from its metadata blob.
|
|
763
719
|
message: (_a = summaryFormat_1.extractSummaryMetadataMessage(this.deltaManager.lastMessage)) !== null && _a !== void 0 ? _a : this.baseSummaryMessage,
|
|
@@ -788,8 +744,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
788
744
|
* @deprecated - Use summarize to get summary of the container runtime.
|
|
789
745
|
*/
|
|
790
746
|
async snapshot() {
|
|
791
|
-
if (this.shouldRunGC) {
|
|
792
|
-
await this.collectGarbage(this.logger, true /* fullGC */);
|
|
747
|
+
if (this.garbageCollector.shouldRunGC) {
|
|
748
|
+
await this.collectGarbage({ logger: this.logger, fullGC: true /* fullGC */ });
|
|
793
749
|
}
|
|
794
750
|
const root = { entries: [] };
|
|
795
751
|
const entries = await this.dataStores.snapshot();
|
|
@@ -799,9 +755,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
799
755
|
else {
|
|
800
756
|
root.entries.push(new protocol_base_1.TreeTreeEntry(runtime_definitions_1.channelsTreeName, { entries }));
|
|
801
757
|
}
|
|
802
|
-
|
|
803
|
-
root.entries.push(new protocol_base_1.BlobTreeEntry(summaryFormat_1.metadataBlobName, JSON.stringify(this.formMetadata())));
|
|
804
|
-
}
|
|
758
|
+
root.entries.push(new protocol_base_1.BlobTreeEntry(summaryFormat_1.metadataBlobName, JSON.stringify(this.formMetadata())));
|
|
805
759
|
if (this.chunkMap.size > 0) {
|
|
806
760
|
root.entries.push(new protocol_base_1.BlobTreeEntry(summaryFormat_1.chunksBlobName, JSON.stringify([...this.chunkMap])));
|
|
807
761
|
}
|
|
@@ -809,9 +763,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
809
763
|
}
|
|
810
764
|
addContainerBlobsToSummary(summaryTree) {
|
|
811
765
|
var _a;
|
|
812
|
-
|
|
813
|
-
runtime_utils_1.addBlobToSummary(summaryTree, summaryFormat_1.metadataBlobName, JSON.stringify(this.formMetadata()));
|
|
814
|
-
}
|
|
766
|
+
runtime_utils_1.addBlobToSummary(summaryTree, summaryFormat_1.metadataBlobName, JSON.stringify(this.formMetadata()));
|
|
815
767
|
if (this.chunkMap.size > 0) {
|
|
816
768
|
const content = JSON.stringify([...this.chunkMap]);
|
|
817
769
|
runtime_utils_1.addBlobToSummary(summaryTree, summaryFormat_1.chunksBlobName, content);
|
|
@@ -1022,7 +974,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1022
974
|
}
|
|
1023
975
|
async createRootDataStore(pkg, rootDataStoreId) {
|
|
1024
976
|
const fluidDataStore = await this._createDataStore(pkg, true /* isRoot */, rootDataStoreId);
|
|
1025
|
-
fluidDataStore.
|
|
977
|
+
fluidDataStore.bindToContext();
|
|
1026
978
|
return fluidDataStore;
|
|
1027
979
|
}
|
|
1028
980
|
createDetachedRootDataStore(pkg, rootDataStoreId) {
|
|
@@ -1034,7 +986,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1034
986
|
async _createDataStoreWithProps(pkg, props, id = uuid_1.v4(), isRoot = false) {
|
|
1035
987
|
const fluidDataStore = await this.dataStores._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id, isRoot, props).realize();
|
|
1036
988
|
if (isRoot) {
|
|
1037
|
-
fluidDataStore.
|
|
989
|
+
fluidDataStore.bindToContext();
|
|
1038
990
|
}
|
|
1039
991
|
return fluidDataStore;
|
|
1040
992
|
}
|
|
@@ -1127,42 +1079,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1127
1079
|
}
|
|
1128
1080
|
return this.context.getAbsoluteUrl(relativeUrl);
|
|
1129
1081
|
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Runs garbage collection and udpates the reference / used state of the nodes in the container.
|
|
1132
|
-
* @returns the number of data stores that have been marked as unreferenced.
|
|
1133
|
-
*/
|
|
1134
|
-
async collectGarbage(logger, fullGC = false) {
|
|
1135
|
-
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
|
|
1136
|
-
var _a;
|
|
1137
|
-
const gcStats = {};
|
|
1138
|
-
// Get the container's GC data and run GC on the reference graph in it.
|
|
1139
|
-
const gcData = await this.dataStores.getGCData(fullGC);
|
|
1140
|
-
const { referencedNodeIds, deletedNodeIds } = garbage_collector_1.runGarbageCollection(gcData.gcNodes, ["/"], this.logger);
|
|
1141
|
-
// Update our summarizer node's used routes. Updating used routes in summarizer node before
|
|
1142
|
-
// summarizing is required and asserted by the the summarizer node. We are the root and are
|
|
1143
|
-
// always referenced, so the used routes is only self-route (empty string).
|
|
1144
|
-
this.summarizerNode.updateUsedRoutes([""]);
|
|
1145
|
-
// Remove this node's route ("/") and notify data stores of routes that are used in it.
|
|
1146
|
-
const usedRoutes = referencedNodeIds.filter((id) => { return id !== "/"; });
|
|
1147
|
-
const { dataStoreCount, unusedDataStoreCount } = this.dataStores.updateUsedRoutes(usedRoutes, (_a =
|
|
1148
|
-
// For now, we use the timestamp of the last op for gcTimestamp. However, there can be cases where
|
|
1149
|
-
// we don't have an op (on demand summaries for instance). In those cases, we will use the timestamp
|
|
1150
|
-
// of this client's connection - https://github.com/microsoft/FluidFramework/issues/7152.
|
|
1151
|
-
this.deltaManager.lastMessage) === null || _a === void 0 ? void 0 : _a.timestamp);
|
|
1152
|
-
// Update stats to be reported in the peformance event.
|
|
1153
|
-
gcStats.deletedNodes = deletedNodeIds.length;
|
|
1154
|
-
gcStats.totalNodes = referencedNodeIds.length + deletedNodeIds.length;
|
|
1155
|
-
gcStats.deletedDataStores = unusedDataStoreCount;
|
|
1156
|
-
gcStats.totalDataStores = dataStoreCount;
|
|
1157
|
-
// If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios
|
|
1158
|
-
// involving access to deleted data.
|
|
1159
|
-
if (this.gcTestMode) {
|
|
1160
|
-
this.dataStores.deleteUnusedRoutes(deletedNodeIds);
|
|
1161
|
-
}
|
|
1162
|
-
event.end(gcStats);
|
|
1163
|
-
return gcStats;
|
|
1164
|
-
}, { end: true, cancel: "error" });
|
|
1165
|
-
}
|
|
1166
1082
|
async summarizeInternal(fullTree, trackState) {
|
|
1167
1083
|
const summarizeResult = await this.dataStores.summarize(fullTree, trackState);
|
|
1168
1084
|
let pathPartsForChildren;
|
|
@@ -1178,14 +1094,47 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1178
1094
|
* Returns a summary of the runtime at the current sequence number.
|
|
1179
1095
|
*/
|
|
1180
1096
|
async summarize(options) {
|
|
1181
|
-
const { summaryLogger, fullTree = false, trackState = true, runGC = true, fullGC
|
|
1097
|
+
const { summaryLogger, fullTree = false, trackState = true, runGC = true, runSweep, fullGC } = options;
|
|
1182
1098
|
if (runGC) {
|
|
1183
|
-
await this.collectGarbage(summaryLogger, fullGC);
|
|
1099
|
+
await this.collectGarbage({ logger: summaryLogger, runSweep, fullGC });
|
|
1184
1100
|
}
|
|
1185
1101
|
const summarizeResult = await this.summarizerNode.summarize(fullTree, trackState);
|
|
1186
1102
|
common_utils_1.assert(summarizeResult.summary.type === 1 /* Tree */, 0x12f /* "Container Runtime's summarize should always return a tree" */);
|
|
1187
1103
|
return summarizeResult;
|
|
1188
1104
|
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Implementation of IGarbageCollectionRuntime::getGCData.
|
|
1107
|
+
* Generates and returns the GC data for this container.
|
|
1108
|
+
* @param fullGC - true to bypass optimizations and force full generation of GC data.
|
|
1109
|
+
*/
|
|
1110
|
+
async getGCData(fullGC) {
|
|
1111
|
+
return this.dataStores.getGCData(fullGC);
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Implementation of IGarbageCollectionRuntime::updateUsedRoutes.
|
|
1115
|
+
* After GC has run, called to notify this container's nodes of routes that are used in it.
|
|
1116
|
+
* @param usedRoutes - The routes that are used in all nodes in this Container.
|
|
1117
|
+
* @returns the statistics of the used state of the data stores.
|
|
1118
|
+
*/
|
|
1119
|
+
updateUsedRoutes(usedRoutes) {
|
|
1120
|
+
var _a;
|
|
1121
|
+
// Update our summarizer node's used routes. Updating used routes in summarizer node before
|
|
1122
|
+
// summarizing is required and asserted by the the summarizer node. We are the root and are
|
|
1123
|
+
// always referenced, so the used routes is only self-route (empty string).
|
|
1124
|
+
this.summarizerNode.updateUsedRoutes([""]);
|
|
1125
|
+
return this.dataStores.updateUsedRoutes(usedRoutes, (_a =
|
|
1126
|
+
// For now, we use the timestamp of the last op for gcTimestamp. However, there can be cases where
|
|
1127
|
+
// we don't have an op (on demand summaries for instance). In those cases, we will use the timestamp
|
|
1128
|
+
// of this client's connection - https://github.com/microsoft/FluidFramework/issues/7152.
|
|
1129
|
+
this.deltaManager.lastMessage) === null || _a === void 0 ? void 0 : _a.timestamp);
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Runs garbage collection and udpates the reference / used state of the nodes in the container.
|
|
1133
|
+
* @returns the statistics of the garbage collection run.
|
|
1134
|
+
*/
|
|
1135
|
+
async collectGarbage(options) {
|
|
1136
|
+
return this.garbageCollector.collectGarbage(options);
|
|
1137
|
+
}
|
|
1189
1138
|
/**
|
|
1190
1139
|
* Generates the summary tree, uploads it to storage, and then submits the summarize op.
|
|
1191
1140
|
* This is intended to be called by the summarizer, since it is the implementation of
|
|
@@ -1245,23 +1194,17 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1245
1194
|
if (!continueResult.continue) {
|
|
1246
1195
|
return { stage: "base", referenceSequenceNumber: summaryRefSeqNum, error: continueResult.error };
|
|
1247
1196
|
}
|
|
1248
|
-
// If the GC version that this container is loaded from differs from the current GC version that this
|
|
1249
|
-
// container is running, we need to regenerate the GC data and run full summary. This is used to handle
|
|
1250
|
-
// scenarios where we upgrade the GC version because we cannot trust the data from the previous GC version.
|
|
1251
|
-
let forceRegenerateData = false;
|
|
1252
|
-
if (this.gcEnabled && this.latestSummaryGCVersion !== this.currentGCVersion) {
|
|
1253
|
-
forceRegenerateData = true;
|
|
1254
|
-
}
|
|
1255
1197
|
const trace = common_utils_1.Trace.start();
|
|
1256
1198
|
let summarizeResult;
|
|
1257
1199
|
try {
|
|
1258
1200
|
summarizeResult = await this.summarize({
|
|
1259
1201
|
summaryLogger,
|
|
1260
|
-
|
|
1202
|
+
// If the GC version changed since the last summary was submitted, we need to regenerate summary by
|
|
1203
|
+
// running full summary. This is used to handle scenarios where we upgrade the GC version because we
|
|
1204
|
+
// cannot trust the data from the previous GC version anymore.
|
|
1205
|
+
fullTree: fullTree || this.garbageCollector.hasGCVersionChanged,
|
|
1261
1206
|
trackState: true,
|
|
1262
|
-
runGC: this.shouldRunGC,
|
|
1263
|
-
fullGC: this.runtimeOptions.gcOptions.runFullGC || forceRegenerateData,
|
|
1264
|
-
runSweep: this.shouldRunSweep,
|
|
1207
|
+
runGC: this.garbageCollector.shouldRunGC,
|
|
1265
1208
|
});
|
|
1266
1209
|
}
|
|
1267
1210
|
catch (error) {
|
|
@@ -1512,18 +1455,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1512
1455
|
eventName: "RefreshLatestSummaryGetSnapshot",
|
|
1513
1456
|
fetchLatest: false,
|
|
1514
1457
|
}), readAndParseBlob, summaryLogger);
|
|
1515
|
-
//
|
|
1516
|
-
|
|
1517
|
-
// If the summary was tracked by this client, it was the one that generated the summary in the first place.
|
|
1518
|
-
// Update the summaryGCVersion to the currentGCVersion of this client.
|
|
1519
|
-
if (result.wasSummaryTracked) {
|
|
1520
|
-
this.latestSummaryGCVersion = this.currentGCVersion;
|
|
1521
|
-
return;
|
|
1522
|
-
}
|
|
1523
|
-
// If the summary was not tracked by this client, update summaryGCVersion from the snapshot that was used
|
|
1524
|
-
// to update the latest summary.
|
|
1525
|
-
await this.updateSummaryGCVersionFromSnapshot(result.snapshot);
|
|
1526
|
-
}
|
|
1458
|
+
// Notify the garbage collector so it can update its latest summary state.
|
|
1459
|
+
await this.garbageCollector.latestSummaryStateRefreshed(result, readAndParseBlob);
|
|
1527
1460
|
}
|
|
1528
1461
|
/**
|
|
1529
1462
|
* Fetches the latest snapshot from storage and uses it to refresh SummarizerNode's
|
|
@@ -1539,26 +1472,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
|
|
|
1539
1472
|
const readAndParseBlob = async (id) => driver_utils_1.readAndParse(this.storage, id);
|
|
1540
1473
|
const snapshotRefSeq = await runtime_utils_1.seqFromTree(snapshot, readAndParseBlob);
|
|
1541
1474
|
const result = await this.summarizerNode.refreshLatestSummary(undefined, snapshotRefSeq, async () => snapshot, readAndParseBlob, summaryLogger);
|
|
1542
|
-
//
|
|
1543
|
-
|
|
1544
|
-
// Since there is not proposal handle for this summary, it should not have been tracked.
|
|
1545
|
-
common_utils_1.assert(!result.wasSummaryTracked, 0x1fd /* "Summary without proposal handle should not have been tracked" */);
|
|
1546
|
-
// Update summaryGCVersion from the snapshot that was used to update the latest summary.
|
|
1547
|
-
await this.updateSummaryGCVersionFromSnapshot(result.snapshot);
|
|
1548
|
-
}
|
|
1475
|
+
// Notify the garbage collector so it can update its latest summary state.
|
|
1476
|
+
await this.garbageCollector.latestSummaryStateRefreshed(result, readAndParseBlob);
|
|
1549
1477
|
return snapshotRefSeq;
|
|
1550
1478
|
}
|
|
1551
|
-
/**
|
|
1552
|
-
* Updates the summary GC version as per the metadata blob in given snapshot.
|
|
1553
|
-
*/
|
|
1554
|
-
async updateSummaryGCVersionFromSnapshot(snapshot) {
|
|
1555
|
-
common_utils_1.assert(this.gcEnabled, 0x25a /* "GC version should not be updated when GC is disabled" */);
|
|
1556
|
-
const metadataBlobId = snapshot.blobs[summaryFormat_1.metadataBlobName];
|
|
1557
|
-
if (metadataBlobId) {
|
|
1558
|
-
const metadata = await driver_utils_1.readAndParse(this.storage, metadataBlobId);
|
|
1559
|
-
this.latestSummaryGCVersion = summaryFormat_1.getGCVersion(metadata);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
1479
|
async fetchSnapshotFromStorage(versionId, logger, event) {
|
|
1563
1480
|
return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, event, async (perfEvent) => {
|
|
1564
1481
|
const stats = {};
|