@fluidframework/container-runtime 2.0.0-internal.3.1.0 → 2.0.0-internal.3.2.0

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 (351) hide show
  1. package/dist/blobManager.d.ts +6 -0
  2. package/dist/blobManager.d.ts.map +1 -1
  3. package/dist/blobManager.js +31 -6
  4. package/dist/blobManager.js.map +1 -1
  5. package/dist/containerRuntime.d.ts +17 -15
  6. package/dist/containerRuntime.d.ts.map +1 -1
  7. package/dist/containerRuntime.js +158 -121
  8. package/dist/containerRuntime.js.map +1 -1
  9. package/dist/dataStoreContext.d.ts +21 -12
  10. package/dist/dataStoreContext.d.ts.map +1 -1
  11. package/dist/dataStoreContext.js +76 -50
  12. package/dist/dataStoreContext.js.map +1 -1
  13. package/dist/dataStores.d.ts +9 -10
  14. package/dist/dataStores.d.ts.map +1 -1
  15. package/dist/dataStores.js +42 -49
  16. package/dist/dataStores.js.map +1 -1
  17. package/dist/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +5 -200
  18. package/dist/gc/garbageCollection.d.ts.map +1 -0
  19. package/dist/{garbageCollection.js → gc/garbageCollection.js} +77 -353
  20. package/dist/gc/garbageCollection.js.map +1 -0
  21. package/dist/gc/gcDefinitions.d.ts +189 -0
  22. package/dist/gc/gcDefinitions.d.ts.map +1 -0
  23. package/dist/{garbageCollectionConstants.js → gc/gcDefinitions.js} +24 -2
  24. package/dist/gc/gcDefinitions.js.map +1 -0
  25. package/{lib/garbageCollectionHelpers.d.ts → dist/gc/gcHelpers.d.ts} +5 -1
  26. package/dist/gc/gcHelpers.d.ts.map +1 -0
  27. package/dist/{garbageCollectionHelpers.js → gc/gcHelpers.js} +27 -7
  28. package/dist/gc/gcHelpers.js.map +1 -0
  29. package/dist/gc/gcSummaryStateTracker.d.ts +86 -0
  30. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
  31. package/dist/gc/gcSummaryStateTracker.js +246 -0
  32. package/dist/gc/gcSummaryStateTracker.js.map +1 -0
  33. package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  34. package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +2 -2
  35. package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
  36. package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
  37. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  38. package/dist/gc/gcUnreferencedStateTracker.js +94 -0
  39. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
  40. package/dist/gc/index.d.ts +11 -0
  41. package/dist/gc/index.d.ts.map +1 -0
  42. package/dist/gc/index.js +40 -0
  43. package/dist/gc/index.js.map +1 -0
  44. package/dist/index.d.ts +2 -5
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +6 -9
  47. package/dist/index.js.map +1 -1
  48. package/dist/opLifecycle/batchManager.d.ts +2 -13
  49. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  50. package/dist/opLifecycle/batchManager.js +7 -36
  51. package/dist/opLifecycle/batchManager.js.map +1 -1
  52. package/dist/opLifecycle/definitions.d.ts +4 -0
  53. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  54. package/dist/opLifecycle/definitions.js.map +1 -1
  55. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  56. package/dist/opLifecycle/opCompressor.js +1 -0
  57. package/dist/opLifecycle/opCompressor.js.map +1 -1
  58. package/dist/opLifecycle/opSplitter.d.ts +1 -1
  59. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  60. package/dist/opLifecycle/opSplitter.js +20 -12
  61. package/dist/opLifecycle/opSplitter.js.map +1 -1
  62. package/dist/opLifecycle/outbox.d.ts +19 -3
  63. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  64. package/dist/opLifecycle/outbox.js +59 -28
  65. package/dist/opLifecycle/outbox.js.map +1 -1
  66. package/dist/packageVersion.d.ts +1 -1
  67. package/dist/packageVersion.js +1 -1
  68. package/dist/packageVersion.js.map +1 -1
  69. package/dist/pendingStateManager.d.ts +1 -2
  70. package/dist/pendingStateManager.d.ts.map +1 -1
  71. package/dist/pendingStateManager.js +14 -9
  72. package/dist/pendingStateManager.js.map +1 -1
  73. package/dist/summary/index.d.ts +17 -0
  74. package/dist/summary/index.d.ts.map +1 -0
  75. package/dist/summary/index.js +47 -0
  76. package/dist/summary/index.js.map +1 -0
  77. package/dist/summary/orderedClientElection.d.ts.map +1 -0
  78. package/dist/summary/orderedClientElection.js.map +1 -0
  79. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  80. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
  81. package/{lib → dist/summary}/runningSummarizer.d.ts +19 -18
  82. package/dist/summary/runningSummarizer.d.ts.map +1 -0
  83. package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +158 -56
  84. package/dist/summary/runningSummarizer.js.map +1 -0
  85. package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +2 -4
  86. package/dist/summary/summarizer.d.ts.map +1 -0
  87. package/dist/{summarizer.js → summary/summarizer.js} +1 -61
  88. package/dist/summary/summarizer.js.map +1 -0
  89. package/dist/summary/summarizerClientElection.d.ts.map +1 -0
  90. package/dist/summary/summarizerClientElection.js.map +1 -0
  91. package/dist/summary/summarizerHandle.d.ts.map +1 -0
  92. package/dist/summary/summarizerHandle.js.map +1 -0
  93. package/dist/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  94. package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
  95. package/dist/summary/summarizerHeuristics.js.map +1 -0
  96. package/{lib → dist/summary}/summarizerTypes.d.ts +1 -1
  97. package/dist/summary/summarizerTypes.d.ts.map +1 -0
  98. package/dist/summary/summarizerTypes.js.map +1 -0
  99. package/dist/summary/summaryCollection.d.ts.map +1 -0
  100. package/dist/summary/summaryCollection.js.map +1 -0
  101. package/{lib → dist/summary}/summaryFormat.d.ts +1 -43
  102. package/dist/summary/summaryFormat.d.ts.map +1 -0
  103. package/dist/{summaryFormat.js → summary/summaryFormat.js} +1 -10
  104. package/dist/summary/summaryFormat.js.map +1 -0
  105. package/dist/summary/summaryGenerator.d.ts.map +1 -0
  106. package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +1 -2
  107. package/dist/summary/summaryGenerator.js.map +1 -0
  108. package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  109. package/dist/summary/summaryManager.d.ts.map +1 -0
  110. package/dist/summary/summaryManager.js.map +1 -0
  111. package/lib/blobManager.d.ts +6 -0
  112. package/lib/blobManager.d.ts.map +1 -1
  113. package/lib/blobManager.js +28 -3
  114. package/lib/blobManager.js.map +1 -1
  115. package/lib/containerRuntime.d.ts +17 -15
  116. package/lib/containerRuntime.d.ts.map +1 -1
  117. package/lib/containerRuntime.js +127 -90
  118. package/lib/containerRuntime.js.map +1 -1
  119. package/lib/dataStoreContext.d.ts +21 -12
  120. package/lib/dataStoreContext.d.ts.map +1 -1
  121. package/lib/dataStoreContext.js +64 -38
  122. package/lib/dataStoreContext.js.map +1 -1
  123. package/lib/dataStores.d.ts +9 -10
  124. package/lib/dataStores.d.ts.map +1 -1
  125. package/lib/dataStores.js +33 -40
  126. package/lib/dataStores.js.map +1 -1
  127. package/lib/{garbageCollection.d.ts → gc/garbageCollection.d.ts} +5 -200
  128. package/lib/gc/garbageCollection.d.ts.map +1 -0
  129. package/lib/{garbageCollection.js → gc/garbageCollection.js} +44 -319
  130. package/lib/gc/garbageCollection.js.map +1 -0
  131. package/lib/gc/gcDefinitions.d.ts +189 -0
  132. package/lib/gc/gcDefinitions.d.ts.map +1 -0
  133. package/lib/{garbageCollectionConstants.js → gc/gcDefinitions.js} +23 -1
  134. package/lib/gc/gcDefinitions.js.map +1 -0
  135. package/{dist/garbageCollectionHelpers.d.ts → lib/gc/gcHelpers.d.ts} +5 -1
  136. package/lib/gc/gcHelpers.d.ts.map +1 -0
  137. package/lib/{garbageCollectionHelpers.js → gc/gcHelpers.js} +20 -2
  138. package/lib/gc/gcHelpers.js.map +1 -0
  139. package/lib/gc/gcSummaryStateTracker.d.ts +86 -0
  140. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
  141. package/lib/gc/gcSummaryStateTracker.js +242 -0
  142. package/lib/gc/gcSummaryStateTracker.js.map +1 -0
  143. package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  144. package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +1 -1
  145. package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
  146. package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
  147. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  148. package/lib/gc/gcUnreferencedStateTracker.js +90 -0
  149. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
  150. package/lib/gc/index.d.ts +11 -0
  151. package/lib/gc/index.d.ts.map +1 -0
  152. package/lib/gc/index.js +11 -0
  153. package/lib/gc/index.js.map +1 -0
  154. package/lib/index.d.ts +2 -5
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +1 -4
  157. package/lib/index.js.map +1 -1
  158. package/lib/opLifecycle/batchManager.d.ts +2 -13
  159. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  160. package/lib/opLifecycle/batchManager.js +7 -36
  161. package/lib/opLifecycle/batchManager.js.map +1 -1
  162. package/lib/opLifecycle/definitions.d.ts +4 -0
  163. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  164. package/lib/opLifecycle/definitions.js.map +1 -1
  165. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  166. package/lib/opLifecycle/opCompressor.js +1 -0
  167. package/lib/opLifecycle/opCompressor.js.map +1 -1
  168. package/lib/opLifecycle/opSplitter.d.ts +1 -1
  169. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  170. package/lib/opLifecycle/opSplitter.js +20 -12
  171. package/lib/opLifecycle/opSplitter.js.map +1 -1
  172. package/lib/opLifecycle/outbox.d.ts +19 -3
  173. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  174. package/lib/opLifecycle/outbox.js +60 -29
  175. package/lib/opLifecycle/outbox.js.map +1 -1
  176. package/lib/packageVersion.d.ts +1 -1
  177. package/lib/packageVersion.js +1 -1
  178. package/lib/packageVersion.js.map +1 -1
  179. package/lib/pendingStateManager.d.ts +1 -2
  180. package/lib/pendingStateManager.d.ts.map +1 -1
  181. package/lib/pendingStateManager.js +14 -9
  182. package/lib/pendingStateManager.js.map +1 -1
  183. package/lib/summary/index.d.ts +17 -0
  184. package/lib/summary/index.d.ts.map +1 -0
  185. package/lib/summary/index.js +16 -0
  186. package/lib/summary/index.js.map +1 -0
  187. package/lib/summary/orderedClientElection.d.ts.map +1 -0
  188. package/lib/summary/orderedClientElection.js.map +1 -0
  189. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  190. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
  191. package/{dist → lib/summary}/runningSummarizer.d.ts +19 -18
  192. package/lib/summary/runningSummarizer.d.ts.map +1 -0
  193. package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +159 -57
  194. package/lib/summary/runningSummarizer.js.map +1 -0
  195. package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +2 -4
  196. package/lib/summary/summarizer.d.ts.map +1 -0
  197. package/lib/{summarizer.js → summary/summarizer.js} +3 -63
  198. package/lib/summary/summarizer.js.map +1 -0
  199. package/lib/summary/summarizerClientElection.d.ts.map +1 -0
  200. package/lib/summary/summarizerClientElection.js.map +1 -0
  201. package/lib/summary/summarizerHandle.d.ts.map +1 -0
  202. package/lib/summary/summarizerHandle.js.map +1 -0
  203. package/lib/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  204. package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
  205. package/lib/summary/summarizerHeuristics.js.map +1 -0
  206. package/{dist → lib/summary}/summarizerTypes.d.ts +1 -1
  207. package/lib/summary/summarizerTypes.d.ts.map +1 -0
  208. package/lib/summary/summarizerTypes.js.map +1 -0
  209. package/lib/summary/summaryCollection.d.ts.map +1 -0
  210. package/lib/summary/summaryCollection.js.map +1 -0
  211. package/{dist → lib/summary}/summaryFormat.d.ts +1 -43
  212. package/lib/summary/summaryFormat.d.ts.map +1 -0
  213. package/lib/{summaryFormat.js → summary/summaryFormat.js} +0 -8
  214. package/lib/summary/summaryFormat.js.map +1 -0
  215. package/lib/summary/summaryGenerator.d.ts.map +1 -0
  216. package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +1 -2
  217. package/lib/summary/summaryGenerator.js.map +1 -0
  218. package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  219. package/lib/summary/summaryManager.d.ts.map +1 -0
  220. package/lib/summary/summaryManager.js.map +1 -0
  221. package/package.json +125 -122
  222. package/src/blobManager.ts +33 -3
  223. package/src/containerRuntime.ts +178 -106
  224. package/src/dataStoreContext.ts +90 -49
  225. package/src/dataStores.ts +44 -51
  226. package/{garbageCollection.md → src/gc/garbageCollection.md} +2 -2
  227. package/src/{garbageCollection.ts → gc/garbageCollection.ts} +90 -560
  228. package/src/gc/gcDefinitions.ts +244 -0
  229. package/src/{garbageCollectionHelpers.ts → gc/gcHelpers.ts} +26 -1
  230. package/src/gc/gcSummaryStateTracker.ts +339 -0
  231. package/src/{gcSweepReadyUsageDetection.ts → gc/gcSweepReadyUsageDetection.ts} +1 -1
  232. package/src/gc/gcUnreferencedStateTracker.ts +114 -0
  233. package/src/gc/index.ts +40 -0
  234. package/src/index.ts +10 -14
  235. package/src/opLifecycle/batchManager.ts +7 -54
  236. package/src/opLifecycle/definitions.ts +4 -0
  237. package/src/opLifecycle/opCompressor.ts +1 -0
  238. package/src/opLifecycle/opSplitter.ts +33 -14
  239. package/src/opLifecycle/outbox.ts +84 -38
  240. package/src/packageVersion.ts +1 -1
  241. package/src/pendingStateManager.ts +26 -14
  242. package/src/summary/index.ts +99 -0
  243. package/src/{runningSummarizer.ts → summary/runningSummarizer.ts} +279 -139
  244. package/src/{summarizer.ts → summary/summarizer.ts} +5 -76
  245. package/src/{summarizerHeuristics.ts → summary/summarizerHeuristics.ts} +1 -1
  246. package/src/{summarizerTypes.ts → summary/summarizerTypes.ts} +1 -1
  247. package/src/{summaryFormat.ts → summary/summaryFormat.ts} +1 -53
  248. package/src/{summaryGenerator.ts → summary/summaryGenerator.ts} +9 -9
  249. package/src/{summaryManager.ts → summary/summaryManager.ts} +1 -1
  250. package/dist/garbageCollection.d.ts.map +0 -1
  251. package/dist/garbageCollection.js.map +0 -1
  252. package/dist/garbageCollectionConstants.d.ts +0 -26
  253. package/dist/garbageCollectionConstants.d.ts.map +0 -1
  254. package/dist/garbageCollectionConstants.js.map +0 -1
  255. package/dist/garbageCollectionHelpers.d.ts.map +0 -1
  256. package/dist/garbageCollectionHelpers.js.map +0 -1
  257. package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
  258. package/dist/gcSweepReadyUsageDetection.js.map +0 -1
  259. package/dist/orderedClientElection.d.ts.map +0 -1
  260. package/dist/orderedClientElection.js.map +0 -1
  261. package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
  262. package/dist/runWhileConnectedCoordinator.js.map +0 -1
  263. package/dist/runningSummarizer.d.ts.map +0 -1
  264. package/dist/runningSummarizer.js.map +0 -1
  265. package/dist/summarizer.d.ts.map +0 -1
  266. package/dist/summarizer.js.map +0 -1
  267. package/dist/summarizerClientElection.d.ts.map +0 -1
  268. package/dist/summarizerClientElection.js.map +0 -1
  269. package/dist/summarizerHandle.d.ts.map +0 -1
  270. package/dist/summarizerHandle.js.map +0 -1
  271. package/dist/summarizerHeuristics.d.ts.map +0 -1
  272. package/dist/summarizerHeuristics.js.map +0 -1
  273. package/dist/summarizerTypes.d.ts.map +0 -1
  274. package/dist/summarizerTypes.js.map +0 -1
  275. package/dist/summaryCollection.d.ts.map +0 -1
  276. package/dist/summaryCollection.js.map +0 -1
  277. package/dist/summaryFormat.d.ts.map +0 -1
  278. package/dist/summaryFormat.js.map +0 -1
  279. package/dist/summaryGenerator.d.ts.map +0 -1
  280. package/dist/summaryGenerator.js.map +0 -1
  281. package/dist/summaryManager.d.ts.map +0 -1
  282. package/dist/summaryManager.js.map +0 -1
  283. package/lib/garbageCollection.d.ts.map +0 -1
  284. package/lib/garbageCollection.js.map +0 -1
  285. package/lib/garbageCollectionConstants.d.ts +0 -26
  286. package/lib/garbageCollectionConstants.d.ts.map +0 -1
  287. package/lib/garbageCollectionConstants.js.map +0 -1
  288. package/lib/garbageCollectionHelpers.d.ts.map +0 -1
  289. package/lib/garbageCollectionHelpers.js.map +0 -1
  290. package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
  291. package/lib/gcSweepReadyUsageDetection.js.map +0 -1
  292. package/lib/orderedClientElection.d.ts.map +0 -1
  293. package/lib/orderedClientElection.js.map +0 -1
  294. package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
  295. package/lib/runWhileConnectedCoordinator.js.map +0 -1
  296. package/lib/runningSummarizer.d.ts.map +0 -1
  297. package/lib/runningSummarizer.js.map +0 -1
  298. package/lib/summarizer.d.ts.map +0 -1
  299. package/lib/summarizer.js.map +0 -1
  300. package/lib/summarizerClientElection.d.ts.map +0 -1
  301. package/lib/summarizerClientElection.js.map +0 -1
  302. package/lib/summarizerHandle.d.ts.map +0 -1
  303. package/lib/summarizerHandle.js.map +0 -1
  304. package/lib/summarizerHeuristics.d.ts.map +0 -1
  305. package/lib/summarizerHeuristics.js.map +0 -1
  306. package/lib/summarizerTypes.d.ts.map +0 -1
  307. package/lib/summarizerTypes.js.map +0 -1
  308. package/lib/summaryCollection.d.ts.map +0 -1
  309. package/lib/summaryCollection.js.map +0 -1
  310. package/lib/summaryFormat.d.ts.map +0 -1
  311. package/lib/summaryFormat.js.map +0 -1
  312. package/lib/summaryGenerator.d.ts.map +0 -1
  313. package/lib/summaryGenerator.js.map +0 -1
  314. package/lib/summaryManager.d.ts.map +0 -1
  315. package/lib/summaryManager.js.map +0 -1
  316. package/src/garbageCollectionConstants.ts +0 -44
  317. /package/dist/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
  318. /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  319. /package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
  320. /package/dist/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
  321. /package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
  322. /package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
  323. /package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
  324. /package/dist/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
  325. /package/dist/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
  326. /package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +0 -0
  327. /package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
  328. /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  329. /package/dist/{summaryCollection.js → summary/summaryCollection.js} +0 -0
  330. /package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
  331. /package/dist/{summaryManager.js → summary/summaryManager.js} +0 -0
  332. /package/lib/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
  333. /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  334. /package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
  335. /package/lib/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +0 -0
  336. /package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +0 -0
  337. /package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
  338. /package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
  339. /package/lib/{summarizerHandle.d.ts → summary/summarizerHandle.d.ts} +0 -0
  340. /package/lib/{summarizerHandle.js → summary/summarizerHandle.js} +0 -0
  341. /package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +0 -0
  342. /package/lib/{summarizerTypes.js → summary/summarizerTypes.js} +0 -0
  343. /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  344. /package/lib/{summaryCollection.js → summary/summaryCollection.js} +0 -0
  345. /package/lib/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
  346. /package/lib/{summaryManager.js → summary/summaryManager.js} +0 -0
  347. /package/src/{orderedClientElection.ts → summary/orderedClientElection.ts} +0 -0
  348. /package/src/{runWhileConnectedCoordinator.ts → summary/runWhileConnectedCoordinator.ts} +0 -0
  349. /package/src/{summarizerClientElection.ts → summary/summarizerClientElection.ts} +0 -0
  350. /package/src/{summarizerHandle.ts → summary/summarizerHandle.ts} +0 -0
  351. /package/src/{summaryCollection.ts → summary/summaryCollection.ts} +0 -0
@@ -16,103 +16,17 @@ var __rest = (this && this.__rest) || function (s, e) {
16
16
  import { assert, LazyPromise, Timer } from "@fluidframework/common-utils";
17
17
  import { ClientSessionExpiredError, DataProcessingError, UsageError, } from "@fluidframework/container-utils";
18
18
  import { cloneGCData, concatGarbageCollectionData, getGCDataFromSnapshot, runGarbageCollection, trimLeadingSlashes, } from "@fluidframework/garbage-collector";
19
- import { SummaryType } from "@fluidframework/protocol-definitions";
20
- import { gcTreeKey, gcBlobPrefix, gcTombstoneBlobKey, gcDeletedBlobKey, } from "@fluidframework/runtime-definitions";
21
- import { mergeStats, packagePathToTelemetryProperty, SummaryTreeBuilder, } from "@fluidframework/runtime-utils";
19
+ import { gcTreeKey, } from "@fluidframework/runtime-definitions";
20
+ import { packagePathToTelemetryProperty, } from "@fluidframework/runtime-utils";
22
21
  import { ChildLogger, generateStack, loggerToMonitoringContext, PerformanceEvent, TelemetryDataTag, } from "@fluidframework/telemetry-utils";
23
- import { RuntimeHeaders } from "./containerRuntime";
24
- import { getSummaryForDatastores } from "./dataStores";
25
- import { currentGCVersion, defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, disableTombstoneKey, gcVersionUpgradeToV2Key, gcTestModeKey, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, stableGCVersion, trackGCStateKey, gcTombstoneGenerationOptionName, } from "./garbageCollectionConstants";
26
- import { sendGCUnexpectedUsageEvent } from "./garbageCollectionHelpers";
22
+ import { RuntimeHeaders } from "../containerRuntime";
23
+ import { getSummaryForDatastores } from "../dataStores";
24
+ import { dataStoreAttributesBlobName, } from "../summary";
25
+ import { defaultInactiveTimeoutMs, defaultSessionExpiryDurationMs, disableSweepLogKey, disableTombstoneKey, GCNodeType, gcTestModeKey, oneDayMs, runGCKey, runSessionExpiryKey, runSweepKey, trackGCStateKey, gcTombstoneGenerationOptionName, UnreferencedState, } from "./gcDefinitions";
26
+ import { getGCVersion, sendGCUnexpectedUsageEvent } from "./gcHelpers";
27
+ import { GCSummaryStateTracker } from "./gcSummaryStateTracker";
27
28
  import { SweepReadyUsageDetectionHandler } from "./gcSweepReadyUsageDetection";
28
- import { getGCVersion, metadataBlobName, dataStoreAttributesBlobName, } from "./summaryFormat";
29
- /** The types of GC nodes in the GC reference graph. */
30
- export const GCNodeType = {
31
- // Nodes that are for data stores.
32
- DataStore: "DataStore",
33
- // Nodes that are within a data store. For example, DDS nodes.
34
- SubDataStore: "SubDataStore",
35
- // Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.
36
- Blob: "Blob",
37
- // Nodes that are neither of the above. For example, root node.
38
- Other: "Other",
39
- };
40
- /** The state of node that is unreferenced. */
41
- export const UnreferencedState = {
42
- /** The node is active, i.e., it can become referenced again. */
43
- Active: "Active",
44
- /** The node is inactive, i.e., it should not become referenced. */
45
- Inactive: "Inactive",
46
- /** The node is ready to be deleted by the sweep phase. */
47
- SweepReady: "SweepReady",
48
- };
49
- /**
50
- * Helper class that tracks the state of an unreferenced node such as the time it was unreferenced and if it can
51
- * be deleted by the sweep phase.
52
- */
53
- export class UnreferencedStateTracker {
54
- constructor(unreferencedTimestampMs,
55
- /** The time after which node transitions to Inactive state. */
56
- inactiveTimeoutMs,
57
- /** The current reference timestamp used to track how long this node has been unreferenced for. */
58
- currentReferenceTimestampMs,
59
- /** The time after which node transitions to SweepReady state; undefined if session expiry is disabled. */
60
- sweepTimeoutMs) {
61
- this.unreferencedTimestampMs = unreferencedTimestampMs;
62
- this.inactiveTimeoutMs = inactiveTimeoutMs;
63
- this.sweepTimeoutMs = sweepTimeoutMs;
64
- this._state = UnreferencedState.Active;
65
- if (this.sweepTimeoutMs !== undefined) {
66
- assert(this.inactiveTimeoutMs <= this.sweepTimeoutMs, 0x3b0 /* inactive timeout must not be greater than the sweep timeout */);
67
- }
68
- this.sweepTimer = new TimerWithNoDefaultTimeout(() => {
69
- this._state = UnreferencedState.SweepReady;
70
- assert(!this.inactiveTimer.hasTimer, 0x3b1 /* inactiveTimer still running after sweepTimer fired! */);
71
- });
72
- this.inactiveTimer = new TimerWithNoDefaultTimeout(() => {
73
- this._state = UnreferencedState.Inactive;
74
- // After the node becomes inactive, start the sweep timer after which the node will be ready for sweep.
75
- if (this.sweepTimeoutMs !== undefined) {
76
- this.sweepTimer.restart(this.sweepTimeoutMs - this.inactiveTimeoutMs);
77
- }
78
- });
79
- this.updateTracking(currentReferenceTimestampMs);
80
- }
81
- get state() {
82
- return this._state;
83
- }
84
- /* Updates the unreferenced state based on the provided timestamp. */
85
- updateTracking(currentReferenceTimestampMs) {
86
- const unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;
87
- // If the node has been unreferenced for sweep timeout amount of time, update the state to SweepReady.
88
- if (this.sweepTimeoutMs !== undefined && unreferencedDurationMs >= this.sweepTimeoutMs) {
89
- this._state = UnreferencedState.SweepReady;
90
- this.clearTimers();
91
- return;
92
- }
93
- // If the node has been unreferenced for inactive timeoutMs amount of time, update the state to inactive.
94
- // Also, start a timer for the sweep timeout.
95
- if (unreferencedDurationMs >= this.inactiveTimeoutMs) {
96
- this._state = UnreferencedState.Inactive;
97
- this.inactiveTimer.clear();
98
- if (this.sweepTimeoutMs !== undefined) {
99
- this.sweepTimer.restart(this.sweepTimeoutMs - unreferencedDurationMs);
100
- }
101
- return;
102
- }
103
- // The node is still active. Ensure the inactive timer is running with the proper remaining duration.
104
- this.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);
105
- }
106
- clearTimers() {
107
- this.inactiveTimer.clear();
108
- this.sweepTimer.clear();
109
- }
110
- /** Stop tracking this node. Reset the unreferenced timers and state, if any. */
111
- stopTracking() {
112
- this.clearTimers();
113
- this._state = UnreferencedState.Active;
114
- }
115
- }
29
+ import { UnreferencedStateTracker } from "./gcUnreferencedStateTracker";
116
30
  /**
117
31
  * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
118
32
  * its state across summaries.
@@ -167,13 +81,8 @@ export class GarbageCollector {
167
81
  this.mc = loggerToMonitoringContext(ChildLogger.create(createParams.baseLogger, "GarbageCollector", {
168
82
  all: { completedGCRuns: () => this.completedRuns },
169
83
  }));
170
- // If version upgrade is not enabled, fall back to the stable GC version.
171
- this.currentGCVersion =
172
- this.mc.config.getBoolean(gcVersionUpgradeToV2Key) === true
173
- ? currentGCVersion
174
- : stableGCVersion;
175
84
  this.sweepReadyUsageHandler = new SweepReadyUsageDetectionHandler(createParams.getContainerDiagnosticId(), this.mc, this.runtime.closeFn);
176
- let prevSummaryGCVersion;
85
+ let gcVersionInBaseSnapshot;
177
86
  /**
178
87
  * Sweep timeout is the time after which unreferenced content can be swept.
179
88
  * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + one day buffer.
@@ -196,10 +105,10 @@ export class GarbageCollector {
196
105
  * For existing containers, we get this information from the metadata blob of its summary.
197
106
  */
198
107
  if (createParams.existing) {
199
- prevSummaryGCVersion = getGCVersion(metadata);
108
+ gcVersionInBaseSnapshot = getGCVersion(metadata);
200
109
  // Existing documents which did not have metadata blob or had GC disabled have version as 0. For all
201
110
  // other existing documents, GC is enabled.
202
- this.gcEnabled = prevSummaryGCVersion > 0;
111
+ this.gcEnabled = gcVersionInBaseSnapshot > 0;
203
112
  this.sweepEnabled = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.sweepEnabled) !== null && _a !== void 0 ? _a : false;
204
113
  this.sessionExpiryTimeoutMs = metadata === null || metadata === void 0 ? void 0 : metadata.sessionExpiryTimeoutMs;
205
114
  this.sweepTimeoutMs =
@@ -242,9 +151,6 @@ export class GarbageCollector {
242
151
  });
243
152
  this.sessionExpiryTimer.start();
244
153
  }
245
- // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
246
- // latest tracked GC version. For new documents, we will be writing the first summary with the current version.
247
- this.latestSummaryGCVersion = prevSummaryGCVersion !== null && prevSummaryGCVersion !== void 0 ? prevSummaryGCVersion : this.currentGCVersion;
248
154
  /**
249
155
  * Whether GC should run or not. The following conditions have to be met to run sweep:
250
156
  *
@@ -289,8 +195,7 @@ export class GarbageCollector {
289
195
  // via feature flags.
290
196
  this.tombstoneMode =
291
197
  !this.shouldRunSweep && this.mc.config.getBoolean(disableTombstoneKey) !== true;
292
- // If GC ran in the container that generated the base snapshot, it will have a GC tree.
293
- this.wasGCRunInLatestSummary = (baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.trees[gcTreeKey]) !== undefined;
198
+ this.summaryStateTracker = new GCSummaryStateTracker(this.shouldRunGC, this.trackGCState, this.tombstoneMode, this.mc, (baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.trees[gcTreeKey]) !== undefined /* wasGCRunInBaseSnapshot */, gcVersionInBaseSnapshot);
294
199
  // Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
295
200
  // it involves fetching blobs from storage which is expensive.
296
201
  this.baseSnapshotDataP = new LazyPromise(async () => {
@@ -417,46 +322,13 @@ export class GarbageCollector {
417
322
  static create(createParams) {
418
323
  return new GarbageCollector(createParams);
419
324
  }
420
- /**
421
- * Tells whether the GC state needs to be reset in the next summary. We need to do this if:
422
- *
423
- * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.
424
- *
425
- * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.
426
- *
427
- * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
428
- *
429
- * 4. The GC version in the latest summary is different from the current GC version. This can happen if:
430
- *
431
- * 4.1. The summary this client loaded with has data from a different GC version.
432
- *
433
- * 4.2. This client's latest summary was updated from a snapshot that has a different GC version.
434
- */
435
- get summaryStateNeedsReset() {
436
- return (this.gcStateNeedsReset ||
437
- (this.shouldRunGC && this.latestSummaryGCVersion !== this.currentGCVersion));
438
- }
439
- /**
440
- * Tells whether the GC state needs to be reset. This can happen under 3 conditions:
441
- *
442
- * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after
443
- * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.
444
- *
445
- * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on
446
- * a document and the first time GC is enabled after is was disabled before.
447
- *
448
- * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
449
- *
450
- * Note that the state will be reset only once for the first summary generated after this returns true. After that,
451
- * this will return false.
452
- */
453
- get gcStateNeedsReset() {
454
- return this.wasGCRunInLatestSummary !== this.shouldRunGC;
455
- }
456
325
  /** Returns a list of all the configurations for garbage collection. */
457
326
  get configs() {
458
327
  return Object.assign({ gcEnabled: this.gcEnabled, sweepEnabled: this.sweepEnabled, runGC: this.shouldRunGC, runSweep: this.shouldRunSweep, testMode: this.testMode, tombstoneMode: this.tombstoneMode, sessionExpiry: this.sessionExpiryTimeoutMs, sweepTimeout: this.sweepTimeoutMs, inactiveTimeout: this.inactiveTimeoutMs, trackGCState: this.trackGCState }, this.gcOptions);
459
328
  }
329
+ get summaryStateNeedsReset() {
330
+ return this.summaryStateTracker.doesSummaryStateNeedReset();
331
+ }
460
332
  /**
461
333
  * Called during container initialization. Initialize from the tombstone state in the base snapshot. This is done
462
334
  * during initialization so that deleted or tombstoned objects are marked as such before they are loaded or used.
@@ -538,10 +410,11 @@ export class GarbageCollector {
538
410
  this.tombstones = (snapshotData === null || snapshotData === void 0 ? void 0 : snapshotData.tombstones) ? Array.from(snapshotData.tombstones) : [];
539
411
  this.runtime.updateTombstonedRoutes(this.tombstones);
540
412
  }
413
+ // Update the summary state tracker's state from this snapshot.
414
+ this.summaryStateTracker.updateStateFromSnapshotData(snapshotData);
541
415
  // If there is no snapshot data, it means this snapshot was generated with GC disabled. Unset all GC state.
542
416
  if (snapshotData === undefined) {
543
417
  this.gcDataFromLastRun = undefined;
544
- this.latestSummaryData = undefined;
545
418
  return;
546
419
  }
547
420
  // Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun
@@ -554,14 +427,6 @@ export class GarbageCollector {
554
427
  gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
555
428
  }
556
429
  this.gcDataFromLastRun = { gcNodes };
557
- // If tracking state across summaries, update latest summary data from the snapshot's GC data.
558
- if (this.trackGCState) {
559
- this.latestSummaryData = {
560
- serializedGCState: JSON.stringify(generateSortedGCState(snapshotData.gcState)),
561
- serializedTombstones: JSON.stringify(snapshotData.tombstones),
562
- serializedDeletedNodes: JSON.stringify(snapshotData.deletedNodes),
563
- };
564
- }
565
430
  }
566
431
  /**
567
432
  * Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this
@@ -591,9 +456,10 @@ export class GarbageCollector {
591
456
  * Runs garbage collection and updates the reference / used state of the nodes in the container.
592
457
  * @returns stats of the GC run or undefined if GC did not run.
593
458
  */
594
- async collectGarbage(options) {
459
+ async collectGarbage(options, telemetryContext) {
595
460
  var _a;
596
- const fullGC = (_a = options.fullGC) !== null && _a !== void 0 ? _a : (this.gcOptions.runFullGC === true || this.summaryStateNeedsReset);
461
+ const fullGC = (_a = options.fullGC) !== null && _a !== void 0 ? _a : (this.gcOptions.runFullGC === true ||
462
+ this.summaryStateTracker.doesSummaryStateNeedReset());
597
463
  const logger = options.logger
598
464
  ? ChildLogger.create(options.logger, undefined, {
599
465
  all: { completedGCRuns: () => this.completedRuns },
@@ -616,6 +482,11 @@ export class GarbageCollector {
616
482
  });
617
483
  return undefined;
618
484
  }
485
+ // Add the options that are used to run GC to the telemetry context.
486
+ telemetryContext === null || telemetryContext === void 0 ? void 0 : telemetryContext.setMultiple("fluid_GC", "Options", {
487
+ fullGC,
488
+ runSweep: options.runSweep,
489
+ });
619
490
  return PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
620
491
  await this.runPreGCSteps();
621
492
  // Get the runtime's GC data and run GC on the reference graph in it.
@@ -683,97 +554,7 @@ export class GarbageCollector {
683
554
  unreferencedTimestampMs: (_a = this.unreferencedNodesState.get(nodeId)) === null || _a === void 0 ? void 0 : _a.unreferencedTimestampMs,
684
555
  };
685
556
  }
686
- const serializedGCState = JSON.stringify(generateSortedGCState(gcState));
687
- // Serialize and write deleted nodes, if any. This is done irrespective of whether sweep is enabled or not so
688
- // to identify deleted nodes' usage.
689
- const serializedDeletedNodes = this.deletedNodes.size > 0
690
- ? JSON.stringify(Array.from(this.deletedNodes).sort())
691
- : undefined;
692
- // If running in tombstone mode, serialize and write tombstones, if any.
693
- const serializedTombstones = this.tombstoneMode
694
- ? this.tombstones.length > 0
695
- ? JSON.stringify(this.tombstones.sort())
696
- : undefined
697
- : undefined;
698
- /**
699
- * Incremental summary of GC data - If none of GC state, deleted nodes or tombstones changed since last summary,
700
- * write summary handle instead of summary tree for GC.
701
- * Otherwise, write the GC summary tree. In the tree, for each of these that changed, write a summary blob and
702
- * for each of these that did not change, write a summary handle.
703
- */
704
- if (this.trackGCState) {
705
- this.pendingSummaryData = {
706
- serializedGCState,
707
- serializedTombstones,
708
- serializedDeletedNodes,
709
- };
710
- if (trackState && !fullTree && this.latestSummaryData !== undefined) {
711
- // If nothing changed since last summary, send a summary handle for the entire GC data.
712
- if (this.latestSummaryData.serializedGCState === serializedGCState &&
713
- this.latestSummaryData.serializedTombstones === serializedTombstones) {
714
- const stats = mergeStats();
715
- stats.handleNodeCount++;
716
- return {
717
- summary: {
718
- type: SummaryType.Handle,
719
- handle: `/${gcTreeKey}`,
720
- handleType: SummaryType.Tree,
721
- },
722
- stats,
723
- };
724
- }
725
- // If some state changed, build a GC summary tree.
726
- return this.buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, true /* trackState */);
727
- }
728
- }
729
- // If not tracking GC state, build a GC summary tree without any summary handles.
730
- return this.buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, false /* trackState */);
731
- }
732
- /**
733
- * Builds the GC summary tree which contains GC state, deleted nodes and tombstones.
734
- * If trackState is false, all of GC state, deleted nodes and tombstones are written as summary blobs.
735
- * If trackState is true, only states that changed are written. Rest are written as handles.
736
- * @param serializedGCState - The GC state serialized as string.
737
- * @param serializedTombstones - The tombstone state serialized as string.
738
- * @param serializedDeletedNodes - Deleted nodes serialized as string.
739
- * @param trackState - Whether we are tracking GC state across summaries.
740
- * @returns the GC summary tree.
741
- */
742
- buildGCSummaryTree(serializedGCState, serializedTombstones, serializedDeletedNodes, trackState) {
743
- var _a, _b, _c;
744
- const gcStateBlobKey = `${gcBlobPrefix}_root`;
745
- const builder = new SummaryTreeBuilder();
746
- // If the GC state hasn't changed, write a summary handle, else write a summary blob for it.
747
- if (((_a = this.latestSummaryData) === null || _a === void 0 ? void 0 : _a.serializedGCState) === serializedGCState && trackState) {
748
- builder.addHandle(gcStateBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcStateBlobKey}`);
749
- }
750
- else {
751
- builder.addBlob(gcStateBlobKey, serializedGCState);
752
- }
753
- // If tombstones exist, write a summary handle if it hasn't changed. If it has changed, write a
754
- // summary blob.
755
- if (serializedTombstones !== undefined) {
756
- if (((_b = this.latestSummaryData) === null || _b === void 0 ? void 0 : _b.serializedTombstones) === serializedTombstones &&
757
- trackState) {
758
- builder.addHandle(gcTombstoneBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcTombstoneBlobKey}`);
759
- }
760
- else {
761
- builder.addBlob(gcTombstoneBlobKey, serializedTombstones);
762
- }
763
- }
764
- // If there are no deleted nodes, return the summary tree.
765
- if (serializedDeletedNodes === undefined) {
766
- return builder.getSummaryTree();
767
- }
768
- // If the deleted nodes hasn't changed, write a summary handle, else write a summary blob for it.
769
- if (((_c = this.latestSummaryData) === null || _c === void 0 ? void 0 : _c.serializedDeletedNodes) === serializedDeletedNodes &&
770
- trackState) {
771
- builder.addHandle(gcDeletedBlobKey, SummaryType.Blob, `/${gcTreeKey}/${gcDeletedBlobKey}`);
772
- }
773
- else {
774
- builder.addBlob(gcDeletedBlobKey, serializedDeletedNodes);
775
- }
776
- return builder.getSummaryTree();
557
+ return this.summaryStateTracker.summarize(fullTree, trackState, gcState, this.deletedNodes, this.tombstones);
777
558
  }
778
559
  getMetadata() {
779
560
  return {
@@ -781,7 +562,7 @@ export class GarbageCollector {
781
562
  * If GC is enabled, the GC data is written using the current GC version and that is the gcFeature that goes
782
563
  * into the metadata blob. If GC is disabled, the gcFeature is 0.
783
564
  */
784
- gcFeature: this.gcEnabled ? this.currentGCVersion : 0,
565
+ gcFeature: this.gcEnabled ? this.summaryStateTracker.currentGCVersion : 0,
785
566
  gcFeatureMatrix: this.persistedGcFeatureMatrix,
786
567
  sessionExpiryTimeoutMs: this.sessionExpiryTimeoutMs,
787
568
  sweepEnabled: this.sweepEnabled,
@@ -800,52 +581,22 @@ export class GarbageCollector {
800
581
  * is downloaded and should be used to update the state.
801
582
  */
802
583
  async refreshLatestSummary(proposalHandle, result, readAndParseBlob) {
803
- // If the latest summary was updated and the summary was tracked, this client is the one that generated this
804
- // summary. So, update wasGCRunInLatestSummary.
805
- // Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return
806
- // true in scenarios where GC is disabled but enabled in the snapshot we loaded from.
807
- if (result.latestSummaryUpdated && result.wasSummaryTracked) {
808
- this.wasGCRunInLatestSummary = this.shouldRunGC;
809
- }
810
- if (!result.latestSummaryUpdated || !this.shouldRunGC) {
811
- return;
812
- }
813
- // If the summary was tracked by this client, it was the one that generated the summary in the first place.
814
- // Update latest state from pending.
815
- if (result.wasSummaryTracked) {
816
- this.latestSummaryGCVersion = this.currentGCVersion;
817
- if (this.trackGCState) {
818
- this.latestSummaryData = this.pendingSummaryData;
819
- this.pendingSummaryData = undefined;
584
+ const latestSnapshotData = await this.summaryStateTracker.refreshLatestSummary(proposalHandle, result, readAndParseBlob);
585
+ // If the latest summary was updated but it was not tracked by this client, our state needs to be updated from
586
+ // this snapshot data.
587
+ if (this.shouldRunGC && result.latestSummaryUpdated && !result.wasSummaryTracked) {
588
+ // The current reference timestamp should be available if we are refreshing state from a snapshot. There has
589
+ // to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.
590
+ const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
591
+ if (currentReferenceTimestampMs === undefined) {
592
+ throw DataProcessingError.create("No reference timestamp when updating GC state from snapshot", "refreshLatestSummary", undefined, {
593
+ proposalHandle,
594
+ summaryRefSeq: result.summaryRefSeq,
595
+ details: JSON.stringify(this.configs),
596
+ });
820
597
  }
821
- return;
822
- }
823
- // If the summary was not tracked by this client, the state should be updated from the downloaded snapshot.
824
- const snapshotTree = result.snapshotTree;
825
- const metadataBlobId = snapshotTree.blobs[metadataBlobName];
826
- if (metadataBlobId) {
827
- const metadata = await readAndParseBlob(metadataBlobId);
828
- this.latestSummaryGCVersion = getGCVersion(metadata);
829
- }
830
- // The current reference timestamp should be available if we are refreshing state from a snapshot. There has
831
- // to be at least one op (summary op / ack, if nothing else) if a snapshot was taken.
832
- const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
833
- if (currentReferenceTimestampMs === undefined) {
834
- throw DataProcessingError.create("No reference timestamp when updating GC state from snapshot", "refreshLatestSummary", undefined, {
835
- proposalHandle,
836
- summaryRefSeq: result.summaryRefSeq,
837
- details: JSON.stringify(this.configs),
838
- });
839
- }
840
- const gcSnapshotTree = snapshotTree.trees[gcTreeKey];
841
- // If GC ran in the container that generated this snapshot, it will have a GC tree.
842
- this.wasGCRunInLatestSummary = gcSnapshotTree !== undefined;
843
- let latestGCData;
844
- if (gcSnapshotTree !== undefined) {
845
- latestGCData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);
598
+ this.updateStateFromSnapshotData(latestSnapshotData, currentReferenceTimestampMs);
846
599
  }
847
- this.updateStateFromSnapshotData(latestGCData, currentReferenceTimestampMs);
848
- this.pendingSummaryData = undefined;
849
600
  }
850
601
  /**
851
602
  * Called when a node with the given id is updated. If the node is inactive, log an error.
@@ -968,7 +719,7 @@ export class GarbageCollector {
968
719
  runSweepPhase(sweepReadyNodes, gcData) {
969
720
  // TODO: GC:Validation - validate that removed routes are not double deleted
970
721
  // TODO: GC:Validation - validate that the child routes of removed routes are deleted as well
971
- const sweptRoutes = this.runtime.deleteUnusedNodes(sweepReadyNodes);
722
+ const sweptRoutes = this.runtime.deleteSweepReadyNodes(sweepReadyNodes);
972
723
  const updatedGCData = this.deleteSweptRoutes(sweptRoutes, gcData);
973
724
  for (const nodeId of sweptRoutes) {
974
725
  const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
@@ -1238,7 +989,7 @@ export class GarbageCollector {
1238
989
  this.loggedUnreferencedEvents.add(uniqueEventId);
1239
990
  const propsToLog = Object.assign(Object.assign({ id: nodeId, type: nodeType, unrefTime: nodeStateTracker.unreferencedTimestampMs, age: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs, timeout: nodeStateTracker.state === UnreferencedState.Inactive
1240
991
  ? this.inactiveTimeoutMs
1241
- : this.sweepTimeoutMs, completedGCRuns: this.completedRuns, lastSummaryTime: this.getLastSummaryTimestampMs() }, this.createContainerMetadata), { externalRequest: requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders[RuntimeHeaders.externalRequest], viaHandle: requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders[RuntimeHeaders.viaHandle], fromId: fromNodeId });
992
+ : this.sweepTimeoutMs, completedGCRuns: this.completedRuns, lastSummaryTime: this.getLastSummaryTimestampMs() }, this.createContainerMetadata), { viaHandle: requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders[RuntimeHeaders.viaHandle], fromId: fromNodeId });
1242
993
  // For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.
1243
994
  // For non-summarizer client, log the event now since GC won't run on it. This may result in false positives
1244
995
  // but it's a good signal nonetheless and we can consume it with a grain of salt.
@@ -1309,30 +1060,4 @@ export class GarbageCollector {
1309
1060
  this.pendingEventsQueue = [];
1310
1061
  }
1311
1062
  }
1312
- function generateSortedGCState(gcState) {
1313
- const sortableArray = Object.entries(gcState.gcNodes);
1314
- sortableArray.sort(([a], [b]) => a.localeCompare(b));
1315
- const sortedGCState = { gcNodes: {} };
1316
- for (const [nodeId, nodeData] of sortableArray) {
1317
- nodeData.outboundRoutes.sort();
1318
- sortedGCState.gcNodes[nodeId] = nodeData;
1319
- }
1320
- return sortedGCState;
1321
- }
1322
- /** A wrapper around common-utils Timer that requires the timeout when calling start/restart */
1323
- class TimerWithNoDefaultTimeout extends Timer {
1324
- constructor(callback) {
1325
- // The default timeout/handlers will never be used since start/restart pass overrides below
1326
- super(0, () => {
1327
- throw new Error("DefaultHandler should not be used");
1328
- });
1329
- this.callback = callback;
1330
- }
1331
- start(timeoutMs) {
1332
- super.start(timeoutMs, this.callback);
1333
- }
1334
- restart(timeoutMs) {
1335
- super.restart(timeoutMs, this.callback);
1336
- }
1337
- }
1338
1063
  //# sourceMappingURL=garbageCollection.js.map