@fluidframework/container-runtime 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229

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 (563) hide show
  1. package/.eslintrc.js +21 -10
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/batchTracker.d.ts +1 -2
  5. package/dist/batchTracker.d.ts.map +1 -1
  6. package/dist/batchTracker.js +2 -1
  7. package/dist/batchTracker.js.map +1 -1
  8. package/dist/blobManager.d.ts +74 -42
  9. package/dist/blobManager.d.ts.map +1 -1
  10. package/dist/blobManager.js +321 -152
  11. package/dist/blobManager.js.map +1 -1
  12. package/dist/connectionTelemetry.d.ts.map +1 -1
  13. package/dist/connectionTelemetry.js +11 -9
  14. package/dist/connectionTelemetry.js.map +1 -1
  15. package/dist/containerHandleContext.d.ts.map +1 -1
  16. package/dist/containerHandleContext.js +3 -1
  17. package/dist/containerHandleContext.js.map +1 -1
  18. package/dist/containerRuntime.d.ts +148 -114
  19. package/dist/containerRuntime.d.ts.map +1 -1
  20. package/dist/containerRuntime.js +534 -342
  21. package/dist/containerRuntime.js.map +1 -1
  22. package/dist/dataStore.d.ts.map +1 -1
  23. package/dist/dataStore.js +11 -9
  24. package/dist/dataStore.js.map +1 -1
  25. package/dist/dataStoreContext.d.ts +40 -13
  26. package/dist/dataStoreContext.d.ts.map +1 -1
  27. package/dist/dataStoreContext.js +146 -66
  28. package/dist/dataStoreContext.js.map +1 -1
  29. package/dist/dataStoreContexts.d.ts.map +1 -1
  30. package/dist/dataStoreContexts.js +7 -3
  31. package/dist/dataStoreContexts.js.map +1 -1
  32. package/dist/dataStoreRegistry.d.ts.map +1 -1
  33. package/dist/dataStoreRegistry.js +3 -1
  34. package/dist/dataStoreRegistry.js.map +1 -1
  35. package/dist/dataStores.d.ts +39 -12
  36. package/dist/dataStores.d.ts.map +1 -1
  37. package/dist/dataStores.js +164 -76
  38. package/dist/dataStores.js.map +1 -1
  39. package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
  40. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
  41. package/dist/deltaManagerSummarizerProxy.js +40 -0
  42. package/dist/deltaManagerSummarizerProxy.js.map +1 -0
  43. package/dist/deltaScheduler.d.ts.map +1 -1
  44. package/dist/deltaScheduler.js +8 -3
  45. package/dist/deltaScheduler.js.map +1 -1
  46. package/dist/gc/garbageCollection.d.ts +204 -0
  47. package/dist/gc/garbageCollection.d.ts.map +1 -0
  48. package/dist/gc/garbageCollection.js +926 -0
  49. package/dist/gc/garbageCollection.js.map +1 -0
  50. package/dist/gc/gcConfigs.d.ts +22 -0
  51. package/dist/gc/gcConfigs.d.ts.map +1 -0
  52. package/dist/gc/gcConfigs.js +143 -0
  53. package/dist/gc/gcConfigs.js.map +1 -0
  54. package/dist/gc/gcDefinitions.d.ts +320 -0
  55. package/dist/gc/gcDefinitions.d.ts.map +1 -0
  56. package/dist/gc/gcDefinitions.js +81 -0
  57. package/dist/gc/gcDefinitions.js.map +1 -0
  58. package/dist/gc/gcHelpers.d.ts +86 -0
  59. package/dist/gc/gcHelpers.d.ts.map +1 -0
  60. package/dist/gc/gcHelpers.js +268 -0
  61. package/dist/gc/gcHelpers.js.map +1 -0
  62. package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  63. package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  64. package/dist/gc/gcReferenceGraphAlgorithm.js +49 -0
  65. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  66. package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
  67. package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
  68. package/dist/gc/gcSummaryDefinitions.js +7 -0
  69. package/dist/gc/gcSummaryDefinitions.js.map +1 -0
  70. package/dist/gc/gcSummaryStateTracker.d.ts +93 -0
  71. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
  72. package/dist/gc/gcSummaryStateTracker.js +239 -0
  73. package/dist/gc/gcSummaryStateTracker.js.map +1 -0
  74. package/{lib → dist/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
  75. package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  76. package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
  77. package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
  78. package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
  79. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  80. package/dist/gc/gcUnreferencedStateTracker.js +94 -0
  81. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
  82. package/dist/gc/index.d.ts +13 -0
  83. package/dist/gc/index.d.ts.map +1 -0
  84. package/dist/gc/index.js +50 -0
  85. package/dist/gc/index.js.map +1 -0
  86. package/dist/index.d.ts +3 -8
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +7 -13
  89. package/dist/index.js.map +1 -1
  90. package/dist/opLifecycle/batchManager.d.ts +10 -0
  91. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  92. package/dist/opLifecycle/batchManager.js +37 -8
  93. package/dist/opLifecycle/batchManager.js.map +1 -1
  94. package/dist/opLifecycle/definitions.d.ts +29 -1
  95. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  96. package/dist/opLifecycle/definitions.js.map +1 -1
  97. package/dist/opLifecycle/index.d.ts +3 -3
  98. package/dist/opLifecycle/index.d.ts.map +1 -1
  99. package/dist/opLifecycle/index.js +3 -1
  100. package/dist/opLifecycle/index.js.map +1 -1
  101. package/dist/opLifecycle/opCompressor.d.ts +1 -1
  102. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  103. package/dist/opLifecycle/opCompressor.js +46 -17
  104. package/dist/opLifecycle/opCompressor.js.map +1 -1
  105. package/dist/opLifecycle/opDecompressor.d.ts +6 -1
  106. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  107. package/dist/opLifecycle/opDecompressor.js +72 -18
  108. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  109. package/dist/opLifecycle/opSplitter.d.ts +46 -2
  110. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  111. package/dist/opLifecycle/opSplitter.js +142 -5
  112. package/dist/opLifecycle/opSplitter.js.map +1 -1
  113. package/dist/opLifecycle/outbox.d.ts +23 -2
  114. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  115. package/dist/opLifecycle/outbox.js +101 -51
  116. package/dist/opLifecycle/outbox.js.map +1 -1
  117. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  118. package/dist/opLifecycle/remoteMessageProcessor.js +17 -2
  119. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  120. package/dist/opProperties.d.ts.map +1 -1
  121. package/dist/opProperties.js +1 -3
  122. package/dist/opProperties.js.map +1 -1
  123. package/dist/packageVersion.d.ts +1 -1
  124. package/dist/packageVersion.js +1 -1
  125. package/dist/packageVersion.js.map +1 -1
  126. package/dist/pendingStateManager.d.ts +6 -15
  127. package/dist/pendingStateManager.d.ts.map +1 -1
  128. package/dist/pendingStateManager.js +137 -165
  129. package/dist/pendingStateManager.js.map +1 -1
  130. package/dist/scheduleManager.d.ts +0 -1
  131. package/dist/scheduleManager.d.ts.map +1 -1
  132. package/dist/scheduleManager.js +11 -21
  133. package/dist/scheduleManager.js.map +1 -1
  134. package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
  135. package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
  136. package/dist/storageServiceWithAttachBlobs.js +32 -0
  137. package/dist/storageServiceWithAttachBlobs.js.map +1 -0
  138. package/dist/summary/index.d.ts +17 -0
  139. package/dist/summary/index.d.ts.map +1 -0
  140. package/dist/summary/index.js +46 -0
  141. package/dist/summary/index.js.map +1 -0
  142. package/dist/summary/orderedClientElection.d.ts.map +1 -0
  143. package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
  144. package/dist/summary/orderedClientElection.js.map +1 -0
  145. package/{lib → dist/summary}/runWhileConnectedCoordinator.d.ts +3 -2
  146. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  147. package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  148. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
  149. package/{lib → dist/summary}/runningSummarizer.d.ts +19 -18
  150. package/dist/summary/runningSummarizer.d.ts.map +1 -0
  151. package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +191 -77
  152. package/dist/summary/runningSummarizer.js.map +1 -0
  153. package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +6 -12
  154. package/dist/summary/summarizer.d.ts.map +1 -0
  155. package/dist/{summarizer.js → summary/summarizer.js} +32 -76
  156. package/dist/summary/summarizer.js.map +1 -0
  157. package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +1 -2
  158. package/dist/summary/summarizerClientElection.d.ts.map +1 -0
  159. package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +3 -30
  160. package/dist/summary/summarizerClientElection.js.map +1 -0
  161. package/dist/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  162. package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
  163. package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +9 -12
  164. package/dist/summary/summarizerHeuristics.js.map +1 -0
  165. package/dist/summary/summarizerNode/index.d.ts +8 -0
  166. package/dist/summary/summarizerNode/index.d.ts.map +1 -0
  167. package/dist/summary/summarizerNode/index.js +12 -0
  168. package/dist/summary/summarizerNode/index.js.map +1 -0
  169. package/dist/summary/summarizerNode/summarizerNode.d.ts +149 -0
  170. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  171. package/dist/summary/summarizerNode/summarizerNode.js +531 -0
  172. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -0
  173. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  174. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  175. package/dist/summary/summarizerNode/summarizerNodeUtils.js +132 -0
  176. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  177. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +22 -0
  178. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  179. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +423 -0
  180. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  181. package/{lib → dist/summary}/summarizerTypes.d.ts +29 -42
  182. package/dist/summary/summarizerTypes.d.ts.map +1 -0
  183. package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -5
  184. package/dist/summary/summarizerTypes.js.map +1 -0
  185. package/dist/summary/summaryCollection.d.ts.map +1 -0
  186. package/dist/{summaryCollection.js → summary/summaryCollection.js} +18 -8
  187. package/dist/summary/summaryCollection.js.map +1 -0
  188. package/{lib → dist/summary}/summaryFormat.d.ts +3 -21
  189. package/dist/summary/summaryFormat.d.ts.map +1 -0
  190. package/dist/{summaryFormat.js → summary/summaryFormat.js} +19 -21
  191. package/dist/summary/summaryFormat.js.map +1 -0
  192. package/dist/summary/summaryGenerator.d.ts.map +1 -0
  193. package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +34 -16
  194. package/dist/summary/summaryGenerator.js.map +1 -0
  195. package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  196. package/dist/summary/summaryManager.d.ts.map +1 -0
  197. package/dist/{summaryManager.js → summary/summaryManager.js} +21 -9
  198. package/dist/summary/summaryManager.js.map +1 -0
  199. package/dist/throttler.d.ts +2 -2
  200. package/dist/throttler.d.ts.map +1 -1
  201. package/dist/throttler.js +4 -4
  202. package/dist/throttler.js.map +1 -1
  203. package/lib/batchTracker.d.ts +1 -2
  204. package/lib/batchTracker.d.ts.map +1 -1
  205. package/lib/batchTracker.js +2 -1
  206. package/lib/batchTracker.js.map +1 -1
  207. package/lib/blobManager.d.ts +74 -42
  208. package/lib/blobManager.d.ts.map +1 -1
  209. package/lib/blobManager.js +322 -153
  210. package/lib/blobManager.js.map +1 -1
  211. package/lib/connectionTelemetry.d.ts.map +1 -1
  212. package/lib/connectionTelemetry.js +11 -9
  213. package/lib/connectionTelemetry.js.map +1 -1
  214. package/lib/containerHandleContext.d.ts.map +1 -1
  215. package/lib/containerHandleContext.js +3 -1
  216. package/lib/containerHandleContext.js.map +1 -1
  217. package/lib/containerRuntime.d.ts +148 -114
  218. package/lib/containerRuntime.d.ts.map +1 -1
  219. package/lib/containerRuntime.js +506 -314
  220. package/lib/containerRuntime.js.map +1 -1
  221. package/lib/dataStore.d.ts.map +1 -1
  222. package/lib/dataStore.js +11 -9
  223. package/lib/dataStore.js.map +1 -1
  224. package/lib/dataStoreContext.d.ts +40 -13
  225. package/lib/dataStoreContext.d.ts.map +1 -1
  226. package/lib/dataStoreContext.js +136 -56
  227. package/lib/dataStoreContext.js.map +1 -1
  228. package/lib/dataStoreContexts.d.ts.map +1 -1
  229. package/lib/dataStoreContexts.js +7 -3
  230. package/lib/dataStoreContexts.js.map +1 -1
  231. package/lib/dataStoreRegistry.d.ts.map +1 -1
  232. package/lib/dataStoreRegistry.js +3 -1
  233. package/lib/dataStoreRegistry.js.map +1 -1
  234. package/lib/dataStores.d.ts +39 -12
  235. package/lib/dataStores.d.ts.map +1 -1
  236. package/lib/dataStores.js +162 -74
  237. package/lib/dataStores.js.map +1 -1
  238. package/lib/deltaManagerSummarizerProxy.d.ts +19 -0
  239. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -0
  240. package/lib/deltaManagerSummarizerProxy.js +36 -0
  241. package/lib/deltaManagerSummarizerProxy.js.map +1 -0
  242. package/lib/deltaScheduler.d.ts.map +1 -1
  243. package/lib/deltaScheduler.js +9 -4
  244. package/lib/deltaScheduler.js.map +1 -1
  245. package/lib/gc/garbageCollection.d.ts +204 -0
  246. package/lib/gc/garbageCollection.d.ts.map +1 -0
  247. package/lib/gc/garbageCollection.js +922 -0
  248. package/lib/gc/garbageCollection.js.map +1 -0
  249. package/lib/gc/gcConfigs.d.ts +22 -0
  250. package/lib/gc/gcConfigs.d.ts.map +1 -0
  251. package/lib/gc/gcConfigs.js +139 -0
  252. package/lib/gc/gcConfigs.js.map +1 -0
  253. package/lib/gc/gcDefinitions.d.ts +320 -0
  254. package/lib/gc/gcDefinitions.d.ts.map +1 -0
  255. package/lib/gc/gcDefinitions.js +78 -0
  256. package/lib/gc/gcDefinitions.js.map +1 -0
  257. package/lib/gc/gcHelpers.d.ts +86 -0
  258. package/lib/gc/gcHelpers.d.ts.map +1 -0
  259. package/lib/gc/gcHelpers.js +254 -0
  260. package/lib/gc/gcHelpers.js.map +1 -0
  261. package/lib/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  262. package/lib/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  263. package/lib/gc/gcReferenceGraphAlgorithm.js +45 -0
  264. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  265. package/lib/gc/gcSummaryDefinitions.d.ts +52 -0
  266. package/lib/gc/gcSummaryDefinitions.d.ts.map +1 -0
  267. package/lib/gc/gcSummaryDefinitions.js +6 -0
  268. package/lib/gc/gcSummaryDefinitions.js.map +1 -0
  269. package/lib/gc/gcSummaryStateTracker.d.ts +93 -0
  270. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
  271. package/lib/gc/gcSummaryStateTracker.js +235 -0
  272. package/lib/gc/gcSummaryStateTracker.js.map +1 -0
  273. package/{dist → lib/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
  274. package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  275. package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
  276. package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
  277. package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
  278. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  279. package/lib/gc/gcUnreferencedStateTracker.js +90 -0
  280. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
  281. package/lib/gc/index.d.ts +13 -0
  282. package/lib/gc/index.d.ts.map +1 -0
  283. package/lib/gc/index.js +12 -0
  284. package/lib/gc/index.js.map +1 -0
  285. package/lib/index.d.ts +3 -8
  286. package/lib/index.d.ts.map +1 -1
  287. package/lib/index.js +2 -6
  288. package/lib/index.js.map +1 -1
  289. package/lib/opLifecycle/batchManager.d.ts +10 -0
  290. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  291. package/lib/opLifecycle/batchManager.js +35 -7
  292. package/lib/opLifecycle/batchManager.js.map +1 -1
  293. package/lib/opLifecycle/definitions.d.ts +29 -1
  294. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  295. package/lib/opLifecycle/definitions.js.map +1 -1
  296. package/lib/opLifecycle/index.d.ts +3 -3
  297. package/lib/opLifecycle/index.d.ts.map +1 -1
  298. package/lib/opLifecycle/index.js +2 -2
  299. package/lib/opLifecycle/index.js.map +1 -1
  300. package/lib/opLifecycle/opCompressor.d.ts +1 -1
  301. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  302. package/lib/opLifecycle/opCompressor.js +47 -18
  303. package/lib/opLifecycle/opCompressor.js.map +1 -1
  304. package/lib/opLifecycle/opDecompressor.d.ts +6 -1
  305. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  306. package/lib/opLifecycle/opDecompressor.js +72 -18
  307. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  308. package/lib/opLifecycle/opSplitter.d.ts +46 -2
  309. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  310. package/lib/opLifecycle/opSplitter.js +141 -5
  311. package/lib/opLifecycle/opSplitter.js.map +1 -1
  312. package/lib/opLifecycle/outbox.d.ts +23 -2
  313. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  314. package/lib/opLifecycle/outbox.js +103 -53
  315. package/lib/opLifecycle/outbox.js.map +1 -1
  316. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  317. package/lib/opLifecycle/remoteMessageProcessor.js +17 -2
  318. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  319. package/lib/opProperties.d.ts.map +1 -1
  320. package/lib/opProperties.js +1 -3
  321. package/lib/opProperties.js.map +1 -1
  322. package/lib/packageVersion.d.ts +1 -1
  323. package/lib/packageVersion.js +1 -1
  324. package/lib/packageVersion.js.map +1 -1
  325. package/lib/pendingStateManager.d.ts +6 -15
  326. package/lib/pendingStateManager.d.ts.map +1 -1
  327. package/lib/pendingStateManager.js +137 -165
  328. package/lib/pendingStateManager.js.map +1 -1
  329. package/lib/scheduleManager.d.ts +0 -1
  330. package/lib/scheduleManager.d.ts.map +1 -1
  331. package/lib/scheduleManager.js +11 -21
  332. package/lib/scheduleManager.js.map +1 -1
  333. package/lib/storageServiceWithAttachBlobs.d.ts +17 -0
  334. package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -0
  335. package/lib/storageServiceWithAttachBlobs.js +28 -0
  336. package/lib/storageServiceWithAttachBlobs.js.map +1 -0
  337. package/lib/summary/index.d.ts +17 -0
  338. package/lib/summary/index.d.ts.map +1 -0
  339. package/lib/summary/index.js +15 -0
  340. package/lib/summary/index.js.map +1 -0
  341. package/lib/summary/orderedClientElection.d.ts.map +1 -0
  342. package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
  343. package/lib/summary/orderedClientElection.js.map +1 -0
  344. package/{dist → lib/summary}/runWhileConnectedCoordinator.d.ts +3 -2
  345. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  346. package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  347. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
  348. package/{dist → lib/summary}/runningSummarizer.d.ts +19 -18
  349. package/lib/summary/runningSummarizer.d.ts.map +1 -0
  350. package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +193 -79
  351. package/lib/summary/runningSummarizer.js.map +1 -0
  352. package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +6 -12
  353. package/lib/summary/summarizer.d.ts.map +1 -0
  354. package/lib/{summarizer.js → summary/summarizer.js} +34 -78
  355. package/lib/summary/summarizer.js.map +1 -0
  356. package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +1 -2
  357. package/lib/summary/summarizerClientElection.d.ts.map +1 -0
  358. package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +3 -30
  359. package/lib/summary/summarizerClientElection.js.map +1 -0
  360. package/lib/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  361. package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
  362. package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +9 -12
  363. package/lib/summary/summarizerHeuristics.js.map +1 -0
  364. package/lib/summary/summarizerNode/index.d.ts +8 -0
  365. package/lib/summary/summarizerNode/index.d.ts.map +1 -0
  366. package/lib/summary/summarizerNode/index.js +7 -0
  367. package/lib/summary/summarizerNode/index.js.map +1 -0
  368. package/lib/summary/summarizerNode/summarizerNode.d.ts +149 -0
  369. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  370. package/lib/summary/summarizerNode/summarizerNode.js +526 -0
  371. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -0
  372. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  373. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  374. package/lib/summary/summarizerNode/summarizerNodeUtils.js +125 -0
  375. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  376. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +22 -0
  377. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  378. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +419 -0
  379. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  380. package/{dist → lib/summary}/summarizerTypes.d.ts +29 -42
  381. package/lib/summary/summarizerTypes.d.ts.map +1 -0
  382. package/lib/summary/summarizerTypes.js +6 -0
  383. package/lib/summary/summarizerTypes.js.map +1 -0
  384. package/lib/summary/summaryCollection.d.ts.map +1 -0
  385. package/lib/{summaryCollection.js → summary/summaryCollection.js} +18 -8
  386. package/lib/summary/summaryCollection.js.map +1 -0
  387. package/{dist → lib/summary}/summaryFormat.d.ts +3 -21
  388. package/lib/summary/summaryFormat.d.ts.map +1 -0
  389. package/lib/{summaryFormat.js → summary/summaryFormat.js} +20 -21
  390. package/lib/summary/summaryFormat.js.map +1 -0
  391. package/lib/summary/summaryGenerator.d.ts.map +1 -0
  392. package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +34 -16
  393. package/lib/summary/summaryGenerator.js.map +1 -0
  394. package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  395. package/lib/summary/summaryManager.d.ts.map +1 -0
  396. package/lib/{summaryManager.js → summary/summaryManager.js} +21 -9
  397. package/lib/summary/summaryManager.js.map +1 -0
  398. package/lib/throttler.d.ts +2 -2
  399. package/lib/throttler.d.ts.map +1 -1
  400. package/lib/throttler.js +4 -4
  401. package/lib/throttler.js.map +1 -1
  402. package/package.json +67 -61
  403. package/prettier.config.cjs +1 -1
  404. package/src/batchTracker.ts +55 -50
  405. package/src/blobManager.ts +863 -594
  406. package/src/connectionTelemetry.ts +280 -249
  407. package/src/containerHandleContext.ts +27 -29
  408. package/src/containerRuntime.ts +3174 -2805
  409. package/src/dataStore.ts +172 -159
  410. package/src/dataStoreContext.ts +1141 -993
  411. package/src/dataStoreContexts.ts +178 -161
  412. package/src/dataStoreRegistry.ts +25 -20
  413. package/src/dataStores.ts +887 -716
  414. package/src/deltaManagerSummarizerProxy.ts +46 -0
  415. package/src/deltaScheduler.ts +158 -150
  416. package/{garbageCollection.md → src/gc/garbageCollection.md} +16 -3
  417. package/src/gc/garbageCollection.ts +1250 -0
  418. package/src/gc/gcConfigs.ts +193 -0
  419. package/src/gc/gcDefinitions.ts +387 -0
  420. package/src/gc/gcHelpers.ts +332 -0
  421. package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
  422. package/src/gc/gcSummaryDefinitions.ts +54 -0
  423. package/src/gc/gcSummaryStateTracker.ts +329 -0
  424. package/src/gc/gcSweepReadyUsageDetection.ts +145 -0
  425. package/src/gc/gcUnreferencedStateTracker.ts +114 -0
  426. package/src/gc/index.ts +65 -0
  427. package/src/index.ts +61 -75
  428. package/src/opLifecycle/README.md +157 -0
  429. package/src/opLifecycle/batchManager.ts +119 -86
  430. package/src/opLifecycle/definitions.ts +49 -19
  431. package/src/opLifecycle/index.ts +7 -6
  432. package/src/opLifecycle/opCompressor.ts +78 -40
  433. package/src/opLifecycle/opDecompressor.ts +148 -64
  434. package/src/opLifecycle/opSplitter.ts +269 -66
  435. package/src/opLifecycle/outbox.ts +268 -184
  436. package/src/opLifecycle/remoteMessageProcessor.ts +63 -47
  437. package/src/opProperties.ts +11 -9
  438. package/src/packageVersion.ts +1 -1
  439. package/src/pendingStateManager.ts +386 -381
  440. package/src/scheduleManager.ts +299 -280
  441. package/src/storageServiceWithAttachBlobs.ts +38 -0
  442. package/src/summary/index.ts +105 -0
  443. package/src/summary/orderedClientElection.ts +564 -0
  444. package/src/summary/runWhileConnectedCoordinator.ts +113 -0
  445. package/src/summary/runningSummarizer.ts +788 -0
  446. package/src/summary/summarizer.ts +372 -0
  447. package/src/summary/summarizerClientElection.ts +139 -0
  448. package/src/summary/summarizerHeuristics.ts +224 -0
  449. package/src/summary/summarizerNode/index.ts +12 -0
  450. package/src/summary/summarizerNode/summarizerNode.ts +766 -0
  451. package/src/summary/summarizerNode/summarizerNodeUtils.ts +214 -0
  452. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +644 -0
  453. package/src/summary/summarizerTypes.ts +507 -0
  454. package/src/summary/summaryCollection.ts +450 -0
  455. package/src/summary/summaryFormat.ts +228 -0
  456. package/src/summary/summaryGenerator.ts +505 -0
  457. package/src/summary/summaryManager.ts +423 -0
  458. package/src/throttler.ts +131 -122
  459. package/tsconfig.esnext.json +6 -6
  460. package/tsconfig.json +9 -13
  461. package/dist/garbageCollection.d.ts +0 -387
  462. package/dist/garbageCollection.d.ts.map +0 -1
  463. package/dist/garbageCollection.js +0 -1138
  464. package/dist/garbageCollection.js.map +0 -1
  465. package/dist/garbageCollectionConstants.d.ts +0 -19
  466. package/dist/garbageCollectionConstants.d.ts.map +0 -1
  467. package/dist/garbageCollectionConstants.js +0 -34
  468. package/dist/garbageCollectionConstants.js.map +0 -1
  469. package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
  470. package/dist/gcSweepReadyUsageDetection.js.map +0 -1
  471. package/dist/orderedClientElection.d.ts.map +0 -1
  472. package/dist/orderedClientElection.js.map +0 -1
  473. package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
  474. package/dist/runWhileConnectedCoordinator.js.map +0 -1
  475. package/dist/runningSummarizer.d.ts.map +0 -1
  476. package/dist/runningSummarizer.js.map +0 -1
  477. package/dist/serializedSnapshotStorage.d.ts +0 -58
  478. package/dist/serializedSnapshotStorage.d.ts.map +0 -1
  479. package/dist/serializedSnapshotStorage.js +0 -108
  480. package/dist/serializedSnapshotStorage.js.map +0 -1
  481. package/dist/summarizer.d.ts.map +0 -1
  482. package/dist/summarizer.js.map +0 -1
  483. package/dist/summarizerClientElection.d.ts.map +0 -1
  484. package/dist/summarizerClientElection.js.map +0 -1
  485. package/dist/summarizerHandle.d.ts +0 -12
  486. package/dist/summarizerHandle.d.ts.map +0 -1
  487. package/dist/summarizerHandle.js +0 -22
  488. package/dist/summarizerHandle.js.map +0 -1
  489. package/dist/summarizerHeuristics.d.ts.map +0 -1
  490. package/dist/summarizerHeuristics.js.map +0 -1
  491. package/dist/summarizerTypes.d.ts.map +0 -1
  492. package/dist/summarizerTypes.js.map +0 -1
  493. package/dist/summaryCollection.d.ts.map +0 -1
  494. package/dist/summaryCollection.js.map +0 -1
  495. package/dist/summaryFormat.d.ts.map +0 -1
  496. package/dist/summaryFormat.js.map +0 -1
  497. package/dist/summaryGenerator.d.ts.map +0 -1
  498. package/dist/summaryGenerator.js.map +0 -1
  499. package/dist/summaryManager.d.ts.map +0 -1
  500. package/dist/summaryManager.js.map +0 -1
  501. package/lib/garbageCollection.d.ts +0 -387
  502. package/lib/garbageCollection.d.ts.map +0 -1
  503. package/lib/garbageCollection.js +0 -1133
  504. package/lib/garbageCollection.js.map +0 -1
  505. package/lib/garbageCollectionConstants.d.ts +0 -19
  506. package/lib/garbageCollectionConstants.d.ts.map +0 -1
  507. package/lib/garbageCollectionConstants.js +0 -31
  508. package/lib/garbageCollectionConstants.js.map +0 -1
  509. package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
  510. package/lib/gcSweepReadyUsageDetection.js.map +0 -1
  511. package/lib/orderedClientElection.d.ts.map +0 -1
  512. package/lib/orderedClientElection.js.map +0 -1
  513. package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
  514. package/lib/runWhileConnectedCoordinator.js.map +0 -1
  515. package/lib/runningSummarizer.d.ts.map +0 -1
  516. package/lib/runningSummarizer.js.map +0 -1
  517. package/lib/serializedSnapshotStorage.d.ts +0 -58
  518. package/lib/serializedSnapshotStorage.d.ts.map +0 -1
  519. package/lib/serializedSnapshotStorage.js +0 -104
  520. package/lib/serializedSnapshotStorage.js.map +0 -1
  521. package/lib/summarizer.d.ts.map +0 -1
  522. package/lib/summarizer.js.map +0 -1
  523. package/lib/summarizerClientElection.d.ts.map +0 -1
  524. package/lib/summarizerClientElection.js.map +0 -1
  525. package/lib/summarizerHandle.d.ts +0 -12
  526. package/lib/summarizerHandle.d.ts.map +0 -1
  527. package/lib/summarizerHandle.js +0 -18
  528. package/lib/summarizerHandle.js.map +0 -1
  529. package/lib/summarizerHeuristics.d.ts.map +0 -1
  530. package/lib/summarizerHeuristics.js.map +0 -1
  531. package/lib/summarizerTypes.d.ts.map +0 -1
  532. package/lib/summarizerTypes.js +0 -9
  533. package/lib/summarizerTypes.js.map +0 -1
  534. package/lib/summaryCollection.d.ts.map +0 -1
  535. package/lib/summaryCollection.js.map +0 -1
  536. package/lib/summaryFormat.d.ts.map +0 -1
  537. package/lib/summaryFormat.js.map +0 -1
  538. package/lib/summaryGenerator.d.ts.map +0 -1
  539. package/lib/summaryGenerator.js.map +0 -1
  540. package/lib/summaryManager.d.ts.map +0 -1
  541. package/lib/summaryManager.js.map +0 -1
  542. package/src/garbageCollection.ts +0 -1646
  543. package/src/garbageCollectionConstants.ts +0 -35
  544. package/src/gcSweepReadyUsageDetection.ts +0 -139
  545. package/src/orderedClientElection.ts +0 -532
  546. package/src/runWhileConnectedCoordinator.ts +0 -106
  547. package/src/runningSummarizer.ts +0 -611
  548. package/src/serializedSnapshotStorage.ts +0 -146
  549. package/src/summarizer.ts +0 -421
  550. package/src/summarizerClientElection.ts +0 -161
  551. package/src/summarizerHandle.ts +0 -21
  552. package/src/summarizerHeuristics.ts +0 -222
  553. package/src/summarizerTypes.ts +0 -510
  554. package/src/summaryCollection.ts +0 -421
  555. package/src/summaryFormat.ts +0 -235
  556. package/src/summaryGenerator.ts +0 -446
  557. package/src/summaryManager.ts +0 -394
  558. /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  559. /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  560. /package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
  561. /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  562. /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  563. /package/lib/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"garbageCollection.js","sourceRoot":"","sources":["../src/garbageCollection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;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,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryPerformanceEvent } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport { ClientSessionExpiredError, DataProcessingError, UsageError } from \"@fluidframework/container-utils\";\nimport { IRequestHeader } from \"@fluidframework/core-interfaces\";\nimport {\n cloneGCData,\n concatGarbageCollectionStates,\n concatGarbageCollectionData,\n IGCResult,\n runGarbageCollection,\n unpackChildNodesGCDetails,\n} from \"@fluidframework/garbage-collector\";\nimport { ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionState,\n IGarbageCollectionDetailsBase,\n ISummarizeResult,\n ITelemetryContext,\n IGarbageCollectionNodeData,\n ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n mergeStats,\n packagePathToTelemetryProperty,\n ReadAndParseBlob,\n RefreshSummaryResult,\n SummaryTreeBuilder,\n} from \"@fluidframework/runtime-utils\";\nimport {\n ChildLogger,\n generateStack,\n loggerToMonitoringContext,\n MonitoringContext,\n PerformanceEvent,\n TelemetryDataTag,\n} from \"@fluidframework/telemetry-utils\";\n\nimport { IGCRuntimeOptions, RuntimeHeaders } from \"./containerRuntime\";\nimport { getSummaryForDatastores } from \"./dataStores\";\nimport {\n defaultInactiveTimeoutMs,\n defaultSessionExpiryDurationMs,\n disableSweepLogKey,\n disableTombstoneKey,\n gcBlobPrefix,\n gcTestModeKey,\n gcTombstoneBlobKey,\n gcTreeKey,\n oneDayMs,\n runGCKey,\n runSessionExpiryKey,\n runSweepKey,\n trackGCStateKey\n} from \"./garbageCollectionConstants\";\nimport { SweepReadyUsageDetectionHandler } from \"./gcSweepReadyUsageDetection\";\nimport {\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n metadataBlobName,\n ReadFluidDataStoreAttributes,\n dataStoreAttributesBlobName,\n IGCMetadata,\n ICreateContainerMetadata,\n} from \"./summaryFormat\";\n\n/** This is the current version of garbage collection. */\nconst GCVersion = 1;\n\n/** The statistics of the system state after a garbage collection run. */\nexport interface IGCStats {\n /** The number of nodes in the container. */\n nodeCount: number;\n /** The number of data stores in the container. */\n dataStoreCount: number;\n /** The number of attachment blobs in the container. */\n attachmentBlobCount: number;\n /** The number of unreferenced nodes in the container. */\n unrefNodeCount: number;\n /** The number of unreferenced data stores in the container. */\n unrefDataStoreCount: number;\n /** The number of unreferenced attachment blobs in the container. */\n unrefAttachmentBlobCount: number;\n /** The number of nodes whose reference state updated since last GC run. */\n updatedNodeCount: number;\n /** The number of data stores whose reference state updated since last GC run. */\n updatedDataStoreCount: number;\n /** The number of attachment blobs whose reference state updated since last GC run. */\n updatedAttachmentBlobCount: number;\n}\n\n/** The types of GC nodes in the GC reference graph. */\nexport const GCNodeType = {\n // Nodes that are for data stores.\n DataStore: \"DataStore\",\n // Nodes that are within a data store. For example, DDS nodes.\n SubDataStore: \"SubDataStore\",\n // Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.\n Blob: \"Blob\",\n // Nodes that are neither of the above. For example, root node.\n Other: \"Other\",\n};\nexport type GCNodeType = typeof GCNodeType[keyof typeof GCNodeType];\n\n/** Defines the APIs for the runtime object to be passed to the garbage collector. */\nexport interface IGarbageCollectionRuntime {\n /** Before GC runs, called to notify the runtime to update any pending GC state. */\n updateStateBeforeGC(): Promise<void>;\n /** Returns the garbage collection data of the runtime. */\n getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;\n /** After GC has run, called to notify the runtime of routes that are used in it. */\n updateUsedRoutes(usedRoutes: string[]): void;\n /** After GC has run, called to notify the runtime of routes that are unused in it. */\n updateUnusedRoutes(unusedRoutes: string[], tombstone: boolean): void;\n /** Returns a referenced timestamp to be used to track unreferenced nodes. */\n getCurrentReferenceTimestampMs(): number | undefined;\n /** Returns the type of the GC node. */\n getNodeType(nodePath: string): GCNodeType;\n /** Called when the runtime should close because of an error. */\n closeFn: (error?: ICriticalContainerError) => void;\n}\n\n/** Defines the contract for the garbage collector. */\nexport interface IGarbageCollector {\n /** Tells whether GC should run or not. */\n readonly shouldRunGC: boolean;\n /** Tells whether the GC state in summary needs to be reset in the next summary. */\n readonly summaryStateNeedsReset: boolean;\n readonly trackGCState: boolean;\n /** Initialize the state from the base snapshot after its creation. */\n initializeBaseState(): Promise<void>;\n /** Run garbage collection and update the reference / used state of the system. */\n collectGarbage(\n options: { logger?: ITelemetryLogger; runSweep?: boolean; fullGC?: boolean; },\n ): Promise<IGCStats | undefined>;\n /** Summarizes the GC data and returns it as a summary tree. */\n summarize(\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ): ISummarizeResult | undefined;\n /** Returns the garbage collector specific metadata to be written into the summary. */\n getMetadata(): IGCMetadata;\n /** Returns a map of each node id to its base GC details in the base summary. */\n getBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>>;\n /** Called when the latest summary of the system has been refreshed. */\n latestSummaryStateRefreshed(result: RefreshSummaryResult, readAndParseBlob: ReadAndParseBlob): Promise<void>;\n /** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */\n nodeUpdated(\n nodePath: string,\n reason: \"Loaded\" | \"Changed\",\n timestampMs?: number,\n packagePath?: readonly string[],\n requestHeaders?: IRequestHeader,\n ): void;\n /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */\n addedOutboundReference(fromNodePath: string, toNodePath: string): void;\n setConnectionState(connected: boolean, clientId?: string): void;\n dispose(): void;\n}\n\n/** Parameters necessary for creating a GarbageCollector. */\nexport interface IGarbageCollectorCreateParams {\n readonly runtime: IGarbageCollectionRuntime;\n readonly gcOptions: IGCRuntimeOptions;\n readonly baseLogger: ITelemetryLogger;\n readonly existing: boolean;\n readonly metadata: IContainerRuntimeMetadata | undefined;\n readonly createContainerMetadata: ICreateContainerMetadata;\n readonly baseSnapshot: ISnapshotTree | undefined;\n readonly isSummarizerClient: boolean;\n readonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;\n readonly getLastSummaryTimestampMs: () => number | undefined;\n readonly readAndParseBlob: ReadAndParseBlob;\n readonly activeConnection: () => boolean;\n readonly getContainerDiagnosticId: () => string;\n}\n\n/** The state of node that is unreferenced. */\nexport const UnreferencedState = {\n /** The node is active, i.e., it can become referenced again. */\n Active: \"Active\",\n /** The node is inactive, i.e., it should not become referenced. */\n Inactive: \"Inactive\",\n /** The node is ready to be deleted by the sweep phase. */\n SweepReady: \"SweepReady\",\n} as const;\nexport type UnreferencedState = typeof UnreferencedState[keyof typeof UnreferencedState];\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps {\n usageType: \"Changed\" | \"Loaded\" | \"Revived\";\n state: UnreferencedState;\n id: string;\n type: GCNodeType;\n unrefTime: number;\n age: number;\n completedGCRuns: number;\n fromId?: string;\n timeout?: number;\n lastSummaryTime?: number;\n externalRequest?: boolean;\n viaHandle?: boolean;\n}\n\n/**\n * The GC data that is tracked for a summary that is submitted.\n */\ninterface IGCSummaryTrackingData {\n serializedGCState: string | undefined;\n serializedTombstones: string | undefined;\n}\n\n/**\n * The GC data that is read from a snapshot. It contains the GC state and tombstone state.\n */\ninterface IGCSnapshotData {\n gcState: IGarbageCollectionState;\n tombstones: string[] | undefined;\n}\n\n/**\n * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced and if it can\n * be deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n private _state: UnreferencedState = UnreferencedState.Active;\n public get state(): UnreferencedState {\n return this._state;\n }\n\n /** Timer to indicate when an unreferenced object is considered Inactive */\n private readonly inactiveTimer: TimerWithNoDefaultTimeout;\n /** Timer to indicate when an unreferenced object is Sweep-Ready */\n private readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n constructor(\n public readonly unreferencedTimestampMs: number,\n /** The time after which node transitions to Inactive state. */\n private readonly inactiveTimeoutMs: number,\n /** The current reference timestamp used to track how long this node has been unreferenced for. */\n currentReferenceTimestampMs: number,\n /** The time after which node transitions to SweepReady state; undefined if session expiry is disabled. */\n private readonly sweepTimeoutMs: number | undefined,\n ) {\n if (this.sweepTimeoutMs !== undefined) {\n assert(this.inactiveTimeoutMs <= this.sweepTimeoutMs,\n 0x3b0 /* inactive timeout must not be greater than the sweep timeout */);\n }\n\n this.sweepTimer = new TimerWithNoDefaultTimeout(\n () => {\n this._state = UnreferencedState.SweepReady;\n assert(!this.inactiveTimer.hasTimer, 0x3b1 /* inactiveTimer still running after sweepTimer fired! */);\n },\n );\n\n this.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n this._state = UnreferencedState.Inactive;\n\n // After the node becomes inactive, start the sweep timer after which the node will be ready for sweep.\n if (this.sweepTimeoutMs !== undefined) {\n this.sweepTimer.restart(this.sweepTimeoutMs - this.inactiveTimeoutMs);\n }\n });\n this.updateTracking(currentReferenceTimestampMs);\n }\n\n /* Updates the unreferenced state based on the provided timestamp. */\n public updateTracking(currentReferenceTimestampMs: number) {\n const unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n // If the node has been unreferenced for sweep timeout amount of time, update the state to SweepReady.\n if (this.sweepTimeoutMs !== undefined && unreferencedDurationMs >= this.sweepTimeoutMs) {\n this._state = UnreferencedState.SweepReady;\n this.clearTimers();\n return;\n }\n\n // If the node has been unreferenced for inactive timeoutMs amount of time, update the state to inactive.\n // Also, start a timer for the sweep timeout.\n if (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n this._state = UnreferencedState.Inactive;\n this.inactiveTimer.clear();\n\n if (this.sweepTimeoutMs !== undefined) {\n this.sweepTimer.restart(this.sweepTimeoutMs - unreferencedDurationMs);\n }\n return;\n }\n\n // The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n this.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n }\n\n private clearTimers() {\n this.inactiveTimer.clear();\n this.sweepTimer.clear();\n }\n\n /** Stop tracking this node. Reset the unreferenced timers and state, if any. */\n public stopTracking() {\n this.clearTimers();\n this._state = UnreferencedState.Active;\n }\n}\n\n/**\n * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains\n * its state across summaries.\n *\n * Node - represented as nodeId, it's a node on the GC graph\n *\n * Outbound Route - a path from one node to another node, think `nodeA` -\\> `nodeB`\n *\n * Graph - all nodes with their respective routes\n *\n * ```\n * GC Graph\n *\n * Node\n * NodeId = \"datastore1\"\n * / \\\\\n * OutboundRoute OutboundRoute\n * / \\\\\n * Node Node\n * NodeId = \"dds1\" NodeId = \"dds2\"\n * ```\n */\nexport class GarbageCollector implements IGarbageCollector {\n public static create(createParams: IGarbageCollectorCreateParams): IGarbageCollector {\n return new GarbageCollector(createParams);\n }\n\n /**\n * Tells whether the GC state needs to be reset in the next summary. We need to do this if:\n *\n * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.\n *\n * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.\n *\n * 3. The GC version in the latest summary is different from the current GC version. This can happen if:\n *\n * 3.1. The summary this client loaded with has data from a different GC version.\n *\n * 3.2. This client's latest summary was updated from a snapshot that has a different GC version.\n */\n public get summaryStateNeedsReset(): boolean {\n return this.initialStateNeedsReset ||\n (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion);\n }\n\n /**\n * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly gcEnabled: boolean;\n /**\n * Tracks if sweep phase is enabled for this document. This is specified during document creation and doesn't change\n * throughout its lifetime.\n */\n private readonly sweepEnabled: boolean;\n\n /**\n * Tracks if GC should run or not. Even if GC is enabled for a document (see gcEnabled), it can be explicitly\n * disabled via runtime options or feature flags.\n */\n public readonly shouldRunGC: boolean;\n /**\n * Tracks if sweep phase should run or not. Even if the sweep phase is enabled for a document (see sweepEnabled), it\n * can be explicitly disabled via feature flags. It also won't run if session expiry is not enabled.\n */\n private readonly shouldRunSweep: boolean;\n\n public readonly trackGCState: boolean;\n\n private readonly testMode: boolean;\n private readonly tombstoneMode: boolean;\n private readonly mc: MonitoringContext;\n\n /**\n * Tells whether the initial GC state needs to be reset. This can happen under 2 conditions:\n *\n * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after\n * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.\n *\n * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on\n * a document and the first time GC is enabled after is was disabled before.\n *\n * Note that the state needs reset only for the very first time summary is generated by this client. After that, the\n * state will be up-to-date and this flag will be reset.\n */\n private initialStateNeedsReset: boolean = false;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary being tracked.\n private latestSummaryGCVersion: GCVersion;\n\n // Keeps track of the GC state from the last run.\n private previousGCDataFromLastRun: IGarbageCollectionData | undefined;\n // Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of\n // outbound routes from that node.\n private readonly newReferencesSinceLastRun: Map<string, string[]> = new Map();\n private tombstones: string[] = [];\n\n /**\n * Keeps track of the GC data from the latest summary successfully submitted to and acked from the server.\n */\n private latestSummaryData: IGCSummaryTrackingData | undefined;\n /**\n * Keeps track of the GC data from the last summary submitted to the server but not yet acked.\n */\n private pendingSummaryData: IGCSummaryTrackingData | undefined;\n\n // Promise when resolved returns the GC data data in the base snapshot.\n private readonly baseSnapshotDataP: Promise<IGCSnapshotData | undefined>;\n // Promise when resolved initializes the GC state from the data in the base snapshot.\n private readonly initializeGCStateFromBaseSnapshotP: Promise<void>;\n // The map of data store ids to their GC details in the base summary returned in getDataStoreGCDetails().\n private readonly baseGCDetailsP: Promise<Map<string, IGarbageCollectionDetailsBase>>;\n // Map of node ids to their unreferenced state tracker.\n private readonly unreferencedNodesState: Map<string, UnreferencedStateTracker> = new Map();\n // The Timer responsible for closing the container when the session has expired\n private sessionExpiryTimer: Timer | undefined;\n\n // Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n // per event per node.\n private readonly loggedUnreferencedEvents: Set<string> = new Set();\n // Queue for unreferenced events that should be logged the next time GC runs.\n private pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n // The number of times GC has successfully completed on this instance of GarbageCollector.\n private completedRuns = 0;\n\n private readonly runtime: IGarbageCollectionRuntime;\n private readonly createContainerMetadata: ICreateContainerMetadata;\n private readonly gcOptions: IGCRuntimeOptions;\n private readonly isSummarizerClient: boolean;\n\n /** The time in ms to expire a session for a client for gc. */\n private readonly sessionExpiryTimeoutMs: number | undefined;\n /** The time after which an unreferenced node is inactive. */\n private readonly inactiveTimeoutMs: number;\n /** The time after which an unreferenced node is ready to be swept. */\n private readonly sweepTimeoutMs: number | undefined;\n\n /** For a given node path, returns the node's package path. */\n private readonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;\n /** Returns the timestamp of the last summary generated for this container. */\n private readonly getLastSummaryTimestampMs: () => number | undefined;\n /** Returns true if connection is active, i.e. it's \"write\" connection and the runtime is connected. */\n private readonly activeConnection: () => boolean;\n\n /** Returns a list of all the configurations for garbage collection. */\n private get configs() {\n return {\n gcEnabled: this.gcEnabled,\n sweepEnabled: this.sweepEnabled,\n runGC: this.shouldRunGC,\n runSweep: this.shouldRunSweep,\n testMode: this.testMode,\n tombstoneMode: this.tombstoneMode,\n sessionExpiry: this.sessionExpiryTimeoutMs,\n sweepTimeout: this.sweepTimeoutMs,\n inactiveTimeout: this.inactiveTimeoutMs,\n trackGCState: this.trackGCState,\n ...this.gcOptions,\n };\n }\n\n /** Handler to respond to when a SweepReady object is used */\n private readonly sweepReadyUsageHandler: SweepReadyUsageDetectionHandler;\n\n protected constructor(createParams: IGarbageCollectorCreateParams) {\n this.runtime = createParams.runtime;\n this.isSummarizerClient = createParams.isSummarizerClient;\n this.gcOptions = createParams.gcOptions;\n this.createContainerMetadata = createParams.createContainerMetadata;\n this.getNodePackagePath = createParams.getNodePackagePath;\n this.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;\n this.activeConnection = createParams.activeConnection;\n\n const baseSnapshot = createParams.baseSnapshot;\n const metadata = createParams.metadata;\n const readAndParseBlob = createParams.readAndParseBlob;\n\n this.mc = loggerToMonitoringContext(ChildLogger.create(\n createParams.baseLogger, \"GarbageCollector\", { all: { completedGCRuns: () => this.completedRuns } },\n ));\n\n this.sweepReadyUsageHandler = new SweepReadyUsageDetectionHandler(\n createParams.getContainerDiagnosticId(),\n this.mc,\n this.runtime.closeFn,\n );\n\n let prevSummaryGCVersion: number | undefined;\n\n /**\n * Sweep timeout is the time after which unreferenced content can be swept.\n * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + one day buffer.\n *\n * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days.\n * The buffer is added to account for any clock skew or other edge cases.\n * We use server timestamps throughout so the skew should be minimal but make it 1 day to be safe.\n */\n function computeSweepTimeout(sessionExpiryTimeoutMs: number | undefined) {\n const maxSnapshotCacheExpiryMs = 5 * oneDayMs;\n const bufferMs = oneDayMs;\n return sessionExpiryTimeoutMs &&\n (sessionExpiryTimeoutMs + maxSnapshotCacheExpiryMs + bufferMs);\n }\n\n /**\n * The following GC state is enabled during container creation and cannot be changed throughout its lifetime:\n * 1. Whether running GC mark phase is allowed or not.\n * 2. Whether running GC sweep phase is allowed or not.\n * 3. Whether GC session expiry is enabled or not.\n * For existing containers, we get this information from the metadata blob of its summary.\n */\n if (createParams.existing) {\n prevSummaryGCVersion = getGCVersion(metadata);\n // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all\n // other existing documents, GC is enabled.\n this.gcEnabled = prevSummaryGCVersion > 0;\n this.sweepEnabled = metadata?.sweepEnabled ?? false;\n this.sessionExpiryTimeoutMs = metadata?.sessionExpiryTimeoutMs;\n this.sweepTimeoutMs =\n metadata?.sweepTimeoutMs\n ?? computeSweepTimeout(this.sessionExpiryTimeoutMs); // Backfill old documents that didn't persist this\n } else {\n // Sweep should not be enabled without enabling GC mark phase. We could silently disable sweep in this\n // scenario but explicitly failing makes it clearer and promotes correct usage.\n if (this.gcOptions.sweepAllowed && this.gcOptions.gcAllowed === false) {\n throw new UsageError(\"GC sweep phase cannot be enabled without enabling GC mark phase\");\n }\n\n // This Test Override only applies for new containers\n const testOverrideSweepTimeoutMs =\n this.mc.config.getNumber(\"Fluid.GarbageCollection.TestOverride.SweepTimeoutMs\");\n\n // For new documents, GC is enabled by default. It can be explicitly disabled by setting the gcAllowed\n // flag in GC options to false.\n this.gcEnabled = this.gcOptions.gcAllowed !== false;\n // The sweep phase has to be explicitly enabled by setting the sweepAllowed flag in GC options to true.\n // ...unless we're using the TestOverride\n this.sweepEnabled = this.gcOptions.sweepAllowed === true || testOverrideSweepTimeoutMs !== undefined;\n\n // Set the Session Expiry only if the flag is enabled and GC is enabled.\n if (this.mc.config.getBoolean(runSessionExpiryKey) && this.gcEnabled) {\n this.sessionExpiryTimeoutMs = this.gcOptions.sessionExpiryTimeoutMs ?? defaultSessionExpiryDurationMs;\n }\n this.sweepTimeoutMs =\n testOverrideSweepTimeoutMs\n ?? computeSweepTimeout(this.sessionExpiryTimeoutMs);\n }\n\n // If session expiry is enabled, we need to close the container when the session expiry timeout expires.\n if (this.sessionExpiryTimeoutMs !== undefined) {\n // If Test Override config is set, override Session Expiry timeout.\n const overrideSessionExpiryTimeoutMs =\n this.mc.config.getNumber(\"Fluid.GarbageCollection.TestOverride.SessionExpiryMs\");\n const timeoutMs = overrideSessionExpiryTimeoutMs ?? this.sessionExpiryTimeoutMs;\n\n this.sessionExpiryTimer = new Timer(\n timeoutMs,\n () => { this.runtime.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs)); },\n );\n this.sessionExpiryTimer.start();\n }\n\n // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the\n // latest tracked GC version. For new documents, we will be writing the first summary with the current version.\n this.latestSummaryGCVersion = prevSummaryGCVersion ?? this.currentGCVersion;\n\n /**\n * Whether GC should run or not. The following conditions have to be met to run sweep:\n *\n * 1. GC should be enabled for this container.\n *\n * 2. GC should not be disabled via disableGC GC option.\n *\n * These conditions can be overridden via runGCKey feature flag.\n */\n this.shouldRunGC = this.mc.config.getBoolean(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // GC must not be disabled via GC options.\n && !this.gcOptions.disableGC\n );\n\n /**\n * Whether sweep should run or not. The following conditions have to be met to run sweep:\n *\n * 1. Overall GC or mark phase must be enabled (this.shouldRunGC).\n * 2. Sweep timeout should be available. Without this, we wouldn't know when an object should be deleted.\n * 3. The driver must implement the policy limiting the age of snapshots used for loading. Otherwise\n * the Sweep Timeout calculation is not valid. We use the persisted value to ensure consistency over time.\n * 4. Sweep should be enabled for this container (this.sweepEnabled). This can be overridden via runSweep\n * feature flag.\n */\n this.shouldRunSweep =\n this.shouldRunGC\n && this.sweepTimeoutMs !== undefined\n && (this.mc.config.getBoolean(runSweepKey) ?? this.sweepEnabled);\n\n this.trackGCState = this.mc.config.getBoolean(trackGCStateKey) === true;\n\n // Override inactive timeout if test config or gc options to override it is set.\n this.inactiveTimeoutMs = this.mc.config.getNumber(\"Fluid.GarbageCollection.TestOverride.InactiveTimeoutMs\") ??\n this.gcOptions.inactiveTimeoutMs ??\n defaultInactiveTimeoutMs;\n\n // Inactive timeout must be greater than sweep timeout since a node goes from active -> inactive -> sweep ready.\n if (this.sweepTimeoutMs !== undefined && this.inactiveTimeoutMs > this.sweepTimeoutMs) {\n throw new UsageError(\"inactive timeout should not be greater than the sweep timeout\");\n }\n\n // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.\n this.testMode = this.mc.config.getBoolean(gcTestModeKey) ?? this.gcOptions.runGCInTestMode === true;\n // Whether we are running in tombstone mode. This is true by default unless disabled via feature flags.\n this.tombstoneMode = this.mc.config.getBoolean(disableTombstoneKey) !== true;\n\n // The GC state needs to be reset if the base snapshot contains GC tree and GC is disabled or it doesn't\n // contain GC tree and GC is enabled.\n const gcTreePresent = baseSnapshot?.trees[gcTreeKey] !== undefined;\n this.initialStateNeedsReset = gcTreePresent !== this.shouldRunGC;\n\n // Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it\n // it involves fetching blobs from storage which is expensive.\n this.baseSnapshotDataP = new LazyPromise<IGCSnapshotData | undefined>(async () => {\n if (baseSnapshot === undefined) {\n return undefined;\n }\n\n try {\n // For newer documents, GC data should be present in the GC tree in the root of the snapshot.\n const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined) {\n return getGCDataFromSnapshot(\n gcSnapshotTree,\n readAndParseBlob,\n );\n }\n\n // back-compat - Older documents will have the GC blobs in each data store's summary tree. Get them and\n // consolidate into IGarbageCollectionState format.\n // Add a node for the root node that is not present in older snapshot format.\n const gcState: IGarbageCollectionState = { gcNodes: { \"/\": { outboundRoutes: [] } } };\n const dataStoreSnapshotTree = getSummaryForDatastores(baseSnapshot, metadata);\n assert(dataStoreSnapshotTree !== undefined,\n 0x2a8 /* \"Expected data store snapshot tree in base snapshot\" */);\n for (const [dsId, dsSnapshotTree] of Object.entries(dataStoreSnapshotTree.trees)) {\n const blobId = dsSnapshotTree.blobs[gcBlobKey];\n if (blobId === undefined) {\n continue;\n }\n\n const gcSummaryDetails = await readAndParseBlob<IGarbageCollectionDetailsBase>(blobId);\n // If there are no nodes for this data store, skip it.\n if (gcSummaryDetails.gcData?.gcNodes === undefined) {\n continue;\n }\n\n const dsRootId = `/${dsId}`;\n // Since we used to write GC data at data store level, we won't have an entry for the root (\"/\").\n // Construct that entry by adding root data store ids to its outbound routes.\n const initialSnapshotDetails = await readAndParseBlob<ReadFluidDataStoreAttributes>(\n dsSnapshotTree.blobs[dataStoreAttributesBlobName],\n );\n if (initialSnapshotDetails.isRootDataStore) {\n gcState.gcNodes[\"/\"].outboundRoutes.push(dsRootId);\n }\n\n for (const [id, outboundRoutes] of Object.entries(gcSummaryDetails.gcData.gcNodes)) {\n // Prefix the data store id to the GC node ids to make them relative to the root from being\n // relative to the data store. Similar to how its done in DataStore::getGCData.\n const rootId = id === \"/\" ? dsRootId : `${dsRootId}${id}`;\n gcState.gcNodes[rootId] = { outboundRoutes: Array.from(outboundRoutes) };\n }\n assert(gcState.gcNodes[dsRootId] !== undefined,\n 0x2a9 /* GC nodes for data store not in GC blob */);\n gcState.gcNodes[dsRootId].unreferencedTimestampMs = gcSummaryDetails.unrefTimestamp;\n }\n // If there is only one node (root node just added above), either GC is disabled or we are loading from\n // the first summary generated by detached container. In both cases, GC was not run - return undefined.\n return Object.keys(gcState.gcNodes).length === 1 ? undefined : { gcState, tombstones: undefined };\n } catch (error) {\n const dpe = DataProcessingError.wrapIfUnrecognized(\n error,\n \"FailedToInitializeGC\",\n );\n dpe.addTelemetryProperties({ gcConfigs: JSON.stringify(this.configs) });\n throw dpe;\n }\n });\n\n /**\n * Set up the initializer which initializes the GC state from the data in base snapshot. This is done when\n * connected in write mode or when GC runs the first time. It sets up all unreferenced nodes from the base\n * GC state and updates their inactive or sweep ready state.\n */\n this.initializeGCStateFromBaseSnapshotP = new LazyPromise<void>(async () => {\n const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n /**\n * If there is no current reference timestamp, skip initialization. We need the current timestamp to track\n * how long objects have been unreferenced and if they can be deleted.\n *\n * Note that the only scenario where there is no reference timestamp is when no ops have ever been processed\n * for this container and it is in read mode. In this scenario, there is no point in running GC anyway\n * because references in the container do not change without any ops, i.e., there is nothing to collect.\n */\n if (currentReferenceTimestampMs === undefined) {\n // Log an event so we can evaluate how often we run into this scenario.\n this.mc.logger.sendErrorEvent({\n eventName: \"GarbageCollectorInitializedWithoutTimestamp\",\n gcConfigs: JSON.stringify(this.configs),\n });\n return;\n }\n\n const baseSnapshotData = await this.baseSnapshotDataP;\n /**\n * The base snapshot data will not be present if the container is loaded from:\n * 1. The first summary created by the detached container.\n * 2. A summary that was generated with GC disabled.\n * 3. A summary that was generated before GC even existed.\n */\n if (baseSnapshotData === undefined) {\n return;\n }\n\n const gcNodes: { [id: string]: string[]; } = {};\n for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n nodeData.unreferencedTimestampMs,\n this.inactiveTimeoutMs,\n currentReferenceTimestampMs,\n this.sweepTimeoutMs,\n ),\n );\n }\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n this.previousGCDataFromLastRun = { gcNodes };\n\n // If tracking state across summaries, update latest summary data from the base snapshot's GC data.\n if (this.trackGCState) {\n this.latestSummaryData = {\n serializedGCState: JSON.stringify(generateSortedGCState(baseSnapshotData.gcState)),\n serializedTombstones: JSON.stringify(baseSnapshotData.tombstones),\n };\n }\n });\n\n // Get the GC details for each node from the GC state in the base summary. This is returned in getBaseGCDetails\n // which the caller uses to initialize each node's GC state.\n this.baseGCDetailsP = new LazyPromise<Map<string, IGarbageCollectionDetailsBase>>(async () => {\n const baseSnapshotData = await this.baseSnapshotDataP;\n if (baseSnapshotData === undefined) {\n return new Map();\n }\n\n const gcNodes: { [id: string]: string[]; } = {};\n for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);\n }\n // Run GC on the nodes in the base summary to get the routes used in each node in the container.\n // This is an optimization for space (vs performance) wherein we don't need to store the used routes of\n // each node in the summary.\n const usedRoutes = runGarbageCollection(gcNodes, [\"/\"]).referencedNodeIds;\n\n const baseGCDetailsMap = unpackChildNodesGCDetails({ gcData: { gcNodes }, usedRoutes });\n // Currently, the nodes may write the GC data. So, we need to update its base GC details with the\n // unreferenced timestamp. Once we start writing the GC data here, we won't need to do this anymore.\n for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {\n if (nodeData.unreferencedTimestampMs !== undefined) {\n const dataStoreGCDetails = baseGCDetailsMap.get(nodeId.slice(1));\n if (dataStoreGCDetails !== undefined) {\n dataStoreGCDetails.unrefTimestamp = nodeData.unreferencedTimestampMs;\n }\n }\n }\n return baseGCDetailsMap;\n });\n\n // Log all the GC options and the state determined by the garbage collector. This is interesting only for the\n // summarizer client since it is the only one that runs GC. It also helps keep the telemetry less noisy.\n if (this.isSummarizerClient) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"GarbageCollectorLoaded\",\n gcConfigs: JSON.stringify(this.configs),\n });\n }\n }\n\n /**\n * Called during container initialization. Initialize the tombstone state so that object are marked as tombstones\n * before they are loaded or used. This is important to get accurate information of whether tombstoned object are\n * in use or not.\n */\n public async initializeBaseState(): Promise<void> {\n const baseSnapshotData = await this.baseSnapshotDataP;\n /**\n * The base snapshot data or tombstone state will not be present if the container is loaded from:\n * 1. The first summary created by the detached container.\n * 2. A summary that was generated with GC disabled.\n * 3. A summary that was generated before GC even existed.\n * 4. A summary that was generated with tombstone feature disabled.\n */\n if (!this.tombstoneMode || baseSnapshotData?.tombstones === undefined) {\n return;\n }\n this.tombstones = baseSnapshotData.tombstones;\n this.runtime.updateUnusedRoutes(this.tombstones, true /* tombstone */);\n }\n\n /**\n * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this\n * to initialize the base state for non-summarizer clients so that they can track inactive / sweep ready nodes.\n * @param connected - Whether the runtime connected / disconnected.\n * @param clientId - The clientId of this runtime.\n */\n public setConnectionState(connected: boolean, clientId?: string | undefined): void {\n /**\n * For all clients, initialize the base state when the container becomes active, i.e., it transitions\n * to \"write\" mode. This will ensure that the container's own join op is processed and there is a recent\n * reference timestamp that will be used to update the state of unreferenced nodes. Also, all trailing ops which\n * could affect the GC state will have been processed.\n *\n * If GC is up-to-date for the client and the summarizing client, there will be an doubling of both\n * InactiveObject_Loaded and SweepReady_Loaded errors, as there will be one from the sending client and one from\n * the receiving summarizer client.\n *\n * Ideally, this initialization should only be done for summarizer client. However, we are currently rolling out\n * sweep in phases and we want to track when inactive and sweep ready objects are used in any client.\n */\n if (this.activeConnection() && this.shouldRunGC) {\n this.initializeGCStateFromBaseSnapshotP.catch((error) => {});\n }\n }\n\n /**\n * Runs garbage collection and updates the reference / used state of the nodes in the container.\n * @returns stats of the GC run or undefined if GC did not run.\n */\n public async collectGarbage(\n options: {\n /** Logger to use for logging GC events */\n logger?: ITelemetryLogger;\n /** True to run GC sweep phase after the mark phase */\n runSweep?: boolean;\n /** True to generate full GC data */\n fullGC?: boolean;\n },\n ): Promise<IGCStats | undefined> {\n const fullGC = options.fullGC ?? (this.gcOptions.runFullGC === true || this.summaryStateNeedsReset);\n const logger = options.logger\n ? ChildLogger.create(options.logger, undefined, { all: { completedGCRuns: () => this.completedRuns } })\n : this.mc.logger;\n\n /**\n * If there is no current reference timestamp, skip running GC. We need the current timestamp to track\n * how long objects have been unreferenced and if they should be deleted.\n *\n * Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever\n * been processed for this container and it is in read mode. In this scenario, there is no point in running GC\n * anyway because references in the container do not change without any ops, i.e., there is nothing to collect.\n */\n const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();\n if (currentReferenceTimestampMs === undefined) {\n // Log an event so we can evaluate how often we run into this scenario.\n logger.sendErrorEvent({\n eventName: \"CollectGarbageCalledWithoutTimestamp\",\n gcConfigs: JSON.stringify(this.configs),\n });\n return undefined;\n }\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n await this.runPreGCSteps();\n\n // Get the runtime's GC data and run GC on the reference graph in it.\n const gcData = await this.runtime.getGCData(fullGC);\n const gcResult = runGarbageCollection(gcData.gcNodes, [\"/\"]);\n\n const gcStats = await this.runPostGCSteps(gcData, gcResult, logger, currentReferenceTimestampMs);\n event.end({ ...gcStats, timestamp: currentReferenceTimestampMs });\n this.completedRuns++;\n return gcStats;\n }, { end: true, cancel: \"error\" });\n }\n\n private async runPreGCSteps() {\n // Ensure that state has been initialized from the base snapshot data.\n await this.initializeGCStateFromBaseSnapshotP;\n // Let the runtime update its pending state before GC runs.\n await this.runtime.updateStateBeforeGC();\n }\n\n private async runPostGCSteps(\n gcData: IGarbageCollectionData,\n gcResult: IGCResult,\n logger: ITelemetryLogger,\n currentReferenceTimestampMs: number,\n ): Promise<IGCStats> {\n // Generate statistics from the current run. This is done before updating the current state because it\n // generates some of its data based on previous state of the system.\n const gcStats = this.generateStats(gcResult);\n\n // Update the state since the last GC run. There can be nodes that were referenced between the last and\n // the current run. We need to identify than and update their unreferenced state if needed.\n this.updateStateSinceLastRun(gcData, logger);\n\n // Update the current state and update the runtime of all routes or ids that used as per the GC run.\n this.updateCurrentState(gcData, gcResult, currentReferenceTimestampMs);\n this.runtime.updateUsedRoutes(gcResult.referencedNodeIds);\n\n // Log events for objects that are ready to be deleted by sweep. When we have sweep enabled, we will\n // delete these objects here instead.\n this.logSweepEvents(logger, currentReferenceTimestampMs);\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.testMode) {\n this.runtime.updateUnusedRoutes(gcResult.deletedNodeIds, false /* tombstone */);\n } else if (this.tombstoneMode) {\n // If we are running in GC tombstone mode, tombstone objects for unused routes. This enables testing\n // scenarios involving access to \"deleted\" data without actually deleting the data from summaries.\n // Note: we will not tombstone in test mode\n this.runtime.updateUnusedRoutes(this.tombstones, true /* tombstone */);\n }\n\n // Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and\n // updates its state so that we don't send false positives based on intermediate state. For example, we may get\n // reference to an unreferenced node from another unreferenced node which means the node wasn't revived.\n await this.logUnreferencedEvents(logger);\n\n return gcStats;\n }\n\n /**\n * Summarizes the GC data and returns it as a summary tree.\n * We current write the entire GC state in a single blob. This can be modified later to write multiple\n * blobs. All the blob keys should start with `gcBlobPrefix`.\n */\n public summarize(\n fullTree: boolean,\n trackState: boolean,\n telemetryContext?: ITelemetryContext,\n ): ISummarizeResult | undefined {\n if (!this.shouldRunGC || this.previousGCDataFromLastRun === undefined) {\n return;\n }\n\n const gcState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, outboundRoutes] of Object.entries(this.previousGCDataFromLastRun.gcNodes)) {\n gcState.gcNodes[nodeId] = {\n outboundRoutes,\n unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,\n };\n }\n\n const serializedGCState = JSON.stringify(generateSortedGCState(gcState));\n const serializedTombstones = this.tombstoneMode\n ? (this.tombstones.length > 0 ? JSON.stringify(this.tombstones.sort()) : undefined)\n : undefined;\n\n /**\n * Incremental summary of GC data - If any of the GC state or tombstone state hasn't changed since the last\n * summary, send summary handles for them. Otherwise, send the data in summary blobs.\n */\n if (this.trackGCState) {\n this.pendingSummaryData = { serializedGCState, serializedTombstones };\n if (trackState && !fullTree && this.latestSummaryData !== undefined) {\n // If neither GC state or tombstone state changed, send a summary handle for the entire GC data.\n if (this.latestSummaryData.serializedGCState === serializedGCState\n && this.latestSummaryData.serializedTombstones === serializedTombstones) {\n const stats = mergeStats();\n stats.handleNodeCount++;\n return {\n summary: {\n type: SummaryType.Handle,\n handle: `/${gcTreeKey}`,\n handleType: SummaryType.Tree,\n },\n stats,\n };\n }\n\n // If either or both of GC state or tombstone state changed, build a GC summary tree.\n return this.buildGCSummaryTree(serializedGCState, serializedTombstones, true /* trackState */);\n }\n }\n // If not tracking GC state, build a GC summary tree without any summary handles.\n return this.buildGCSummaryTree(serializedGCState, serializedTombstones, false /* trackState */);\n }\n\n /**\n * Builds the GC summary tree which contains GC state and tombstone state.\n * If trackState is false, both GC state and tombstone state are written as summary blobs.\n * If trackState is true, summary blob is written for GC state or tombstone state if they changed.\n * @param serializedGCState - The GC state serialized as string.\n * @param serializedTombstones - THe tombstone state serialized as string.\n * @param trackState - Whether we are tracking GC state across summaries.\n * @returns the GC summary tree.\n */\n private buildGCSummaryTree(\n serializedGCState: string,\n serializedTombstones: string | undefined,\n trackState: boolean,\n ): ISummaryTreeWithStats {\n const gcStateBlobKey = `${gcBlobPrefix}_root`;\n const builder = new SummaryTreeBuilder();\n\n // If the GC state hasn't changed, write a summary handle, else write a summary blob for it.\n if (this.latestSummaryData?.serializedGCState === serializedGCState && trackState) {\n builder.addHandle(gcStateBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcStateBlobKey}`);\n } else {\n builder.addBlob(gcStateBlobKey, serializedGCState);\n }\n\n // If there is no tombstone data, return only the GC state.\n if (serializedTombstones === undefined) {\n return builder.getSummaryTree();\n }\n\n // If the tombstone state hasn't changed, write a summary handle, else write a summary blob for it.\n if (this.latestSummaryData?.serializedTombstones === serializedTombstones && trackState) {\n builder.addHandle(gcTombstoneBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcTombstoneBlobKey}`);\n } else {\n builder.addBlob(gcTombstoneBlobKey, serializedTombstones);\n }\n return builder.getSummaryTree();\n }\n\n public getMetadata(): IGCMetadata {\n return {\n /**\n * If GC is enabled, the GC data is written using the current GC version and that is the gcFeature that goes\n * into the metadata blob. If GC is disabled, the gcFeature is 0.\n */\n gcFeature: this.gcEnabled ? this.currentGCVersion : 0,\n sessionExpiryTimeoutMs: this.sessionExpiryTimeoutMs,\n sweepEnabled: this.sweepEnabled,\n sweepTimeoutMs: this.sweepTimeoutMs,\n };\n }\n\n /**\n * Returns a map of node ids to their base GC details generated from the base summary. This is used by the caller\n * to initialize the GC state of the nodes.\n */\n public async getBaseGCDetails(): Promise<Map<string, IGarbageCollectionDetailsBase>> {\n return this.baseGCDetailsP;\n }\n\n /**\n * Called when the latest summary of the system has been refreshed. This will be used to update the state of the\n * latest summary tracked.\n */\n public async latestSummaryStateRefreshed(\n result: RefreshSummaryResult,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n if (!this.shouldRunGC || !result.latestSummaryUpdated) {\n return;\n }\n\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Basically, it was written in the current GC version.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n this.initialStateNeedsReset = false;\n if (this.trackGCState) {\n this.latestSummaryData = this.pendingSummaryData;\n this.pendingSummaryData = undefined;\n }\n return;\n }\n // If the summary was not tracked by this client, update latest GC version and blob from the snapshot in the\n // result as that is now the latest summary.\n const snapshot = result.snapshot;\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParseBlob<IContainerRuntimeMetadata>(metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n\n const gcSnapshotTree = snapshot.trees[gcTreeKey];\n if (gcSnapshotTree !== undefined && this.trackGCState) {\n const latestGCData = await getGCDataFromSnapshot(\n gcSnapshotTree,\n readAndParseBlob,\n );\n this.latestSummaryData = {\n serializedGCState: JSON.stringify(generateSortedGCState(latestGCData.gcState)),\n serializedTombstones: JSON.stringify(latestGCData.tombstones),\n };\n } else {\n this.latestSummaryData = undefined;\n }\n this.pendingSummaryData = undefined;\n }\n\n /**\n * Called when a node with the given id is updated. If the node is inactive, log an error.\n * @param nodePath - The id of the node that changed.\n * @param reason - Whether the node was loaded or changed.\n * @param timestampMs - The timestamp when the node changed.\n * @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.\n * @param requestHeaders - If the node was loaded via request path, the headers in the request.\n */\n public nodeUpdated(\n nodePath: string,\n reason: \"Loaded\" | \"Changed\",\n timestampMs?: number,\n packagePath?: readonly string[],\n requestHeaders?: IRequestHeader,\n ) {\n if (!this.shouldRunGC) {\n return;\n }\n\n const nodeStateTracker = this.unreferencedNodesState.get(nodePath);\n if (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n this.inactiveNodeUsed(\n reason,\n nodePath,\n nodeStateTracker,\n undefined /* fromNodeId */,\n packagePath,\n timestampMs,\n requestHeaders,\n );\n }\n }\n\n /**\n * Called when an outbound reference is added to a node. This is used to identify all nodes that have been\n * referenced between summaries so that their unreferenced timestamp can be reset.\n *\n * @param fromNodePath - The node from which the reference is added.\n * @param toNodePath - The node to which the reference is added.\n */\n public addedOutboundReference(fromNodePath: string, toNodePath: string) {\n if (!this.shouldRunGC) {\n return;\n }\n\n const outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];\n outboundRoutes.push(toNodePath);\n this.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);\n\n const nodeStateTracker = this.unreferencedNodesState.get(toNodePath);\n if (nodeStateTracker && nodeStateTracker.state !== UnreferencedState.Active) {\n this.inactiveNodeUsed(\"Revived\", toNodePath, nodeStateTracker, fromNodePath);\n }\n }\n\n public dispose(): void {\n this.sessionExpiryTimer?.clear();\n this.sessionExpiryTimer = undefined;\n }\n\n /**\n * Updates the state of the system as per the current GC run. It does the following:\n * 1. Sets up the current GC state as per the gcData.\n * 2. Starts tracking for nodes that have become unreferenced in this run.\n * 3. Clears tracking for nodes that were unreferenced but became referenced in this run.\n * @param gcData - The data representing the reference graph on which GC is run.\n * @param gcResult - The result of the GC run on the gcData.\n * @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.\n */\n private updateCurrentState(\n gcData: IGarbageCollectionData,\n gcResult: IGCResult,\n currentReferenceTimestampMs: number,\n ) {\n this.previousGCDataFromLastRun = cloneGCData(gcData);\n this.tombstones = [];\n this.newReferencesSinceLastRun.clear();\n\n // Iterate through the referenced nodes and stop tracking if they were unreferenced before.\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the node as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n\n /**\n * If a node became unreferenced in this run, start tracking it.\n * If a node was already unreferenced, update its tracking information. Since the current reference time is\n * from the ops seen, this will ensure that we keep updating the unreferenced state as time moves forward.\n */\n for (const nodeId of gcResult.deletedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker === undefined) {\n this.unreferencedNodesState.set(\n nodeId,\n new UnreferencedStateTracker(\n currentReferenceTimestampMs,\n this.inactiveTimeoutMs,\n currentReferenceTimestampMs,\n this.sweepTimeoutMs,\n ),\n );\n } else {\n nodeStateTracker.updateTracking(currentReferenceTimestampMs);\n if (this.tombstoneMode && nodeStateTracker.state === UnreferencedState.SweepReady) {\n const nodeType = this.runtime.getNodeType(nodeId);\n if (nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) {\n this.tombstones.push(nodeId);\n }\n }\n }\n }\n }\n\n /**\n * Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in\n * time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be\n * updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of\n * these objects while there can be in-memory referenced to it:\n * 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is\n * added, the object may have been accessed and in-memory reference to it added.\n * 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were\n * unreferenced, they could have been accessed and in-memory reference to them added.\n *\n * This function identifies nodes that were referenced since last run and removes their unreferenced state, if any.\n * If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.\n */\n private updateStateSinceLastRun(currentGCData: IGarbageCollectionData, logger: ITelemetryLogger) {\n // If we haven't run GC before there is nothing to do.\n if (this.previousGCDataFromLastRun === undefined) {\n return;\n }\n\n // Find any references that haven't been identified correctly.\n const missingExplicitReferences = this.findMissingExplicitReferences(\n currentGCData,\n this.previousGCDataFromLastRun,\n this.newReferencesSinceLastRun,\n );\n\n if (missingExplicitReferences.length > 0) {\n missingExplicitReferences.forEach((missingExplicitReference) => {\n const event: ITelemetryPerformanceEvent = {\n eventName: \"gcUnknownOutboundReferences\",\n gcNodeId: missingExplicitReference[0],\n gcRoutes: JSON.stringify(missingExplicitReference[1]),\n };\n logger.sendPerformanceEvent(event);\n });\n }\n\n // No references were added since the last run so we don't have to update reference states of any unreferenced\n // nodes\n if (this.newReferencesSinceLastRun.size === 0) {\n return;\n }\n\n /**\n * Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and\n * edges that have been added since then. To do this, combine the GC data from the last run and the current\n * run, and then add the references since last run.\n *\n * Note on why we need to combine the data from previous run, current run and all references in between -\n * 1. We need data from last run because some of its references may have been deleted since then. If those\n * references added new outbound references before they were deleted, we need to detect them.\n *\n * 2. We need new outbound references since last run because some of them may have been deleted later. If those\n * references added new outbound references before they were deleted, we need to detect them.\n *\n * 3. We need data from the current run because currently we may not detect when DDSes are referenced:\n * - We don't require DDSes handles to be stored in a referenced DDS.\n * - A new data store may have \"root\" DDSes already created and we don't detect them today.\n */\n const gcDataSuperSet = concatGarbageCollectionData(this.previousGCDataFromLastRun, currentGCData);\n const newOutboundRoutesSinceLastRun: string[] = [];\n this.newReferencesSinceLastRun.forEach((outboundRoutes: string[], sourceNodeId: string) => {\n if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {\n gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;\n } else {\n gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);\n }\n newOutboundRoutesSinceLastRun.push(...outboundRoutes);\n });\n\n /**\n * Run GC on the above reference graph starting with root and all new outbound routes. This will generate a\n * list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,\n * unreferenced, stop tracking them and remove from unreferenced list.\n * Note that some of these nodes may be unreferenced now and if so, the current run will mark them as\n * unreferenced and add unreferenced state.\n */\n const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [\"/\", ...newOutboundRoutesSinceLastRun]);\n for (const nodeId of gcResult.referencedNodeIds) {\n const nodeStateTracker = this.unreferencedNodesState.get(nodeId);\n if (nodeStateTracker !== undefined) {\n // Stop tracking so as to clear out any running timers.\n nodeStateTracker.stopTracking();\n // Delete the unreferenced state as we don't need to track it any more.\n this.unreferencedNodesState.delete(nodeId);\n }\n }\n }\n\n /**\n * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n * The principle is that every new reference or outbound route must be notified to GC via the\n * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n *\n * In more simple terms:\n * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n *\n * @param currentGCData - The GC data (reference graph) from the current GC run.\n * @param previousGCData - The GC data (reference graph) from the previous GC run.\n * @param explicitReferences - New references added explicity between the previous and the current run.\n * @returns - a list of missing explicit references\n */\n private findMissingExplicitReferences(\n currentGCData: IGarbageCollectionData,\n previousGCData: IGarbageCollectionData,\n explicitReferences: Map<string, string[]>,\n ): [string, string[]][] {\n assert(\n previousGCData !== undefined,\n 0x2b7, /* \"Can't validate correctness without GC data from last run\" */\n );\n\n const currentGraph = Object.entries(currentGCData.gcNodes);\n const missingExplicitReferences: [string, string[]][] = [];\n currentGraph.forEach(([nodeId, currentOutboundRoutes]) => {\n const previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n const explicitRoutes = explicitReferences.get(nodeId) ?? [];\n const missingExplicitRoutes: string[] = [];\n currentOutboundRoutes.forEach((route) => {\n const isBlobOrDataStoreRoute =\n this.runtime.getNodeType(route) === GCNodeType.Blob ||\n this.runtime.getNodeType(route) === GCNodeType.DataStore;\n // Ignore implicitly added DDS routes to their parent datastores\n const notRouteFromDDSToParentDataStore = !nodeId.startsWith(route);\n if (\n isBlobOrDataStoreRoute &&\n notRouteFromDDSToParentDataStore &&\n (!previousRoutes.includes(route) && !explicitRoutes.includes(route))\n ) {\n missingExplicitRoutes.push(route);\n }\n });\n if (missingExplicitRoutes.length > 0) {\n missingExplicitReferences.push([nodeId, missingExplicitRoutes]);\n }\n });\n\n // Ideally missingExplicitReferences should always have a size 0\n return missingExplicitReferences;\n }\n\n /**\n * Generates the stats of a garbage collection run from the given results of the run.\n * @param gcResult - The result of a GC run.\n * @returns the GC stats of the GC run.\n */\n private generateStats(gcResult: IGCResult): IGCStats {\n const gcStats: IGCStats = {\n nodeCount: 0,\n dataStoreCount: 0,\n attachmentBlobCount: 0,\n unrefNodeCount: 0,\n unrefDataStoreCount: 0,\n unrefAttachmentBlobCount: 0,\n updatedNodeCount: 0,\n updatedDataStoreCount: 0,\n updatedAttachmentBlobCount: 0,\n };\n\n const updateNodeStats = (nodeId: string, referenced: boolean) => {\n gcStats.nodeCount++;\n // If there is no previous GC data, every node's state is generated and is considered as updated.\n // Otherwise, find out if any node went from referenced to unreferenced or vice-versa.\n const stateUpdated = this.previousGCDataFromLastRun === undefined ||\n this.unreferencedNodesState.has(nodeId) === referenced;\n if (stateUpdated) {\n gcStats.updatedNodeCount++;\n }\n if (!referenced) {\n gcStats.unrefNodeCount++;\n }\n\n if (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {\n gcStats.dataStoreCount++;\n if (stateUpdated) {\n gcStats.updatedDataStoreCount++;\n }\n if (!referenced) {\n gcStats.unrefDataStoreCount++;\n }\n }\n if (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {\n gcStats.attachmentBlobCount++;\n if (stateUpdated) {\n gcStats.updatedAttachmentBlobCount++;\n }\n if (!referenced) {\n gcStats.unrefAttachmentBlobCount++;\n }\n }\n };\n\n for (const nodeId of gcResult.referencedNodeIds) {\n updateNodeStats(nodeId, true /* referenced */);\n }\n\n for (const nodeId of gcResult.deletedNodeIds) {\n updateNodeStats(nodeId, false /* referenced */);\n }\n\n return gcStats;\n }\n\n /**\n * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,\n * this will give us a view into how much deleted content a container has.\n */\n private logSweepEvents(logger: ITelemetryLogger, currentReferenceTimestampMs: number) {\n if (this.mc.config.getBoolean(disableSweepLogKey) === true || this.sweepTimeoutMs === undefined) {\n return;\n }\n\n this.unreferencedNodesState.forEach((nodeStateTracker, nodeId) => {\n if (nodeStateTracker.state !== UnreferencedState.SweepReady) {\n return;\n }\n\n const nodeType = this.runtime.getNodeType(nodeId);\n if (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n return;\n }\n\n // Log deleted event for each node only once to reduce noise in telemetry.\n const uniqueEventId = `Deleted-${nodeId}`;\n if (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n return;\n }\n this.loggedUnreferencedEvents.add(uniqueEventId);\n logger.sendTelemetryEvent({\n eventName: \"GCObjectDeleted\",\n id: nodeId,\n type: nodeType,\n age: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n timeout: this.sweepTimeoutMs,\n completedGCRuns: this.completedRuns,\n lastSummaryTime: this.getLastSummaryTimestampMs(),\n });\n });\n }\n\n /**\n * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.\n */\n private inactiveNodeUsed(\n usageType: \"Changed\" | \"Loaded\" | \"Revived\",\n nodeId: string,\n nodeStateTracker: UnreferencedStateTracker,\n fromNodeId?: string,\n packagePath?: readonly string[],\n currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(),\n requestHeaders?: IRequestHeader,\n ) {\n // If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip\n // logging as nothing interesting would have happened worth logging.\n // If the node is active, skip logging.\n if (currentReferenceTimestampMs === undefined || nodeStateTracker.state === UnreferencedState.Active) {\n return;\n }\n\n // We only care about data stores and attachment blobs for this telemetry since GC only marks these objects\n // as unreferenced. Also, if an inactive DDS is used, the corresponding data store store will also be used.\n const nodeType = this.runtime.getNodeType(nodeId);\n if (nodeType !== GCNodeType.DataStore && nodeType !== GCNodeType.Blob) {\n return;\n }\n\n const state = nodeStateTracker.state;\n const uniqueEventId = `${state}-${nodeId}-${usageType}`;\n if (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n return;\n }\n this.loggedUnreferencedEvents.add(uniqueEventId);\n\n const propsToLog = {\n id: nodeId,\n type: nodeType,\n unrefTime: nodeStateTracker.unreferencedTimestampMs,\n age: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,\n timeout: nodeStateTracker.state === UnreferencedState.Inactive\n ? this.inactiveTimeoutMs\n : this.sweepTimeoutMs,\n completedGCRuns: this.completedRuns,\n lastSummaryTime: this.getLastSummaryTimestampMs(),\n ...this.createContainerMetadata,\n externalRequest: requestHeaders?.[RuntimeHeaders.externalRequest],\n viaHandle: requestHeaders?.[RuntimeHeaders.viaHandle],\n fromId: fromNodeId,\n };\n\n // For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n // For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n // but it's a good signal nonetheless and we can consume it with a grain of salt.\n // Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n // SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n if (this.isSummarizerClient) {\n this.pendingEventsQueue.push({ ...propsToLog, usageType, state });\n } else {\n // For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n // summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n // Events generated:\n // InactiveObject_Loaded, SweepReadyObject_Loaded\n if (usageType === \"Loaded\") {\n this.mc.logger.sendErrorEvent({\n ...propsToLog,\n eventName: `${state}Object_${usageType}`,\n pkg: packagePathToTelemetryProperty(packagePath),\n stack: generateStack(),\n });\n }\n\n // If SweepReady Usage Detection is enabed, the handler may close the interactive container.\n // Once Sweep is fully implemented, this will be removed since the objects will be gone\n // and errors will arise elsewhere in the runtime\n if (state === UnreferencedState.SweepReady) {\n this.sweepReadyUsageHandler.usageDetectedInInteractiveClient({ ...propsToLog, usageType });\n }\n }\n }\n\n private async logUnreferencedEvents(logger: ITelemetryLogger) {\n // Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n // summary time they are then logged.\n // Events generated:\n // InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n // SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n for (const eventProps of this.pendingEventsQueue) {\n const { usageType, state, ...propsToLog } = eventProps;\n /**\n * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n * from another unreferenced node and this scenario is not interesting to log.\n * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n * revived and a Revived event will be logged for it.\n */\n const nodeStateTracker = this.unreferencedNodesState.get(eventProps.id);\n const active = nodeStateTracker === undefined || nodeStateTracker.state === UnreferencedState.Active;\n if ((usageType === \"Revived\") === active) {\n const pkg = await this.getNodePackagePath(eventProps.id);\n const fromPkg = eventProps.fromId ? await this.getNodePackagePath(eventProps.fromId) : undefined;\n logger.sendErrorEvent({\n ...propsToLog,\n eventName: `${state}Object_${usageType}`,\n pkg: pkg ? { value: pkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact } : undefined,\n fromPkg: fromPkg ? { value: fromPkg.join(\"/\"), tag: TelemetryDataTag.CodeArtifact } : undefined,\n });\n }\n }\n this.pendingEventsQueue = [];\n }\n}\n\n/**\n * Gets the base garbage collection state from the given snapshot tree. It contains GC state and tombstone state.\n * The GC state may be written into multiple blobs. Merge the GC state from all such blobs into one.\n */\nasync function getGCDataFromSnapshot(\n gcSnapshotTree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<IGCSnapshotData> {\n let rootGCState: IGarbageCollectionState = { gcNodes: {} };\n let tombstones: string[] | undefined;\n for (const key of Object.keys(gcSnapshotTree.blobs)) {\n if (key === gcTombstoneBlobKey) {\n tombstones = await readAndParseBlob<string[]>(gcSnapshotTree.blobs[key]);\n continue;\n }\n\n // Skip blobs that do not start with the GC prefix.\n if (!key.startsWith(gcBlobPrefix)) {\n continue;\n }\n\n const blobId = gcSnapshotTree.blobs[key];\n if (blobId === undefined) {\n continue;\n }\n const gcState = await readAndParseBlob<IGarbageCollectionState>(blobId);\n assert(gcState !== undefined, 0x2ad /* \"GC blob missing from snapshot\" */);\n // Merge the GC state of this blob into the root GC state.\n rootGCState = concatGarbageCollectionStates(rootGCState, gcState);\n }\n return { gcState: rootGCState, tombstones };\n}\n\nfunction generateSortedGCState(gcState: IGarbageCollectionState): IGarbageCollectionState {\n const sortableArray: [string, IGarbageCollectionNodeData][] = Object.entries(gcState.gcNodes);\n sortableArray.sort(([a], [b]) => a.localeCompare(b));\n const sortedGCState: IGarbageCollectionState = { gcNodes: {} };\n for (const [nodeId, nodeData] of sortableArray) {\n nodeData.outboundRoutes.sort();\n sortedGCState.gcNodes[nodeId] = nodeData;\n }\n return sortedGCState;\n}\n\n/** A wrapper around common-utils Timer that requires the timeout when calling start/restart */\nclass TimerWithNoDefaultTimeout extends Timer {\n constructor(\n private readonly callback: () => void,\n ) {\n // The default timeout/handlers will never be used since start/restart pass overrides below\n super(0, () => { throw new Error(\"DefaultHandler should not be used\"); });\n }\n\n start(timeoutMs: number) {\n super.start(timeoutMs, this.callback);\n }\n\n restart(timeoutMs: number): void {\n super.restart(timeoutMs, this.callback);\n }\n}\n"]}
@@ -1,19 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- export declare const gcTreeKey = "gc";
6
- export declare const gcBlobPrefix = "__gc";
7
- export declare const gcTombstoneBlobKey = "__tombstones";
8
- export declare const runGCKey = "Fluid.GarbageCollection.RunGC";
9
- export declare const runSweepKey = "Fluid.GarbageCollection.RunSweep";
10
- export declare const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
11
- export declare const runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
12
- export declare const trackGCStateKey = "Fluid.GarbageCollection.TrackGCState";
13
- export declare const disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
14
- export declare const disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
15
- export declare const throwOnTombstoneUsageKey = "Fluid.GarbageCollection.ThrowOnTombstoneUsage";
16
- export declare const oneDayMs: number;
17
- export declare const defaultInactiveTimeoutMs: number;
18
- export declare const defaultSessionExpiryDurationMs: number;
19
- //# sourceMappingURL=garbageCollectionConstants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"garbageCollectionConstants.d.ts","sourceRoot":"","sources":["../src/garbageCollectionConstants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,eAAO,MAAM,SAAS,OAAO,CAAC;AAE9B,eAAO,MAAM,YAAY,SAAS,CAAC;AAEnC,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAGjD,eAAO,MAAM,QAAQ,kCAAkC,CAAC;AAExD,eAAO,MAAM,WAAW,qCAAqC,CAAC;AAE9D,eAAO,MAAM,aAAa,uCAAuC,CAAC;AAElE,eAAO,MAAM,mBAAmB,6CAA6C,CAAC;AAE9E,eAAO,MAAM,eAAe,yCAAyC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,4CAA4C,CAAC;AAE5E,eAAO,MAAM,mBAAmB,6CAA6C,CAAC;AAE9E,eAAO,MAAM,wBAAwB,kDAAkD,CAAC;AAGxF,eAAO,MAAM,QAAQ,QAA0B,CAAC;AAEhD,eAAO,MAAM,wBAAwB,QAAe,CAAC;AACrD,eAAO,MAAM,8BAA8B,QAAgB,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.defaultSessionExpiryDurationMs = exports.defaultInactiveTimeoutMs = exports.oneDayMs = exports.throwOnTombstoneUsageKey = exports.disableTombstoneKey = exports.disableSweepLogKey = exports.trackGCStateKey = exports.runSessionExpiryKey = exports.gcTestModeKey = exports.runSweepKey = exports.runGCKey = exports.gcTombstoneBlobKey = exports.gcBlobPrefix = exports.gcTreeKey = void 0;
8
- // The key for the GC tree in summary.
9
- exports.gcTreeKey = "gc";
10
- // They prefix for GC blobs in the GC tree in summary.
11
- exports.gcBlobPrefix = "__gc";
12
- // The key for tombstone blob in the GC tree in summary.
13
- exports.gcTombstoneBlobKey = "__tombstones";
14
- // Feature gate key to turn GC on / off.
15
- exports.runGCKey = "Fluid.GarbageCollection.RunGC";
16
- // Feature gate key to turn GC sweep on / off.
17
- exports.runSweepKey = "Fluid.GarbageCollection.RunSweep";
18
- // Feature gate key to turn GC test mode on / off.
19
- exports.gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
20
- // Feature gate key to expire a session after a set period of time.
21
- exports.runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
22
- // Feature gate key to write the gc blob as a handle if the data is the same.
23
- exports.trackGCStateKey = "Fluid.GarbageCollection.TrackGCState";
24
- // Feature gate key to turn GC sweep log off.
25
- exports.disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
26
- // Feature gate key to disable the tombstone feature, i.e., tombstone information is not read / written into summary.
27
- exports.disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
28
- // Feature gate to enable throwing an error when tombstone object is used.
29
- exports.throwOnTombstoneUsageKey = "Fluid.GarbageCollection.ThrowOnTombstoneUsage";
30
- // One day in milliseconds.
31
- exports.oneDayMs = 1 * 24 * 60 * 60 * 1000;
32
- exports.defaultInactiveTimeoutMs = 7 * exports.oneDayMs; // 7 days
33
- exports.defaultSessionExpiryDurationMs = 30 * exports.oneDayMs; // 30 days
34
- //# sourceMappingURL=garbageCollectionConstants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"garbageCollectionConstants.js","sourceRoot":"","sources":["../src/garbageCollectionConstants.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,sCAAsC;AACzB,QAAA,SAAS,GAAG,IAAI,CAAC;AAC9B,sDAAsD;AACzC,QAAA,YAAY,GAAG,MAAM,CAAC;AACnC,wDAAwD;AAC3C,QAAA,kBAAkB,GAAG,cAAc,CAAC;AAEjD,wCAAwC;AAC3B,QAAA,QAAQ,GAAG,+BAA+B,CAAC;AACxD,8CAA8C;AACjC,QAAA,WAAW,GAAG,kCAAkC,CAAC;AAC9D,kDAAkD;AACrC,QAAA,aAAa,GAAG,oCAAoC,CAAC;AAClE,mEAAmE;AACtD,QAAA,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,6EAA6E;AAChE,QAAA,eAAe,GAAG,sCAAsC,CAAC;AACtE,6CAA6C;AAChC,QAAA,kBAAkB,GAAG,yCAAyC,CAAC;AAC5E,qHAAqH;AACxG,QAAA,mBAAmB,GAAG,0CAA0C,CAAC;AAC9E,0EAA0E;AAC7D,QAAA,wBAAwB,GAAG,+CAA+C,CAAC;AAExF,2BAA2B;AACd,QAAA,QAAQ,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEnC,QAAA,wBAAwB,GAAG,CAAC,GAAG,gBAAQ,CAAC,CAAC,SAAS;AAClD,QAAA,8BAA8B,GAAG,EAAE,GAAG,gBAAQ,CAAC,CAAC,UAAU","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n\n// The key for the GC tree in summary.\nexport const gcTreeKey = \"gc\";\n// They prefix for GC blobs in the GC tree in summary.\nexport const gcBlobPrefix = \"__gc\";\n// The key for tombstone blob in the GC tree in summary.\nexport const gcTombstoneBlobKey = \"__tombstones\";\n\n// Feature gate key to turn GC on / off.\nexport const runGCKey = \"Fluid.GarbageCollection.RunGC\";\n// Feature gate key to turn GC sweep on / off.\nexport const runSweepKey = \"Fluid.GarbageCollection.RunSweep\";\n// Feature gate key to turn GC test mode on / off.\nexport const gcTestModeKey = \"Fluid.GarbageCollection.GCTestMode\";\n// Feature gate key to expire a session after a set period of time.\nexport const runSessionExpiryKey = \"Fluid.GarbageCollection.RunSessionExpiry\";\n// Feature gate key to write the gc blob as a handle if the data is the same.\nexport const trackGCStateKey = \"Fluid.GarbageCollection.TrackGCState\";\n// Feature gate key to turn GC sweep log off.\nexport const disableSweepLogKey = \"Fluid.GarbageCollection.DisableSweepLog\";\n// Feature gate key to disable the tombstone feature, i.e., tombstone information is not read / written into summary.\nexport const disableTombstoneKey = \"Fluid.GarbageCollection.DisableTombstone\";\n// Feature gate to enable throwing an error when tombstone object is used.\nexport const throwOnTombstoneUsageKey = \"Fluid.GarbageCollection.ThrowOnTombstoneUsage\";\n\n// One day in milliseconds.\nexport const oneDayMs = 1 * 24 * 60 * 60 * 1000;\n\nexport const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days\nexport const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gcSweepReadyUsageDetection.d.ts","sourceRoot":"","sources":["../src/gcSweepReadyUsageDetection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAEH,eAAe,EACf,YAAY,EACZ,iBAAiB,EACpB,MAAM,iCAAiC,CAAC;AAGzC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,iFAAiF,CAAC;AAErH;;;GAGG;AACH,eAAO,MAAM,0BAA0B,sEAAsE,CAAC;AAoB9G;;;;;;;GAOG;AACH,qBAAa,oBAAqB,SAAQ,YAAa,YAAW,eAAe;IAC7E,oHAAoH;IAC7G,SAAS,EAAE,MAAM,CAAiD;CAC5E;AAED;;;;;;;GAOG;AACH,qBAAa,+BAA+B;IAIpC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL5B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuC;gBAG/C,kBAAkB,EAAE,MAAM,EAC1B,EAAE,EAAE,iBAAiB,EACrB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,uBAAuB,KAAK,IAAI,EACnE,oBAAoB,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC;IAY/D;;;;;;OAMG;IACI,gCAAgC,CAAC,UAAU,EAAE,oBAAoB;CA8C3E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"gcSweepReadyUsageDetection.js","sourceRoot":"","sources":["../src/gcSweepReadyUsageDetection.ts"],"names":[],"mappings":";AAA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AAoB,CAClC,iDAAiD,EACjD,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,iCAAM,UAAU,KAAE,aAAa,EAAE,mBAAmB,IAAG,EAAE,CAC1F,CAAC;QACF,IAAI,WAAW,EAAE;YACb,qDAAqD;YACrD,8FAA8F;YAC9F,mGAAmG;YACnG,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACzE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,kCAA0B,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;YAEvF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;SACvB;aAAM;YACH,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,+BAA+B,EAAE,EAAE,KAAK,CAAC,CAAC;SACxF;IACL,CAAC;CACJ;AAxED,0EAwEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { ICriticalContainerError } from \"@fluidframework/container-definitions\";\nimport {\n IConfigProvider,\n IFluidErrorBase,\n LoggingError,\n MonitoringContext,\n} from \"@fluidframework/telemetry-utils\";\nimport { oneDayMs } from \"./garbageCollectionConstants\";\n\n/**\n * Feature Gate Key -\n * How many days between closing the container from this error (avoids locking user out of their file altogether)\n */\nexport const skipClosureForXDaysKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.SkipClosureForXDays\";\n\n/**\n * LocalStorage key (NOT via feature gate / monitoring context)\n * A map from docId to info about the last time we closed due to this error\n */\nexport const closuresMapLocalStorageKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection.Closures\";\n\n/**\n * Feature gate key to enable closing the container if SweepReady objects are used.\n * Value should contain keywords \"interactiveClient\" and/or \"summarizer\" to enable detection in each container type\n */\nconst sweepReadyUsageDetectionSetting = {\n read(config: IConfigProvider) {\n const sweepReadyUsageDetectionKey = \"Fluid.GarbageCollection.Dogfood.SweepReadyUsageDetection\";\n const value = config.getString(sweepReadyUsageDetectionKey);\n if (value === undefined) {\n return { interactiveClient: false, summarizer: false };\n }\n return {\n interactiveClient: value.includes(\"interactiveClient\"),\n summarizer: value.includes(\"summarizer\"),\n };\n },\n};\n\n/**\n * Error class raised when a SweepReady object is used, indicating a bug in how\n * references are managed in the container by the application, or a bug in how\n * GC tracks those references.\n *\n * There's a chance for false positives when this error is raised by an Interactive Container,\n * since only the Summarizer has the latest truth about unreferenced node tracking\n */\nexport class SweepReadyUsageError extends LoggingError implements IFluidErrorBase {\n /** This errorType will be in temporary use (until Sweep is fully implemented) so don't add to any errorType type */\n public errorType: string = \"unreferencedObjectUsedAfterGarbageCollected\";\n}\n\n/**\n * This class encapsulates the logic around what to do when a SweepReady object is used.\n * There are several tactics we plan to use in Dogfood environments to aid diagnosis of these cases:\n * - Closing the interactive container when either the interactive or summarizer client detects this kind of violation\n * (via sweepReadyUsageDetectionSetting above)\n * - Throttling the frequency of these crashes via a \"Skip Closure Period\" per container per device\n * (via skipClosureForXDaysKey above. Uses localStorage and closuresMapLocalStorageKey to implement this behavior)\n */\nexport class SweepReadyUsageDetectionHandler {\n private readonly localStorage: Pick<Storage, \"getItem\" | \"setItem\">;\n\n constructor(\n private readonly uniqueContainerKey: string,\n private readonly mc: MonitoringContext,\n private readonly closeFn: (error?: ICriticalContainerError) => void,\n localStorageOverride?: Pick<Storage, \"getItem\" | \"setItem\">,\n ) {\n const noopStorage = { getItem: () => null, setItem: () => {} };\n // localStorage is not defined in Node environment, so fall back to noopStorage if needed.\n this.localStorage = localStorageOverride ?? globalThis.localStorage ?? noopStorage;\n\n if (this.localStorage === noopStorage) {\n // This means the Skip Closure Period logic will not work.\n this.mc.logger.sendTelemetryEvent({ eventName: \"SweepReadyUsageDetectionHandlerNoopStorage\" });\n }\n }\n\n /**\n * If SweepReady Usage Detection is enabled, close the interactive container.\n * If the SkipClosureForXDays setting is set, don't close the container more than once in that period.\n *\n * Once Sweep is fully implemented, this will be removed since the objects will be gone\n * and errors will arise elsewhere in the runtime\n */\n public usageDetectedInInteractiveClient(errorProps: ITelemetryProperties) {\n if (!sweepReadyUsageDetectionSetting.read(this.mc.config).interactiveClient) {\n return;\n }\n\n // Default stance is we close every time - this reflects the severity of SweepReady Object Usage.\n // However, we may choose to \"throttle\" the closures by setting the SkipClosureForXDays setting,\n // which will only allow the container to close once during that period, to avoid locking users out.\n let shouldClose: boolean = true;\n let pastClosuresMap: Record<string, { lastCloseTime: number; } | undefined> = {};\n let lastCloseTime: number | undefined;\n const skipClosureForXDays = this.mc.config.getNumber(skipClosureForXDaysKey);\n if (skipClosureForXDays !== undefined) {\n // Read pastClosuresMap from localStorage then extract the lastCloseTime from the map\n try {\n const rawValue = this.localStorage.getItem(closuresMapLocalStorageKey);\n const parsedValue = rawValue === null ? {} : JSON.parse(rawValue);\n if (typeof parsedValue === \"object\") {\n pastClosuresMap = parsedValue;\n }\n } catch (e) {\n }\n lastCloseTime = pastClosuresMap[this.uniqueContainerKey]?.lastCloseTime;\n\n // Don't close if we did already within the Skip Closure Period\n if (lastCloseTime !== undefined && Date.now() < lastCloseTime + skipClosureForXDays * oneDayMs) {\n shouldClose = false;\n }\n }\n\n const error = new SweepReadyUsageError(\n \"SweepReady object used in Non-Summarizer Client\",\n { errorDetails: JSON.stringify({ ...errorProps, lastCloseTime, skipClosureForXDays }) },\n );\n if (shouldClose) {\n // Update closures map in localStorage before closing\n // Note there is a race condition between different tabs updating localStorage and overwriting\n // each others' updates. If so, some tab will crash again. Just reload one at a time to get unstuck\n pastClosuresMap[this.uniqueContainerKey] = { lastCloseTime: Date.now() };\n this.localStorage.setItem(closuresMapLocalStorageKey, JSON.stringify(pastClosuresMap));\n\n this.closeFn(error);\n } else {\n this.mc.logger.sendErrorEvent({ eventName: \"SweepReadyObject_Usage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uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC5E,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,EAAE;YAClF,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;SACtD;aAAM;YACH,4FAA4F;YAC5F,wDAAwD;YACxD,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;SACtD;IACL,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,cAAsB;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC5F,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,cAAc,EAAE;YAClF,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;SACvD;aAAM;YACH,4FAA4F;YAC5F,wDAAwD;YACxD,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;SACvD;IACL,CAAC;IAEM,qBAAqB;;QACxB,OAAO,MAAA,IAAI,CAAC,uBAAuB,CAAC,MAAA,IAAI,CAAC,cAAc,0CAAE,aAAa,CAAC,mCACnE,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAChF,CAAC;IAEM,SAAS;;QACZ,OAAO;YACH,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;YACnD,eAAe,EAAE,MAAA,IAAI,CAAC,aAAa,0CAAE,QAAQ;YAC7C,eAAe,EAAE,MAAA,IAAI,CAAC,aAAa,0CAAE,QAAQ;SAChD,CAAC;IACN,CAAC;CACJ;AA9QD,sDA8QC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/* eslint-disable @rushstack/no-new-null */\nimport { IEvent, IEventProvider, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { UsageError } from \"@fluidframework/container-utils\";\nimport { IClient, IQuorumClients, ISequencedClient } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { summarizerClientType } from \"./summarizerClientElection\";\n\n// helper types for recursive readonly.\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport type ImmutablePrimitives = undefined | null | boolean | string | number | Function;\nexport type Immutable<T> = T extends ImmutablePrimitives\n ? T\n : T extends (infer A)[]\n ? readonly Immutable<A>[]\n : T extends Map<infer K, infer V>\n ? ReadonlyMap<Immutable<K>, Immutable<V>>\n : T extends Set<infer V>\n ? ReadonlySet<Immutable<V>>\n : { readonly [K in keyof T]: Immutable<T[K]> };\n\n/** Minimum information for a client tracked for election consideration. */\nexport interface ITrackedClient {\n readonly clientId: string;\n readonly sequenceNumber: number;\n readonly client: Immutable<IClient>;\n}\n\n/** Common contract for link nodes within an OrderedClientCollection. */\nexport interface ILinkNode {\n readonly sequenceNumber: number;\n youngerClient: ILinkedClient | undefined;\n}\n\n/** Placeholder root node within an OrderedClientCollection; does not represent a client. */\nexport interface IRootLinkNode extends ILinkNode {\n readonly sequenceNumber: -1;\n readonly olderClient: undefined;\n}\n\n/** Additional information required to keep track of the client within the doubly-linked list. */\nexport interface ILinkedClient extends ILinkNode, ITrackedClient {\n olderClient: LinkNode;\n}\n\n/** Any link node within OrderedClientCollection including the placeholder root node. */\nexport type LinkNode = IRootLinkNode | ILinkedClient;\n\n/** Events raised by an OrderedClientCollection. */\nexport interface IOrderedClientCollectionEvents extends IEvent {\n /** Event fires when client is being added. */\n (event: \"addClient\" | \"removeClient\", listener: (client: ILinkedClient, sequenceNumber: number) => void);\n}\n\n/** Contract for a sorted collection of all clients in the quorum. */\nexport interface IOrderedClientCollection extends IEventProvider<IOrderedClientCollectionEvents> {\n /** Count of clients in the collection. */\n readonly count: number;\n /** Pointer to the oldest client in the collection. */\n readonly oldestClient: ILinkedClient | undefined;\n /** Returns a sorted array of all the clients in the collection. */\n getAllClients(): ILinkedClient[];\n}\n\n/**\n * Tracks clients in the Quorum. It maintains their order using their join op\n * sequence numbers.\n * Internally, the collection of clients is maintained in a doubly-linked list,\n * with pointers to both the first and last nodes.\n * The first (root) node is a placeholder to simplify logic and reduce null checking.\n */\nexport class OrderedClientCollection\n extends TypedEventEmitter<IOrderedClientCollectionEvents>\n implements IOrderedClientCollection {\n /** Collection of ALL clients currently in the quorum, with client ids as keys. */\n private readonly clientMap = new Map<string, ILinkedClient>();\n /** Placeholder head node of linked list, for simplified null checking. */\n private readonly rootNode: IRootLinkNode = {\n sequenceNumber: -1,\n olderClient: undefined,\n youngerClient: undefined,\n };\n /** Pointer to end of linked list, for optimized client adds. */\n private _youngestClient: LinkNode = this.rootNode;\n private readonly logger: ITelemetryLogger;\n\n public get count() {\n return this.clientMap.size;\n }\n public get oldestClient() {\n return this.rootNode.youngerClient;\n }\n\n constructor(\n logger: ITelemetryLogger,\n deltaManager: Pick<IDeltaManager<unknown, unknown>, \"lastSequenceNumber\">,\n quorum: Pick<IQuorumClients, \"getMembers\" | \"on\">,\n ) {\n super();\n this.logger = ChildLogger.create(logger, \"OrderedClientCollection\");\n const members = quorum.getMembers();\n for (const [clientId, client] of members) {\n this.addClient(clientId, client);\n }\n\n quorum.on(\"addMember\", (clientId, client) => {\n const newClient = this.addClient(clientId, client);\n this.emit(\"addClient\", newClient, deltaManager.lastSequenceNumber);\n });\n quorum.on(\"removeMember\", (clientId) => {\n const sequenceNumber = deltaManager.lastSequenceNumber;\n const removeClient = this.removeClient(clientId);\n if (removeClient === undefined) {\n this.logger.sendErrorEvent({ eventName: \"ClientNotFound\", clientId, sequenceNumber });\n } else {\n this.emit(\"removeClient\", removeClient, sequenceNumber);\n }\n });\n }\n\n private addClient(clientId: string, client: ISequencedClient): ITrackedClient {\n // Normal case is adding the latest client, which will bypass loop.\n // Find where it belongs otherwise (maybe possible during initial load?).\n assert(client.sequenceNumber > -1, 0x1f6 /* \"Negative client sequence number not allowed\" */);\n let currClient = this._youngestClient;\n while (currClient.sequenceNumber > client.sequenceNumber) {\n assert(currClient.olderClient !== undefined, 0x1f7 /* \"Previous client should always be defined\" */);\n // Note: If adding a client older than the elected client, it will not be automatically elected.\n currClient = currClient.olderClient;\n }\n\n // Now currClient is the node right before where the new client node should be.\n const newClient: ILinkedClient = {\n clientId,\n sequenceNumber: client.sequenceNumber,\n client: { ...client.client }, // shallow clone\n olderClient: currClient,\n youngerClient: currClient.youngerClient,\n };\n\n // Update prev node to point to this new node.\n newClient.olderClient.youngerClient = newClient;\n\n if (newClient.youngerClient === undefined) {\n // Update linked list end pointer to youngest client.\n this._youngestClient = newClient;\n } else {\n // Update next node to point back to this new node.\n newClient.youngerClient.olderClient = newClient;\n }\n\n this.clientMap.set(clientId, newClient);\n return newClient;\n }\n\n private removeClient(clientId: string): ITrackedClient | undefined {\n const removeClient = this.clientMap.get(clientId);\n if (removeClient === undefined) {\n return;\n }\n\n // Update prev node to point to next node.\n removeClient.olderClient.youngerClient = removeClient.youngerClient;\n\n if (removeClient.youngerClient === undefined) {\n // Update linked list end pointer to youngest client.\n this._youngestClient = removeClient.olderClient;\n } else {\n // Update next node to point back to previous node.\n removeClient.youngerClient.olderClient = removeClient.olderClient;\n }\n\n this.clientMap.delete(clientId);\n return removeClient;\n }\n\n /** Returns an array of all clients being tracked in order from oldest to newest. */\n public getAllClients(): ILinkedClient[] {\n const result: ILinkedClient[] = [];\n let currClient: LinkNode = this.rootNode;\n while (currClient.youngerClient !== undefined) {\n result.push(currClient.youngerClient);\n currClient = currClient.youngerClient;\n }\n return result;\n }\n}\n\n/** Events raised by an OrderedClientElection. */\nexport interface IOrderedClientElectionEvents extends IEvent {\n /** Event fires when the currently elected client changes. */\n (event: \"election\", listener: (\n /** Newly elected client. */\n client: ITrackedClient | undefined,\n /** Sequence number where election took place. */\n sequenceNumber: number,\n /** Previously elected client. */\n prevClient: ITrackedClient | undefined,\n ) => void);\n}\n\n/** Serialized state of IOrderedClientElection. */\nexport interface ISerializedElection {\n /** Sequence number at the time of the latest election. */\n readonly electionSequenceNumber: number;\n\n /**\n * Most recently elected client id. This is either:\n *\n * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n * and the SummaryManager on the elected client will spawn a summarizer client, or\n *\n * 2. the non-interactive summarizer client itself.\n */\n readonly electedClientId: string | undefined;\n\n /** Most recently elected parent client id. This is always an interactive client. */\n readonly electedParentId: string | undefined;\n}\n\n/** Contract for maintaining a deterministic client election based on eligibility. */\nexport interface IOrderedClientElection extends IEventProvider<IOrderedClientElectionEvents> {\n /** Count of eligible clients in the collection. */\n readonly eligibleCount: number;\n\n /**\n * Currently elected client. This is either:\n *\n * 1. the interactive elected parent client, in which case electedClientId === electedParentId,\n * and the SummaryManager on the elected client will spawn a summarizer client, or\n *\n * 2. the non-interactive summarizer client itself.\n */\n readonly electedClient: ITrackedClient | undefined;\n /** Currently elected parent client. This is always an interactive client. */\n readonly electedParent: ITrackedClient | undefined;\n /** Sequence number of most recent election. */\n readonly electionSequenceNumber: number;\n /** Marks the currently elected client as invalid, and elects the next eligible client. */\n incrementElectedClient(sequenceNumber: number): void;\n /** Resets the currently elected client back to the oldest eligible client. */\n resetElectedClient(sequenceNumber: number): void;\n /** Peeks at what the next elected client would be if incrementElectedClient were called. */\n peekNextElectedClient(): ITrackedClient | undefined;\n /** Returns a sorted array of all the eligible clients in the collection. */\n getAllEligibleClients(): ITrackedClient[];\n /** Serialize election data */\n serialize(): ISerializedElection;\n}\n\n/**\n * Adapter for OrderedClientCollection, with the purpose of deterministically maintaining\n * a currently elected client, excluding ineligible clients, in a distributed fashion.\n * This can be true as long as incrementElectedClient and resetElectedClient calls\n * are called under the same conditions for all clients.\n */\nexport class OrderedClientElection\n extends TypedEventEmitter<IOrderedClientElectionEvents>\n implements IOrderedClientElection {\n private _eligibleCount: number = 0;\n private _electedClient: ILinkedClient | undefined;\n private _electedParent: ILinkedClient | undefined;\n private _electionSequenceNumber: number;\n\n public get eligibleCount() {\n return this._eligibleCount;\n }\n public get electionSequenceNumber() {\n return this._electionSequenceNumber;\n }\n\n /**\n * OrderedClientCollection tracks electedClient and electedParent separately. This allows us to handle the case\n * where a new interactive parent client has been elected, but the summarizer is still doing work, so\n * a new summarizer should not yet be spawned. In this case, changing electedParent will cause SummaryManager\n * to stop the current summarizer, but a new summarizer will not be spawned until the old summarizer client has\n * left the quorum.\n *\n * Details:\n *\n * electedParent is the interactive client that has been elected to spawn a summarizer. It is typically the oldest\n * eligible interactive client in the quorum. Only the electedParent is permitted to spawn a summarizer.\n * Once elected, this client will remain the electedParent until it leaves the quorum or the summarizer that\n * it spawned stops producing summaries, at which point a new electedParent will be chosen.\n *\n * electedClient is the non-interactive summarizer client if one exists. If not, then electedClient is equal to\n * electedParent. If electedParent === electedClient, this is the signal for electedParent to spawn a new\n * electedClient. Once a summarizer client becomes electedClient, a new summarizer will not be spawned until\n * electedClient leaves the quorum.\n *\n * A typical sequence looks like this:\n *\n * i. Begin by electing A. electedParent === A, electedClient === A.\n *\n * ii. SummaryManager running on A spawns a summarizer client, A'. electedParent === A, electedClient === A'\n *\n * iii. A' stops producing summaries. A new parent client, B, is elected. electedParent === B, electedClient === A'\n *\n * iv. SummaryManager running on A detects the change to electedParent and tells the summarizer to stop, but A'\n * is in mid-summarization. No new summarizer is spawned, as electedParent !== electedClient.\n *\n * v. A' completes its summary, and the summarizer and backing client are torn down.\n *\n * vi. A' leaves the quorum, and B takes its place as electedClient. electedParent === B, electedClient === B\n *\n * vii. SummaryManager running on B spawns a summarizer client, B'. electedParent === B, electedClient === B'\n */\n public get electedClient() {\n return this._electedClient;\n }\n public get electedParent() {\n return this._electedParent;\n }\n\n constructor(\n logger: ITelemetryLogger,\n private readonly orderedClientCollection: IOrderedClientCollection,\n /** Serialized state from summary or current sequence number at time of load if new. */\n initialState: ISerializedElection | number,\n private readonly isEligibleFn: (c: ITrackedClient) => boolean,\n ) {\n super();\n let initialClient: ILinkedClient | undefined;\n let initialParent: ILinkedClient | undefined;\n for (const client of orderedClientCollection.getAllClients()) {\n this.addClient(client, 0);\n if (typeof initialState !== \"number\") {\n if (client.clientId === initialState.electedClientId) {\n initialClient = client;\n if (initialState.electedParentId === undefined &&\n client.client.details.type !== summarizerClientType) {\n // If there was no elected parent in the serialized data, use this one.\n initialParent = client;\n }\n }\n if (client.clientId === initialState.electedParentId) {\n initialParent = client;\n }\n }\n }\n orderedClientCollection.on(\"addClient\", (client, seq) => this.addClient(client, seq));\n orderedClientCollection.on(\"removeClient\", (client, seq) => this.removeClient(client, seq));\n\n if (typeof initialState === \"number\") {\n this._electionSequenceNumber = initialState;\n } else {\n // Override the initially elected client with the initial state.\n if (initialClient?.clientId !== initialState.electedClientId) {\n // Cannot find initially elected client, so elect undefined.\n logger.sendErrorEvent({\n eventName: \"InitialElectedClientNotFound\",\n electionSequenceNumber: initialState.electionSequenceNumber,\n expectedClientId: initialState.electedClientId,\n electedClientId: initialClient?.clientId,\n clientCount: orderedClientCollection.count,\n });\n } else if (initialClient !== undefined && !isEligibleFn(initialClient)) {\n // Initially elected client is ineligible, so elect next eligible client.\n initialClient = initialParent = this.findFirstEligibleParent(initialParent);\n logger.sendErrorEvent({\n eventName: \"InitialElectedClientIneligible\",\n electionSequenceNumber: initialState.electionSequenceNumber,\n expectedClientId: initialState.electedClientId,\n electedClientId: initialClient?.clientId,\n });\n }\n this._electedParent = initialParent;\n this._electedClient = initialClient;\n this._electionSequenceNumber = initialState.electionSequenceNumber;\n }\n }\n\n /**\n * Tries changing the elected client, raising an event if it is different.\n * Note that this function does no eligibility or suitability checks. If we get here, then\n * we will set _electedClient, and we will set _electedParent if this is an interactive client.\n */\n private tryElectingClient(client: ILinkedClient | undefined, sequenceNumber: number): void {\n let change = false;\n const isSummarizerClient = client?.client.details.type === summarizerClientType;\n const prevClient = this._electedClient;\n if (this._electedClient !== client) {\n // Changing the elected client. Record the sequence number and note that we have to fire an event.\n this._electionSequenceNumber = sequenceNumber;\n this._electedClient = client;\n change = true;\n }\n if (this._electedParent !== client && !isSummarizerClient) {\n // Changing the elected parent as well.\n this._electedParent = client;\n change = true;\n }\n if (change) {\n this.emit(\"election\", client, sequenceNumber, prevClient);\n }\n }\n\n private tryElectingParent(client: ILinkedClient | undefined, sequenceNumber: number): void {\n if (this._electedParent !== client) {\n this._electedParent = client;\n this.emit(\"election\", this._electedClient, sequenceNumber, this._electedClient);\n }\n }\n\n /**\n * Helper function to find the first eligible parent client starting with the passed in client,\n * or undefined if none are eligible.\n * @param client - client to start checking\n * @returns oldest eligible client starting with passed in client or undefined if none.\n */\n private findFirstEligibleParent(client: ILinkedClient | undefined): ILinkedClient | undefined {\n let candidateClient = client;\n while (candidateClient !== undefined &&\n (!this.isEligibleFn(candidateClient) || candidateClient.client.details.type === summarizerClientType)) {\n candidateClient = candidateClient.youngerClient;\n }\n return candidateClient;\n }\n\n /**\n * Updates tracking for when a new client is added to the collection.\n * Will automatically elect that new client if none is elected currently.\n * @param client - client added to the collection\n * @param sequenceNumber - sequence number when client was added\n */\n private addClient(client: ILinkedClient, sequenceNumber: number): void {\n if (this.isEligibleFn(client)) {\n this._eligibleCount++;\n const newClientIsSummarizer = client.client.details.type === summarizerClientType;\n const electedClientIsSummarizer = this._electedClient?.client.details.type === summarizerClientType;\n // Note that we allow a summarizer client to supercede an interactive client as elected client.\n if (this._electedClient === undefined || (!electedClientIsSummarizer && newClientIsSummarizer)) {\n this.tryElectingClient(client, sequenceNumber);\n } else if (this._electedParent === undefined && !newClientIsSummarizer) {\n // This is an odd case. If the _electedClient is set, the _electedParent should be as well.\n this.tryElectingParent(client, sequenceNumber);\n }\n }\n }\n\n /**\n * Updates tracking for when an existing client is removed from the collection.\n * Will automatically elect next oldest client if currently elected is removed.\n * @param client - client removed from the collection\n * @param sequenceNumber - sequence number when client was removed\n */\n private removeClient(client: ILinkedClient, sequenceNumber: number): void {\n if (this.isEligibleFn(client)) {\n this._eligibleCount--;\n if (this._electedClient === client) {\n // Removing the _electedClient. There are 2 possible cases:\n if (this._electedParent !== client) {\n // 1. The _electedClient is a summarizer that we've been allowing to finish its work.\n // Let the _electedParent become the _electedClient so that it can start its own summarizer.\n if (this._electedClient.client.details.type !== summarizerClientType) {\n throw new UsageError(\"Elected client should be a summarizer client 1\");\n }\n this.tryElectingClient(this._electedParent, sequenceNumber);\n } else {\n // 2. The _electedClient is an interactive client that has left the quorum.\n // Automatically shift to next oldest client.\n const nextClient = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n this.tryElectingClient(nextClient, sequenceNumber);\n }\n } else if (this._electedParent === client) {\n // Removing the _electedParent (but not _electedClient).\n // Shift to the next oldest parent, but do not replace the _electedClient,\n // which is a summarizer that is still doing work.\n if (this._electedClient?.client.details.type !== summarizerClientType) {\n throw new UsageError(\"Elected client should be a summarizer client 2\");\n }\n const nextParent = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n this.tryElectingParent(nextParent, sequenceNumber);\n }\n }\n }\n\n public getAllEligibleClients(): ITrackedClient[] {\n return this.orderedClientCollection.getAllClients().filter(this.isEligibleFn);\n }\n\n /**\n * Advance election to the next-oldest client. This is called if the current parent is leaving the quorum,\n * or if the current summarizer is not responsive and we want to stop it and spawn a new one.\n */\n public incrementElectedClient(sequenceNumber: number): void {\n const nextClient = this.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n if (this._electedClient === undefined || this._electedClient === this._electedParent) {\n this.tryElectingClient(nextClient, sequenceNumber);\n } else {\n // The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n // Changing the _electedParent will stop the summarizer.\n this.tryElectingParent(nextClient, sequenceNumber);\n }\n }\n\n /**\n * (Re-)start election with the oldest client in the quorum. This is called if we need to summarize\n * and no client has been elected.\n */\n public resetElectedClient(sequenceNumber: number): void {\n const firstClient = this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n if (this._electedClient === undefined || this._electedClient === this._electedParent) {\n this.tryElectingClient(firstClient, sequenceNumber);\n } else {\n // The _electedClient is a summarizer and should not be replaced until it leaves the quorum.\n // Changing the _electedParent will stop the summarizer.\n this.tryElectingParent(firstClient, sequenceNumber);\n }\n }\n\n public peekNextElectedClient(): ITrackedClient | undefined {\n return this.findFirstEligibleParent(this._electedParent?.youngerClient) ??\n this.findFirstEligibleParent(this.orderedClientCollection.oldestClient);\n }\n\n public serialize(): ISerializedElection {\n return {\n electionSequenceNumber: this.electionSequenceNumber,\n electedClientId: this.electedClient?.clientId,\n electedParentId: this.electedParent?.clientId,\n };\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runWhileConnectedCoordinator.d.ts","sourceRoot":"","sources":["../src/runWhileConnectedCoordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAGzG,MAAM,WAAW,gCAAiC,SAAQ,yBAAyB;IAC/E,IAAI,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,yBAGxC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,4BAA6B,YAAW,gCAAgC;IAqC3D,OAAO,CAAC,QAAQ,CAAC,OAAO;IApC9C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAwC;IAErE,IAAW,SAAS,YAkBnB;IAED;;OAEG;IACF,IAAW,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAEzD;WAEmB,MAAM,CAAC,OAAO,EAAE,mBAAmB;IAM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CAAC;QACtB,OAAO,GAAG,CAAC;IACf,CAAC;IAKD;;;;;;;;;;;;OAYG;IACO,KAAK,CAAC,SAAS;QACrB,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;YACvB,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;YAC1C,OAAO;SACV;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAE9E,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACzB,MAAM,aAAa,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAChD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;YAC7C,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;SAC3D;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACvF,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,MAA4B;QACpC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SACrC;IACL,CAAC;CACJ;AA9ED,oEA8EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/common-utils\";\nimport { SummarizerStopReason, IConnectableRuntime, ISummaryCancellationToken } from \"./summarizerTypes\";\n\n/* Similar to AbortController, but using promise instead of events */\nexport interface ICancellableSummarizerController extends ISummaryCancellationToken {\n stop(reason: SummarizerStopReason): void;\n}\n\n/**\n * Can be useful in testing as well as in places where caller does not use cancellation.\n * This object implements ISummaryCancellationToken interface but cancellation is never leveraged.\n */\nexport const neverCancelledSummaryToken: ISummaryCancellationToken = {\n cancelled: false,\n waitCancelled: new Promise(() => {}),\n};\n\n/**\n * Helper class to coordinate something that needs to run only while connected.\n * This provides promises that resolve as it starts or stops. Stopping happens\n * when disconnected or if stop() is called.\n */\nexport class RunWhileConnectedCoordinator implements ICancellableSummarizerController {\n private _cancelled = false;\n private readonly stopDeferred = new Deferred<SummarizerStopReason>();\n\n public get cancelled() {\n if (!this._cancelled) {\n assert(this.runtime.deltaManager.active, 0x25d /* \"We should never connect as 'read'\" */);\n\n // This check can't be enabled in current design due to lastSummary flow, where\n // summarizer for closed container stays around and can produce one more summary.\n // Currently we solve the problem of overlapping summarizer by doing wait in\n // SummaryManager.createSummarizer()\n // Better solution would involve these steps:\n // 1. Summarizer selection logic should chose summarizing client (with clientType === \"summarizer\")\n // if such client exists.\n // 2. Summarizer should be updated about such changes (to update onBehalfOfClientId)\n //\n // assert(this.runtime.summarizerClientId === this.onBehalfOfClientId ||\n // this.runtime.summarizerClientId === this.runtime.clientId, \"onBehalfOfClientId\");\n }\n\n return this._cancelled;\n }\n\n /**\n * Returns a promise that resolves once stopped either externally or by disconnect.\n */\n public get waitCancelled(): Promise<SummarizerStopReason> {\n return this.stopDeferred.promise;\n }\n\n public static async create(runtime: IConnectableRuntime) {\n const obj = new RunWhileConnectedCoordinator(runtime);\n await obj.waitStart();\n return obj;\n }\n\n protected constructor(private readonly runtime: IConnectableRuntime) {\n }\n\n /**\n * Starts and waits for a promise which resolves when connected.\n * The promise will also resolve if stopped either externally or by disconnect.\n *\n * We only listen on disconnected event for clientType === \"summarizer\" container!\n * And only do it here - no other place should check it! That way we have only one place\n * that controls policy and it's easy to change policy in the future if we want to!\n * We do not listen for \"main\" (aka interactive) container disconnect here, as it's\n * responsibility of SummaryManager to decide if that's material or not. There are cases\n * like \"lastSummary\", or main client experiencing nacks / disconnects due to hitting limit\n * of non-summarized ops, where can make determination to continue with summary even if main\n * client is disconnected.\n */\n protected async waitStart() {\n if (this.runtime.disposed) {\n this.stop(\"summarizerClientDisconnected\");\n return;\n }\n\n this.runtime.once(\"dispose\", () => this.stop(\"summarizerClientDisconnected\"));\n\n if (!this.runtime.connected) {\n const waitConnected = new Promise<void>((resolve) =>\n this.runtime.once(\"connected\", resolve));\n await Promise.race([waitConnected, this.waitCancelled]);\n }\n this.runtime.once(\"disconnected\", () => this.stop(\"summarizerClientDisconnected\"));\n }\n\n /**\n * Stops running.\n */\n public stop(reason: SummarizerStopReason): void {\n if (!this._cancelled) {\n this._cancelled = true;\n this.stopDeferred.resolve(reason);\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"runningSummarizer.d.ts","sourceRoot":"","sources":["../src/runningSummarizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAInF,OAAO,EACH,yBAAyB,EAE5B,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACH,qBAAqB,EACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACH,wBAAwB,EAExB,uBAAuB,EAEvB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,kBAAkB,EAErB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAGH,sBAAsB,EAEzB,MAAM,oBAAoB,CAAC;AAI5B;;;;;;GAMG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IA6E7C,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO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