@fluidframework/container-runtime 0.55.0-48551 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containerRuntime.d.ts +3 -12
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +22 -38
- package/dist/containerRuntime.js.map +1 -1
- package/dist/dataStoreContext.d.ts +42 -29
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +27 -49
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStores.d.ts +2 -1
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/dataStores.js +74 -16
- package/dist/dataStores.js.map +1 -1
- package/dist/garbageCollection.d.ts +22 -9
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +55 -32
- package/dist/garbageCollection.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -17
- 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/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +2 -9
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/summaryFormat.d.ts.map +1 -1
- package/dist/summaryFormat.js +2 -1
- package/dist/summaryFormat.js.map +1 -1
- package/dist/summaryGenerator.d.ts +0 -5
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js.map +1 -1
- package/garbageCollection.md +33 -0
- package/lib/containerRuntime.d.ts +3 -12
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +23 -39
- package/lib/containerRuntime.js.map +1 -1
- package/lib/dataStoreContext.d.ts +42 -29
- package/lib/dataStoreContext.d.ts.map +1 -1
- package/lib/dataStoreContext.js +25 -47
- package/lib/dataStoreContext.js.map +1 -1
- package/lib/dataStores.d.ts +2 -1
- package/lib/dataStores.d.ts.map +1 -1
- package/lib/dataStores.js +75 -17
- package/lib/dataStores.js.map +1 -1
- package/lib/garbageCollection.d.ts +22 -9
- package/lib/garbageCollection.d.ts.map +1 -1
- package/lib/garbageCollection.js +55 -32
- package/lib/garbageCollection.js.map +1 -1
- package/lib/index.d.ts +6 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -6
- 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/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +2 -9
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/summaryFormat.d.ts.map +1 -1
- package/lib/summaryFormat.js +2 -1
- package/lib/summaryFormat.js.map +1 -1
- package/lib/summaryGenerator.d.ts +0 -5
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js.map +1 -1
- package/package.json +15 -15
- package/src/containerRuntime.ts +36 -42
- package/src/dataStoreContext.ts +76 -122
- package/src/dataStores.ts +75 -48
- package/src/garbageCollection.ts +62 -35
- package/src/index.ts +51 -6
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +2 -7
- package/src/summaryFormat.ts +2 -1
- package/src/summaryGenerator.ts +0 -5
package/src/dataStoreContext.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
IAudience,
|
|
15
15
|
IDeltaManager,
|
|
16
|
-
ContainerWarning,
|
|
17
16
|
BindState,
|
|
18
17
|
AttachState,
|
|
19
18
|
ILoaderOptions,
|
|
@@ -120,6 +119,36 @@ interface FluidDataStoreMessage {
|
|
|
120
119
|
type: string;
|
|
121
120
|
}
|
|
122
121
|
|
|
122
|
+
/** Properties necessary for creating a FluidDataStoreContext */
|
|
123
|
+
export interface IFluidDataStoreContextProps {
|
|
124
|
+
readonly id: string;
|
|
125
|
+
readonly runtime: ContainerRuntime;
|
|
126
|
+
readonly storage: IDocumentStorageService;
|
|
127
|
+
readonly scope: FluidObject;
|
|
128
|
+
readonly createSummarizerNodeFn: CreateChildSummarizerNodeFn;
|
|
129
|
+
readonly writeGCDataAtRoot: boolean;
|
|
130
|
+
readonly disableIsolatedChannels: boolean;
|
|
131
|
+
readonly pkg?: Readonly<string[]>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Properties necessary for creating a local FluidDataStoreContext */
|
|
135
|
+
export interface ILocalFluidDataStoreContextProps extends IFluidDataStoreContextProps {
|
|
136
|
+
readonly pkg: Readonly<string[]> | undefined;
|
|
137
|
+
readonly snapshotTree: ISnapshotTree | undefined;
|
|
138
|
+
readonly isRootDataStore: boolean | undefined;
|
|
139
|
+
readonly bindChannelFn: (channel: IFluidDataStoreChannel) => void;
|
|
140
|
+
/**
|
|
141
|
+
* @deprecated 0.16 Issue #1635, #3631
|
|
142
|
+
*/
|
|
143
|
+
readonly createProps?: any;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Properties necessary for creating a remote FluidDataStoreContext */
|
|
147
|
+
export interface IRemoteFluidDataStoreContextProps extends IFluidDataStoreContextProps {
|
|
148
|
+
readonly snapshotTree: ISnapshotTree | string | undefined;
|
|
149
|
+
readonly getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase | undefined>;
|
|
150
|
+
}
|
|
151
|
+
|
|
123
152
|
/**
|
|
124
153
|
* Represents the context for the store. This context is passed to the store runtime.
|
|
125
154
|
*/
|
|
@@ -186,15 +215,6 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
|
|
|
186
215
|
return (await this.getInitialSnapshotDetails()).isRootDataStore;
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
protected get disableIsolatedChannels(): boolean {
|
|
190
|
-
return this._containerRuntime.disableIsolatedChannels;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/** Tells whether GC data will be written at the root of the summary tree. If so, data store should not write it. */
|
|
194
|
-
protected get writeGCDataAtRoot(): boolean {
|
|
195
|
-
return this._containerRuntime.writeGCDataAtRoot;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
218
|
protected registry: IFluidDataStoreRegistry | undefined;
|
|
199
219
|
|
|
200
220
|
protected detachedRuntimeCreation = false;
|
|
@@ -214,23 +234,34 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
|
|
|
214
234
|
// if it realizes after GC is run.
|
|
215
235
|
private lastUsedState: { usedRoutes: string[], gcTimestamp?: number } | undefined;
|
|
216
236
|
|
|
237
|
+
public readonly id: string;
|
|
238
|
+
private readonly _containerRuntime: ContainerRuntime;
|
|
239
|
+
public readonly storage: IDocumentStorageService;
|
|
240
|
+
public readonly scope: FluidObject;
|
|
241
|
+
private readonly writeGCDataAtRoot: boolean;
|
|
242
|
+
protected readonly disableIsolatedChannels: boolean;
|
|
243
|
+
protected pkg?: readonly string[];
|
|
244
|
+
|
|
217
245
|
constructor(
|
|
218
|
-
|
|
219
|
-
public readonly id: string,
|
|
246
|
+
props: IFluidDataStoreContextProps,
|
|
220
247
|
private readonly existing: boolean,
|
|
221
|
-
public readonly storage: IDocumentStorageService,
|
|
222
|
-
public readonly scope: FluidObject | FluidObject,
|
|
223
|
-
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
224
248
|
private bindState: BindState,
|
|
225
249
|
public readonly isLocalDataStore: boolean,
|
|
226
|
-
|
|
227
|
-
protected pkg?: readonly string[],
|
|
250
|
+
bindChannelFn: (channel: IFluidDataStoreChannel) => void,
|
|
228
251
|
) {
|
|
229
252
|
super();
|
|
230
253
|
|
|
254
|
+
this._containerRuntime = props.runtime;
|
|
255
|
+
this.id = props.id;
|
|
256
|
+
this.storage = props.storage;
|
|
257
|
+
this.scope = props.scope;
|
|
258
|
+
this.writeGCDataAtRoot = props.writeGCDataAtRoot;
|
|
259
|
+
this.disableIsolatedChannels = props.disableIsolatedChannels;
|
|
260
|
+
this.pkg = props.pkg;
|
|
261
|
+
|
|
231
262
|
// URIs use slashes as delimiters. Handles use URIs.
|
|
232
263
|
// Thus having slashes in types almost guarantees trouble down the road!
|
|
233
|
-
assert(id.indexOf("/") === -1, 0x13a /* `Data store ID contains slash: ${id}` */);
|
|
264
|
+
assert(this.id.indexOf("/") === -1, 0x13a /* `Data store ID contains slash: ${id}` */);
|
|
234
265
|
|
|
235
266
|
this._attachState = this.containerRuntime.attachState !== AttachState.Detached && this.existing ?
|
|
236
267
|
this.containerRuntime.attachState : AttachState.Detached;
|
|
@@ -239,14 +270,14 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
|
|
|
239
270
|
assert(this.bindState === BindState.NotBound, 0x13b /* "datastore context is already in bound state" */);
|
|
240
271
|
this.bindState = BindState.Binding;
|
|
241
272
|
assert(this.channel !== undefined, 0x13c /* "undefined channel on datastore context" */);
|
|
242
|
-
|
|
273
|
+
bindChannelFn(this.channel);
|
|
243
274
|
this.bindState = BindState.Bound;
|
|
244
275
|
};
|
|
245
276
|
|
|
246
277
|
const thisSummarizeInternal =
|
|
247
278
|
async (fullTree: boolean, trackState: boolean) => this.summarizeInternal(fullTree, trackState);
|
|
248
279
|
|
|
249
|
-
this.summarizerNode =
|
|
280
|
+
this.summarizerNode = props.createSummarizerNodeFn(
|
|
250
281
|
thisSummarizeInternal,
|
|
251
282
|
async (fullGC?: boolean) => this.getGCDataInternal(fullGC),
|
|
252
283
|
async () => this.getBaseGCDetails(),
|
|
@@ -581,11 +612,6 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
|
|
|
581
612
|
return this._containerRuntime.submitDataStoreSignal(this.id, type, content);
|
|
582
613
|
}
|
|
583
614
|
|
|
584
|
-
// @deprecated Warnings are being deprecated
|
|
585
|
-
public raiseContainerWarning(warning: ContainerWarning): void {
|
|
586
|
-
this.containerRuntime.raiseContainerWarning(warning);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
615
|
protected bindRuntime(channel: IFluidDataStoreChannel) {
|
|
590
616
|
if (this.channel) {
|
|
591
617
|
throw new Error("Runtime already bound");
|
|
@@ -702,37 +728,25 @@ export abstract class FluidDataStoreContext extends TypedEventEmitter<IFluidData
|
|
|
702
728
|
}
|
|
703
729
|
}
|
|
704
730
|
|
|
705
|
-
export class
|
|
731
|
+
export class RemoteFluidDataStoreContext extends FluidDataStoreContext {
|
|
706
732
|
private isRootDataStore: boolean | undefined;
|
|
733
|
+
private readonly initSnapshotValue: ISnapshotTree | string | undefined;
|
|
707
734
|
private readonly baseGCDetailsP: Promise<IGarbageCollectionDetailsBase>;
|
|
708
735
|
|
|
709
|
-
constructor(
|
|
710
|
-
id: string,
|
|
711
|
-
private readonly initSnapshotValue: ISnapshotTree | string | undefined,
|
|
712
|
-
getBaseGCDetails: () => Promise<IGarbageCollectionDetailsBase | undefined>,
|
|
713
|
-
runtime: ContainerRuntime,
|
|
714
|
-
storage: IDocumentStorageService,
|
|
715
|
-
scope: FluidObject,
|
|
716
|
-
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
717
|
-
pkg?: string[],
|
|
718
|
-
) {
|
|
736
|
+
constructor(props: IRemoteFluidDataStoreContextProps) {
|
|
719
737
|
super(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
true,
|
|
723
|
-
storage,
|
|
724
|
-
scope,
|
|
725
|
-
createSummarizerNode,
|
|
738
|
+
props,
|
|
739
|
+
true /* existing */,
|
|
726
740
|
BindState.Bound,
|
|
727
|
-
false
|
|
741
|
+
false /* isLocalDataStore */,
|
|
728
742
|
() => {
|
|
729
743
|
throw new Error("Already attached");
|
|
730
744
|
},
|
|
731
|
-
pkg,
|
|
732
745
|
);
|
|
733
746
|
|
|
747
|
+
this.initSnapshotValue = props.snapshotTree;
|
|
734
748
|
this.baseGCDetailsP = new LazyPromise<IGarbageCollectionDetailsBase>(async () => {
|
|
735
|
-
return (await getBaseGCDetails()) ?? {};
|
|
749
|
+
return (await props.getBaseGCDetails()) ?? {};
|
|
736
750
|
});
|
|
737
751
|
}
|
|
738
752
|
|
|
@@ -831,32 +845,20 @@ export class RemotedFluidDataStoreContext extends FluidDataStoreContext {
|
|
|
831
845
|
* Base class for detached & attached context classes
|
|
832
846
|
*/
|
|
833
847
|
export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
storage: IDocumentStorageService,
|
|
839
|
-
scope: FluidObject,
|
|
840
|
-
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
841
|
-
bindChannel: (channel: IFluidDataStoreChannel) => void,
|
|
842
|
-
private readonly snapshotTree: ISnapshotTree | undefined,
|
|
843
|
-
protected isRootDataStore: boolean | undefined,
|
|
844
|
-
/**
|
|
845
|
-
* @deprecated 0.16 Issue #1635, #3631
|
|
846
|
-
*/
|
|
847
|
-
public readonly createProps?: any,
|
|
848
|
-
) {
|
|
848
|
+
private readonly snapshotTree: ISnapshotTree | undefined;
|
|
849
|
+
protected isRootDataStore: boolean | undefined;
|
|
850
|
+
|
|
851
|
+
constructor(props: ILocalFluidDataStoreContextProps) {
|
|
849
852
|
super(
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
snapshotTree
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
pkg);
|
|
853
|
+
props,
|
|
854
|
+
props.snapshotTree !== undefined ? true : false /* existing */,
|
|
855
|
+
props.snapshotTree ? BindState.Bound : BindState.NotBound,
|
|
856
|
+
true /* isLocalDataStore */,
|
|
857
|
+
props.bindChannelFn,
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
this.snapshotTree = props.snapshotTree;
|
|
861
|
+
this.isRootDataStore = props.isRootDataStore;
|
|
860
862
|
this.attachListeners();
|
|
861
863
|
}
|
|
862
864
|
|
|
@@ -892,11 +894,6 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
892
894
|
);
|
|
893
895
|
addBlobToSummary(summarizeResult, dataStoreAttributesBlobName, JSON.stringify(attributes));
|
|
894
896
|
|
|
895
|
-
// Add GC data to the summary if it's not written at the root.
|
|
896
|
-
if (!this.writeGCDataAtRoot) {
|
|
897
|
-
addBlobToSummary(summarizeResult, gcBlobKey, JSON.stringify(this.summarizerNode.getGCSummaryDetails()));
|
|
898
|
-
}
|
|
899
|
-
|
|
900
897
|
// Attach message needs the summary in ITree format. Convert the ISummaryTree into an ITree.
|
|
901
898
|
const snapshot = convertSummaryTreeToITree(summarizeResult.summary);
|
|
902
899
|
|
|
@@ -970,32 +967,8 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
|
|
|
970
967
|
* Runtime is created using data store factory that is associated with this context.
|
|
971
968
|
*/
|
|
972
969
|
export class LocalFluidDataStoreContext extends LocalFluidDataStoreContextBase {
|
|
973
|
-
constructor(
|
|
974
|
-
|
|
975
|
-
pkg: string[] | undefined,
|
|
976
|
-
runtime: ContainerRuntime,
|
|
977
|
-
storage: IDocumentStorageService,
|
|
978
|
-
scope: FluidObject & FluidObject,
|
|
979
|
-
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
980
|
-
bindChannel: (channel: IFluidDataStoreChannel) => void,
|
|
981
|
-
snapshotTree: ISnapshotTree | undefined,
|
|
982
|
-
isRootDataStore: boolean | undefined,
|
|
983
|
-
/**
|
|
984
|
-
* @deprecated 0.16 Issue #1635, #3631
|
|
985
|
-
*/
|
|
986
|
-
createProps?: any,
|
|
987
|
-
) {
|
|
988
|
-
super(
|
|
989
|
-
id,
|
|
990
|
-
pkg,
|
|
991
|
-
runtime,
|
|
992
|
-
storage,
|
|
993
|
-
scope,
|
|
994
|
-
createSummarizerNode,
|
|
995
|
-
bindChannel,
|
|
996
|
-
snapshotTree,
|
|
997
|
-
isRootDataStore,
|
|
998
|
-
createProps);
|
|
970
|
+
constructor(props: ILocalFluidDataStoreContextProps) {
|
|
971
|
+
super(props);
|
|
999
972
|
}
|
|
1000
973
|
}
|
|
1001
974
|
|
|
@@ -1009,27 +982,8 @@ export class LocalDetachedFluidDataStoreContext
|
|
|
1009
982
|
extends LocalFluidDataStoreContextBase
|
|
1010
983
|
implements IFluidDataStoreContextDetached
|
|
1011
984
|
{
|
|
1012
|
-
constructor(
|
|
1013
|
-
|
|
1014
|
-
pkg: Readonly<string[]>,
|
|
1015
|
-
runtime: ContainerRuntime,
|
|
1016
|
-
storage: IDocumentStorageService,
|
|
1017
|
-
scope: FluidObject & FluidObject,
|
|
1018
|
-
createSummarizerNode: CreateChildSummarizerNodeFn,
|
|
1019
|
-
bindChannel: (channel: IFluidDataStoreChannel) => void,
|
|
1020
|
-
isRootDataStore: boolean,
|
|
1021
|
-
) {
|
|
1022
|
-
super(
|
|
1023
|
-
id,
|
|
1024
|
-
pkg,
|
|
1025
|
-
runtime,
|
|
1026
|
-
storage,
|
|
1027
|
-
scope,
|
|
1028
|
-
createSummarizerNode,
|
|
1029
|
-
bindChannel,
|
|
1030
|
-
undefined,
|
|
1031
|
-
isRootDataStore,
|
|
1032
|
-
);
|
|
985
|
+
constructor(props: ILocalFluidDataStoreContextProps) {
|
|
986
|
+
super(props);
|
|
1033
987
|
this.detachedRuntimeCreation = true;
|
|
1034
988
|
}
|
|
1035
989
|
|
package/src/dataStores.ts
CHANGED
|
@@ -44,7 +44,7 @@ import { DataStoreContexts } from "./dataStoreContexts";
|
|
|
44
44
|
import { ContainerRuntime } from "./containerRuntime";
|
|
45
45
|
import {
|
|
46
46
|
FluidDataStoreContext,
|
|
47
|
-
|
|
47
|
+
RemoteFluidDataStoreContext,
|
|
48
48
|
LocalFluidDataStoreContext,
|
|
49
49
|
createAttributesBlob,
|
|
50
50
|
LocalDetachedFluidDataStoreContext,
|
|
@@ -117,6 +117,7 @@ export class DataStores implements IDisposable {
|
|
|
117
117
|
getBaseGCDetails: () => Promise<Map<string, IGarbageCollectionDetailsBase>>,
|
|
118
118
|
private readonly dataStoreChanged: (id: string) => void,
|
|
119
119
|
private readonly aliasMap: Map<string, string>,
|
|
120
|
+
private readonly writeGCDataAtRoot: boolean,
|
|
120
121
|
private readonly contexts: DataStoreContexts = new DataStoreContexts(baseLogger),
|
|
121
122
|
) {
|
|
122
123
|
this.logger = ChildLogger.create(baseLogger);
|
|
@@ -150,30 +151,41 @@ export class DataStores implements IDisposable {
|
|
|
150
151
|
}
|
|
151
152
|
// If we have a detached container, then create local data store contexts.
|
|
152
153
|
if (this.runtime.attachState !== AttachState.Detached) {
|
|
153
|
-
dataStoreContext = new
|
|
154
|
-
key,
|
|
155
|
-
value,
|
|
156
|
-
async () => dataStoreBaseGCDetails(key),
|
|
157
|
-
this.runtime,
|
|
158
|
-
this.runtime.storage,
|
|
159
|
-
this.runtime.scope,
|
|
160
|
-
this.getCreateChildSummarizerNodeFn(
|
|
154
|
+
dataStoreContext = new RemoteFluidDataStoreContext({
|
|
155
|
+
id: key,
|
|
156
|
+
snapshotTree: value,
|
|
157
|
+
getBaseGCDetails: async () => dataStoreBaseGCDetails(key),
|
|
158
|
+
runtime: this.runtime,
|
|
159
|
+
storage: this.runtime.storage,
|
|
160
|
+
scope: this.runtime.scope,
|
|
161
|
+
createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(
|
|
162
|
+
key,
|
|
163
|
+
{ type: CreateSummarizerNodeSource.FromSummary },
|
|
164
|
+
),
|
|
165
|
+
writeGCDataAtRoot: this.writeGCDataAtRoot,
|
|
166
|
+
disableIsolatedChannels: this.runtime.disableIsolatedChannels,
|
|
167
|
+
});
|
|
161
168
|
} else {
|
|
162
169
|
if (typeof value !== "object") {
|
|
163
170
|
throw new Error("Snapshot should be there to load from!!");
|
|
164
171
|
}
|
|
165
172
|
const snapshotTree = value;
|
|
166
|
-
dataStoreContext = new LocalFluidDataStoreContext(
|
|
167
|
-
key,
|
|
168
|
-
undefined,
|
|
169
|
-
this.runtime,
|
|
170
|
-
this.runtime.storage,
|
|
171
|
-
this.runtime.scope,
|
|
172
|
-
this.getCreateChildSummarizerNodeFn(
|
|
173
|
-
|
|
173
|
+
dataStoreContext = new LocalFluidDataStoreContext({
|
|
174
|
+
id: key,
|
|
175
|
+
pkg: undefined,
|
|
176
|
+
runtime: this.runtime,
|
|
177
|
+
storage: this.runtime.storage,
|
|
178
|
+
scope: this.runtime.scope,
|
|
179
|
+
createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(
|
|
180
|
+
key,
|
|
181
|
+
{ type: CreateSummarizerNodeSource.FromSummary },
|
|
182
|
+
),
|
|
183
|
+
bindChannelFn: (cr: IFluidDataStoreChannel) => this.bindFluidDataStore(cr),
|
|
174
184
|
snapshotTree,
|
|
175
|
-
undefined,
|
|
176
|
-
|
|
185
|
+
isRootDataStore: undefined,
|
|
186
|
+
writeGCDataAtRoot: this.writeGCDataAtRoot,
|
|
187
|
+
disableIsolatedChannels: this.runtime.disableIsolatedChannels,
|
|
188
|
+
});
|
|
177
189
|
}
|
|
178
190
|
this.contexts.addBoundOrRemoted(dataStoreContext);
|
|
179
191
|
}
|
|
@@ -224,17 +236,17 @@ export class DataStores implements IDisposable {
|
|
|
224
236
|
}
|
|
225
237
|
|
|
226
238
|
// Include the type of attach message which is the pkg of the store to be
|
|
227
|
-
// used by
|
|
239
|
+
// used by RemoteFluidDataStoreContext in case it is not in the snapshot.
|
|
228
240
|
const pkg = [attachMessage.type];
|
|
229
|
-
const
|
|
230
|
-
attachMessage.id,
|
|
241
|
+
const remoteFluidDataStoreContext = new RemoteFluidDataStoreContext({
|
|
242
|
+
id: attachMessage.id,
|
|
231
243
|
snapshotTree,
|
|
232
244
|
// New data stores begin with empty GC details since GC hasn't run on them yet.
|
|
233
|
-
async () => { return {}; },
|
|
234
|
-
this.runtime,
|
|
235
|
-
new BlobCacheStorageService(this.runtime.storage, flatBlobs),
|
|
236
|
-
this.runtime.scope,
|
|
237
|
-
this.getCreateChildSummarizerNodeFn(
|
|
245
|
+
getBaseGCDetails: async () => { return {}; },
|
|
246
|
+
runtime: this.runtime,
|
|
247
|
+
storage: new BlobCacheStorageService(this.runtime.storage, flatBlobs),
|
|
248
|
+
scope: this.runtime.scope,
|
|
249
|
+
createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(
|
|
238
250
|
attachMessage.id,
|
|
239
251
|
{
|
|
240
252
|
type: CreateSummarizerNodeSource.FromAttach,
|
|
@@ -246,10 +258,14 @@ export class DataStores implements IDisposable {
|
|
|
246
258
|
this.runtime.disableIsolatedChannels,
|
|
247
259
|
)],
|
|
248
260
|
},
|
|
249
|
-
}
|
|
250
|
-
|
|
261
|
+
},
|
|
262
|
+
),
|
|
263
|
+
writeGCDataAtRoot: this.writeGCDataAtRoot,
|
|
264
|
+
disableIsolatedChannels: this.runtime.disableIsolatedChannels,
|
|
265
|
+
pkg,
|
|
266
|
+
});
|
|
251
267
|
|
|
252
|
-
this.contexts.addBoundOrRemoted(
|
|
268
|
+
this.contexts.addBoundOrRemoted(remoteFluidDataStoreContext);
|
|
253
269
|
}
|
|
254
270
|
|
|
255
271
|
public processAliasMessage(
|
|
@@ -322,33 +338,44 @@ export class DataStores implements IDisposable {
|
|
|
322
338
|
isRoot: boolean,
|
|
323
339
|
id = uuid()): IFluidDataStoreContextDetached
|
|
324
340
|
{
|
|
325
|
-
const context = new LocalDetachedFluidDataStoreContext(
|
|
341
|
+
const context = new LocalDetachedFluidDataStoreContext({
|
|
326
342
|
id,
|
|
327
343
|
pkg,
|
|
328
|
-
this.runtime,
|
|
329
|
-
this.runtime.storage,
|
|
330
|
-
this.runtime.scope,
|
|
331
|
-
this.getCreateChildSummarizerNodeFn(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
344
|
+
runtime: this.runtime,
|
|
345
|
+
storage: this.runtime.storage,
|
|
346
|
+
scope: this.runtime.scope,
|
|
347
|
+
createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(
|
|
348
|
+
id,
|
|
349
|
+
{ type: CreateSummarizerNodeSource.Local },
|
|
350
|
+
),
|
|
351
|
+
bindChannelFn: (cr: IFluidDataStoreChannel) => this.bindFluidDataStore(cr),
|
|
352
|
+
snapshotTree: undefined,
|
|
353
|
+
isRootDataStore: isRoot,
|
|
354
|
+
writeGCDataAtRoot: this.writeGCDataAtRoot,
|
|
355
|
+
disableIsolatedChannels: this.runtime.disableIsolatedChannels,
|
|
356
|
+
});
|
|
335
357
|
this.contexts.addUnbound(context);
|
|
336
358
|
return context;
|
|
337
359
|
}
|
|
338
360
|
|
|
339
361
|
public _createFluidDataStoreContext(pkg: string[], id: string, isRoot: boolean, props?: any) {
|
|
340
|
-
const context = new LocalFluidDataStoreContext(
|
|
362
|
+
const context = new LocalFluidDataStoreContext({
|
|
341
363
|
id,
|
|
342
364
|
pkg,
|
|
343
|
-
this.runtime,
|
|
344
|
-
this.runtime.storage,
|
|
345
|
-
this.runtime.scope,
|
|
346
|
-
this.getCreateChildSummarizerNodeFn(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
365
|
+
runtime: this.runtime,
|
|
366
|
+
storage: this.runtime.storage,
|
|
367
|
+
scope: this.runtime.scope,
|
|
368
|
+
createSummarizerNodeFn: this.getCreateChildSummarizerNodeFn(
|
|
369
|
+
id,
|
|
370
|
+
{ type: CreateSummarizerNodeSource.Local },
|
|
371
|
+
),
|
|
372
|
+
bindChannelFn: (cr: IFluidDataStoreChannel) => this.bindFluidDataStore(cr),
|
|
373
|
+
snapshotTree: undefined,
|
|
374
|
+
isRootDataStore: isRoot,
|
|
375
|
+
writeGCDataAtRoot: this.writeGCDataAtRoot,
|
|
376
|
+
disableIsolatedChannels: this.runtime.disableIsolatedChannels,
|
|
377
|
+
createProps: props,
|
|
378
|
+
});
|
|
352
379
|
this.contexts.addUnbound(context);
|
|
353
380
|
return context;
|
|
354
381
|
}
|
package/src/garbageCollection.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { assert, LazyPromise, Timer } from "@fluidframework/common-utils";
|
|
8
8
|
import { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
9
|
+
import { ClientSessionExpiredError } from "@fluidframework/container-utils";
|
|
9
10
|
import {
|
|
10
11
|
cloneGCData,
|
|
11
12
|
concatGarbageCollectionStates,
|
|
@@ -53,12 +54,14 @@ export const gcTreeKey = "gc";
|
|
|
53
54
|
// They prefix for GC blobs in the GC tree in summary.
|
|
54
55
|
export const gcBlobPrefix = "__gc";
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
+
// Feature gate key to turn GC on / off.
|
|
57
58
|
const runGCKey = "Fluid.GarbageCollection.RunGC";
|
|
58
|
-
//
|
|
59
|
+
// Feature gate key to turn GC test mode on / off.
|
|
59
60
|
const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
|
|
60
|
-
//
|
|
61
|
+
// Feature gate key to turn GC sweep on / off.
|
|
61
62
|
const runSweepKey = "Fluid.GarbageCollection.RunSweep";
|
|
63
|
+
// Feature gate key to write GC data at the root of the summary tree.
|
|
64
|
+
const writeAtRootKey = "Fluid.GarbageCollection.WriteDataAtRoot";
|
|
62
65
|
|
|
63
66
|
const defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
64
67
|
|
|
@@ -98,8 +101,8 @@ export interface IGarbageCollector {
|
|
|
98
101
|
* 2. If GC is enabled, the version of GC used to generate the GC data written in a summary.
|
|
99
102
|
*/
|
|
100
103
|
readonly gcSummaryFeatureVersion: number;
|
|
101
|
-
/** Tells whether the GC
|
|
102
|
-
readonly
|
|
104
|
+
/** Tells whether the GC state in summary needs to be reset in the next summary. */
|
|
105
|
+
readonly summaryStateNeedsReset: boolean;
|
|
103
106
|
/** Tells whether GC data should be written to the root of the summary tree. */
|
|
104
107
|
readonly writeDataAtRoot: boolean;
|
|
105
108
|
/** Run garbage collection and update the reference / used state of the system. */
|
|
@@ -114,9 +117,9 @@ export interface IGarbageCollector {
|
|
|
114
117
|
latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;
|
|
115
118
|
/** Called when a node is changed. Used to detect and log when an inactive node is changed. */
|
|
116
119
|
nodeChanged(id: string): void;
|
|
117
|
-
dispose(): void;
|
|
118
120
|
/** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
|
|
119
121
|
addedOutboundReference(fromNodeId: string, toNodeId: string): void;
|
|
122
|
+
dispose(): void;
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
/**
|
|
@@ -221,13 +224,16 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
/**
|
|
224
|
-
* Tells whether the GC
|
|
227
|
+
* Tells whether the GC state needs to be reset in the next summary. We need to do this if:
|
|
228
|
+
* 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.
|
|
229
|
+
* 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.
|
|
230
|
+
* 3. The GC version in the latest summary is different from the current GC version. This can happen if:
|
|
231
|
+
* 3.1. The summary this client loaded with has data from a different GC version.
|
|
232
|
+
* 3.2. This client's latest summary was updated from a snapshot that has a different GC version.
|
|
225
233
|
*/
|
|
226
|
-
public get
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// 2. This client's latest summary was updated from a snapshot that has a different GC version.
|
|
230
|
-
return this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion;
|
|
234
|
+
public get summaryStateNeedsReset(): boolean {
|
|
235
|
+
return this.initialStateNeedsReset ||
|
|
236
|
+
(this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
/**
|
|
@@ -240,15 +246,24 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
240
246
|
private readonly mc: MonitoringContext;
|
|
241
247
|
|
|
242
248
|
/**
|
|
243
|
-
* Tells whether the GC data should be written to the root of the summary tree.
|
|
244
|
-
* 1. If `writeDataAtRoot` GC option is enabled.
|
|
245
|
-
* 2. If the base summary has the GC data written at the root. This is to support forward compatibility where when
|
|
246
|
-
* we start writing the GC data at root, older versions can detect that and write at root too.
|
|
249
|
+
* Tells whether the GC data should be written to the root of the summary tree.
|
|
247
250
|
*/
|
|
248
251
|
private _writeDataAtRoot: boolean = false;
|
|
249
252
|
public get writeDataAtRoot(): boolean {
|
|
250
253
|
return this._writeDataAtRoot;
|
|
251
|
-
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:
|
|
258
|
+
* 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after
|
|
259
|
+
* it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.
|
|
260
|
+
* 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on
|
|
261
|
+
* a document and the first time GC is enabled after is was disabled before.
|
|
262
|
+
*
|
|
263
|
+
* Note that the state needs reset only for the very first time summary is generated by this client. After that, the
|
|
264
|
+
* state will be up-to-date and this flag will be reset.
|
|
265
|
+
*/
|
|
266
|
+
private initialStateNeedsReset: boolean = false;
|
|
252
267
|
|
|
253
268
|
// The current GC version that this container is running.
|
|
254
269
|
private readonly currentGCVersion = GCVersion;
|
|
@@ -310,15 +325,9 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
310
325
|
|
|
311
326
|
// If session expiry is enabled, we need to close the container when the timeout expires
|
|
312
327
|
if (this.sessionExpiryTimeoutMs !== undefined) {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
// this.sessionExpiryTimeoutMs)),
|
|
317
|
-
// this.sessionExpiryTimeoutMs);
|
|
318
|
-
this.sessionExpiryTimer = setTimeout(() => this.closeFn({
|
|
319
|
-
errorType: "clientSessionExpiredError",
|
|
320
|
-
message: `The client has reached the expiry time of ${this.sessionExpiryTimeoutMs} ms.`,
|
|
321
|
-
}), this.sessionExpiryTimeoutMs);
|
|
328
|
+
const expiryMs = this.sessionExpiryTimeoutMs;
|
|
329
|
+
this.sessionExpiryTimer = setTimeout(() => this.closeFn(
|
|
330
|
+
new ClientSessionExpiredError(`Client session expired.`, expiryMs)), expiryMs);
|
|
322
331
|
}
|
|
323
332
|
|
|
324
333
|
// For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
|
|
@@ -342,9 +351,19 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
342
351
|
// Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
|
|
343
352
|
this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? gcOptions.runGCInTestMode === true;
|
|
344
353
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
354
|
+
/**
|
|
355
|
+
* Enable resetting initial state once the following issue is resolved:
|
|
356
|
+
* https://github.com/microsoft/FluidFramework/issues/8878.
|
|
357
|
+
* Currently, the GC tree is not written at root, so we don't know if the base snapshot contains GC tree or not.
|
|
358
|
+
*/
|
|
359
|
+
// The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't contain
|
|
360
|
+
// GC tree and GC is enabled.
|
|
361
|
+
// const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;
|
|
362
|
+
// this.initialStateNeedsReset = gcTreePresent ? !this.shouldRunGC : this.shouldRunGC;
|
|
363
|
+
|
|
364
|
+
// If `writeDataAtRoot` setting is true, write the GC data into the root of the summary tree. We do this so that
|
|
365
|
+
// the roll out can be staged. Once its rolled out everywhere, we will start writing at root by default.
|
|
366
|
+
this._writeDataAtRoot = this.mc.config.getBoolean(writeAtRootKey) ?? this.gcOptions.writeDataAtRoot === true;
|
|
348
367
|
|
|
349
368
|
// Get the GC state from the GC blob in the base snapshot. Use LazyPromise because we only want to do
|
|
350
369
|
// this once since it involves fetching blobs from storage which is expensive.
|
|
@@ -356,7 +375,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
356
375
|
// For newer documents, GC data should be present in the GC tree in the root of the snapshot.
|
|
357
376
|
const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];
|
|
358
377
|
if (gcSnapshotTree !== undefined) {
|
|
359
|
-
//
|
|
378
|
+
// If the GC tree is written at root, we should also do the same.
|
|
360
379
|
this._writeDataAtRoot = true;
|
|
361
380
|
return getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob);
|
|
362
381
|
}
|
|
@@ -488,7 +507,7 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
488
507
|
const {
|
|
489
508
|
logger = this.mc.logger,
|
|
490
509
|
runSweep = this.shouldRunSweep,
|
|
491
|
-
fullGC = this.gcOptions.runFullGC === true || this.
|
|
510
|
+
fullGC = this.gcOptions.runFullGC === true || this.summaryStateNeedsReset,
|
|
492
511
|
} = options;
|
|
493
512
|
|
|
494
513
|
return PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
|
|
@@ -582,6 +601,10 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
582
601
|
result: RefreshSummaryResult,
|
|
583
602
|
readAndParseBlob: ReadAndParseBlob,
|
|
584
603
|
): Promise<void> {
|
|
604
|
+
// After a summary is successfully submitted and ack'd by this client, the GC state should have been reset in
|
|
605
|
+
// the summary and doesn't need to be reset anymore.
|
|
606
|
+
this.initialStateNeedsReset = false;
|
|
607
|
+
|
|
585
608
|
if (!this.shouldRunGC || !result.latestSummaryUpdated) {
|
|
586
609
|
return;
|
|
587
610
|
}
|
|
@@ -791,12 +814,16 @@ export class GarbageCollector implements IGarbageCollector {
|
|
|
791
814
|
// Validate references for data stores only whose routes are of the format "/dataStoreId". Currently, layers
|
|
792
815
|
// below data stores don't have GC implemented so there is no guarantee their references will be notified.
|
|
793
816
|
if (route.split("/").length === 2 && !explicitReferences.includes(route)) {
|
|
817
|
+
/**
|
|
818
|
+
* The following log will be enabled once this issue is resolved:
|
|
819
|
+
* https://github.com/microsoft/FluidFramework/issues/8878.
|
|
820
|
+
*/
|
|
794
821
|
// We should ideally throw a data corruption error here. However, send an error for now until we have
|
|
795
822
|
// implemented sweep and have reasonable confidence in the sweep process.
|
|
796
|
-
this.mc.logger.sendErrorEvent({
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
});
|
|
823
|
+
// this.mc.logger.sendErrorEvent({
|
|
824
|
+
// eventName: "gcUnknownOutboundRoute",
|
|
825
|
+
// route,
|
|
826
|
+
// });
|
|
800
827
|
}
|
|
801
828
|
});
|
|
802
829
|
}
|