@fluidframework/container-runtime 2.0.0-internal.7.2.0 → 2.0.0-internal.7.2.1

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 (70) hide show
  1. package/api-report/container-runtime.api.md +0 -1
  2. package/dist/blobManager.d.ts +3 -4
  3. package/dist/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager.js +17 -36
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/containerRuntime.d.ts +1 -2
  7. package/dist/containerRuntime.d.ts.map +1 -1
  8. package/dist/containerRuntime.js +11 -7
  9. package/dist/containerRuntime.js.map +1 -1
  10. package/dist/dataStoreContext.d.ts +1 -0
  11. package/dist/dataStoreContext.d.ts.map +1 -1
  12. package/dist/dataStoreContext.js +38 -29
  13. package/dist/dataStoreContext.js.map +1 -1
  14. package/dist/dataStores.d.ts +0 -14
  15. package/dist/dataStores.d.ts.map +1 -1
  16. package/dist/dataStores.js +0 -43
  17. package/dist/dataStores.js.map +1 -1
  18. package/dist/gc/garbageCollection.d.ts +6 -3
  19. package/dist/gc/garbageCollection.d.ts.map +1 -1
  20. package/dist/gc/garbageCollection.js +27 -17
  21. package/dist/gc/garbageCollection.js.map +1 -1
  22. package/dist/gc/gcDefinitions.d.ts +7 -3
  23. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  24. package/dist/gc/gcDefinitions.js.map +1 -1
  25. package/dist/gc/gcTelemetry.d.ts +11 -4
  26. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  27. package/dist/gc/gcTelemetry.js +72 -39
  28. package/dist/gc/gcTelemetry.js.map +1 -1
  29. package/dist/packageVersion.d.ts +1 -1
  30. package/dist/packageVersion.js +1 -1
  31. package/dist/packageVersion.js.map +1 -1
  32. package/lib/blobManager.d.ts +3 -4
  33. package/lib/blobManager.d.ts.map +1 -1
  34. package/lib/blobManager.js +18 -37
  35. package/lib/blobManager.js.map +1 -1
  36. package/lib/containerRuntime.d.ts +1 -2
  37. package/lib/containerRuntime.d.ts.map +1 -1
  38. package/lib/containerRuntime.js +11 -7
  39. package/lib/containerRuntime.js.map +1 -1
  40. package/lib/dataStoreContext.d.ts +1 -0
  41. package/lib/dataStoreContext.d.ts.map +1 -1
  42. package/lib/dataStoreContext.js +38 -29
  43. package/lib/dataStoreContext.js.map +1 -1
  44. package/lib/dataStores.d.ts +0 -14
  45. package/lib/dataStores.d.ts.map +1 -1
  46. package/lib/dataStores.js +1 -44
  47. package/lib/dataStores.js.map +1 -1
  48. package/lib/gc/garbageCollection.d.ts +6 -3
  49. package/lib/gc/garbageCollection.d.ts.map +1 -1
  50. package/lib/gc/garbageCollection.js +28 -18
  51. package/lib/gc/garbageCollection.js.map +1 -1
  52. package/lib/gc/gcDefinitions.d.ts +7 -3
  53. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  54. package/lib/gc/gcDefinitions.js.map +1 -1
  55. package/lib/gc/gcTelemetry.d.ts +11 -4
  56. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  57. package/lib/gc/gcTelemetry.js +72 -39
  58. package/lib/gc/gcTelemetry.js.map +1 -1
  59. package/lib/packageVersion.d.ts +1 -1
  60. package/lib/packageVersion.js +1 -1
  61. package/lib/packageVersion.js.map +1 -1
  62. package/package.json +15 -15
  63. package/src/blobManager.ts +18 -46
  64. package/src/containerRuntime.ts +20 -10
  65. package/src/dataStoreContext.ts +15 -2
  66. package/src/dataStores.ts +1 -67
  67. package/src/gc/garbageCollection.ts +39 -25
  68. package/src/gc/gcDefinitions.ts +8 -3
  69. package/src/gc/gcTelemetry.ts +102 -54
  70. package/src/packageVersion.ts +1 -1
@@ -29,11 +29,12 @@ export class GCTelemetryTracker {
29
29
  this.pendingEventsQueue = [];
30
30
  }
31
31
  /**
32
- * Returns whether an event should be logged for a node that isn't active anymore. Some scenarios where we won't log:
32
+ * Returns whether an event should be logged for a node that isn't active anymore. This does not apply to
33
+ * tombstoned nodes for which an event is always logged. Some scenarios where we won't log:
33
34
  * 1. When a DDS is changed. The corresponding data store's event will be logged instead.
34
35
  * 2. An event is logged only once per container instance per event per node.
35
36
  */
36
- shouldLogNonActiveEvent(nodeId, nodeType, usageType, nodeStateTracker, uniqueEventId) {
37
+ shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId) {
37
38
  if (nodeStateTracker.state === UnreferencedState.Active) {
38
39
  return false;
39
40
  }
@@ -45,55 +46,58 @@ export class GCTelemetryTracker {
45
46
  if (nodeType === GCNodeType.SubDataStore && usageType === "Changed") {
46
47
  return false;
47
48
  }
49
+ // Non-tombstone events are logged once per event per node. A unique id is generated by joining
50
+ // node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).
48
51
  if (this.loggedUnreferencedEvents.has(uniqueEventId)) {
49
52
  return false;
50
53
  }
51
54
  return true;
52
55
  }
53
56
  /**
54
- * Called when a node is used. If the node is not active, log an event indicating object is used when its not active.
57
+ * Called when a node is used. If the node is not active or tombstoned, log telemetry indicating object is used
58
+ * when it should not have been.
55
59
  */
56
60
  nodeUsed(nodeUsageProps) {
57
61
  // If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip
58
62
  // logging as nothing interesting would have happened worth logging.
59
- // If the node is not unreferenced, skip logging.
60
- const nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);
61
- if (!nodeStateTracker || nodeUsageProps.currentReferenceTimestampMs === undefined) {
63
+ if (nodeUsageProps.currentReferenceTimestampMs === undefined) {
62
64
  return;
63
65
  }
64
- // We log these events once per event per node. A unique id is generated by joining node state (inactive / sweep ready),
65
- // node's id and usage (loaded / changed / revived).
66
- const uniqueEventId = `${nodeStateTracker.state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;
66
+ const nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);
67
67
  const nodeType = this.getNodeType(nodeUsageProps.id);
68
- if (!this.shouldLogNonActiveEvent(nodeUsageProps.id, nodeType, nodeUsageProps.usageType, nodeStateTracker, uniqueEventId)) {
69
- return;
70
- }
71
- // Add the unique event id so that we don't generate a log for this event again in this session..
72
- this.loggedUnreferencedEvents.add(uniqueEventId);
73
- const state = nodeStateTracker.state;
74
- const { usageType, currentReferenceTimestampMs, packagePath, id, fromId, ...propsToLog } = nodeUsageProps;
75
- const eventProps = {
68
+ const { usageType, currentReferenceTimestampMs, packagePath, id: untaggedId, fromId: untaggedFromId, ...propsToLog } = nodeUsageProps;
69
+ const unrefEventProps = {
76
70
  type: nodeType,
77
- unrefTime: nodeStateTracker.unreferencedTimestampMs,
78
- age: nodeUsageProps.currentReferenceTimestampMs -
79
- nodeStateTracker.unreferencedTimestampMs,
80
- timeout: state === UnreferencedState.Inactive
71
+ unrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,
72
+ age: nodeStateTracker !== undefined
73
+ ? nodeUsageProps.currentReferenceTimestampMs -
74
+ nodeStateTracker.unreferencedTimestampMs
75
+ : -1,
76
+ timeout: nodeStateTracker?.state === UnreferencedState.Inactive
81
77
  ? this.configs.inactiveTimeoutMs
82
78
  : this.configs.sweepTimeoutMs,
83
- ...tagCodeArtifacts({ id, fromId }),
79
+ ...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),
84
80
  ...propsToLog,
85
81
  ...this.createContainerMetadata,
86
82
  };
87
- // This will log the following events:
88
- // GC_Tombstone_DataStore_Revived, GC_Tombstone_SubDataStore_Revived, GC_Tombstone_Blob_Revived
89
- if (nodeUsageProps.usageType === "Revived" && nodeUsageProps.isTombstoned) {
90
- sendGCUnexpectedUsageEvent(this.mc, {
91
- eventName: `GC_Tombstone_${nodeType}_Revived`,
92
- category: "generic",
93
- ...tagCodeArtifacts({ url: id }),
94
- gcTombstoneEnforcementAllowed: this.configs.tombstoneEnforcementAllowed,
95
- }, undefined /* packagePath */);
83
+ // If the node that is used is tombstoned, log a tombstone telemetry.
84
+ // Note that this is done before checking if "nodeStateTracker" is undefined below because unreferenced
85
+ // tracking may not have yet been enabled. That happens only after the client transitions to write mode.
86
+ if (nodeUsageProps.isTombstoned) {
87
+ this.logTombstoneUsageTelemetry(nodeUsageProps, unrefEventProps, nodeType, usageType);
96
88
  }
89
+ // After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing
90
+ // else to log.
91
+ if (nodeStateTracker === undefined) {
92
+ return;
93
+ }
94
+ const state = nodeStateTracker.state;
95
+ const uniqueEventId = `${state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;
96
+ if (!this.shouldLogNonActiveEvent(nodeType, nodeUsageProps.usageType, nodeStateTracker, uniqueEventId)) {
97
+ return;
98
+ }
99
+ // Add the unique event id so that we don't generate a log for this event again in this session.
100
+ this.loggedUnreferencedEvents.add(uniqueEventId);
97
101
  // For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.
98
102
  // For non-summarizer client, log the event now since GC won't run on it. This may result in false positives
99
103
  // but it's a good signal nonetheless and we can consume it with a grain of salt.
@@ -101,7 +105,7 @@ export class GCTelemetryTracker {
101
105
  // SweepReady errors are usages of Objects that will be deleted by GC Sweep!
102
106
  if (this.isSummarizerClient) {
103
107
  this.pendingEventsQueue.push({
104
- ...eventProps,
108
+ ...unrefEventProps,
105
109
  usageType: nodeUsageProps.usageType,
106
110
  state,
107
111
  });
@@ -112,16 +116,15 @@ export class GCTelemetryTracker {
112
116
  // Events generated:
113
117
  // InactiveObject_Loaded, SweepReadyObject_Loaded
114
118
  if (nodeUsageProps.usageType === "Loaded") {
115
- const { id: taggedId, fromId: taggedFromId, ...otherProps } = eventProps;
119
+ const { id, fromId, headers, ...detailedProps } = unrefEventProps;
116
120
  const event = {
117
121
  eventName: `${state}Object_${nodeUsageProps.usageType}`,
118
- pkg: tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join("/") }).pkg,
122
+ ...tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join("/") }),
119
123
  stack: generateStack(),
120
- id: taggedId,
121
- fromId: taggedFromId,
122
- details: JSON.stringify({
123
- ...otherProps,
124
- }),
124
+ id,
125
+ fromId,
126
+ headers: { ...headers },
127
+ details: detailedProps,
125
128
  };
126
129
  // Do not log the inactive object x events as error events as they are not the best signal for
127
130
  // detecting something wrong with GC either from the partner or from the runtime itself.
@@ -134,6 +137,36 @@ export class GCTelemetryTracker {
134
137
  }
135
138
  }
136
139
  }
140
+ /**
141
+ * Logs telemetry when a tombstoned object is changed, revived or loaded.
142
+ */
143
+ logTombstoneUsageTelemetry(nodeUsageProps, unrefEventProps, nodeType, usageType) {
144
+ // This will log the following events:
145
+ // GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived
146
+ // GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived
147
+ // GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived
148
+ const { id, fromId, headers, ...detailedProps } = unrefEventProps;
149
+ const eventUsageName = usageType === "Loaded" ? "Requested" : usageType;
150
+ const event = {
151
+ eventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,
152
+ pkg: tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join("/") }).pkg,
153
+ stack: generateStack(),
154
+ id,
155
+ fromId,
156
+ headers: { ...headers },
157
+ details: detailedProps,
158
+ gcTombstoneEnforcementAllowed: this.configs.tombstoneEnforcementAllowed,
159
+ };
160
+ if ((usageType === "Loaded" &&
161
+ this.configs.throwOnTombstoneLoad &&
162
+ !headers?.allowTombstone) ||
163
+ (usageType === "Changed" && this.configs.throwOnTombstoneUsage)) {
164
+ this.mc.logger.sendErrorEvent(event);
165
+ }
166
+ else {
167
+ this.mc.logger.sendTelemetryEvent(event);
168
+ }
169
+ }
137
170
  /**
138
171
  * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.
139
172
  * The principle is that every new reference or outbound route must be notified to GC via the
@@ -1 +1 @@
1
- {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":"A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cesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryGenericEvent } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\nimport {\n\tgenerateStack,\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tUnreferencedState,\n\tIGarbageCollectorConfigs,\n\tdisableTombstoneKey,\n\tthrowOnTombstoneUsageKey,\n\tthrowOnTombstoneLoadKey,\n\trunSweepKey,\n} from \"./gcDefinitions\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\";\n\n/** Properties that are common to IUnreferencedEventProps and INodeUsageProps */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\tviaHandle?: boolean;\n}\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\tstate: UnreferencedState;\n\tid: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\ttimeout?: number;\n\tfromId?: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n}\n\n/** Properties passed to nodeUsed function when a node is used. */\ninterface INodeUsageProps extends ICommonProps {\n\tid: string;\n\tcurrentReferenceTimestampMs: number | undefined;\n\tpackagePath: readonly string[] | undefined;\n\tfromId?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector. There are 4 types of\n * telemetry logged:\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. sweepReadyObject telemetry - When a sweep ready node is used - A node that has been unreferenced for sweepTimeoutMs.\n * 3. Tombstone telemetry - When a tombstoned node is used - A node that that has been marked as tombstone.\n * 4. Sweep / deleted telemetry - When a node is detected as sweep ready in the sweep phase.\n * 5. Unknown outbound reference telemetry - When a node is referenced but GC is not explicitly notified of it.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t\"inactiveTimeoutMs\" | \"sweepTimeoutMs\" | \"tombstoneEnforcementAllowed\"\n\t\t>,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore. Some scenarios where we won't log:\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeId: string,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t) {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is not active, log an event indicating object is used when its not active.\n\t */\n\tpublic nodeUsed(nodeUsageProps: INodeUsageProps) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\t// If the node is not unreferenced, skip logging.\n\t\tconst nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);\n\t\tif (!nodeStateTracker || nodeUsageProps.currentReferenceTimestampMs === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// We log these events once per event per node. A unique id is generated by joining node state (inactive / sweep ready),\n\t\t// node's id and usage (loaded / changed / revived).\n\t\tconst uniqueEventId = `${nodeStateTracker.state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;\n\t\tconst nodeType = this.getNodeType(nodeUsageProps.id);\n\t\tif (\n\t\t\t!this.shouldLogNonActiveEvent(\n\t\t\t\tnodeUsageProps.id,\n\t\t\t\tnodeType,\n\t\t\t\tnodeUsageProps.usageType,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tuniqueEventId,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session..\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst { usageType, currentReferenceTimestampMs, packagePath, id, fromId, ...propsToLog } =\n\t\t\tnodeUsageProps;\n\t\tconst eventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> = {\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker.unreferencedTimestampMs,\n\t\t\tage:\n\t\t\t\tnodeUsageProps.currentReferenceTimestampMs -\n\t\t\t\tnodeStateTracker.unreferencedTimestampMs,\n\t\t\ttimeout:\n\t\t\t\tstate === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\t...tagCodeArtifacts({ id, fromId }),\n\t\t\t...propsToLog,\n\t\t\t...this.createContainerMetadata,\n\t\t};\n\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Revived, GC_Tombstone_SubDataStore_Revived, GC_Tombstone_Blob_Revived\n\t\tif (nodeUsageProps.usageType === \"Revived\" && nodeUsageProps.isTombstoned) {\n\t\t\tsendGCUnexpectedUsageEvent(\n\t\t\t\tthis.mc,\n\t\t\t\t{\n\t\t\t\t\teventName: `GC_Tombstone_${nodeType}_Revived`,\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t...tagCodeArtifacts({ url: id }),\n\t\t\t\t\tgcTombstoneEnforcementAllowed: this.configs.tombstoneEnforcementAllowed,\n\t\t\t\t},\n\t\t\t\tundefined /* packagePath */,\n\t\t\t);\n\t\t}\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...eventProps,\n\t\t\t\tusageType: nodeUsageProps.usageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (nodeUsageProps.usageType === \"Loaded\") {\n\t\t\t\tconst { id: taggedId, fromId: taggedFromId, ...otherProps } = eventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${nodeUsageProps.usageType}`,\n\t\t\t\t\tpkg: tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join(\"/\") }).pkg,\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid: taggedId,\n\t\t\t\t\tfromId: taggedFromId,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...otherProps,\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, id, fromId, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(eventProps.id.value);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...propsToLog,\n\t\t\t\t\t}),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tpublic logSweepEvents(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tunreferencedNodesState: Map<string, UnreferencedStateTracker>,\n\t\tcompletedGCRuns: number,\n\t\tlastSummaryTime?: number,\n\t) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst deletedNodeIds: string[] = [];\n\t\tfor (const [nodeId, nodeStateTracker] of unreferencedNodesState) {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tdeletedNodeIds.push(nodeId);\n\t\t}\n\n\t\tif (deletedNodeIds.length > 0) {\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GC_SweepReadyObjects_Delete\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\t\tcompletedGCRuns,\n\t\t\t\t\tlastSummaryTime,\n\t\t\t\t\t...this.createContainerMetadata,\n\t\t\t\t}),\n\t\t\t\t...tagCodeArtifacts({ id: JSON.stringify(deletedNodeIds) }),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Consolidates info / logic for logging when we encounter unexpected usage of GC'd objects. For example, when a\n * tombstoned or deleted object is loaded.\n */\nexport function sendGCUnexpectedUsageEvent(\n\tmc: MonitoringContext,\n\tevent: ITelemetryGenericEvent & {\n\t\tcategory: \"error\" | \"generic\";\n\t\tgcTombstoneEnforcementAllowed: boolean | undefined;\n\t},\n\tpackagePath: readonly string[] | undefined,\n\terror?: unknown,\n) {\n\tevent.pkg = tagCodeArtifacts({ pkg: packagePath?.join(\"/\") })?.pkg;\n\tevent.tombstoneFlags = JSON.stringify({\n\t\tDisableTombstone: mc.config.getBoolean(disableTombstoneKey),\n\t\tThrowOnTombstoneUsage: mc.config.getBoolean(throwOnTombstoneUsageKey),\n\t\tThrowOnTombstoneLoad: mc.config.getBoolean(throwOnTombstoneLoadKey),\n\t});\n\tevent.sweepFlags = JSON.stringify({\n\t\tEnableSweepFlag: mc.config.getBoolean(runSweepKey),\n\t});\n\n\tmc.logger.sendTelemetryEvent(event, error);\n}\n"]}
1
+ {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,aAAa,EAGb,gBAAgB,GAChB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACN,kBAAkB,EAClB,UAAU,EACV,iBAAiB,EAEjB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,WAAW,GACX,MAAM,iBAAiB,CAAC;AAuCzB;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IAO9B,YACkB,EAAqB,EACrB,OAOhB,EACgB,kBAA2B,EAC3B,uBAAiD,EACjD,WAA2C,EAC3C,mBAEwB,EACxB,kBAE0B;QAjB1B,OAAE,GAAF,EAAE,CAAmB;QACrB,YAAO,GAAP,OAAO,CAOvB;QACgB,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,4BAAuB,GAAvB,uBAAuB,CAA0B;QACjD,gBAAW,GAAX,WAAW,CAAgC;QAC3C,wBAAmB,GAAnB,mBAAmB,CAEK;QACxB,uBAAkB,GAAlB,kBAAkB,CAEQ;QAxB5C,iHAAiH;QACjH,sBAAsB;QACL,6BAAwB,GAAgB,IAAI,GAAG,EAAE,CAAC;QACnE,6EAA6E;QACrE,uBAAkB,GAA8B,EAAE,CAAC;IAqBxD,CAAC;IAEJ;;;;;OAKG;IACK,uBAAuB,CAC9B,QAAoB,EACpB,SAAwB,EACxB,gBAA0C,EAC1C,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AAC,WAAW,CAAC;KAClD,CAAC,CAAC;IAEH,EAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryGenericEvent } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions\";\nimport {\n\tgenerateStack,\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\ttagCodeArtifacts,\n} from \"@fluidframework/telemetry-utils\";\nimport { RuntimeHeaderData } from \"../containerRuntime\";\nimport { ICreateContainerMetadata } from \"../summary\";\nimport {\n\tdisableSweepLogKey,\n\tGCNodeType,\n\tUnreferencedState,\n\tIGarbageCollectorConfigs,\n\tdisableTombstoneKey,\n\tthrowOnTombstoneUsageKey,\n\tthrowOnTombstoneLoadKey,\n\trunSweepKey,\n} from \"./gcDefinitions\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\";\n\n/** Properties that are common to IUnreferencedEventProps and INodeUsageProps */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\theaders?: RuntimeHeaderData;\n}\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\tstate: UnreferencedState;\n\tid: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\ttimeout?: number;\n\tfromId?: {\n\t\tvalue: string;\n\t\ttag: string;\n\t};\n}\n\n/** Properties passed to nodeUsed function when a node is used. */\ninterface INodeUsageProps extends ICommonProps {\n\tid: string;\n\tcurrentReferenceTimestampMs: number | undefined;\n\tpackagePath: readonly string[] | undefined;\n\tfromId?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector. There are 4 types of\n * telemetry logged:\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. sweepReadyObject telemetry - When a sweep ready node is used - A node that has been unreferenced for sweepTimeoutMs.\n * 3. Tombstone telemetry - When a tombstoned node is used - A node that that has been marked as tombstone.\n * 4. Sweep / deleted telemetry - When a node is detected as sweep ready in the sweep phase.\n * 5. Unknown outbound reference telemetry - When a node is referenced but GC is not explicitly notified of it.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: Pick<\n\t\t\tIGarbageCollectorConfigs,\n\t\t\t| \"inactiveTimeoutMs\"\n\t\t\t| \"sweepTimeoutMs\"\n\t\t\t| \"tombstoneEnforcementAllowed\"\n\t\t\t| \"throwOnTombstoneLoad\"\n\t\t\t| \"throwOnTombstoneUsage\"\n\t\t>,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore. This does not apply to\n\t * tombstoned nodes for which an event is always logged. Some scenarios where we won't log:\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t) {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Non-tombstone events are logged once per event per node. A unique id is generated by joining\n\t\t// node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is not active or tombstoned, log telemetry indicating object is used\n\t * when it should not have been.\n\t */\n\tpublic nodeUsed(nodeUsageProps: INodeUsageProps) {\n\t\t// If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n\t\t// logging as nothing interesting would have happened worth logging.\n\t\tif (nodeUsageProps.currentReferenceTimestampMs === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nodeStateTracker = this.getNodeStateTracker(nodeUsageProps.id);\n\t\tconst nodeType = this.getNodeType(nodeUsageProps.id);\n\t\tconst {\n\t\t\tusageType,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tpackagePath,\n\t\t\tid: untaggedId,\n\t\t\tfromId: untaggedFromId,\n\t\t\t...propsToLog\n\t\t} = nodeUsageProps;\n\t\tconst unrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> = {\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,\n\t\t\tage:\n\t\t\t\tnodeStateTracker !== undefined\n\t\t\t\t\t? nodeUsageProps.currentReferenceTimestampMs -\n\t\t\t\t\t nodeStateTracker.unreferencedTimestampMs\n\t\t\t\t\t: -1,\n\t\t\ttimeout:\n\t\t\t\tnodeStateTracker?.state === UnreferencedState.Inactive\n\t\t\t\t\t? this.configs.inactiveTimeoutMs\n\t\t\t\t\t: this.configs.sweepTimeoutMs,\n\t\t\t...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),\n\t\t\t...propsToLog,\n\t\t\t...this.createContainerMetadata,\n\t\t};\n\n\t\t// If the node that is used is tombstoned, log a tombstone telemetry.\n\t\t// Note that this is done before checking if \"nodeStateTracker\" is undefined below because unreferenced\n\t\t// tracking may not have yet been enabled. That happens only after the client transitions to write mode.\n\t\tif (nodeUsageProps.isTombstoned) {\n\t\t\tthis.logTombstoneUsageTelemetry(nodeUsageProps, unrefEventProps, nodeType, usageType);\n\t\t}\n\n\t\t// After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing\n\t\t// else to log.\n\t\tif (nodeStateTracker === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${nodeUsageProps.id}-${nodeUsageProps.usageType}`;\n\n\t\tif (\n\t\t\t!this.shouldLogNonActiveEvent(\n\t\t\t\tnodeType,\n\t\t\t\tnodeUsageProps.usageType,\n\t\t\t\tnodeStateTracker,\n\t\t\t\tuniqueEventId,\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session.\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...unrefEventProps,\n\t\t\t\tusageType: nodeUsageProps.usageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (nodeUsageProps.usageType === \"Loaded\") {\n\t\t\t\tconst { id, fromId, headers, ...detailedProps } = unrefEventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${nodeUsageProps.usageType}`,\n\t\t\t\t\t...tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join(\"/\") }),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: detailedProps,\n\t\t\t\t};\n\n\t\t\t\t// Do not log the inactive object x events as error events as they are not the best signal for\n\t\t\t\t// detecting something wrong with GC either from the partner or from the runtime itself.\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Logs telemetry when a tombstoned object is changed, revived or loaded.\n\t */\n\tprivate logTombstoneUsageTelemetry(\n\t\tnodeUsageProps: INodeUsageProps,\n\t\tunrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\">,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t) {\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived\n\t\t// GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived\n\t\t// GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived\n\t\tconst { id, fromId, headers, ...detailedProps } = unrefEventProps;\n\t\tconst eventUsageName = usageType === \"Loaded\" ? \"Requested\" : usageType;\n\t\tconst event = {\n\t\t\teventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,\n\t\t\tpkg: tagCodeArtifacts({ pkg: nodeUsageProps.packagePath?.join(\"/\") }).pkg,\n\t\t\tstack: generateStack(),\n\t\t\tid,\n\t\t\tfromId,\n\t\t\theaders: { ...headers },\n\t\t\tdetails: detailedProps,\n\t\t\tgcTombstoneEnforcementAllowed: this.configs.tombstoneEnforcementAllowed,\n\t\t};\n\n\t\tif (\n\t\t\t(usageType === \"Loaded\" &&\n\t\t\t\tthis.configs.throwOnTombstoneLoad &&\n\t\t\t\t!headers?.allowTombstone) ||\n\t\t\t(usageType === \"Changed\" && this.configs.throwOnTombstoneUsage)\n\t\t) {\n\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t} else {\n\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst { usageType, state, id, fromId, ...propsToLog } = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(eventProps.id.value);\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined ||\n\t\t\t\tnodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...propsToLog,\n\t\t\t\t\t}),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\tif (state === UnreferencedState.Inactive) {\n\t\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.sendErrorEvent(event);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n\n\t/**\n\t * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n\t * this will give us a view into how much deleted content a container has.\n\t */\n\tpublic logSweepEvents(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcurrentReferenceTimestampMs: number,\n\t\tunreferencedNodesState: Map<string, UnreferencedStateTracker>,\n\t\tcompletedGCRuns: number,\n\t\tlastSummaryTime?: number,\n\t) {\n\t\tif (\n\t\t\tthis.mc.config.getBoolean(disableSweepLogKey) === true ||\n\t\t\tthis.configs.sweepTimeoutMs === undefined\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst deletedNodeIds: string[] = [];\n\t\tfor (const [nodeId, nodeStateTracker] of unreferencedNodesState) {\n\t\t\tif (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst nodeType = this.getNodeType(nodeId);\n\t\t\tif (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Log deleted event for each node only once to reduce noise in telemetry.\n\t\t\tconst uniqueEventId = `Deleted-${nodeId}`;\n\t\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\t\t\tdeletedNodeIds.push(nodeId);\n\t\t}\n\n\t\tif (deletedNodeIds.length > 0) {\n\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\teventName: \"GC_SweepReadyObjects_Delete\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\ttimeout: this.configs.sweepTimeoutMs,\n\t\t\t\t\tcompletedGCRuns,\n\t\t\t\t\tlastSummaryTime,\n\t\t\t\t\t...this.createContainerMetadata,\n\t\t\t\t}),\n\t\t\t\t...tagCodeArtifacts({ id: JSON.stringify(deletedNodeIds) }),\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Consolidates info / logic for logging when we encounter unexpected usage of GC'd objects. For example, when a\n * tombstoned or deleted object is loaded.\n */\nexport function sendGCUnexpectedUsageEvent(\n\tmc: MonitoringContext,\n\tevent: ITelemetryGenericEvent & {\n\t\tcategory: \"error\" | \"generic\";\n\t\tgcTombstoneEnforcementAllowed: boolean | undefined;\n\t},\n\tpackagePath: readonly string[] | undefined,\n\terror?: unknown,\n) {\n\tevent.pkg = tagCodeArtifacts({ pkg: packagePath?.join(\"/\") })?.pkg;\n\tevent.tombstoneFlags = JSON.stringify({\n\t\tDisableTombstone: mc.config.getBoolean(disableTombstoneKey),\n\t\tThrowOnTombstoneUsage: mc.config.getBoolean(throwOnTombstoneUsageKey),\n\t\tThrowOnTombstoneLoad: mc.config.getBoolean(throwOnTombstoneLoadKey),\n\t});\n\tevent.sweepFlags = JSON.stringify({\n\t\tEnableSweepFlag: mc.config.getBoolean(runSweepKey),\n\t});\n\n\tmc.logger.sendTelemetryEvent(event, error);\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/container-runtime";
8
- export declare const pkgVersion = "2.0.0-internal.7.2.0";
8
+ export declare const pkgVersion = "2.0.0-internal.7.2.1";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/container-runtime";
8
- export const pkgVersion = "2.0.0-internal.7.2.0";
8
+ export const pkgVersion = "2.0.0-internal.7.2.1";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.7.2.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,mCAAmC,CAAC;AAC3D,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/container-runtime\";\nexport const pkgVersion = \"2.0.0-internal.7.2.1\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/container-runtime",
3
- "version": "2.0.0-internal.7.2.0",
3
+ "version": "2.0.0-internal.7.2.1",
4
4
  "description": "Fluid container runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -35,18 +35,18 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluid-internal/client-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
39
- "@fluidframework/container-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
40
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
41
- "@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
42
- "@fluidframework/core-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
43
- "@fluidframework/datastore": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
44
- "@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
45
- "@fluidframework/driver-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
38
+ "@fluid-internal/client-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
39
+ "@fluidframework/container-definitions": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
40
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
41
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
42
+ "@fluidframework/core-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
43
+ "@fluidframework/datastore": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
44
+ "@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
45
+ "@fluidframework/driver-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
46
46
  "@fluidframework/protocol-definitions": "^3.0.0",
47
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
48
- "@fluidframework/runtime-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
49
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
47
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
48
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
49
+ "@fluidframework/telemetry-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
50
50
  "double-ended-queue": "^2.1.0-0",
51
51
  "events": "^3.1.0",
52
52
  "lz4js": "^0.2.0",
@@ -54,15 +54,15 @@
54
54
  "uuid": "^9.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
57
+ "@fluid-internal/stochastic-test-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
58
58
  "@fluid-tools/benchmark": "^0.48.0",
59
59
  "@fluid-tools/build-cli": "^0.26.1",
60
60
  "@fluidframework/build-common": "^2.0.3",
61
61
  "@fluidframework/build-tools": "^0.26.1",
62
62
  "@fluidframework/container-runtime-previous": "npm:@fluidframework/container-runtime@2.0.0-internal.7.1.0",
63
63
  "@fluidframework/eslint-config-fluid": "^3.0.0",
64
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
65
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
64
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
65
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.7.2.1 <2.0.0-internal.7.3.0",
66
66
  "@microsoft/api-extractor": "^7.37.0",
67
67
  "@types/double-ended-queue": "^2.1.0",
68
68
  "@types/events": "^3.0.0",
@@ -39,8 +39,7 @@ import {
39
39
  } from "@fluidframework/runtime-definitions";
40
40
 
41
41
  import { canRetryOnError, runWithRetry } from "@fluidframework/driver-utils";
42
- import { ContainerRuntime, TombstoneResponseHeaderKey } from "./containerRuntime";
43
- import { sendGCUnexpectedUsageEvent, disableAttachmentBlobSweepKey } from "./gc";
42
+ import { disableAttachmentBlobSweepKey } from "./gc";
44
43
  import { IBlobMetadata } from "./metadata";
45
44
 
46
45
  /**
@@ -99,7 +98,6 @@ export type IBlobManagerRuntime = Pick<
99
98
  IContainerRuntime,
100
99
  "attachState" | "connected" | "logger" | "clientDetails"
101
100
  > &
102
- Pick<ContainerRuntime, "gcTombstoneEnforcementAllowed" | "gcThrowOnTombstoneLoad"> &
103
101
  TypedEventEmitter<IContainerRuntimeEvents>;
104
102
 
105
103
  type ICreateBlobResponseWithTTL = ICreateBlobResponse & Partial<Record<"minTTLInSeconds", number>>;
@@ -340,14 +338,19 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
340
338
  }
341
339
 
342
340
  public async getBlob(blobId: string): Promise<ArrayBufferLike> {
343
- // Verify that the blob is valid, i.e., it has not been garbage collected. If it is, this will throw an error,
344
- // failing the call.
345
- this.verifyBlobValidity(blobId);
341
+ // Verify that the blob is not deleted, i.e., it has not been garbage collected. If it is, this will throw
342
+ // an error, failing the call.
343
+ this.verifyBlobNotDeleted(blobId);
344
+ // Let runtime know that the corresponding GC node was requested.
345
+ // Note that this will throw if the blob is inactive or tombstoned and throwing on incorrect usage
346
+ // is configured.
347
+ this.blobRequested(getGCNodePathFromBlobId(blobId));
346
348
 
347
349
  const pending = this.pendingBlobs.get(blobId);
348
350
  if (pending) {
349
351
  return pending.blob;
350
352
  }
353
+
351
354
  let storageId: string;
352
355
  if (this.runtime.attachState === AttachState.Detached) {
353
356
  assert(this.redirectTable.has(blobId), 0x383 /* requesting unknown blobs */);
@@ -361,9 +364,6 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
361
364
  storageId = attachedStorageId;
362
365
  }
363
366
 
364
- // Let runtime know that the corresponding GC node was requested.
365
- this.blobRequested(getGCNodePathFromBlobId(blobId));
366
-
367
367
  return PerformanceEvent.timedExecAsync(
368
368
  this.mc.logger,
369
369
  { eventName: "AttachmentReadBlob", id: storageId },
@@ -828,56 +828,28 @@ export class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
828
828
  }
829
829
 
830
830
  /**
831
- * Verifies that the blob with given id is valid, i.e., it has not been garbage collected. If the blob is GC'd,
831
+ * Verifies that the blob with given id is not deleted, i.e., it has not been garbage collected. If the blob is GC'd,
832
832
  * log an error and throw if necessary.
833
833
  */
834
- private verifyBlobValidity(blobId: string) {
835
- /**
836
- * A blob can be in one of the following states:
837
- * 1. "deleted" - It has been deleted by garbage collection sweep phase.
838
- * 2. "tombstoned" - It is ready for deletion but sweep phase isn't enabled and tombstone feature is enabled.
839
- * 3. "valid" - It has not been deleted or tombstoned.
840
- */
841
- let state: "valid" | "tombstoned" | "deleted" = "valid";
842
- if (this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {
843
- state = "deleted";
844
- } else if (this.tombstonedBlobs.has(blobId)) {
845
- state = "tombstoned";
846
- }
847
-
848
- if (state === "valid") {
834
+ private verifyBlobNotDeleted(blobId: string) {
835
+ if (!this.isBlobDeleted(getGCNodePathFromBlobId(blobId))) {
849
836
  return;
850
837
  }
851
838
 
852
- // If the blob is deleted or throw on tombstone load is enabled, throw an error which will fail any attempt
853
- // to load the blob.
854
- const shouldFail = state === "deleted" || this.runtime.gcThrowOnTombstoneLoad;
855
839
  const request = { url: blobId };
856
840
  const error = responseToException(
857
- createResponseError(
858
- 404,
859
- "Blob was deleted",
860
- request,
861
- state === "tombstoned" ? { [TombstoneResponseHeaderKey]: true } : undefined,
862
- ),
841
+ createResponseError(404, `Blob was deleted`, request),
863
842
  request,
864
843
  );
865
- sendGCUnexpectedUsageEvent(
866
- this.mc,
844
+ // Only log deleted events. Tombstone events are logged by garbage collector.
845
+ this.mc.logger.sendErrorEvent(
867
846
  {
868
- eventName:
869
- state === "tombstoned"
870
- ? "GC_Tombstone_Blob_Requested"
871
- : "GC_Deleted_Blob_Requested",
872
- category: shouldFail ? "error" : "generic",
873
- gcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,
847
+ eventName: "GC_Deleted_Blob_Requested",
848
+ pkg: BlobManager.basePath,
874
849
  },
875
- [BlobManager.basePath],
876
850
  error,
877
851
  );
878
- if (shouldFail) {
879
- throw error;
880
- }
852
+ throw error;
881
853
  }
882
854
 
883
855
  public setRedirectTable(table: Map<string, string>) {
@@ -513,6 +513,7 @@ export interface RuntimeHeaderData {
513
513
  wait?: boolean;
514
514
  viaHandle?: boolean;
515
515
  allowTombstone?: boolean;
516
+ allowInactive?: boolean;
516
517
  }
517
518
 
518
519
  /** Default values for Runtime Headers */
@@ -520,6 +521,7 @@ export const defaultRuntimeHeaderData: Required<RuntimeHeaderData> = {
520
521
  wait: true,
521
522
  viaHandle: false,
522
523
  allowTombstone: false,
524
+ allowInactive: false,
523
525
  };
524
526
 
525
527
  /**
@@ -1186,11 +1188,6 @@ export class ContainerRuntime
1186
1188
  return this.garbageCollector.tombstoneEnforcementAllowed;
1187
1189
  }
1188
1190
 
1189
- /** If true, throw an error when a tombstone data store is retrieved */
1190
- public get gcThrowOnTombstoneLoad(): boolean {
1191
- return this.garbageCollector.throwOnTombstoneLoad;
1192
- }
1193
-
1194
1191
  /** If true, throw an error when a tombstone data store is used. */
1195
1192
  public get gcThrowOnTombstoneUsage(): boolean {
1196
1193
  return this.garbageCollector.throwOnTombstoneUsage;
@@ -1872,6 +1869,9 @@ export class ContainerRuntime
1872
1869
  if (typeof request.headers?.[AllowTombstoneRequestHeaderKey] === "boolean") {
1873
1870
  headerData.allowTombstone = request.headers[AllowTombstoneRequestHeaderKey];
1874
1871
  }
1872
+ if (typeof request.headers?.[AllowInactiveRequestHeaderKey] === "boolean") {
1873
+ headerData.allowInactive = request.headers[AllowInactiveRequestHeaderKey];
1874
+ }
1875
1875
 
1876
1876
  // We allow Tombstone requests for sub-DataStore objects
1877
1877
  if (requestForChild) {
@@ -1881,20 +1881,24 @@ export class ContainerRuntime
1881
1881
  await this.dataStores.waitIfPendingAlias(id);
1882
1882
  const internalId = this.internalId(id);
1883
1883
  const dataStoreContext = await this.dataStores.getDataStore(internalId, headerData);
1884
- const dataStoreChannel = await dataStoreContext.realize();
1885
1884
 
1886
1885
  // Remove query params, leading and trailing slashes from the url. This is done to make sure the format is
1887
1886
  // the same as GC nodes id.
1888
1887
  const urlWithoutQuery = trimLeadingAndTrailingSlashes(request.url.split("?")[0]);
1888
+ // Get the initial snapshot details which contain the data store package path.
1889
+ const details = await dataStoreContext.getInitialSnapshotDetails();
1890
+
1891
+ // Note that this will throw if the data store is inactive or tombstoned and throwing on incorrect usage
1892
+ // is configured.
1889
1893
  this.garbageCollector.nodeUpdated(
1890
1894
  `/${urlWithoutQuery}`,
1891
1895
  "Loaded",
1892
1896
  undefined /* timestampMs */,
1893
- dataStoreContext.packagePath,
1894
- request?.headers,
1897
+ details.pkg,
1898
+ request,
1899
+ headerData,
1895
1900
  );
1896
-
1897
- return dataStoreChannel;
1901
+ return dataStoreContext.realize();
1898
1902
  }
1899
1903
 
1900
1904
  /** Adds the container's metadata to the given summary tree. */
@@ -2538,6 +2542,12 @@ export class ContainerRuntime
2538
2542
  "entryPoint must be defined on data store runtime for using getAliasedDataStoreEntryPoint",
2539
2543
  );
2540
2544
  }
2545
+ this.garbageCollector.nodeUpdated(
2546
+ `/${internalId}`,
2547
+ "Loaded",
2548
+ undefined /* timestampMs */,
2549
+ context.packagePath,
2550
+ );
2541
2551
  return channel.entryPoint;
2542
2552
  }
2543
2553
 
@@ -487,7 +487,16 @@ export abstract class FluidDataStoreContext
487
487
  local: boolean,
488
488
  localOpMetadata: unknown,
489
489
  ): void {
490
- this.verifyNotClosed("process", true, extractSafePropertiesFromMessage(messageArg));
490
+ const safeTelemetryProps = extractSafePropertiesFromMessage(messageArg);
491
+ // On op process, tombstone error is logged in garbage collector. So, set "checkTombstone" to false when calling
492
+ // "verifyNotClosed" which logs tombstone errors. Throw error if tombstoned and throwing on load is configured.
493
+ this.verifyNotClosed("process", false /* checkTombstone */, safeTelemetryProps);
494
+ if (this.tombstoned && this.throwOnTombstoneUsage) {
495
+ throw new DataCorruptionError(
496
+ "Context is tombstoned! Call site [process]",
497
+ safeTelemetryProps,
498
+ );
499
+ }
491
500
 
492
501
  const innerContents = messageArg.contents as FluidDataStoreMessage;
493
502
  const message = {
@@ -1096,7 +1105,7 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
1096
1105
  return message;
1097
1106
  }
1098
1107
 
1099
- public async getInitialSnapshotDetails(): Promise<ISnapshotDetails> {
1108
+ private readonly initialSnapshotDetailsP = new LazyPromise<ISnapshotDetails>(async () => {
1100
1109
  let snapshot = this.snapshotTree;
1101
1110
  let attributes: ReadFluidDataStoreAttributes;
1102
1111
  let isRootDataStore = false;
@@ -1129,6 +1138,10 @@ export class LocalFluidDataStoreContextBase extends FluidDataStoreContext {
1129
1138
  isRootDataStore,
1130
1139
  snapshot,
1131
1140
  };
1141
+ });
1142
+
1143
+ public async getInitialSnapshotDetails(): Promise<ISnapshotDetails> {
1144
+ return this.initialSnapshotDetailsP;
1132
1145
  }
1133
1146
 
1134
1147
  /**