@fluidframework/container-runtime 0.58.2002 → 0.59.1000

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.
Files changed (97) hide show
  1. package/dist/blobManager.d.ts +15 -2
  2. package/dist/blobManager.d.ts.map +1 -1
  3. package/dist/blobManager.js +65 -9
  4. package/dist/blobManager.js.map +1 -1
  5. package/dist/connectionTelemetry.d.ts.map +1 -1
  6. package/dist/connectionTelemetry.js +63 -23
  7. package/dist/connectionTelemetry.js.map +1 -1
  8. package/dist/containerRuntime.d.ts +39 -7
  9. package/dist/containerRuntime.d.ts.map +1 -1
  10. package/dist/containerRuntime.js +161 -29
  11. package/dist/containerRuntime.js.map +1 -1
  12. package/dist/dataStore.js +8 -1
  13. package/dist/dataStore.js.map +1 -1
  14. package/dist/dataStoreContext.d.ts +9 -3
  15. package/dist/dataStoreContext.d.ts.map +1 -1
  16. package/dist/dataStoreContext.js +22 -6
  17. package/dist/dataStoreContext.js.map +1 -1
  18. package/dist/dataStores.d.ts +13 -5
  19. package/dist/dataStores.d.ts.map +1 -1
  20. package/dist/dataStores.js +39 -18
  21. package/dist/dataStores.js.map +1 -1
  22. package/dist/deltaScheduler.d.ts +4 -5
  23. package/dist/deltaScheduler.d.ts.map +1 -1
  24. package/dist/deltaScheduler.js +54 -35
  25. package/dist/deltaScheduler.js.map +1 -1
  26. package/dist/garbageCollection.d.ts +31 -27
  27. package/dist/garbageCollection.d.ts.map +1 -1
  28. package/dist/garbageCollection.js +76 -75
  29. package/dist/garbageCollection.js.map +1 -1
  30. package/dist/opTelemetry.d.ts +22 -0
  31. package/dist/opTelemetry.d.ts.map +1 -0
  32. package/dist/opTelemetry.js +59 -0
  33. package/dist/opTelemetry.js.map +1 -0
  34. package/dist/packageVersion.d.ts +1 -1
  35. package/dist/packageVersion.js +1 -1
  36. package/dist/packageVersion.js.map +1 -1
  37. package/dist/summarizerTypes.d.ts +9 -0
  38. package/dist/summarizerTypes.d.ts.map +1 -1
  39. package/dist/summarizerTypes.js.map +1 -1
  40. package/dist/summaryGenerator.d.ts.map +1 -1
  41. package/dist/summaryGenerator.js +1 -1
  42. package/dist/summaryGenerator.js.map +1 -1
  43. package/lib/blobManager.d.ts +15 -2
  44. package/lib/blobManager.d.ts.map +1 -1
  45. package/lib/blobManager.js +66 -10
  46. package/lib/blobManager.js.map +1 -1
  47. package/lib/connectionTelemetry.d.ts.map +1 -1
  48. package/lib/connectionTelemetry.js +63 -23
  49. package/lib/connectionTelemetry.js.map +1 -1
  50. package/lib/containerRuntime.d.ts +39 -7
  51. package/lib/containerRuntime.d.ts.map +1 -1
  52. package/lib/containerRuntime.js +163 -31
  53. package/lib/containerRuntime.js.map +1 -1
  54. package/lib/dataStore.js +8 -1
  55. package/lib/dataStore.js.map +1 -1
  56. package/lib/dataStoreContext.d.ts +9 -3
  57. package/lib/dataStoreContext.d.ts.map +1 -1
  58. package/lib/dataStoreContext.js +22 -6
  59. package/lib/dataStoreContext.js.map +1 -1
  60. package/lib/dataStores.d.ts +13 -5
  61. package/lib/dataStores.d.ts.map +1 -1
  62. package/lib/dataStores.js +39 -18
  63. package/lib/dataStores.js.map +1 -1
  64. package/lib/deltaScheduler.d.ts +4 -5
  65. package/lib/deltaScheduler.d.ts.map +1 -1
  66. package/lib/deltaScheduler.js +54 -35
  67. package/lib/deltaScheduler.js.map +1 -1
  68. package/lib/garbageCollection.d.ts +31 -27
  69. package/lib/garbageCollection.d.ts.map +1 -1
  70. package/lib/garbageCollection.js +75 -74
  71. package/lib/garbageCollection.js.map +1 -1
  72. package/lib/opTelemetry.d.ts +22 -0
  73. package/lib/opTelemetry.d.ts.map +1 -0
  74. package/lib/opTelemetry.js +55 -0
  75. package/lib/opTelemetry.js.map +1 -0
  76. package/lib/packageVersion.d.ts +1 -1
  77. package/lib/packageVersion.js +1 -1
  78. package/lib/packageVersion.js.map +1 -1
  79. package/lib/summarizerTypes.d.ts +9 -0
  80. package/lib/summarizerTypes.d.ts.map +1 -1
  81. package/lib/summarizerTypes.js.map +1 -1
  82. package/lib/summaryGenerator.d.ts.map +1 -1
  83. package/lib/summaryGenerator.js +1 -1
  84. package/lib/summaryGenerator.js.map +1 -1
  85. package/package.json +63 -19
  86. package/src/blobManager.ts +78 -11
  87. package/src/connectionTelemetry.ts +110 -19
  88. package/src/containerRuntime.ts +191 -36
  89. package/src/dataStore.ts +7 -1
  90. package/src/dataStoreContext.ts +22 -7
  91. package/src/dataStores.ts +40 -19
  92. package/src/deltaScheduler.ts +65 -39
  93. package/src/garbageCollection.ts +92 -78
  94. package/src/opTelemetry.ts +71 -0
  95. package/src/packageVersion.ts +1 -1
  96. package/src/summarizerTypes.ts +9 -0
  97. package/src/summaryGenerator.ts +9 -1
@@ -19,15 +19,28 @@ export interface IGCStats {
19
19
  nodeCount: number;
20
20
  /** The number of data stores in the container. */
21
21
  dataStoreCount: number;
22
+ /** The number of attachment blobs in the container. */
23
+ attachmentBlobCount: number;
22
24
  /** The number of unreferenced nodes in the container. */
23
25
  unrefNodeCount: number;
24
26
  /** The number of unreferenced data stores in the container. */
25
27
  unrefDataStoreCount: number;
28
+ /** The number of unreferenced attachment blobs in the container. */
29
+ unrefAttachmentBlobCount: number;
26
30
  /** The number of nodes whose reference state updated since last GC run. */
27
31
  updatedNodeCount: number;
28
32
  /** The number of data stores whose reference state updated since last GC run. */
29
33
  updatedDataStoreCount: number;
34
+ /** The number of attachment blobs whose reference state updated since last GC run. */
35
+ updatedAttachmentBlobCount: number;
30
36
  }
37
+ /** The types of GC nodes in the GC reference graph. */
38
+ export declare const GCNodeType: {
39
+ DataStore: string;
40
+ Blob: string;
41
+ Other: string;
42
+ };
43
+ export declare type GCNodeType = typeof GCNodeType[keyof typeof GCNodeType];
31
44
  /** Defines the APIs for the runtime object to be passed to the garbage collector. */
32
45
  export interface IGarbageCollectionRuntime {
33
46
  /** Before GC runs, called to notify the runtime to update any pending GC state. */
@@ -36,6 +49,12 @@ export interface IGarbageCollectionRuntime {
36
49
  getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
37
50
  /** After GC has run, called to notify the runtime of routes that are used in it. */
38
51
  updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
52
+ /** After GC has run, called to delete objects in the runtime whose routes are unused. */
53
+ deleteUnusedRoutes(unusedRoutes: string[]): void;
54
+ /** Returns a referenced timestamp to be used to track unreferenced nodes. */
55
+ getCurrentReferenceTimestampMs(): number | undefined;
56
+ /** Returns the type of the GC node. */
57
+ getNodeType(nodePath: string): GCNodeType;
39
58
  /** Called when the runtime should close because of an error. */
40
59
  closeFn(error?: ICriticalContainerError): void;
41
60
  }
@@ -64,8 +83,8 @@ export interface IGarbageCollector {
64
83
  }): Promise<IGCStats>;
65
84
  /** Summarizes the GC data and returns it as a summary tree. */
66
85
  summarize(): ISummaryTreeWithStats | undefined;
67
- /** Returns a map of each data store id to its GC details in the base summary. */
68
- getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;
86
+ /** Returns a map of each node id to its base GC details in the base summary. */
87
+ getBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;
69
88
  /** Called when the latest summary of the system has been refreshed. */
70
89
  latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;
71
90
  /** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */
@@ -79,21 +98,13 @@ export interface IGarbageCollector {
79
98
  * its state across summaries.
80
99
  */
81
100
  export declare class GarbageCollector implements IGarbageCollector {
82
- private readonly provider;
101
+ private readonly runtime;
83
102
  private readonly gcOptions;
84
- /** After GC has run, called to delete objects in the runtime whose routes are unused. */
85
- private readonly deleteUnusedRoutes;
86
103
  /** For a given node path, returns the node's package path. */
87
104
  private readonly getNodePackagePath;
88
- /**
89
- * Returns a referenced timestamp to be used to track unreferenced nodes. This is a server generated timestamp
90
- * and may not be available if there aren't any ops processed yet. If so, we skip tracking unreferenced state
91
- * such as time when node becomes unreferenced or inactive.
92
- */
93
- private readonly getCurrentReferenceTimestampMs;
94
105
  /** Returns the timestamp of the last summary generated for this container. */
95
106
  private readonly getLastSummaryTimestampMs;
96
- static create(provider: IGarbageCollectionRuntime, gcOptions: IGCRuntimeOptions, deleteUnusedRoutes: (unusedRoutes: string[]) => void, getNodePackagePath: (nodeId: string) => readonly string[] | undefined, getCurrentReferenceTimestampMs: () => number | undefined, getLastSummaryTimestampMs: () => number | undefined, baseSnapshot: ISnapshotTree | undefined, readAndParseBlob: ReadAndParseBlob, baseLogger: ITelemetryLogger, existing: boolean, metadata?: IContainerRuntimeMetadata): IGarbageCollector;
107
+ static create(provider: IGarbageCollectionRuntime, gcOptions: IGCRuntimeOptions, getNodePackagePath: (nodePath: string) => readonly string[] | undefined, getLastSummaryTimestampMs: () => number | undefined, baseSnapshot: ISnapshotTree | undefined, readAndParseBlob: ReadAndParseBlob, baseLogger: ITelemetryLogger, existing: boolean, metadata?: IContainerRuntimeMetadata): IGarbageCollector;
97
108
  /**
98
109
  * Tells whether GC should be run based on the GC options and local storage flags.
99
110
  */
@@ -146,27 +157,19 @@ export declare class GarbageCollector implements IGarbageCollector {
146
157
  private gcDataFromLastRun;
147
158
  private readonly referencesSinceLastRun;
148
159
  private readonly initializeBaseStateP;
149
- private readonly dataStoreGCDetailsP;
160
+ private readonly baseGCDetailsP;
150
161
  private readonly deleteTimeoutMs;
151
162
  private readonly unreferencedNodesState;
152
163
  private sessionExpiryTimer?;
153
164
  private readonly loggedUnreferencedEvents;
154
165
  private readonly pendingEventsQueue;
155
- protected constructor(provider: IGarbageCollectionRuntime, gcOptions: IGCRuntimeOptions,
156
- /** After GC has run, called to delete objects in the runtime whose routes are unused. */
157
- deleteUnusedRoutes: (unusedRoutes: string[]) => void,
166
+ protected constructor(runtime: IGarbageCollectionRuntime, gcOptions: IGCRuntimeOptions,
158
167
  /** For a given node path, returns the node's package path. */
159
168
  getNodePackagePath: (nodePath: string) => readonly string[] | undefined,
160
- /**
161
- * Returns a referenced timestamp to be used to track unreferenced nodes. This is a server generated timestamp
162
- * and may not be available if there aren't any ops processed yet. If so, we skip tracking unreferenced state
163
- * such as time when node becomes unreferenced or inactive.
164
- */
165
- getCurrentReferenceTimestampMs: () => number | undefined,
166
169
  /** Returns the timestamp of the last summary generated for this container. */
167
170
  getLastSummaryTimestampMs: () => number | undefined, baseSnapshot: ISnapshotTree | undefined, readAndParseBlob: ReadAndParseBlob, baseLogger: ITelemetryLogger, existing: boolean, metadata?: IContainerRuntimeMetadata);
168
171
  /**
169
- * Runs garbage collection and udpates the reference / used state of the nodes in the container.
172
+ * Runs garbage collection and updates the reference / used state of the nodes in the container.
170
173
  * @returns the number of data stores that have been marked as unreferenced.
171
174
  */
172
175
  collectGarbage(options: {
@@ -184,10 +187,10 @@ export declare class GarbageCollector implements IGarbageCollector {
184
187
  */
185
188
  summarize(): ISummaryTreeWithStats | undefined;
186
189
  /**
187
- * Returns a map of data store ids to their base GC details generated from the base summary.This is used to
188
- * initialize the GC state of data stores.
190
+ * Returns a map of node ids to their base GC details generated from the base summary. This is used by the caller
191
+ * to initialize the GC state of the nodes.
189
192
  */
190
- getDataStoreBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;
193
+ getBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;
191
194
  /**
192
195
  * Called when the latest summary of the system has been refreshed. This will be used to update the state of the
193
196
  * latest summary tracked.
@@ -245,7 +248,8 @@ export declare class GarbageCollector implements IGarbageCollector {
245
248
  private validateReferenceCorrectness;
246
249
  /**
247
250
  * Generates the stats of a garbage collection run from the given results of the run. Also, logs any pending events
248
- * in the pendingEventsQueue.
251
+ * in the pendingEventsQueue. This should be called before updating the current state because it generates stats
252
+ * based on previous state of the system.
249
253
  * @param gcResult - The result of a GC run.
250
254
  * @returns the GC stats of the GC run.
251
255
  */
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":"AA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ACU,cAAc,CACvB,OAAO,EAAE;QACL,0CAA0C;QAC1C,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAC1B,sDAAsD;QACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,oCAAoC;QACpC,MAAM,CAAC,EAAE,OAAO,CAAC;KACpB,GACF,OAAO,CAAC,QAAQ,CAAC;IA+CpB;;;;OAIG;IACI,SAAS,IAAI,qBAAqB,GAAG,SAAS;IAkBrD;;;OAGG;IACU,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;IAIpF;;;OAGG;IACU,2BAA2B,CACpC,MAAM,EAAE,oBAAoB,EAC5B,gBAAgB,EAAE,gBAAgB,GACnC,OAAO,CAAC,IAAI,CAAC;IAoBhB;;;;;;;OAOG;IACI,WAAW,CACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC5B,WAAW,CAAC,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,EAC/B,cAAc,CAAC,EAAE,cAAc;IAenC;;;;;;OAMG;IACI,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAgB/D,OAAO,IAAI,IAAI;IAOtB;;OAEG;YACW,kCAAkC;IAQhD;;;;;;;;OAQG;IACH,OAAO,CAAC,kBAAkB;IAkD1B;;;;;;;OAOG;IACH,OAAO,CAAC,uBAAuB;IAkD/B;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAgDpC;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IAsEjC;;OAEG;IACH,OAAO,CAAC,aAAa;CA0CxB"}
@@ -29,6 +29,15 @@ const writeAtRootKey = "Fluid.GarbageCollection.WriteDataAtRoot";
29
29
  const runSessionExpiry = "Fluid.GarbageCollection.RunSessionExpiry";
30
30
  const defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days
31
31
  export const defaultSessionExpiryDurationMs = 30 * 24 * 60 * 60 * 1000; // 30 days
32
+ /** The types of GC nodes in the GC reference graph. */
33
+ export const GCNodeType = {
34
+ // Nodes that are for data stores.
35
+ DataStore: "DataStore",
36
+ // Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.
37
+ Blob: "Blob",
38
+ // Nodes that are neither data store not blobs. For example, root node and DDS nodes.
39
+ Other: "Other",
40
+ };
32
41
  /**
33
42
  * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets
34
43
  * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).
@@ -80,25 +89,15 @@ class UnreferencedStateTracker {
80
89
  * its state across summaries.
81
90
  */
82
91
  export class GarbageCollector {
83
- constructor(provider, gcOptions,
84
- /** After GC has run, called to delete objects in the runtime whose routes are unused. */
85
- deleteUnusedRoutes,
92
+ constructor(runtime, gcOptions,
86
93
  /** For a given node path, returns the node's package path. */
87
94
  getNodePackagePath,
88
- /**
89
- * Returns a referenced timestamp to be used to track unreferenced nodes. This is a server generated timestamp
90
- * and may not be available if there aren't any ops processed yet. If so, we skip tracking unreferenced state
91
- * such as time when node becomes unreferenced or inactive.
92
- */
93
- getCurrentReferenceTimestampMs,
94
95
  /** Returns the timestamp of the last summary generated for this container. */
95
96
  getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
96
97
  var _a, _b, _c, _d, _e;
97
- this.provider = provider;
98
+ this.runtime = runtime;
98
99
  this.gcOptions = gcOptions;
99
- this.deleteUnusedRoutes = deleteUnusedRoutes;
100
100
  this.getNodePackagePath = getNodePackagePath;
101
- this.getCurrentReferenceTimestampMs = getCurrentReferenceTimestampMs;
102
101
  this.getLastSummaryTimestampMs = getLastSummaryTimestampMs;
103
102
  /**
104
103
  * Tells whether the GC data should be written to the root of the summary tree.
@@ -136,12 +135,12 @@ export class GarbageCollector {
136
135
  if (existing) {
137
136
  prevSummaryGCVersion = getGCVersion(metadata);
138
137
  // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all
139
- // other exsiting documents, GC is enabled.
138
+ // other existing documents, GC is enabled.
140
139
  this.gcEnabled = prevSummaryGCVersion > 0;
141
140
  this.sessionExpiryTimeoutMs = metadata === null || metadata === void 0 ? void 0 : metadata.sessionExpiryTimeoutMs;
142
141
  }
143
142
  else {
144
- // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.
143
+ // For new documents, GC has to be explicitly enabled via the gcAllowed flag in GC options.
145
144
  this.gcEnabled = gcOptions.gcAllowed === true;
146
145
  // Set the Session Expiry only if the flag is enabled or the test option is set.
147
146
  if (this.mc.config.getBoolean(runSessionExpiry) && this.gcEnabled) {
@@ -152,7 +151,7 @@ export class GarbageCollector {
152
151
  if (this.sessionExpiryTimeoutMs !== undefined) {
153
152
  const timeoutMs = this.sessionExpiryTimeoutMs;
154
153
  setLongTimeout(timeoutMs, () => {
155
- this.provider.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));
154
+ this.runtime.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));
156
155
  }, (timer) => {
157
156
  this.sessionExpiryTimer = timer;
158
157
  });
@@ -203,9 +202,9 @@ export class GarbageCollector {
203
202
  // consolidate into IGarbageCollectionState format.
204
203
  // Add a node for the root node that is not present in older snapshot format.
205
204
  const gcState = { gcNodes: { "/": { outboundRoutes: [] } } };
206
- const dataStoreSnaphotTree = getSummaryForDatastores(baseSnapshot, metadata);
207
- assert(dataStoreSnaphotTree !== undefined, 0x2a8 /* "Expected data store snapshot tree in base snapshot" */);
208
- for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {
205
+ const dataStoreSnapshotTree = getSummaryForDatastores(baseSnapshot, metadata);
206
+ assert(dataStoreSnapshotTree !== undefined, 0x2a8 /* "Expected data store snapshot tree in base snapshot" */);
207
+ for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnapshotTree.trees)) {
209
208
  const blobId = dsSnapshotTree.blobs[gcBlobKey];
210
209
  if (blobId === undefined) {
211
210
  continue;
@@ -241,7 +240,7 @@ export class GarbageCollector {
241
240
  * may be out of date. This is fine because the state is updated every time GC runs based on the time then.
242
241
  */
243
242
  this.initializeBaseStateP = new LazyPromise(async () => {
244
- const currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs();
243
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
245
244
  const baseState = await baseSummaryStateP;
246
245
  if (baseState === undefined) {
247
246
  return;
@@ -255,9 +254,9 @@ export class GarbageCollector {
255
254
  }
256
255
  this.gcDataFromLastRun = { gcNodes };
257
256
  });
258
- // Get the GC details for each data store from the GC state in the base summary. This is returned in
259
- // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.
260
- this.dataStoreGCDetailsP = new LazyPromise(async () => {
257
+ // Get the GC details for each node from the GC state in the base summary. This is returned in getBaseGCDetails
258
+ // which the caller uses to initialize each node's GC state.
259
+ this.baseGCDetailsP = new LazyPromise(async () => {
261
260
  const baseState = await baseSummaryStateP;
262
261
  if (baseState === undefined) {
263
262
  return new Map();
@@ -270,18 +269,18 @@ export class GarbageCollector {
270
269
  // This is an optimization for space (vs performance) wherein we don't need to store the used routes of
271
270
  // each node in the summary.
272
271
  const usedRoutes = runGarbageCollection(gcNodes, ["/"], this.mc.logger).referencedNodeIds;
273
- const dataStoreGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });
274
- // Currently, the data stores write the GC data. So, we need to update it's base GC details with the
272
+ const baseGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });
273
+ // Currently, the nodes may write the GC data. So, we need to update it's base GC details with the
275
274
  // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.
276
275
  for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {
277
276
  if (nodeData.unreferencedTimestampMs !== undefined) {
278
- const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));
277
+ const dataStoreGCDetails = baseGCDetailsMap.get(nodeId.slice(1));
279
278
  if (dataStoreGCDetails !== undefined) {
280
279
  dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;
281
280
  }
282
281
  }
283
282
  }
284
- return dataStoreGCDetailsMap;
283
+ return baseGCDetailsMap;
285
284
  });
286
285
  // Initialize the base state. The base GC data is used to detect and log when inactive / deleted objects are
287
286
  // used in the container.
@@ -299,8 +298,8 @@ export class GarbageCollector {
299
298
  });
300
299
  }
301
300
  }
302
- static create(provider, gcOptions, deleteUnusedRoutes, getNodePackagePath, getCurrentReferenceTimestampMs, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
303
- return new GarbageCollector(provider, gcOptions, deleteUnusedRoutes, getNodePackagePath, getCurrentReferenceTimestampMs, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata);
301
+ static create(provider, gcOptions, getNodePackagePath, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
302
+ return new GarbageCollector(provider, gcOptions, getNodePackagePath, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata);
304
303
  }
305
304
  /**
306
305
  * This tracks two things:
@@ -326,7 +325,7 @@ export class GarbageCollector {
326
325
  return this._writeDataAtRoot;
327
326
  }
328
327
  /**
329
- * Runs garbage collection and udpates the reference / used state of the nodes in the container.
328
+ * Runs garbage collection and updates the reference / used state of the nodes in the container.
330
329
  * @returns the number of data stores that have been marked as unreferenced.
331
330
  */
332
331
  async collectGarbage(options) {
@@ -334,25 +333,25 @@ export class GarbageCollector {
334
333
  return PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
335
334
  await this.initializeBaseStateP;
336
335
  // Let the runtime update its pending state before GC runs.
337
- await this.provider.updateStateBeforeGC();
336
+ await this.runtime.updateStateBeforeGC();
338
337
  // Get the runtime's GC data and run GC on the reference graph in it.
339
- const gcData = await this.provider.getGCData(fullGC);
338
+ const gcData = await this.runtime.getGCData(fullGC);
340
339
  const gcResult = runGarbageCollection(gcData.gcNodes, ["/"], logger);
341
340
  const gcStats = this.generateStatsAndLogEvents(gcResult);
342
341
  // Update the state since the last GC run. There can be nodes that were referenced between the last and
343
342
  // the current run. We need to identify than and update their unreferenced state if needed.
344
343
  this.updateStateSinceLastRun(gcData);
345
344
  // Update the current state of the system based on the GC run.
346
- const currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs();
345
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
347
346
  this.updateCurrentState(gcData, gcResult, currentReferenceTimestampMs);
348
- this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentReferenceTimestampMs);
347
+ this.runtime.updateUsedRoutes(gcResult.referencedNodeIds, currentReferenceTimestampMs);
349
348
  if (runSweep) {
350
349
  // Placeholder for running sweep logic.
351
350
  }
352
351
  // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios
353
352
  // involving access to deleted data.
354
353
  if (this.testMode) {
355
- this.deleteUnusedRoutes(gcResult.deletedNodeIds);
354
+ this.runtime.deleteUnusedRoutes(gcResult.deletedNodeIds);
356
355
  }
357
356
  event.end(Object.assign({}, gcStats));
358
357
  return gcStats;
@@ -380,11 +379,11 @@ export class GarbageCollector {
380
379
  return builder.getSummaryTree();
381
380
  }
382
381
  /**
383
- * Returns a map of data store ids to their base GC details generated from the base summary.This is used to
384
- * initialize the GC state of data stores.
382
+ * Returns a map of node ids to their base GC details generated from the base summary. This is used by the caller
383
+ * to initialize the GC state of the nodes.
385
384
  */
386
- async getDataStoreBaseGCDetails() {
387
- return this.dataStoreGCDetailsP;
385
+ async getBaseGCDetails() {
386
+ return this.baseGCDetailsP;
388
387
  }
389
388
  /**
390
389
  * Called when the latest summary of the system has been refreshed. This will be used to update the state of the
@@ -590,7 +589,7 @@ export class GarbageCollector {
590
589
  currentReferences.forEach((route) => {
591
590
  // Validate references for data stores only. Currently, layers below data stores don't have GC implemented
592
591
  // so there is no guarantee their references will be notified.
593
- if (isDataStoreNode(route) && !explicitReferences.includes(route)) {
592
+ if (this.runtime.getNodeType(route) === GCNodeType.DataStore && !explicitReferences.includes(route)) {
594
593
  /**
595
594
  * The following log will be enabled once this issue is resolved:
596
595
  * https://github.com/microsoft/FluidFramework/issues/8878.
@@ -606,7 +605,8 @@ export class GarbageCollector {
606
605
  }
607
606
  /**
608
607
  * Generates the stats of a garbage collection run from the given results of the run. Also, logs any pending events
609
- * in the pendingEventsQueue.
608
+ * in the pendingEventsQueue. This should be called before updating the current state because it generates stats
609
+ * based on previous state of the system.
610
610
  * @param gcResult - The result of a GC run.
611
611
  * @returns the GC stats of the GC run.
612
612
  */
@@ -622,49 +622,58 @@ export class GarbageCollector {
622
622
  const gcStats = {
623
623
  nodeCount: 0,
624
624
  dataStoreCount: 0,
625
+ attachmentBlobCount: 0,
625
626
  unrefNodeCount: 0,
626
627
  unrefDataStoreCount: 0,
628
+ unrefAttachmentBlobCount: 0,
627
629
  updatedNodeCount: 0,
628
630
  updatedDataStoreCount: 0,
631
+ updatedAttachmentBlobCount: 0,
629
632
  };
630
- for (const nodeId of gcResult.referencedNodeIds) {
633
+ const updateNodeStats = (nodeId, referenced) => {
631
634
  gcStats.nodeCount++;
632
- const isDataStore = isDataStoreNode(nodeId);
633
- if (isDataStore) {
634
- gcStats.dataStoreCount++;
635
- }
636
- // If a referenced node has an entry in `unreferencedNodesState`, it was previously unreferenced. So, its
637
- // reference state updated from the last GC run.
638
- if (this.unreferencedNodesState.has(nodeId)) {
635
+ /**
636
+ * `this.unreferencedNodesState` has the previous unreferenced state of all nodes. `referenced` flag passed
637
+ * here is current state of the give node. Check if the reference state of the changed.
638
+ */
639
+ const stateUpdated = this.unreferencedNodesState.has(nodeId) ? referenced : !referenced;
640
+ if (stateUpdated) {
639
641
  gcStats.updatedNodeCount++;
640
- if (isDataStore) {
641
- gcStats.updatedDataStoreCount++;
642
- }
643
642
  }
644
- }
645
- for (const nodeId of gcResult.deletedNodeIds) {
646
- gcStats.nodeCount++;
647
- gcStats.unrefNodeCount++;
648
- const isDataStore = isDataStoreNode(nodeId);
649
- if (isDataStore) {
650
- gcStats.dataStoreCount++;
651
- gcStats.unrefDataStoreCount++;
643
+ if (!referenced) {
644
+ gcStats.unrefNodeCount++;
652
645
  }
653
- // If an unreferenced node doesn't an entry in `unreferencedNodesState`, it was previously referenced. So,
654
- // its reference state updated from the last GC run.
655
- if (!this.unreferencedNodesState.has(nodeId)) {
656
- gcStats.updatedNodeCount++;
657
- if (isDataStore) {
646
+ if (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {
647
+ gcStats.dataStoreCount++;
648
+ if (stateUpdated) {
658
649
  gcStats.updatedDataStoreCount++;
659
650
  }
651
+ if (!referenced) {
652
+ gcStats.unrefDataStoreCount++;
653
+ }
660
654
  }
655
+ if (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {
656
+ gcStats.attachmentBlobCount++;
657
+ if (stateUpdated) {
658
+ gcStats.updatedAttachmentBlobCount++;
659
+ }
660
+ if (!referenced) {
661
+ gcStats.unrefAttachmentBlobCount++;
662
+ }
663
+ }
664
+ };
665
+ for (const nodeId of gcResult.referencedNodeIds) {
666
+ updateNodeStats(nodeId, true /* referenced */);
667
+ }
668
+ for (const nodeId of gcResult.deletedNodeIds) {
669
+ updateNodeStats(nodeId, false /* referenced */);
661
670
  }
662
671
  return gcStats;
663
672
  }
664
673
  /**
665
674
  * Logs an event if a node is inactive and is used.
666
675
  */
667
- logIfInactive(eventSuffix, nodeId, currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs(), packagePath, requestHeaders) {
676
+ logIfInactive(eventSuffix, nodeId, currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(), packagePath, requestHeaders) {
668
677
  // If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip
669
678
  // logging as nothing interesting would have happened worth logging.
670
679
  if (currentReferenceTimestampMs === undefined) {
@@ -704,7 +713,7 @@ export class GarbageCollector {
704
713
  async function getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob) {
705
714
  let rootGCState = { gcNodes: {} };
706
715
  for (const key of Object.keys(gcSnapshotTree.blobs)) {
707
- // Skip blobs that do not stsart with the GC prefix.
716
+ // Skip blobs that do not start with the GC prefix.
708
717
  if (!key.startsWith(gcBlobPrefix)) {
709
718
  continue;
710
719
  }
@@ -738,12 +747,4 @@ function setLongTimeout(timeoutMs, timeoutFn, setTimerFn) {
738
747
  }
739
748
  setTimerFn(timer);
740
749
  }
741
- /**
742
- * Given a GC nodeId, tells whether it belongs to a data store or not.
743
- */
744
- function isDataStoreNode(nodeId) {
745
- const pathParts = nodeId.split("/");
746
- // Data store ids are in the format "/dataStoreId".
747
- return pathParts.length === 2 && pathParts[1] !== "" ? true : false;
748
- }
749
750
  //# sourceMappingURL=garbageCollection.js.map