@fluidframework/container-runtime 0.58.2001 → 0.59.2000-61729

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 (124) 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/orderedClientElection.d.ts +57 -6
  35. package/dist/orderedClientElection.d.ts.map +1 -1
  36. package/dist/orderedClientElection.js +141 -26
  37. package/dist/orderedClientElection.js.map +1 -1
  38. package/dist/packageVersion.d.ts +1 -1
  39. package/dist/packageVersion.d.ts.map +1 -1
  40. package/dist/packageVersion.js +1 -1
  41. package/dist/packageVersion.js.map +1 -1
  42. package/dist/summarizerClientElection.d.ts +2 -0
  43. package/dist/summarizerClientElection.d.ts.map +1 -1
  44. package/dist/summarizerClientElection.js +15 -2
  45. package/dist/summarizerClientElection.js.map +1 -1
  46. package/dist/summarizerTypes.d.ts +9 -0
  47. package/dist/summarizerTypes.d.ts.map +1 -1
  48. package/dist/summarizerTypes.js.map +1 -1
  49. package/dist/summaryGenerator.d.ts.map +1 -1
  50. package/dist/summaryGenerator.js +3 -4
  51. package/dist/summaryGenerator.js.map +1 -1
  52. package/dist/summaryManager.d.ts.map +1 -1
  53. package/dist/summaryManager.js +14 -3
  54. package/dist/summaryManager.js.map +1 -1
  55. package/lib/blobManager.d.ts +15 -2
  56. package/lib/blobManager.d.ts.map +1 -1
  57. package/lib/blobManager.js +66 -10
  58. package/lib/blobManager.js.map +1 -1
  59. package/lib/connectionTelemetry.d.ts.map +1 -1
  60. package/lib/connectionTelemetry.js +63 -23
  61. package/lib/connectionTelemetry.js.map +1 -1
  62. package/lib/containerRuntime.d.ts +39 -7
  63. package/lib/containerRuntime.d.ts.map +1 -1
  64. package/lib/containerRuntime.js +163 -31
  65. package/lib/containerRuntime.js.map +1 -1
  66. package/lib/dataStore.js +8 -1
  67. package/lib/dataStore.js.map +1 -1
  68. package/lib/dataStoreContext.d.ts +9 -3
  69. package/lib/dataStoreContext.d.ts.map +1 -1
  70. package/lib/dataStoreContext.js +22 -6
  71. package/lib/dataStoreContext.js.map +1 -1
  72. package/lib/dataStores.d.ts +13 -5
  73. package/lib/dataStores.d.ts.map +1 -1
  74. package/lib/dataStores.js +39 -18
  75. package/lib/dataStores.js.map +1 -1
  76. package/lib/deltaScheduler.d.ts +4 -5
  77. package/lib/deltaScheduler.d.ts.map +1 -1
  78. package/lib/deltaScheduler.js +54 -35
  79. package/lib/deltaScheduler.js.map +1 -1
  80. package/lib/garbageCollection.d.ts +31 -27
  81. package/lib/garbageCollection.d.ts.map +1 -1
  82. package/lib/garbageCollection.js +75 -74
  83. package/lib/garbageCollection.js.map +1 -1
  84. package/lib/opTelemetry.d.ts +22 -0
  85. package/lib/opTelemetry.d.ts.map +1 -0
  86. package/lib/opTelemetry.js +55 -0
  87. package/lib/opTelemetry.js.map +1 -0
  88. package/lib/orderedClientElection.d.ts +57 -6
  89. package/lib/orderedClientElection.d.ts.map +1 -1
  90. package/lib/orderedClientElection.js +141 -26
  91. package/lib/orderedClientElection.js.map +1 -1
  92. package/lib/packageVersion.d.ts +1 -1
  93. package/lib/packageVersion.d.ts.map +1 -1
  94. package/lib/packageVersion.js +1 -1
  95. package/lib/packageVersion.js.map +1 -1
  96. package/lib/summarizerClientElection.d.ts +2 -0
  97. package/lib/summarizerClientElection.d.ts.map +1 -1
  98. package/lib/summarizerClientElection.js +15 -2
  99. package/lib/summarizerClientElection.js.map +1 -1
  100. package/lib/summarizerTypes.d.ts +9 -0
  101. package/lib/summarizerTypes.d.ts.map +1 -1
  102. package/lib/summarizerTypes.js.map +1 -1
  103. package/lib/summaryGenerator.d.ts.map +1 -1
  104. package/lib/summaryGenerator.js +3 -4
  105. package/lib/summaryGenerator.js.map +1 -1
  106. package/lib/summaryManager.d.ts.map +1 -1
  107. package/lib/summaryManager.js +14 -3
  108. package/lib/summaryManager.js.map +1 -1
  109. package/package.json +63 -19
  110. package/src/blobManager.ts +78 -11
  111. package/src/connectionTelemetry.ts +110 -19
  112. package/src/containerRuntime.ts +191 -36
  113. package/src/dataStore.ts +7 -1
  114. package/src/dataStoreContext.ts +22 -7
  115. package/src/dataStores.ts +40 -19
  116. package/src/deltaScheduler.ts +65 -39
  117. package/src/garbageCollection.ts +92 -78
  118. package/src/opTelemetry.ts +71 -0
  119. package/src/orderedClientElection.ts +155 -25
  120. package/src/packageVersion.ts +1 -1
  121. package/src/summarizerClientElection.ts +15 -2
  122. package/src/summarizerTypes.ts +9 -0
  123. package/src/summaryGenerator.ts +10 -8
  124. package/src/summaryManager.ts +15 -4
@@ -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":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AASjE,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAEH,sBAAsB,EAEtB,6BAA6B,EAC7B,qBAAqB,EACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EAEvB,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAAE,iBAAiB,EAAkB,MAAM,o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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"}
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.GarbageCollector = exports.defaultSessionExpiryDurationMs = exports.gcBlobPrefix = exports.gcTreeKey = void 0;
7
+ exports.GarbageCollector = exports.GCNodeType = exports.defaultSessionExpiryDurationMs = exports.gcBlobPrefix = exports.gcTreeKey = void 0;
8
8
  const common_utils_1 = require("@fluidframework/common-utils");
9
9
  const container_utils_1 = require("@fluidframework/container-utils");
10
10
  const garbage_collector_1 = require("@fluidframework/garbage-collector");
@@ -32,6 +32,15 @@ const writeAtRootKey = "Fluid.GarbageCollection.WriteDataAtRoot";
32
32
  const runSessionExpiry = "Fluid.GarbageCollection.RunSessionExpiry";
33
33
  const defaultDeleteTimeoutMs = 7 * 24 * 60 * 60 * 1000; // 7 days
34
34
  exports.defaultSessionExpiryDurationMs = 30 * 24 * 60 * 60 * 1000; // 30 days
35
+ /** The types of GC nodes in the GC reference graph. */
36
+ exports.GCNodeType = {
37
+ // Nodes that are for data stores.
38
+ DataStore: "DataStore",
39
+ // Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.
40
+ Blob: "Blob",
41
+ // Nodes that are neither data store not blobs. For example, root node and DDS nodes.
42
+ Other: "Other",
43
+ };
35
44
  /**
36
45
  * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced. It also sets
37
46
  * the node's state to inactive if it remains unreferenced for a given amount of time (inactiveTimeoutMs).
@@ -83,25 +92,15 @@ class UnreferencedStateTracker {
83
92
  * its state across summaries.
84
93
  */
85
94
  class GarbageCollector {
86
- constructor(provider, gcOptions,
87
- /** After GC has run, called to delete objects in the runtime whose routes are unused. */
88
- deleteUnusedRoutes,
95
+ constructor(runtime, gcOptions,
89
96
  /** For a given node path, returns the node's package path. */
90
97
  getNodePackagePath,
91
- /**
92
- * Returns a referenced timestamp to be used to track unreferenced nodes. This is a server generated timestamp
93
- * and may not be available if there aren't any ops processed yet. If so, we skip tracking unreferenced state
94
- * such as time when node becomes unreferenced or inactive.
95
- */
96
- getCurrentReferenceTimestampMs,
97
98
  /** Returns the timestamp of the last summary generated for this container. */
98
99
  getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
99
100
  var _a, _b, _c, _d, _e;
100
- this.provider = provider;
101
+ this.runtime = runtime;
101
102
  this.gcOptions = gcOptions;
102
- this.deleteUnusedRoutes = deleteUnusedRoutes;
103
103
  this.getNodePackagePath = getNodePackagePath;
104
- this.getCurrentReferenceTimestampMs = getCurrentReferenceTimestampMs;
105
104
  this.getLastSummaryTimestampMs = getLastSummaryTimestampMs;
106
105
  /**
107
106
  * Tells whether the GC data should be written to the root of the summary tree.
@@ -139,12 +138,12 @@ class GarbageCollector {
139
138
  if (existing) {
140
139
  prevSummaryGCVersion = summaryFormat_1.getGCVersion(metadata);
141
140
  // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all
142
- // other exsiting documents, GC is enabled.
141
+ // other existing documents, GC is enabled.
143
142
  this.gcEnabled = prevSummaryGCVersion > 0;
144
143
  this.sessionExpiryTimeoutMs = metadata === null || metadata === void 0 ? void 0 : metadata.sessionExpiryTimeoutMs;
145
144
  }
146
145
  else {
147
- // For new documents, GC has to be exlicitly enabled via the gcAllowed flag in GC options.
146
+ // For new documents, GC has to be explicitly enabled via the gcAllowed flag in GC options.
148
147
  this.gcEnabled = gcOptions.gcAllowed === true;
149
148
  // Set the Session Expiry only if the flag is enabled or the test option is set.
150
149
  if (this.mc.config.getBoolean(runSessionExpiry) && this.gcEnabled) {
@@ -155,7 +154,7 @@ class GarbageCollector {
155
154
  if (this.sessionExpiryTimeoutMs !== undefined) {
156
155
  const timeoutMs = this.sessionExpiryTimeoutMs;
157
156
  setLongTimeout(timeoutMs, () => {
158
- this.provider.closeFn(new container_utils_1.ClientSessionExpiredError(`Client session expired.`, timeoutMs));
157
+ this.runtime.closeFn(new container_utils_1.ClientSessionExpiredError(`Client session expired.`, timeoutMs));
159
158
  }, (timer) => {
160
159
  this.sessionExpiryTimer = timer;
161
160
  });
@@ -206,9 +205,9 @@ class GarbageCollector {
206
205
  // consolidate into IGarbageCollectionState format.
207
206
  // Add a node for the root node that is not present in older snapshot format.
208
207
  const gcState = { gcNodes: { "/": { outboundRoutes: [] } } };
209
- const dataStoreSnaphotTree = dataStores_1.getSummaryForDatastores(baseSnapshot, metadata);
210
- common_utils_1.assert(dataStoreSnaphotTree !== undefined, 0x2a8 /* "Expected data store snapshot tree in base snapshot" */);
211
- for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnaphotTree.trees)) {
208
+ const dataStoreSnapshotTree = dataStores_1.getSummaryForDatastores(baseSnapshot, metadata);
209
+ common_utils_1.assert(dataStoreSnapshotTree !== undefined, 0x2a8 /* "Expected data store snapshot tree in base snapshot" */);
210
+ for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnapshotTree.trees)) {
212
211
  const blobId = dsSnapshotTree.blobs[runtime_definitions_1.gcBlobKey];
213
212
  if (blobId === undefined) {
214
213
  continue;
@@ -244,7 +243,7 @@ class GarbageCollector {
244
243
  * may be out of date. This is fine because the state is updated every time GC runs based on the time then.
245
244
  */
246
245
  this.initializeBaseStateP = new common_utils_1.LazyPromise(async () => {
247
- const currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs();
246
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
248
247
  const baseState = await baseSummaryStateP;
249
248
  if (baseState === undefined) {
250
249
  return;
@@ -258,9 +257,9 @@ class GarbageCollector {
258
257
  }
259
258
  this.gcDataFromLastRun = { gcNodes };
260
259
  });
261
- // Get the GC details for each data store from the GC state in the base summary. This is returned in
262
- // getDataStoreBaseGCDetails and is used to initialize each data store's GC state.
263
- this.dataStoreGCDetailsP = new common_utils_1.LazyPromise(async () => {
260
+ // Get the GC details for each node from the GC state in the base summary. This is returned in getBaseGCDetails
261
+ // which the caller uses to initialize each node's GC state.
262
+ this.baseGCDetailsP = new common_utils_1.LazyPromise(async () => {
264
263
  const baseState = await baseSummaryStateP;
265
264
  if (baseState === undefined) {
266
265
  return new Map();
@@ -273,18 +272,18 @@ class GarbageCollector {
273
272
  // This is an optimization for space (vs performance) wherein we don't need to store the used routes of
274
273
  // each node in the summary.
275
274
  const usedRoutes = garbage_collector_1.runGarbageCollection(gcNodes, ["/"], this.mc.logger).referencedNodeIds;
276
- const dataStoreGCDetailsMap = garbage_collector_1.unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });
277
- // Currently, the data stores write the GC data. So, we need to update it's base GC details with the
275
+ const baseGCDetailsMap = garbage_collector_1.unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });
276
+ // Currently, the nodes may write the GC data. So, we need to update it's base GC details with the
278
277
  // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.
279
278
  for (const [nodeId, nodeData] of Object.entries(baseState.gcNodes)) {
280
279
  if (nodeData.unreferencedTimestampMs !== undefined) {
281
- const dataStoreGCDetails = dataStoreGCDetailsMap.get(nodeId.slice(1));
280
+ const dataStoreGCDetails = baseGCDetailsMap.get(nodeId.slice(1));
282
281
  if (dataStoreGCDetails !== undefined) {
283
282
  dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;
284
283
  }
285
284
  }
286
285
  }
287
- return dataStoreGCDetailsMap;
286
+ return baseGCDetailsMap;
288
287
  });
289
288
  // Initialize the base state. The base GC data is used to detect and log when inactive / deleted objects are
290
289
  // used in the container.
@@ -302,8 +301,8 @@ class GarbageCollector {
302
301
  });
303
302
  }
304
303
  }
305
- static create(provider, gcOptions, deleteUnusedRoutes, getNodePackagePath, getCurrentReferenceTimestampMs, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
306
- return new GarbageCollector(provider, gcOptions, deleteUnusedRoutes, getNodePackagePath, getCurrentReferenceTimestampMs, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata);
304
+ static create(provider, gcOptions, getNodePackagePath, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata) {
305
+ return new GarbageCollector(provider, gcOptions, getNodePackagePath, getLastSummaryTimestampMs, baseSnapshot, readAndParseBlob, baseLogger, existing, metadata);
307
306
  }
308
307
  /**
309
308
  * This tracks two things:
@@ -329,7 +328,7 @@ class GarbageCollector {
329
328
  return this._writeDataAtRoot;
330
329
  }
331
330
  /**
332
- * Runs garbage collection and udpates the reference / used state of the nodes in the container.
331
+ * Runs garbage collection and updates the reference / used state of the nodes in the container.
333
332
  * @returns the number of data stores that have been marked as unreferenced.
334
333
  */
335
334
  async collectGarbage(options) {
@@ -337,25 +336,25 @@ class GarbageCollector {
337
336
  return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
338
337
  await this.initializeBaseStateP;
339
338
  // Let the runtime update its pending state before GC runs.
340
- await this.provider.updateStateBeforeGC();
339
+ await this.runtime.updateStateBeforeGC();
341
340
  // Get the runtime's GC data and run GC on the reference graph in it.
342
- const gcData = await this.provider.getGCData(fullGC);
341
+ const gcData = await this.runtime.getGCData(fullGC);
343
342
  const gcResult = garbage_collector_1.runGarbageCollection(gcData.gcNodes, ["/"], logger);
344
343
  const gcStats = this.generateStatsAndLogEvents(gcResult);
345
344
  // Update the state since the last GC run. There can be nodes that were referenced between the last and
346
345
  // the current run. We need to identify than and update their unreferenced state if needed.
347
346
  this.updateStateSinceLastRun(gcData);
348
347
  // Update the current state of the system based on the GC run.
349
- const currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs();
348
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
350
349
  this.updateCurrentState(gcData, gcResult, currentReferenceTimestampMs);
351
- this.provider.updateUsedRoutes(gcResult.referencedNodeIds, currentReferenceTimestampMs);
350
+ this.runtime.updateUsedRoutes(gcResult.referencedNodeIds, currentReferenceTimestampMs);
352
351
  if (runSweep) {
353
352
  // Placeholder for running sweep logic.
354
353
  }
355
354
  // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios
356
355
  // involving access to deleted data.
357
356
  if (this.testMode) {
358
- this.deleteUnusedRoutes(gcResult.deletedNodeIds);
357
+ this.runtime.deleteUnusedRoutes(gcResult.deletedNodeIds);
359
358
  }
360
359
  event.end(Object.assign({}, gcStats));
361
360
  return gcStats;
@@ -383,11 +382,11 @@ class GarbageCollector {
383
382
  return builder.getSummaryTree();
384
383
  }
385
384
  /**
386
- * Returns a map of data store ids to their base GC details generated from the base summary.This is used to
387
- * initialize the GC state of data stores.
385
+ * Returns a map of node ids to their base GC details generated from the base summary. This is used by the caller
386
+ * to initialize the GC state of the nodes.
388
387
  */
389
- async getDataStoreBaseGCDetails() {
390
- return this.dataStoreGCDetailsP;
388
+ async getBaseGCDetails() {
389
+ return this.baseGCDetailsP;
391
390
  }
392
391
  /**
393
392
  * Called when the latest summary of the system has been refreshed. This will be used to update the state of the
@@ -593,7 +592,7 @@ class GarbageCollector {
593
592
  currentReferences.forEach((route) => {
594
593
  // Validate references for data stores only. Currently, layers below data stores don't have GC implemented
595
594
  // so there is no guarantee their references will be notified.
596
- if (isDataStoreNode(route) && !explicitReferences.includes(route)) {
595
+ if (this.runtime.getNodeType(route) === exports.GCNodeType.DataStore && !explicitReferences.includes(route)) {
597
596
  /**
598
597
  * The following log will be enabled once this issue is resolved:
599
598
  * https://github.com/microsoft/FluidFramework/issues/8878.
@@ -609,7 +608,8 @@ class GarbageCollector {
609
608
  }
610
609
  /**
611
610
  * Generates the stats of a garbage collection run from the given results of the run. Also, logs any pending events
612
- * in the pendingEventsQueue.
611
+ * in the pendingEventsQueue. This should be called before updating the current state because it generates stats
612
+ * based on previous state of the system.
613
613
  * @param gcResult - The result of a GC run.
614
614
  * @returns the GC stats of the GC run.
615
615
  */
@@ -625,49 +625,58 @@ class GarbageCollector {
625
625
  const gcStats = {
626
626
  nodeCount: 0,
627
627
  dataStoreCount: 0,
628
+ attachmentBlobCount: 0,
628
629
  unrefNodeCount: 0,
629
630
  unrefDataStoreCount: 0,
631
+ unrefAttachmentBlobCount: 0,
630
632
  updatedNodeCount: 0,
631
633
  updatedDataStoreCount: 0,
634
+ updatedAttachmentBlobCount: 0,
632
635
  };
633
- for (const nodeId of gcResult.referencedNodeIds) {
636
+ const updateNodeStats = (nodeId, referenced) => {
634
637
  gcStats.nodeCount++;
635
- const isDataStore = isDataStoreNode(nodeId);
636
- if (isDataStore) {
637
- gcStats.dataStoreCount++;
638
- }
639
- // If a referenced node has an entry in `unreferencedNodesState`, it was previously unreferenced. So, its
640
- // reference state updated from the last GC run.
641
- if (this.unreferencedNodesState.has(nodeId)) {
638
+ /**
639
+ * `this.unreferencedNodesState` has the previous unreferenced state of all nodes. `referenced` flag passed
640
+ * here is current state of the give node. Check if the reference state of the changed.
641
+ */
642
+ const stateUpdated = this.unreferencedNodesState.has(nodeId) ? referenced : !referenced;
643
+ if (stateUpdated) {
642
644
  gcStats.updatedNodeCount++;
643
- if (isDataStore) {
644
- gcStats.updatedDataStoreCount++;
645
- }
646
645
  }
647
- }
648
- for (const nodeId of gcResult.deletedNodeIds) {
649
- gcStats.nodeCount++;
650
- gcStats.unrefNodeCount++;
651
- const isDataStore = isDataStoreNode(nodeId);
652
- if (isDataStore) {
653
- gcStats.dataStoreCount++;
654
- gcStats.unrefDataStoreCount++;
646
+ if (!referenced) {
647
+ gcStats.unrefNodeCount++;
655
648
  }
656
- // If an unreferenced node doesn't an entry in `unreferencedNodesState`, it was previously referenced. So,
657
- // its reference state updated from the last GC run.
658
- if (!this.unreferencedNodesState.has(nodeId)) {
659
- gcStats.updatedNodeCount++;
660
- if (isDataStore) {
649
+ if (this.runtime.getNodeType(nodeId) === exports.GCNodeType.DataStore) {
650
+ gcStats.dataStoreCount++;
651
+ if (stateUpdated) {
661
652
  gcStats.updatedDataStoreCount++;
662
653
  }
654
+ if (!referenced) {
655
+ gcStats.unrefDataStoreCount++;
656
+ }
663
657
  }
658
+ if (this.runtime.getNodeType(nodeId) === exports.GCNodeType.Blob) {
659
+ gcStats.attachmentBlobCount++;
660
+ if (stateUpdated) {
661
+ gcStats.updatedAttachmentBlobCount++;
662
+ }
663
+ if (!referenced) {
664
+ gcStats.unrefAttachmentBlobCount++;
665
+ }
666
+ }
667
+ };
668
+ for (const nodeId of gcResult.referencedNodeIds) {
669
+ updateNodeStats(nodeId, true /* referenced */);
670
+ }
671
+ for (const nodeId of gcResult.deletedNodeIds) {
672
+ updateNodeStats(nodeId, false /* referenced */);
664
673
  }
665
674
  return gcStats;
666
675
  }
667
676
  /**
668
677
  * Logs an event if a node is inactive and is used.
669
678
  */
670
- logIfInactive(eventSuffix, nodeId, currentReferenceTimestampMs = this.getCurrentReferenceTimestampMs(), packagePath, requestHeaders) {
679
+ logIfInactive(eventSuffix, nodeId, currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(), packagePath, requestHeaders) {
671
680
  // If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip
672
681
  // logging as nothing interesting would have happened worth logging.
673
682
  if (currentReferenceTimestampMs === undefined) {
@@ -708,7 +717,7 @@ exports.GarbageCollector = GarbageCollector;
708
717
  async function getGCStateFromSnapshot(gcSnapshotTree, readAndParseBlob) {
709
718
  let rootGCState = { gcNodes: {} };
710
719
  for (const key of Object.keys(gcSnapshotTree.blobs)) {
711
- // Skip blobs that do not stsart with the GC prefix.
720
+ // Skip blobs that do not start with the GC prefix.
712
721
  if (!key.startsWith(exports.gcBlobPrefix)) {
713
722
  continue;
714
723
  }
@@ -742,12 +751,4 @@ function setLongTimeout(timeoutMs, timeoutFn, setTimerFn) {
742
751
  }
743
752
  setTimerFn(timer);
744
753
  }
745
- /**
746
- * Given a GC nodeId, tells whether it belongs to a data store or not.
747
- */
748
- function isDataStoreNode(nodeId) {
749
- const pathParts = nodeId.split("/");
750
- // Data store ids are in the format "/dataStoreId".
751
- return pathParts.length === 2 && pathParts[1] !== "" ? true : false;
752
- }
753
754
  //# sourceMappingURL=garbageCollection.js.map