@fluidframework/container-runtime 2.0.0-dev.7.4.0.217212 → 2.0.0-dev.7.4.0.221926

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 (233) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/api-extractor.json +0 -3
  3. package/api-report/container-runtime.api.md +77 -73
  4. package/dist/blobManager.d.ts +4 -4
  5. package/dist/blobManager.d.ts.map +1 -1
  6. package/dist/blobManager.js.map +1 -1
  7. package/dist/container-runtime-alpha.d.ts +1361 -132
  8. package/dist/container-runtime-beta.d.ts +40 -2
  9. package/dist/container-runtime-public.d.ts +40 -2
  10. package/dist/container-runtime-untrimmed.d.ts +106 -93
  11. package/dist/containerRuntime.d.ts +19 -17
  12. package/dist/containerRuntime.d.ts.map +1 -1
  13. package/dist/containerRuntime.js +44 -24
  14. package/dist/containerRuntime.js.map +1 -1
  15. package/dist/dataStores.d.ts +10 -15
  16. package/dist/dataStores.d.ts.map +1 -1
  17. package/dist/dataStores.js +63 -36
  18. package/dist/dataStores.js.map +1 -1
  19. package/dist/gc/garbageCollection.d.ts +29 -10
  20. package/dist/gc/garbageCollection.d.ts.map +1 -1
  21. package/dist/gc/garbageCollection.js +149 -67
  22. package/dist/gc/garbageCollection.js.map +1 -1
  23. package/dist/gc/gcConfigs.d.ts.map +1 -1
  24. package/dist/gc/gcConfigs.js +34 -37
  25. package/dist/gc/gcConfigs.js.map +1 -1
  26. package/dist/gc/gcDefinitions.d.ts +97 -44
  27. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  28. package/dist/gc/gcDefinitions.js +26 -16
  29. package/dist/gc/gcDefinitions.js.map +1 -1
  30. package/dist/gc/gcHelpers.d.ts +18 -25
  31. package/dist/gc/gcHelpers.d.ts.map +1 -1
  32. package/dist/gc/gcHelpers.js +29 -45
  33. package/dist/gc/gcHelpers.js.map +1 -1
  34. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  35. package/dist/gc/gcTelemetry.js +14 -3
  36. package/dist/gc/gcTelemetry.js.map +1 -1
  37. package/dist/gc/gcUnreferencedStateTracker.d.ts +11 -5
  38. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  39. package/dist/gc/gcUnreferencedStateTracker.js +43 -19
  40. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  41. package/dist/gc/index.d.ts +1 -1
  42. package/dist/gc/index.d.ts.map +1 -1
  43. package/dist/gc/index.js +4 -4
  44. package/dist/gc/index.js.map +1 -1
  45. package/dist/index.d.ts +13 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +16 -5
  48. package/dist/index.js.map +1 -1
  49. package/dist/messageTypes.d.ts +13 -5
  50. package/dist/messageTypes.d.ts.map +1 -1
  51. package/dist/messageTypes.js +5 -0
  52. package/dist/messageTypes.js.map +1 -1
  53. package/dist/packageVersion.d.ts +1 -1
  54. package/dist/packageVersion.js +1 -1
  55. package/dist/packageVersion.js.map +1 -1
  56. package/dist/pendingStateManager.d.ts +1 -0
  57. package/dist/pendingStateManager.d.ts.map +1 -1
  58. package/dist/pendingStateManager.js +1 -0
  59. package/dist/pendingStateManager.js.map +1 -1
  60. package/dist/summary/orderedClientElection.d.ts +1 -1
  61. package/dist/summary/orderedClientElection.js.map +1 -1
  62. package/dist/summary/summarizerTypes.d.ts +28 -28
  63. package/dist/summary/summarizerTypes.js.map +1 -1
  64. package/dist/summary/summaryCollection.d.ts +3 -3
  65. package/dist/summary/summaryCollection.js.map +1 -1
  66. package/dist/summary/summaryFormat.d.ts +3 -3
  67. package/dist/summary/summaryFormat.js.map +1 -1
  68. package/lib/blobManager.d.ts +4 -4
  69. package/lib/blobManager.d.ts.map +1 -1
  70. package/lib/blobManager.js.map +1 -1
  71. package/lib/container-runtime-alpha.d.ts +1361 -132
  72. package/lib/container-runtime-beta.d.ts +40 -2
  73. package/lib/container-runtime-public.d.ts +40 -2
  74. package/lib/container-runtime-untrimmed.d.ts +106 -93
  75. package/lib/containerRuntime.d.ts +19 -17
  76. package/lib/containerRuntime.d.ts.map +1 -1
  77. package/lib/containerRuntime.js +46 -26
  78. package/lib/containerRuntime.js.map +1 -1
  79. package/lib/dataStores.d.ts +10 -15
  80. package/lib/dataStores.d.ts.map +1 -1
  81. package/lib/dataStores.js +65 -38
  82. package/lib/dataStores.js.map +1 -1
  83. package/lib/gc/garbageCollection.d.ts +29 -10
  84. package/lib/gc/garbageCollection.d.ts.map +1 -1
  85. package/lib/gc/garbageCollection.js +151 -69
  86. package/lib/gc/garbageCollection.js.map +1 -1
  87. package/lib/gc/gcConfigs.d.ts.map +1 -1
  88. package/lib/gc/gcConfigs.js +37 -40
  89. package/lib/gc/gcConfigs.js.map +1 -1
  90. package/lib/gc/gcDefinitions.d.ts +97 -44
  91. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  92. package/lib/gc/gcDefinitions.js +25 -15
  93. package/lib/gc/gcDefinitions.js.map +1 -1
  94. package/lib/gc/gcHelpers.d.ts +18 -25
  95. package/lib/gc/gcHelpers.d.ts.map +1 -1
  96. package/lib/gc/gcHelpers.js +27 -43
  97. package/lib/gc/gcHelpers.js.map +1 -1
  98. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  99. package/lib/gc/gcTelemetry.js +14 -3
  100. package/lib/gc/gcTelemetry.js.map +1 -1
  101. package/lib/gc/gcUnreferencedStateTracker.d.ts +11 -5
  102. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  103. package/lib/gc/gcUnreferencedStateTracker.js +43 -19
  104. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  105. package/lib/gc/index.d.ts +1 -1
  106. package/lib/gc/index.d.ts.map +1 -1
  107. package/lib/gc/index.js +1 -1
  108. package/lib/gc/index.js.map +1 -1
  109. package/lib/index.d.ts +13 -1
  110. package/lib/index.d.ts.map +1 -1
  111. package/lib/index.js +15 -1
  112. package/lib/index.js.map +1 -1
  113. package/lib/messageTypes.d.ts +13 -5
  114. package/lib/messageTypes.d.ts.map +1 -1
  115. package/lib/messageTypes.js +5 -0
  116. package/lib/messageTypes.js.map +1 -1
  117. package/lib/packageVersion.d.ts +1 -1
  118. package/lib/packageVersion.js +1 -1
  119. package/lib/packageVersion.js.map +1 -1
  120. package/lib/pendingStateManager.d.ts +1 -0
  121. package/lib/pendingStateManager.d.ts.map +1 -1
  122. package/lib/pendingStateManager.js +1 -0
  123. package/lib/pendingStateManager.js.map +1 -1
  124. package/lib/summary/orderedClientElection.d.ts +1 -1
  125. package/lib/summary/orderedClientElection.js.map +1 -1
  126. package/lib/summary/summarizerTypes.d.ts +28 -28
  127. package/lib/summary/summarizerTypes.js.map +1 -1
  128. package/lib/summary/summaryCollection.d.ts +3 -3
  129. package/lib/summary/summaryCollection.js.map +1 -1
  130. package/lib/summary/summaryFormat.d.ts +3 -3
  131. package/lib/summary/summaryFormat.js.map +1 -1
  132. package/package.json +18 -15
  133. package/src/blobManager.ts +5 -5
  134. package/src/containerRuntime.ts +66 -40
  135. package/src/dataStores.ts +118 -59
  136. package/src/gc/garbageCollection.md +14 -15
  137. package/src/gc/garbageCollection.ts +182 -75
  138. package/src/gc/gcConfigs.ts +50 -52
  139. package/src/gc/gcDefinitions.ts +112 -50
  140. package/src/gc/gcHelpers.ts +31 -52
  141. package/src/gc/gcTelemetry.ts +16 -4
  142. package/src/gc/gcUnreferencedStateTracker.ts +61 -22
  143. package/src/gc/index.ts +4 -3
  144. package/src/index.ts +17 -1
  145. package/src/messageTypes.ts +16 -2
  146. package/src/packageVersion.ts +1 -1
  147. package/src/pendingStateManager.ts +1 -0
  148. package/src/summary/orderedClientElection.ts +1 -1
  149. package/src/summary/summarizerTypes.ts +28 -28
  150. package/src/summary/summaryCollection.ts +3 -3
  151. package/src/summary/summaryFormat.ts +3 -3
  152. package/dist/id-compressor/appendOnlySortedMap.d.ts +0 -124
  153. package/dist/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
  154. package/dist/id-compressor/appendOnlySortedMap.js +0 -318
  155. package/dist/id-compressor/appendOnlySortedMap.js.map +0 -1
  156. package/dist/id-compressor/finalSpace.d.ts +0 -29
  157. package/dist/id-compressor/finalSpace.d.ts.map +0 -1
  158. package/dist/id-compressor/finalSpace.js +0 -62
  159. package/dist/id-compressor/finalSpace.js.map +0 -1
  160. package/dist/id-compressor/idCompressor.d.ts +0 -54
  161. package/dist/id-compressor/idCompressor.d.ts.map +0 -1
  162. package/dist/id-compressor/idCompressor.js +0 -495
  163. package/dist/id-compressor/idCompressor.js.map +0 -1
  164. package/dist/id-compressor/identifiers.d.ts +0 -32
  165. package/dist/id-compressor/identifiers.d.ts.map +0 -1
  166. package/dist/id-compressor/identifiers.js +0 -15
  167. package/dist/id-compressor/identifiers.js.map +0 -1
  168. package/dist/id-compressor/index.d.ts +0 -13
  169. package/dist/id-compressor/index.d.ts.map +0 -1
  170. package/dist/id-compressor/index.js +0 -32
  171. package/dist/id-compressor/index.js.map +0 -1
  172. package/dist/id-compressor/persistanceUtilities.d.ts +0 -22
  173. package/dist/id-compressor/persistanceUtilities.d.ts.map +0 -1
  174. package/dist/id-compressor/persistanceUtilities.js +0 -43
  175. package/dist/id-compressor/persistanceUtilities.js.map +0 -1
  176. package/dist/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
  177. package/dist/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
  178. package/dist/id-compressor/sessionSpaceNormalizer.js +0 -80
  179. package/dist/id-compressor/sessionSpaceNormalizer.js.map +0 -1
  180. package/dist/id-compressor/sessions.d.ts +0 -115
  181. package/dist/id-compressor/sessions.d.ts.map +0 -1
  182. package/dist/id-compressor/sessions.js +0 -305
  183. package/dist/id-compressor/sessions.js.map +0 -1
  184. package/dist/id-compressor/utilities.d.ts +0 -52
  185. package/dist/id-compressor/utilities.d.ts.map +0 -1
  186. package/dist/id-compressor/utilities.js +0 -169
  187. package/dist/id-compressor/utilities.js.map +0 -1
  188. package/lib/id-compressor/appendOnlySortedMap.d.ts +0 -124
  189. package/lib/id-compressor/appendOnlySortedMap.d.ts.map +0 -1
  190. package/lib/id-compressor/appendOnlySortedMap.js +0 -314
  191. package/lib/id-compressor/appendOnlySortedMap.js.map +0 -1
  192. package/lib/id-compressor/finalSpace.d.ts +0 -29
  193. package/lib/id-compressor/finalSpace.d.ts.map +0 -1
  194. package/lib/id-compressor/finalSpace.js +0 -58
  195. package/lib/id-compressor/finalSpace.js.map +0 -1
  196. package/lib/id-compressor/idCompressor.d.ts +0 -54
  197. package/lib/id-compressor/idCompressor.d.ts.map +0 -1
  198. package/lib/id-compressor/idCompressor.js +0 -491
  199. package/lib/id-compressor/idCompressor.js.map +0 -1
  200. package/lib/id-compressor/identifiers.d.ts +0 -32
  201. package/lib/id-compressor/identifiers.d.ts.map +0 -1
  202. package/lib/id-compressor/identifiers.js +0 -11
  203. package/lib/id-compressor/identifiers.js.map +0 -1
  204. package/lib/id-compressor/index.d.ts +0 -13
  205. package/lib/id-compressor/index.d.ts.map +0 -1
  206. package/lib/id-compressor/index.js +0 -13
  207. package/lib/id-compressor/index.js.map +0 -1
  208. package/lib/id-compressor/persistanceUtilities.d.ts +0 -22
  209. package/lib/id-compressor/persistanceUtilities.d.ts.map +0 -1
  210. package/lib/id-compressor/persistanceUtilities.js +0 -34
  211. package/lib/id-compressor/persistanceUtilities.js.map +0 -1
  212. package/lib/id-compressor/sessionSpaceNormalizer.d.ts +0 -46
  213. package/lib/id-compressor/sessionSpaceNormalizer.d.ts.map +0 -1
  214. package/lib/id-compressor/sessionSpaceNormalizer.js +0 -76
  215. package/lib/id-compressor/sessionSpaceNormalizer.js.map +0 -1
  216. package/lib/id-compressor/sessions.d.ts +0 -115
  217. package/lib/id-compressor/sessions.d.ts.map +0 -1
  218. package/lib/id-compressor/sessions.js +0 -290
  219. package/lib/id-compressor/sessions.js.map +0 -1
  220. package/lib/id-compressor/utilities.d.ts +0 -52
  221. package/lib/id-compressor/utilities.d.ts.map +0 -1
  222. package/lib/id-compressor/utilities.js +0 -151
  223. package/lib/id-compressor/utilities.js.map +0 -1
  224. package/src/id-compressor/README.md +0 -69
  225. package/src/id-compressor/appendOnlySortedMap.ts +0 -366
  226. package/src/id-compressor/finalSpace.ts +0 -67
  227. package/src/id-compressor/idCompressor.ts +0 -630
  228. package/src/id-compressor/identifiers.ts +0 -42
  229. package/src/id-compressor/index.ts +0 -26
  230. package/src/id-compressor/persistanceUtilities.ts +0 -58
  231. package/src/id-compressor/sessionSpaceNormalizer.ts +0 -83
  232. package/src/id-compressor/sessions.ts +0 -405
  233. package/src/id-compressor/utilities.ts +0 -190
package/src/dataStores.ts CHANGED
@@ -61,13 +61,8 @@ import {
61
61
  } from "./dataStoreContext";
62
62
  import { StorageServiceWithAttachBlobs } from "./storageServiceWithAttachBlobs";
63
63
  import { IDataStoreAliasMessage, isDataStoreAliasMessage } from "./dataStore";
64
- import { GCNodeType, disableDatastoreSweepKey, sendGCUnexpectedUsageEvent } from "./gc";
65
- import {
66
- summarizerClientType,
67
- IContainerRuntimeMetadata,
68
- nonDataStorePaths,
69
- rootHasIsolatedChannels,
70
- } from "./summary";
64
+ import { GCNodeType, disableDatastoreSweepKey } from "./gc";
65
+ import { IContainerRuntimeMetadata, nonDataStorePaths, rootHasIsolatedChannels } from "./summary";
71
66
 
72
67
  type PendingAliasResolve = (success: boolean) => void;
73
68
 
@@ -281,6 +276,19 @@ export class DataStores implements IDisposable {
281
276
  }
282
277
 
283
278
  const context = this.contexts.get(aliasMessage.internalId);
279
+ // If the data store has been deleted, log an error and ignore this message. This helps prevent document
280
+ // corruption in case a deleted data store accidentally submitted a signal.
281
+ if (
282
+ this.checkAndLogIfDeleted(
283
+ aliasMessage.internalId,
284
+ context,
285
+ "Changed",
286
+ "processAliasMessageCore",
287
+ )
288
+ ) {
289
+ return false;
290
+ }
291
+
284
292
  if (context === undefined) {
285
293
  this.mc.logger.sendErrorEvent({
286
294
  eventName: "AliasFluidDataStoreNotFound",
@@ -382,18 +390,43 @@ export class DataStores implements IDisposable {
382
390
 
383
391
  public resubmitDataStoreOp(envelope: IEnvelope, localOpMetadata: unknown) {
384
392
  const context = this.contexts.get(envelope.address);
393
+ // If the data store has been deleted, log an error and throw an error. If there are local changes for a
394
+ // deleted data store, it can otherwise lead to inconsistent state when compared to other clients.
395
+ if (
396
+ this.checkAndLogIfDeleted(envelope.address, context, "Changed", "resubmitDataStoreOp")
397
+ ) {
398
+ throw new DataCorruptionError("Context is deleted!", {
399
+ callSite: "resubmitDataStoreOp",
400
+ ...tagCodeArtifacts({ id: envelope.address }),
401
+ });
402
+ }
385
403
  assert(!!context, 0x160 /* "There should be a store context for the op" */);
386
404
  context.reSubmit(envelope.contents, localOpMetadata);
387
405
  }
388
406
 
389
407
  public rollbackDataStoreOp(envelope: IEnvelope, localOpMetadata: unknown) {
390
408
  const context = this.contexts.get(envelope.address);
409
+ // If the data store has been deleted, log an error and throw an error. If there are local changes for a
410
+ // deleted data store, it can otherwise lead to inconsistent state when compared to other clients.
411
+ if (
412
+ this.checkAndLogIfDeleted(envelope.address, context, "Changed", "rollbackDataStoreOp")
413
+ ) {
414
+ throw new DataCorruptionError("Context is deleted!", {
415
+ callSite: "rollbackDataStoreOp",
416
+ ...tagCodeArtifacts({ id: envelope.address }),
417
+ });
418
+ }
391
419
  assert(!!context, 0x2e8 /* "There should be a store context for the op" */);
392
420
  context.rollback(envelope.contents, localOpMetadata);
393
421
  }
394
422
 
395
423
  public async applyStashedOp(envelope: IEnvelope): Promise<unknown> {
396
424
  const context = this.contexts.get(envelope.address);
425
+ // If the data store has been deleted, log an error and ignore this message. This helps prevent document
426
+ // corruption in case the data store that stashed the op is deleted.
427
+ if (this.checkAndLogIfDeleted(envelope.address, context, "Changed", "applyStashedOp")) {
428
+ return undefined;
429
+ }
397
430
  assert(!!context, 0x161 /* "There should be a store context for the op" */);
398
431
  return context.applyStashedOp(envelope.contents);
399
432
  }
@@ -411,8 +444,21 @@ export class DataStores implements IDisposable {
411
444
  ) {
412
445
  const envelope = message.contents as IEnvelope;
413
446
  const transformed = { ...message, contents: envelope.contents };
414
- this.validateNotDeleted(envelope.address);
415
447
  const context = this.contexts.get(envelope.address);
448
+
449
+ // If the data store has been deleted, log an error and ignore this message. This helps prevent document
450
+ // corruption in case a deleted data store accidentally submitted an op.
451
+ if (
452
+ this.checkAndLogIfDeleted(
453
+ envelope.address,
454
+ context,
455
+ "Changed",
456
+ "processFluidDataStoreOp",
457
+ )
458
+ ) {
459
+ return;
460
+ }
461
+
416
462
  assert(!!context, 0x162 /* "There should be a store context for the op" */);
417
463
  context.process(transformed, local, localMessageMetadata);
418
464
 
@@ -430,7 +476,22 @@ export class DataStores implements IDisposable {
430
476
  requestHeaderData: RuntimeHeaderData,
431
477
  ): Promise<FluidDataStoreContext> {
432
478
  const headerData = { ...defaultRuntimeHeaderData, ...requestHeaderData };
433
- this.validateNotDeleted(id, headerData);
479
+ if (
480
+ this.checkAndLogIfDeleted(
481
+ id,
482
+ this.contexts.get(id),
483
+ "Requested",
484
+ "getDataStore",
485
+ requestHeaderData,
486
+ )
487
+ ) {
488
+ // The requested data store has been deleted by gc. Create a 404 response exception.
489
+ const request: IRequest = { url: id };
490
+ throw responseToException(
491
+ createResponseError(404, "DataStore was deleted", request),
492
+ request,
493
+ );
494
+ }
434
495
 
435
496
  const context = await this.contexts.getBoundOrRemoted(id, headerData.wait);
436
497
  if (context === undefined) {
@@ -448,8 +509,16 @@ export class DataStores implements IDisposable {
448
509
  id: string,
449
510
  requestHeaderData: RuntimeHeaderData,
450
511
  ): Promise<FluidDataStoreContext | undefined> {
451
- // If the data store has been deleted, return undefined.
452
- if (this.checkIfDeleted(id, requestHeaderData)) {
512
+ // If the data store has been deleted, log an error and return undefined.
513
+ if (
514
+ this.checkAndLogIfDeleted(
515
+ id,
516
+ this.contexts.get(id),
517
+ "Requested",
518
+ "getDataStoreIfAvailable",
519
+ requestHeaderData,
520
+ )
521
+ ) {
453
522
  return undefined;
454
523
  }
455
524
  const headerData = { ...defaultRuntimeHeaderData, ...requestHeaderData };
@@ -461,55 +530,43 @@ export class DataStores implements IDisposable {
461
530
  }
462
531
 
463
532
  /**
464
- * Checks if the data store has been deleted by GC.
465
- * @param id - data store id
466
- * @param request - the request information to log if the validation detects the data store has been deleted
467
- * @param requestHeaderData - the request header information to log if the validation detects the data store has been deleted
533
+ * Checks if the data store has been deleted by GC. If so, log an error.
534
+ * @param id - The data store's id.
535
+ * @param context - The data store context.
536
+ * @param callSite - The function name this is called from.
537
+ * @param requestHeaderData - The request header information to log if the data store is deleted.
468
538
  * @returns true if the data store is deleted. Otherwise, returns false.
469
539
  */
470
- private checkIfDeleted(id: string, requestHeaderData?: RuntimeHeaderData) {
540
+ private checkAndLogIfDeleted(
541
+ id: string,
542
+ context: FluidDataStoreContext | undefined,
543
+ deletedLogSuffix: string,
544
+ callSite: string,
545
+ requestHeaderData?: RuntimeHeaderData,
546
+ ) {
471
547
  const dataStoreNodePath = `/${id}`;
472
548
  if (!this.isDataStoreDeleted(dataStoreNodePath)) {
473
549
  return false;
474
550
  }
475
- assert(
476
- !this.contexts.has(id),
477
- 0x570 /* Inconsistent state! GC says the data store is deleted, but the data store is not deleted from the runtime. */,
478
- );
479
- sendGCUnexpectedUsageEvent(
480
- this.mc,
481
- {
482
- eventName: "GC_Deleted_DataStore_Requested",
483
- category: "error",
484
- isSummarizerClient: this.runtime.clientDetails.type === summarizerClientType,
485
- id,
486
- headers: JSON.stringify(requestHeaderData),
487
- gcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,
488
- },
489
- undefined /* packagePath */,
490
- );
491
- return true;
492
- }
493
551
 
494
- /**
495
- * Validate that the data store had not been deleted by GC.
496
- * @param id - data store id
497
- * @param requestHeaderData - the request header information to log if the validation detects the data store has been deleted
498
- */
499
- private validateNotDeleted(id: string, requestHeaderData?: RuntimeHeaderData) {
500
- if (this.checkIfDeleted(id, requestHeaderData)) {
501
- // The requested data store is removed by gc. Create a 404 gc response exception.
502
- const request: IRequest = { url: id };
503
- throw responseToException(
504
- createResponseError(404, "DataStore was deleted", request),
505
- request,
506
- );
507
- }
552
+ this.mc.logger.sendErrorEvent({
553
+ eventName: `GC_Deleted_DataStore_${deletedLogSuffix}`,
554
+ ...tagCodeArtifacts({ id }),
555
+ callSite,
556
+ headers: JSON.stringify(requestHeaderData),
557
+ exists: context !== undefined,
558
+ });
559
+ return true;
508
560
  }
509
561
 
510
562
  public processSignal(fluidDataStoreId: string, message: IInboundSignalMessage, local: boolean) {
511
- this.validateNotDeleted(fluidDataStoreId);
512
563
  const context = this.contexts.get(fluidDataStoreId);
564
+ // If the data store has been deleted, log an error and ignore this message. This helps prevent document
565
+ // corruption in case a deleted data store accidentally submitted a signal.
566
+ if (this.checkAndLogIfDeleted(fluidDataStoreId, context, "Changed", "processSignal")) {
567
+ return;
568
+ }
569
+
513
570
  if (!context) {
514
571
  // Attach message may not have been processed yet
515
572
  assert(!local, 0x163 /* "Missing datastore for local signal" */);
@@ -711,7 +768,7 @@ export class DataStores implements IDisposable {
711
768
  * After GC has run, called to notify this Container's data stores of routes that are used in it.
712
769
  * @param usedRoutes - The routes that are used in all data stores in this Container.
713
770
  */
714
- public updateUsedRoutes(usedRoutes: string[]) {
771
+ public updateUsedRoutes(usedRoutes: readonly string[]) {
715
772
  // Get a map of data store ids to routes used in it.
716
773
  const usedDataStoreRoutes = unpackChildNodesUsedRoutes(usedRoutes);
717
774
 
@@ -733,7 +790,7 @@ export class DataStores implements IDisposable {
733
790
  * This is called to update objects whose routes are unused. The unused objects are deleted.
734
791
  * @param unusedRoutes - The routes that are unused in all data stores in this Container.
735
792
  */
736
- public updateUnusedRoutes(unusedRoutes: string[]) {
793
+ public updateUnusedRoutes(unusedRoutes: readonly string[]) {
737
794
  for (const route of unusedRoutes) {
738
795
  const pathParts = route.split("/");
739
796
  // Delete data store only if its route (/datastoreId) is in unusedRoutes. We don't want to delete a data
@@ -756,7 +813,7 @@ export class DataStores implements IDisposable {
756
813
  * be deleted.
757
814
  * @returns The routes of data stores and its objects that were deleted.
758
815
  */
759
- public deleteSweepReadyNodes(sweepReadyDataStoreRoutes: string[]): string[] {
816
+ public deleteSweepReadyNodes(sweepReadyDataStoreRoutes: readonly string[]): readonly string[] {
760
817
  // If sweep for data stores is not enabled, return empty list indicating nothing is deleted.
761
818
  if (this.mc.config.getBoolean(disableDatastoreSweepKey) === true) {
762
819
  return [];
@@ -765,23 +822,25 @@ export class DataStores implements IDisposable {
765
822
  const pathParts = route.split("/");
766
823
  const dataStoreId = pathParts[1];
767
824
 
768
- // TODO: GC:Validation - Skip any routes already deleted
769
825
  // Ignore sub-data store routes because a data store and its sub-routes are deleted together, so, we only
770
826
  // need to delete the data store.
771
827
  if (pathParts.length > 2) {
772
828
  continue;
773
829
  }
774
830
 
775
- if (!this.contexts.has(dataStoreId)) {
831
+ const dataStoreContext = this.contexts.get(dataStoreId);
832
+ if (dataStoreContext === undefined) {
776
833
  this.mc.logger.sendErrorEvent({
777
834
  eventName: "DeletedDataStoreNotFound",
778
- dataStoreId,
835
+ ...tagCodeArtifacts({ id: dataStoreId }),
836
+ details: {
837
+ alreadyDeleted: this.isDataStoreDeleted(dataStoreId),
838
+ },
779
839
  });
840
+ continue;
780
841
  }
781
842
 
782
- const dataStore = this.contexts.get(dataStoreId);
783
- assert(dataStore !== undefined, 0x571 /* Attempting to delete unknown dataStore */);
784
- dataStore.delete();
843
+ dataStoreContext.delete();
785
844
 
786
845
  // Delete the contexts of sweep ready data stores.
787
846
  this.contexts.delete(dataStoreId);
@@ -796,7 +855,7 @@ export class DataStores implements IDisposable {
796
855
  * scenarios with accessing deleted content without actually deleting content from summaries.
797
856
  * @param tombstonedRoutes - The routes that are tombstones in all data stores in this Container.
798
857
  */
799
- public updateTombstonedRoutes(tombstonedRoutes: string[]) {
858
+ public updateTombstonedRoutes(tombstonedRoutes: readonly string[]) {
800
859
  const tombstonedDataStoresSet: Set<string> = new Set();
801
860
  for (const route of tombstonedRoutes) {
802
861
  const pathParts = route.split("/");
@@ -50,16 +50,19 @@ Mark phase is enabled by default for a container. It is enabled during creation
50
50
 
51
51
  ### Sweep phase
52
52
 
53
- In this phase, the GC algorithm identifies all Fluid objects that have been unreferenced for a specific amount of time (typically 30-40 days) and deletes them.
54
- Objects are only swept once the GC system is sure that they could never be referenced again by any active clients, i.e., clients that have the object in memory and could reference it.
55
- The Fluid Runtime enforces a maximum session length (configurable) in order to guarantee an object is safe to delete after sufficient time has elapsed.
53
+ In this phase, the GC algorithm deletes any Fluid object that has been unreferenced for a sufficient time to guarantee
54
+ they could never be referenced again by any active clients, i.e., clients that have the object in memory and could reference it again.
55
+ The Fluid Runtime enforces a maximum session length (configurable) in order to guarantee all in-memory objects are cleared before
56
+ it concludes an object is safe to delete.
56
57
 
57
- GC sweep phase has not been enabled by default yet. A "soft" version of Sweep called "Tombstone Mode" is enabled by default
58
- as part of the Mark Phase when Sweep is disabled. In this mode, any object that GC determines is ready to be deleted is
59
- marked as a "Tombstone", which triggers certain logging events and/or behavior changes if/when that Tombstoned object is
60
- accessed by the application.
58
+ GC sweep phase runs in two stages:
61
59
 
62
- Tombstone is intended for use by early adopters of GC and is documented in more detail [here](./gcEarlyAdoption.md).
60
+ - The first stage is the "Tombstone" stage, where objects are marked as Tombstones, meaning GC believes they will
61
+ never be referenced again and are safe to delete. They are not yet deleted at this point, but any attempt to
62
+ load them will fail. This way, there's a chance to recover a Tombstoned object in case we detect it's still being used.
63
+ - The second stage is the "Sweep" or "Delete" stage, where the objects are fully deleted.
64
+ This occurs after a configurable delay called the "Sweep Grace Period", to give time for application teams
65
+ to monitor for Tombstone-related errors and react before delete occurs.
63
66
 
64
67
  ## GC Configuration
65
68
 
@@ -67,7 +70,8 @@ The default configuration for GC today is:
67
70
 
68
71
  - GC Mark Phase is **enabled**, including Tombstone Mode
69
72
  - Session Expiry is **enabled**
70
- - GC Sweep Phase is **disabled**
73
+ - The "Tombstone" stage of Sweep Phase is **enabled** (attempting to load a tombstoned object will fail)
74
+ - The "Delete" stage of Sweep Phase is **disabled**
71
75
  - Note: Once enabled, Sweep will only run for documents created from that point forward
72
76
 
73
77
  ### Techniques used for configuration
@@ -94,12 +98,7 @@ covered in the [Advanced Configuration](./gcEarlyAdoption.md#more-advanced-confi
94
98
 
95
99
  ### Enabling Sweep Phase
96
100
 
97
- To enable Sweep Phase for new documents, you must set the `gcSweepGeneration` GC Option to a number, e.g. 0 to start.
98
- The full semantics of this GC Option are discussed [here](./gcEarlyAdoption.md#more-about-gcsweepgeneration-and-gctombstonegeneration).
99
- Note that this will disabled Tombstone Mode.
100
-
101
- A full treatment of Tombstone and Sweep configuration can be found in
102
- [this companion document geared towards early adopters of GC](./gcEarlyAdoption.md).
101
+ To enable the Sweep Phase for new documents, you must set the `enableGCSweep` GC Option to true.
103
102
 
104
103
  ### More Advanced Configuration
105
104