@fluidframework/container-runtime 2.12.0 → 2.20.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 (440) hide show
  1. package/.eslintrc.cjs +36 -0
  2. package/CHANGELOG.md +50 -0
  3. package/api-report/container-runtime.legacy.alpha.api.md +9 -203
  4. package/container-runtime.test-files.tar +0 -0
  5. package/dist/batchTracker.d.ts.map +1 -1
  6. package/dist/batchTracker.js.map +1 -1
  7. package/dist/blobManager/blobManager.d.ts +5 -1
  8. package/dist/blobManager/blobManager.d.ts.map +1 -1
  9. package/dist/blobManager/blobManager.js +16 -2
  10. package/dist/blobManager/blobManager.js.map +1 -1
  11. package/dist/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  12. package/dist/blobManager/blobManagerSnapSum.js.map +1 -1
  13. package/dist/channelCollection.d.ts +23 -12
  14. package/dist/channelCollection.d.ts.map +1 -1
  15. package/dist/channelCollection.js +22 -12
  16. package/dist/channelCollection.js.map +1 -1
  17. package/dist/connectionTelemetry.d.ts.map +1 -1
  18. package/dist/connectionTelemetry.js +6 -2
  19. package/dist/connectionTelemetry.js.map +1 -1
  20. package/dist/containerHandleContext.d.ts +1 -1
  21. package/dist/containerHandleContext.d.ts.map +1 -1
  22. package/dist/containerHandleContext.js.map +1 -1
  23. package/dist/containerRuntime.d.ts +74 -65
  24. package/dist/containerRuntime.d.ts.map +1 -1
  25. package/dist/containerRuntime.js +53 -37
  26. package/dist/containerRuntime.js.map +1 -1
  27. package/dist/dataStore.d.ts +7 -3
  28. package/dist/dataStore.d.ts.map +1 -1
  29. package/dist/dataStore.js +2 -1
  30. package/dist/dataStore.js.map +1 -1
  31. package/dist/dataStoreContext.d.ts +41 -25
  32. package/dist/dataStoreContext.d.ts.map +1 -1
  33. package/dist/dataStoreContext.js +31 -18
  34. package/dist/dataStoreContext.js.map +1 -1
  35. package/dist/dataStoreContexts.d.ts +6 -2
  36. package/dist/dataStoreContexts.d.ts.map +1 -1
  37. package/dist/dataStoreContexts.js +6 -2
  38. package/dist/dataStoreContexts.js.map +1 -1
  39. package/dist/dataStoreRegistry.d.ts +1 -1
  40. package/dist/dataStoreRegistry.d.ts.map +1 -1
  41. package/dist/dataStoreRegistry.js.map +1 -1
  42. package/dist/deltaManagerProxies.d.ts +1 -17
  43. package/dist/deltaManagerProxies.d.ts.map +1 -1
  44. package/dist/deltaManagerProxies.js.map +1 -1
  45. package/dist/deltaScheduler.d.ts +9 -6
  46. package/dist/deltaScheduler.d.ts.map +1 -1
  47. package/dist/deltaScheduler.js +95 -89
  48. package/dist/deltaScheduler.js.map +1 -1
  49. package/dist/gc/garbageCollection.d.ts +21 -7
  50. package/dist/gc/garbageCollection.d.ts.map +1 -1
  51. package/dist/gc/garbageCollection.js +12 -5
  52. package/dist/gc/garbageCollection.js.map +1 -1
  53. package/dist/gc/gcConfigs.d.ts +11 -0
  54. package/dist/gc/gcConfigs.d.ts.map +1 -1
  55. package/dist/gc/gcConfigs.js +2 -1
  56. package/dist/gc/gcConfigs.js.map +1 -1
  57. package/dist/gc/gcDefinitions.d.ts +210 -70
  58. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  59. package/dist/gc/gcDefinitions.js +39 -13
  60. package/dist/gc/gcDefinitions.js.map +1 -1
  61. package/dist/gc/gcHelpers.d.ts +6 -2
  62. package/dist/gc/gcHelpers.d.ts.map +1 -1
  63. package/dist/gc/gcHelpers.js +6 -2
  64. package/dist/gc/gcHelpers.js.map +1 -1
  65. package/dist/gc/gcSummaryDefinitions.d.ts +18 -6
  66. package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -1
  67. package/dist/gc/gcSummaryDefinitions.js.map +1 -1
  68. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  69. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  70. package/dist/gc/gcTelemetry.d.ts +33 -11
  71. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  72. package/dist/gc/gcTelemetry.js +6 -2
  73. package/dist/gc/gcTelemetry.js.map +1 -1
  74. package/dist/gc/gcUnreferencedStateTracker.d.ts +42 -13
  75. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  76. package/dist/gc/gcUnreferencedStateTracker.js +27 -9
  77. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  78. package/dist/gc/index.d.ts +1 -0
  79. package/dist/gc/index.d.ts.map +1 -1
  80. package/dist/gc/index.js +3 -1
  81. package/dist/gc/index.js.map +1 -1
  82. package/dist/inboundBatchAggregator.d.ts +34 -0
  83. package/dist/inboundBatchAggregator.d.ts.map +1 -0
  84. package/dist/inboundBatchAggregator.js +185 -0
  85. package/dist/inboundBatchAggregator.js.map +1 -0
  86. package/dist/index.d.ts +1 -1
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js.map +1 -1
  89. package/dist/legacy.d.ts +0 -4
  90. package/dist/messageTypes.d.ts +14 -5
  91. package/dist/messageTypes.d.ts.map +1 -1
  92. package/dist/messageTypes.js.map +1 -1
  93. package/dist/metadata.d.ts +12 -4
  94. package/dist/metadata.d.ts.map +1 -1
  95. package/dist/metadata.js +6 -2
  96. package/dist/metadata.js.map +1 -1
  97. package/dist/opLifecycle/batchManager.d.ts +9 -3
  98. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  99. package/dist/opLifecycle/batchManager.js +3 -1
  100. package/dist/opLifecycle/batchManager.js.map +1 -1
  101. package/dist/opLifecycle/duplicateBatchDetector.d.ts +9 -3
  102. package/dist/opLifecycle/duplicateBatchDetector.d.ts.map +1 -1
  103. package/dist/opLifecycle/duplicateBatchDetector.js +9 -3
  104. package/dist/opLifecycle/duplicateBatchDetector.js.map +1 -1
  105. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  106. package/dist/opLifecycle/opCompressor.js.map +1 -1
  107. package/dist/opLifecycle/opDecompressor.d.ts +3 -1
  108. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  109. package/dist/opLifecycle/opDecompressor.js +12 -8
  110. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  111. package/dist/opLifecycle/opGroupingManager.d.ts +0 -1
  112. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  113. package/dist/opLifecycle/opGroupingManager.js +5 -4
  114. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  115. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  116. package/dist/opLifecycle/opSplitter.js +2 -1
  117. package/dist/opLifecycle/opSplitter.js.map +1 -1
  118. package/dist/opLifecycle/outbox.d.ts +1 -1
  119. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  120. package/dist/opLifecycle/outbox.js +6 -1
  121. package/dist/opLifecycle/outbox.js.map +1 -1
  122. package/dist/opLifecycle/remoteMessageProcessor.d.ts +9 -3
  123. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  124. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  125. package/dist/package.json +2 -1
  126. package/dist/packageVersion.d.ts +1 -1
  127. package/dist/packageVersion.js +1 -1
  128. package/dist/packageVersion.js.map +1 -1
  129. package/dist/pendingStateManager.d.ts +22 -6
  130. package/dist/pendingStateManager.d.ts.map +1 -1
  131. package/dist/pendingStateManager.js +43 -5
  132. package/dist/pendingStateManager.js.map +1 -1
  133. package/dist/summary/documentSchema.d.ts.map +1 -1
  134. package/dist/summary/documentSchema.js +2 -0
  135. package/dist/summary/documentSchema.js.map +1 -1
  136. package/dist/summary/index.d.ts +1 -1
  137. package/dist/summary/index.d.ts.map +1 -1
  138. package/dist/summary/index.js.map +1 -1
  139. package/dist/summary/orderedClientElection.d.ts +93 -31
  140. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  141. package/dist/summary/orderedClientElection.js +15 -5
  142. package/dist/summary/orderedClientElection.js.map +1 -1
  143. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  144. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  145. package/dist/summary/runningSummarizer.d.ts +17 -6
  146. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  147. package/dist/summary/runningSummarizer.js +12 -4
  148. package/dist/summary/runningSummarizer.js.map +1 -1
  149. package/dist/summary/summarizer.d.ts +9 -5
  150. package/dist/summary/summarizer.d.ts.map +1 -1
  151. package/dist/summary/summarizer.js +9 -3
  152. package/dist/summary/summarizer.js.map +1 -1
  153. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  154. package/dist/summary/summarizerClientElection.js.map +1 -1
  155. package/dist/summary/summarizerHeuristics.d.ts +6 -2
  156. package/dist/summary/summarizerHeuristics.d.ts.map +1 -1
  157. package/dist/summary/summarizerHeuristics.js +12 -4
  158. package/dist/summary/summarizerHeuristics.js.map +1 -1
  159. package/dist/summary/summarizerNode/summarizerNode.d.ts +24 -8
  160. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  161. package/dist/summary/summarizerNode/summarizerNode.js +15 -5
  162. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  163. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +48 -16
  164. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  165. package/dist/summary/summarizerNode/summarizerNodeUtils.js +3 -1
  166. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  167. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +12 -4
  168. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  169. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +12 -4
  170. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  171. package/dist/summary/summarizerTypes.d.ts +246 -135
  172. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  173. package/dist/summary/summarizerTypes.js.map +1 -1
  174. package/dist/summary/summaryCollection.d.ts.map +1 -1
  175. package/dist/summary/summaryCollection.js +1 -4
  176. package/dist/summary/summaryCollection.js.map +1 -1
  177. package/dist/summary/summaryFormat.d.ts +24 -8
  178. package/dist/summary/summaryFormat.d.ts.map +1 -1
  179. package/dist/summary/summaryFormat.js.map +1 -1
  180. package/dist/summary/summaryGenerator.d.ts +9 -3
  181. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  182. package/dist/summary/summaryGenerator.js +3 -1
  183. package/dist/summary/summaryGenerator.js.map +1 -1
  184. package/dist/summary/summaryManager.d.ts +8 -4
  185. package/dist/summary/summaryManager.d.ts.map +1 -1
  186. package/dist/summary/summaryManager.js +12 -4
  187. package/dist/summary/summaryManager.js.map +1 -1
  188. package/dist/throttler.d.ts +26 -10
  189. package/dist/throttler.d.ts.map +1 -1
  190. package/dist/throttler.js +12 -4
  191. package/dist/throttler.js.map +1 -1
  192. package/lib/batchTracker.d.ts.map +1 -1
  193. package/lib/batchTracker.js.map +1 -1
  194. package/lib/blobManager/blobManager.d.ts +5 -1
  195. package/lib/blobManager/blobManager.d.ts.map +1 -1
  196. package/lib/blobManager/blobManager.js +16 -2
  197. package/lib/blobManager/blobManager.js.map +1 -1
  198. package/lib/blobManager/blobManagerSnapSum.d.ts.map +1 -1
  199. package/lib/blobManager/blobManagerSnapSum.js.map +1 -1
  200. package/lib/channelCollection.d.ts +23 -12
  201. package/lib/channelCollection.d.ts.map +1 -1
  202. package/lib/channelCollection.js +22 -12
  203. package/lib/channelCollection.js.map +1 -1
  204. package/lib/connectionTelemetry.d.ts.map +1 -1
  205. package/lib/connectionTelemetry.js +6 -2
  206. package/lib/connectionTelemetry.js.map +1 -1
  207. package/lib/containerHandleContext.d.ts +1 -1
  208. package/lib/containerHandleContext.d.ts.map +1 -1
  209. package/lib/containerHandleContext.js.map +1 -1
  210. package/lib/containerRuntime.d.ts +74 -65
  211. package/lib/containerRuntime.d.ts.map +1 -1
  212. package/lib/containerRuntime.js +53 -37
  213. package/lib/containerRuntime.js.map +1 -1
  214. package/lib/dataStore.d.ts +7 -3
  215. package/lib/dataStore.d.ts.map +1 -1
  216. package/lib/dataStore.js +2 -1
  217. package/lib/dataStore.js.map +1 -1
  218. package/lib/dataStoreContext.d.ts +41 -25
  219. package/lib/dataStoreContext.d.ts.map +1 -1
  220. package/lib/dataStoreContext.js +31 -18
  221. package/lib/dataStoreContext.js.map +1 -1
  222. package/lib/dataStoreContexts.d.ts +6 -2
  223. package/lib/dataStoreContexts.d.ts.map +1 -1
  224. package/lib/dataStoreContexts.js +6 -2
  225. package/lib/dataStoreContexts.js.map +1 -1
  226. package/lib/dataStoreRegistry.d.ts +1 -1
  227. package/lib/dataStoreRegistry.d.ts.map +1 -1
  228. package/lib/dataStoreRegistry.js.map +1 -1
  229. package/lib/deltaManagerProxies.d.ts +1 -17
  230. package/lib/deltaManagerProxies.d.ts.map +1 -1
  231. package/lib/deltaManagerProxies.js.map +1 -1
  232. package/lib/deltaScheduler.d.ts +9 -6
  233. package/lib/deltaScheduler.d.ts.map +1 -1
  234. package/lib/deltaScheduler.js +95 -89
  235. package/lib/deltaScheduler.js.map +1 -1
  236. package/lib/gc/garbageCollection.d.ts +21 -7
  237. package/lib/gc/garbageCollection.d.ts.map +1 -1
  238. package/lib/gc/garbageCollection.js +12 -5
  239. package/lib/gc/garbageCollection.js.map +1 -1
  240. package/lib/gc/gcConfigs.d.ts +11 -0
  241. package/lib/gc/gcConfigs.d.ts.map +1 -1
  242. package/lib/gc/gcConfigs.js +1 -1
  243. package/lib/gc/gcConfigs.js.map +1 -1
  244. package/lib/gc/gcDefinitions.d.ts +210 -70
  245. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  246. package/lib/gc/gcDefinitions.js +39 -13
  247. package/lib/gc/gcDefinitions.js.map +1 -1
  248. package/lib/gc/gcHelpers.d.ts +6 -2
  249. package/lib/gc/gcHelpers.d.ts.map +1 -1
  250. package/lib/gc/gcHelpers.js +6 -2
  251. package/lib/gc/gcHelpers.js.map +1 -1
  252. package/lib/gc/gcSummaryDefinitions.d.ts +18 -6
  253. package/lib/gc/gcSummaryDefinitions.d.ts.map +1 -1
  254. package/lib/gc/gcSummaryDefinitions.js.map +1 -1
  255. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  256. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  257. package/lib/gc/gcTelemetry.d.ts +33 -11
  258. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  259. package/lib/gc/gcTelemetry.js +6 -2
  260. package/lib/gc/gcTelemetry.js.map +1 -1
  261. package/lib/gc/gcUnreferencedStateTracker.d.ts +42 -13
  262. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -1
  263. package/lib/gc/gcUnreferencedStateTracker.js +27 -9
  264. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  265. package/lib/gc/index.d.ts +1 -0
  266. package/lib/gc/index.d.ts.map +1 -1
  267. package/lib/gc/index.js +1 -0
  268. package/lib/gc/index.js.map +1 -1
  269. package/lib/inboundBatchAggregator.d.ts +34 -0
  270. package/lib/inboundBatchAggregator.d.ts.map +1 -0
  271. package/lib/inboundBatchAggregator.js +181 -0
  272. package/lib/inboundBatchAggregator.js.map +1 -0
  273. package/lib/index.d.ts +1 -1
  274. package/lib/index.d.ts.map +1 -1
  275. package/lib/index.js.map +1 -1
  276. package/lib/legacy.d.ts +0 -4
  277. package/lib/messageTypes.d.ts +14 -5
  278. package/lib/messageTypes.d.ts.map +1 -1
  279. package/lib/messageTypes.js.map +1 -1
  280. package/lib/metadata.d.ts +12 -4
  281. package/lib/metadata.d.ts.map +1 -1
  282. package/lib/metadata.js +6 -2
  283. package/lib/metadata.js.map +1 -1
  284. package/lib/opLifecycle/batchManager.d.ts +9 -3
  285. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  286. package/lib/opLifecycle/batchManager.js +3 -1
  287. package/lib/opLifecycle/batchManager.js.map +1 -1
  288. package/lib/opLifecycle/duplicateBatchDetector.d.ts +9 -3
  289. package/lib/opLifecycle/duplicateBatchDetector.d.ts.map +1 -1
  290. package/lib/opLifecycle/duplicateBatchDetector.js +9 -3
  291. package/lib/opLifecycle/duplicateBatchDetector.js.map +1 -1
  292. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  293. package/lib/opLifecycle/opCompressor.js +1 -1
  294. package/lib/opLifecycle/opCompressor.js.map +1 -1
  295. package/lib/opLifecycle/opDecompressor.d.ts +3 -1
  296. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  297. package/lib/opLifecycle/opDecompressor.js +13 -9
  298. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  299. package/lib/opLifecycle/opGroupingManager.d.ts +0 -1
  300. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  301. package/lib/opLifecycle/opGroupingManager.js +6 -5
  302. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  303. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  304. package/lib/opLifecycle/opSplitter.js +2 -1
  305. package/lib/opLifecycle/opSplitter.js.map +1 -1
  306. package/lib/opLifecycle/outbox.d.ts +1 -1
  307. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  308. package/lib/opLifecycle/outbox.js +6 -1
  309. package/lib/opLifecycle/outbox.js.map +1 -1
  310. package/lib/opLifecycle/remoteMessageProcessor.d.ts +9 -3
  311. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  312. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  313. package/lib/packageVersion.d.ts +1 -1
  314. package/lib/packageVersion.js +1 -1
  315. package/lib/packageVersion.js.map +1 -1
  316. package/lib/pendingStateManager.d.ts +22 -6
  317. package/lib/pendingStateManager.d.ts.map +1 -1
  318. package/lib/pendingStateManager.js +41 -4
  319. package/lib/pendingStateManager.js.map +1 -1
  320. package/lib/summary/documentSchema.d.ts.map +1 -1
  321. package/lib/summary/documentSchema.js +2 -0
  322. package/lib/summary/documentSchema.js.map +1 -1
  323. package/lib/summary/index.d.ts +1 -1
  324. package/lib/summary/index.d.ts.map +1 -1
  325. package/lib/summary/index.js.map +1 -1
  326. package/lib/summary/orderedClientElection.d.ts +93 -31
  327. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  328. package/lib/summary/orderedClientElection.js +15 -5
  329. package/lib/summary/orderedClientElection.js.map +1 -1
  330. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -1
  331. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  332. package/lib/summary/runningSummarizer.d.ts +17 -6
  333. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  334. package/lib/summary/runningSummarizer.js +12 -4
  335. package/lib/summary/runningSummarizer.js.map +1 -1
  336. package/lib/summary/summarizer.d.ts +9 -5
  337. package/lib/summary/summarizer.d.ts.map +1 -1
  338. package/lib/summary/summarizer.js +9 -3
  339. package/lib/summary/summarizer.js.map +1 -1
  340. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  341. package/lib/summary/summarizerClientElection.js.map +1 -1
  342. package/lib/summary/summarizerHeuristics.d.ts +6 -2
  343. package/lib/summary/summarizerHeuristics.d.ts.map +1 -1
  344. package/lib/summary/summarizerHeuristics.js +12 -4
  345. package/lib/summary/summarizerHeuristics.js.map +1 -1
  346. package/lib/summary/summarizerNode/summarizerNode.d.ts +24 -8
  347. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  348. package/lib/summary/summarizerNode/summarizerNode.js +15 -5
  349. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  350. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +48 -16
  351. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  352. package/lib/summary/summarizerNode/summarizerNodeUtils.js +3 -1
  353. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  354. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +12 -4
  355. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  356. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +12 -4
  357. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  358. package/lib/summary/summarizerTypes.d.ts +246 -135
  359. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  360. package/lib/summary/summarizerTypes.js.map +1 -1
  361. package/lib/summary/summaryCollection.d.ts.map +1 -1
  362. package/lib/summary/summaryCollection.js +1 -4
  363. package/lib/summary/summaryCollection.js.map +1 -1
  364. package/lib/summary/summaryFormat.d.ts +24 -8
  365. package/lib/summary/summaryFormat.d.ts.map +1 -1
  366. package/lib/summary/summaryFormat.js.map +1 -1
  367. package/lib/summary/summaryGenerator.d.ts +9 -3
  368. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  369. package/lib/summary/summaryGenerator.js +3 -1
  370. package/lib/summary/summaryGenerator.js.map +1 -1
  371. package/lib/summary/summaryManager.d.ts +8 -4
  372. package/lib/summary/summaryManager.d.ts.map +1 -1
  373. package/lib/summary/summaryManager.js +12 -4
  374. package/lib/summary/summaryManager.js.map +1 -1
  375. package/lib/throttler.d.ts +26 -10
  376. package/lib/throttler.d.ts.map +1 -1
  377. package/lib/throttler.js +12 -4
  378. package/lib/throttler.js.map +1 -1
  379. package/package.json +44 -31
  380. package/src/batchTracker.ts +31 -33
  381. package/src/blobManager/blobManager.ts +38 -19
  382. package/src/blobManager/blobManagerSnapSum.ts +1 -1
  383. package/src/channelCollection.ts +44 -37
  384. package/src/connectionTelemetry.ts +31 -13
  385. package/src/containerHandleContext.ts +2 -2
  386. package/src/containerRuntime.ts +198 -140
  387. package/src/dataStore.ts +11 -6
  388. package/src/dataStoreContext.ts +80 -59
  389. package/src/dataStoreContexts.ts +16 -12
  390. package/src/dataStoreRegistry.ts +1 -1
  391. package/src/deltaManagerProxies.ts +5 -5
  392. package/src/deltaScheduler.ts +19 -13
  393. package/src/gc/garbageCollection.ts +41 -18
  394. package/src/gc/gcConfigs.ts +4 -4
  395. package/src/gc/gcDefinitions.ts +212 -70
  396. package/src/gc/gcHelpers.ts +11 -5
  397. package/src/gc/gcSummaryDefinitions.ts +18 -6
  398. package/src/gc/gcSummaryStateTracker.ts +4 -2
  399. package/src/gc/gcTelemetry.ts +47 -19
  400. package/src/gc/gcUnreferencedStateTracker.ts +40 -16
  401. package/src/gc/index.ts +1 -0
  402. package/src/{scheduleManager.ts → inboundBatchAggregator.ts} +54 -121
  403. package/src/index.ts +0 -3
  404. package/src/messageTypes.ts +14 -5
  405. package/src/metadata.ts +12 -4
  406. package/src/opLifecycle/batchManager.ts +12 -6
  407. package/src/opLifecycle/duplicateBatchDetector.ts +10 -4
  408. package/src/opLifecycle/opCompressor.ts +8 -4
  409. package/src/opLifecycle/opDecompressor.ts +20 -11
  410. package/src/opLifecycle/opGroupingManager.ts +12 -8
  411. package/src/opLifecycle/opSplitter.ts +11 -8
  412. package/src/opLifecycle/outbox.ts +22 -13
  413. package/src/opLifecycle/remoteMessageProcessor.ts +10 -4
  414. package/src/packageVersion.ts +1 -1
  415. package/src/pendingStateManager.ts +71 -15
  416. package/src/summary/documentSchema.ts +30 -18
  417. package/src/summary/index.ts +0 -3
  418. package/src/summary/orderedClientElection.ts +100 -38
  419. package/src/summary/runWhileConnectedCoordinator.ts +6 -3
  420. package/src/summary/runningSummarizer.ts +38 -19
  421. package/src/summary/summarizer.ts +29 -16
  422. package/src/summary/summarizerClientElection.ts +2 -2
  423. package/src/summary/summarizerHeuristics.ts +22 -11
  424. package/src/summary/summarizerNode/summarizerNode.ts +22 -12
  425. package/src/summary/summarizerNode/summarizerNodeUtils.ts +48 -16
  426. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +21 -11
  427. package/src/summary/summarizerTypes.ts +246 -139
  428. package/src/summary/summaryCollection.ts +24 -25
  429. package/src/summary/summaryFormat.ts +24 -8
  430. package/src/summary/summaryGenerator.ts +14 -8
  431. package/src/summary/summaryManager.ts +28 -18
  432. package/src/throttler.ts +23 -11
  433. package/dist/scheduleManager.d.ts +0 -28
  434. package/dist/scheduleManager.d.ts.map +0 -1
  435. package/dist/scheduleManager.js +0 -235
  436. package/dist/scheduleManager.js.map +0 -1
  437. package/lib/scheduleManager.d.ts +0 -28
  438. package/lib/scheduleManager.d.ts.map +0 -1
  439. package/lib/scheduleManager.js +0 -231
  440. package/lib/scheduleManager.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAGN,aAAa,EACb,gBAAgB,GAEhB,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAEN,UAAU,EAEV,iBAAiB,GACjB,MAAM,oBAAoB,CAAC;AAmD5B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,kBAAkB;IAO9B,YACkB,EAAqB,EACrB,OAAiC,EACjC,kBAA2B,EAC3B,uBAAiD,EACjD,WAA2C,EAC3C,mBAEwB,EACxB,kBAE0B;QAV1B,OAAE,GAAF,EAAE,CAAmB;QACrB,YAAO,GAAP,OAAO,CAA0B;QACjC,uBAAkB,GAAlB,kBAAkB,CAAS;QAC3B,4BAAuB,GAAvB,uBAAuB,CAA0B;QACjD,gBAAW,GAAX,WAAW,CAAgC;QAC3C,wBAAmB,GAAnB,mBAAmB,CAEK;QACxB,uBAAkB,GAAlB,kBAAkB,CAEQ;QAjB5C,iHAAiH;QACjH,sBAAsB;QACL,6BAAwB,GAAgB,IAAI,GAAG,EAAE,CAAC;QACnE,6EAA6E;QACrE,uBAAkB,GAA8B,EAAE,CAAC;IAcxD,CAAC;IAEJ;;;;;OAKG;IACK,uBAAuB,CAC9B,QAAoB,EACpB,SAAwB,EACxB,gBAA0C,EAC1C,aAAqB;QAErB,IAAI,gBAAgB,CAAC,KAAK,KAAK,iBAAiB,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,QAAQ,KAAK,UAAU,CAAC,KAAK,EAAE,CAAC;YACnC,OAAO,KAAK,CAAC;QACd,CAAC;QAED,4FAA4F;QAC5F,oDAAoD;QACpD,IAAI,QAAQ,KAAK,UAAU,CAAC,YAAY,IAA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M;oBAChC,CAAC,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;oBACxD,CAAC,CAAC,SAAS,CAAC;gBACb,MAAM,KAAK,GAAG;oBACb,SAAS,EAAE,GAAG,KAAK,UAAU,SAAS,EAAE;oBACxC,EAAE;oBACF,MAAM;oBACN,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;oBACvB,OAAO,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,eAAe,EAAE;oBACjD,SAAS;oBACT,GAAG,gBAAgB,CAAC;wBACnB,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;wBACnB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC;qBAC3B,CAAC;iBACF,CAAC;gBAEF,wGAAwG;gBACxG,4DAA4D;gBAC5D,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Tagged } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tgenerateStack,\n\ttagCodeArtifacts,\n\ttype ITelemetryPropertiesExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeHeaderData } from \"../containerRuntime.js\";\nimport { ICreateContainerMetadata } from \"../summary/index.js\";\n\nimport {\n\tGCFeatureMatrix,\n\tGCNodeType,\n\tIGarbageCollectorConfigs,\n\tUnreferencedState,\n} from \"./gcDefinitions.js\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\" | \"Realized\";\n\n/** Properties that are common to IUnreferencedEventProps and INodeUsageProps */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\theaders?: RuntimeHeaderData;\n\tadditionalProps?: ITelemetryPropertiesExt;\n}\n\n/** The event that is logged when unreferenced node is used after a certain time. */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\t/** The id that GC uses to track the node. May or may not match id */\n\ttrackedId: string;\n\tstate: UnreferencedState;\n\t/** The full path (in GC Path format) to the node in question */\n\tid: Tagged<string>;\n\tfromId?: Tagged<string>;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\t// Expanding GC feature matrix. Without doing this, the configs cannot be logged in telemetry directly.\n\tgcConfigs: Omit<IGarbageCollectorConfigs, \"persistedGcFeatureMatrix\"> & {\n\t\t[K in keyof GCFeatureMatrix]: GCFeatureMatrix[K];\n\t};\n\ttimeout?: number;\n}\n\n/** Properties passed to nodeUsed function when a node is used. */\ninterface INodeUsageProps extends ICommonProps {\n\t/** The full path (in GC Path format) to the node in question */\n\tid: string;\n\t/** Latest timestamp received from the server, as a baseline for computing GC state/age */\n\tcurrentReferenceTimestampMs: number;\n\t/** The package path of the node. This may not be available if the node hasn't been loaded yet */\n\tpackagePath: readonly string[] | undefined;\n\t/** In case of Revived - what node added the reference? */\n\tfromId?: string;\n\t/** In case of Revived - was it revived due to autorecovery? */\n\tautorecovery?: true;\n\t/** URL (including query string) if this usage came from a request */\n\trequestUrl?: string;\n\t/** Original request headers if this usage came from a request or handle.get */\n\trequestHeaders?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector.\n *\n * These events are not logged as errors, just generic events, since there can be false positives:\n *\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. tombstoneReadyObject telemetry - When a tombstone-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs.\n * 3. sweepReadyObject telemetry - When a sweep-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs + sweepGracePeriodMs.\n *\n * These events are logged as errors since they are based on the core GC logic:\n *\n * 1. Tombstone telemetry - When a tombstoned node is used - A node that has been marked as tombstone.\n * 2. Unknown outbound reference telemetry - When a node is referenced but GC was not notified of it when the new reference appeared.\n *\n * Note: The telemetry for a Deleted node being used is logged elsewhere in this package.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: IGarbageCollectorConfigs,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore. This does not apply to\n\t * tombstoned nodes for which an event is always logged. Some scenarios where we won't log:\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t) {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Non-tombstone events are logged once per event per node. A unique id is generated by joining\n\t\t// node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is inactive or tombstoned, log telemetry indicating object is used\n\t * when it should not have been.\n\t * @param trackedId - The id that GC uses to track the node. For SubDataStore nodes, this should be the DataStore ID.\n\t * @param INodeUsageProps - All kind of details about this event to be logged\n\t */\n\tpublic nodeUsed(\n\t\ttrackedId: string,\n\t\t{\n\t\t\tusageType,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tpackagePath,\n\t\t\tid: untaggedId,\n\t\t\tfromId: untaggedFromId,\n\t\t\tisTombstoned,\n\t\t\t...otherNodeUsageProps\n\t\t}: INodeUsageProps,\n\t) {\n\t\t// Note: For SubDataStore Load usage, trackedId will be the DataStore's id, not the full path in question.\n\t\t// This is necessary because the SubDataStore path may be unrecognized by GC (if suited for a custom request handler)\n\t\tconst nodeStateTracker = this.getNodeStateTracker(trackedId);\n\t\tconst nodeType = this.getNodeType(untaggedId);\n\n\t\tconst timeout = (() => {\n\t\t\tswitch (nodeStateTracker?.state) {\n\t\t\t\tcase UnreferencedState.Inactive:\n\t\t\t\t\treturn this.configs.inactiveTimeoutMs;\n\t\t\t\tcase UnreferencedState.TombstoneReady:\n\t\t\t\t\treturn this.configs.tombstoneTimeoutMs;\n\t\t\t\tcase UnreferencedState.SweepReady:\n\t\t\t\t\treturn (\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs &&\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs + this.configs.sweepGracePeriodMs\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})();\n\t\tconst { persistedGcFeatureMatrix, ...configs } = this.configs;\n\t\tconst unrefEventProps = {\n\t\t\ttrackedId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,\n\t\t\tage:\n\t\t\t\tnodeStateTracker !== undefined\n\t\t\t\t\t? currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs\n\t\t\t\t\t: -1,\n\t\t\ttimeout,\n\t\t\tisTombstoned,\n\t\t\t...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),\n\t\t\t...otherNodeUsageProps,\n\t\t\t...this.createContainerMetadata,\n\t\t\tgcConfigs: { ...configs, ...persistedGcFeatureMatrix },\n\t\t} satisfies Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> &\n\t\t\ttypeof otherNodeUsageProps;\n\n\t\t// If the node that is used is tombstoned, log a tombstone telemetry.\n\t\tif (isTombstoned) {\n\t\t\tthis.logTombstoneUsageTelemetry(unrefEventProps, nodeType, usageType, packagePath);\n\t\t}\n\n\t\t// After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing\n\t\t// else to log.\n\t\tif (nodeStateTracker === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${untaggedId}-${usageType}`;\n\n\t\tif (!this.shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session.\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...unrefEventProps, // Note: Contains some properties from INodeUsageProps as well\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\t\t\tunrefEventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Logs telemetry when a tombstoned object is changed, revived or loaded.\n\t */\n\tprivate logTombstoneUsageTelemetry(\n\t\tunrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\">,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tpackagePath?: readonly string[],\n\t) {\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived\n\t\t// GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived\n\t\t// GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived\n\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\tunrefEventProps;\n\t\tconst eventUsageName = usageType === \"Loaded\" ? \"Requested\" : usageType;\n\t\tconst event = {\n\t\t\teventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,\n\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\tstack: generateStack(),\n\t\t\tid,\n\t\t\tfromId,\n\t\t\theaders: { ...headers },\n\t\t\tdetails: { ...detailedProps, ...additionalProps }, // Also includes some properties from INodeUsageProps type\n\t\t\tgcConfigs,\n\t\t};\n\n\t\tif (\n\t\t\tusageType === \"Loaded\" &&\n\t\t\tthis.configs.throwOnTombstoneLoad &&\n\t\t\t!headers?.allowTombstone\n\t\t) {\n\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t} else {\n\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t) {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\t// Send as Generic not Error since there are known corner cases where this will fire.\n\t\t\t\t// E.g. If an old client re-references a node via an attach op (that doesn't include GC Data)\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt) {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst {\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t\tid,\n\t\t\t\tfromId,\n\t\t\t\theaders,\n\t\t\t\tgcConfigs,\n\t\t\t\tadditionalProps,\n\t\t\t\t...detailedProps\n\t\t\t} = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(detailedProps.trackedId); // Note: This is never SubDataStore path\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined || nodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcTelemetry.js","sourceRoot":"","sources":["../../src/gc/gcTelemetry.ts"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GAAG,KAAK,UAAU,SAAS,EAAE;oBACxC,EAAE;oBACF,MAAM;oBACN,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;oBACvB,OAAO,EAAE,EAAE,GAAG,aAAa,EAAE,GAAG,eAAe,EAAE;oBACjD,SAAS;oBACT,GAAG,gBAAgB,CAAC;wBACnB,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;wBACnB,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC;qBAC3B,CAAC;iBACF,CAAC;gBAEF,wGAAwG;gBACxG,4DAA4D;gBAC5D,MAAM,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Tagged } from \"@fluidframework/core-interfaces\";\nimport { IGarbageCollectionData } from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\tgenerateStack,\n\ttagCodeArtifacts,\n\ttype ITelemetryPropertiesExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeHeaderData } from \"../containerRuntime.js\";\nimport { ICreateContainerMetadata } from \"../summary/index.js\";\n\nimport {\n\tGCFeatureMatrix,\n\tGCNodeType,\n\tIGarbageCollectorConfigs,\n\tUnreferencedState,\n} from \"./gcDefinitions.js\";\nimport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n\ntype NodeUsageType = \"Changed\" | \"Loaded\" | \"Revived\" | \"Realized\";\n\n/**\n * Properties that are common to IUnreferencedEventProps and INodeUsageProps\n */\ninterface ICommonProps {\n\tusageType: NodeUsageType;\n\tcompletedGCRuns: number;\n\tisTombstoned: boolean;\n\tlastSummaryTime?: number;\n\theaders?: RuntimeHeaderData;\n\tadditionalProps?: ITelemetryPropertiesExt;\n}\n\n/**\n * The event that is logged when unreferenced node is used after a certain time.\n */\ninterface IUnreferencedEventProps extends ICreateContainerMetadata, ICommonProps {\n\t/**\n\t * The id that GC uses to track the node. May or may not match id\n\t */\n\ttrackedId: string;\n\tstate: UnreferencedState;\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: Tagged<string>;\n\tfromId?: Tagged<string>;\n\ttype: GCNodeType;\n\tunrefTime: number;\n\tage: number;\n\t// Expanding GC feature matrix. Without doing this, the configs cannot be logged in telemetry directly.\n\tgcConfigs: Omit<IGarbageCollectorConfigs, \"persistedGcFeatureMatrix\"> & {\n\t\t[K in keyof GCFeatureMatrix]: GCFeatureMatrix[K];\n\t};\n\ttimeout?: number;\n}\n\n/**\n * Properties passed to nodeUsed function when a node is used.\n */\ninterface INodeUsageProps extends ICommonProps {\n\t/**\n\t * The full path (in GC Path format) to the node in question\n\t */\n\tid: string;\n\t/**\n\t * Latest timestamp received from the server, as a baseline for computing GC state/age\n\t */\n\tcurrentReferenceTimestampMs: number;\n\t/**\n\t * The package path of the node. This may not be available if the node hasn't been loaded yet\n\t */\n\tpackagePath: readonly string[] | undefined;\n\t/**\n\t * In case of Revived - what node added the reference?\n\t */\n\tfromId?: string;\n\t/**\n\t * In case of Revived - was it revived due to autorecovery?\n\t */\n\tautorecovery?: true;\n\t/**\n\t * URL (including query string) if this usage came from a request\n\t */\n\trequestUrl?: string;\n\t/**\n\t * Original request headers if this usage came from a request or handle.get\n\t */\n\trequestHeaders?: string;\n}\n\n/**\n * Encapsulates the logic that tracks the various telemetry logged by the Garbage Collector.\n *\n * These events are not logged as errors, just generic events, since there can be false positives:\n *\n * 1. inactiveObject telemetry - When an inactive node is used - A node that has been unreferenced for inactiveTimeoutMs.\n * 2. tombstoneReadyObject telemetry - When a tombstone-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs.\n * 3. sweepReadyObject telemetry - When a sweep-ready node is used - A node that has been unreferenced for tombstoneTimeoutMs + sweepGracePeriodMs.\n *\n * These events are logged as errors since they are based on the core GC logic:\n *\n * 1. Tombstone telemetry - When a tombstoned node is used - A node that has been marked as tombstone.\n * 2. Unknown outbound reference telemetry - When a node is referenced but GC was not notified of it when the new reference appeared.\n *\n * Note: The telemetry for a Deleted node being used is logged elsewhere in this package.\n */\nexport class GCTelemetryTracker {\n\t// Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one\n\t// per event per node.\n\tprivate readonly loggedUnreferencedEvents: Set<string> = new Set();\n\t// Queue for unreferenced events that should be logged the next time GC runs.\n\tprivate pendingEventsQueue: IUnreferencedEventProps[] = [];\n\n\tconstructor(\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly configs: IGarbageCollectorConfigs,\n\t\tprivate readonly isSummarizerClient: boolean,\n\t\tprivate readonly createContainerMetadata: ICreateContainerMetadata,\n\t\tprivate readonly getNodeType: (nodeId: string) => GCNodeType,\n\t\tprivate readonly getNodeStateTracker: (\n\t\t\tnodeId: string,\n\t\t) => UnreferencedStateTracker | undefined,\n\t\tprivate readonly getNodePackagePath: (\n\t\t\tnodePath: string,\n\t\t) => Promise<readonly string[] | undefined>,\n\t) {}\n\n\t/**\n\t * Returns whether an event should be logged for a node that isn't active anymore.\n\t *\n\t * @remarks\n\t * This does not apply to tombstoned nodes for which an event is always logged. Some scenarios where we won't log:\n\t *\n\t * 1. When a DDS is changed. The corresponding data store's event will be logged instead.\n\t *\n\t * 2. An event is logged only once per container instance per event per node.\n\t */\n\tprivate shouldLogNonActiveEvent(\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tnodeStateTracker: UnreferencedStateTracker,\n\t\tuniqueEventId: string,\n\t): boolean {\n\t\tif (nodeStateTracker.state === UnreferencedState.Active) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (nodeType === GCNodeType.Other) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// For sub data store (DDS) nodes, if they are changed, its data store will also be changed,\n\t\t// so skip logging to make the telemetry less noisy.\n\t\tif (nodeType === GCNodeType.SubDataStore && usageType === \"Changed\") {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Non-tombstone events are logged once per event per node. A unique id is generated by joining\n\t\t// node state (inactive / sweep ready), node's id and usage (loaded / changed / revived).\n\t\tif (this.loggedUnreferencedEvents.has(uniqueEventId)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Called when a node is used. If the node is inactive or tombstoned, log telemetry indicating object is used\n\t * when it should not have been.\n\t * @param trackedId - The id that GC uses to track the node. For SubDataStore nodes, this should be the DataStore ID.\n\t * @param INodeUsageProps - All kind of details about this event to be logged\n\t */\n\tpublic nodeUsed(\n\t\ttrackedId: string,\n\t\t{\n\t\t\tusageType,\n\t\t\tcurrentReferenceTimestampMs,\n\t\t\tpackagePath,\n\t\t\tid: untaggedId,\n\t\t\tfromId: untaggedFromId,\n\t\t\tisTombstoned,\n\t\t\t...otherNodeUsageProps\n\t\t}: INodeUsageProps,\n\t): void {\n\t\t// Note: For SubDataStore Load usage, trackedId will be the DataStore's id, not the full path in question.\n\t\t// This is necessary because the SubDataStore path may be unrecognized by GC (if suited for a custom request handler)\n\t\tconst nodeStateTracker = this.getNodeStateTracker(trackedId);\n\t\tconst nodeType = this.getNodeType(untaggedId);\n\n\t\tconst timeout = (() => {\n\t\t\tswitch (nodeStateTracker?.state) {\n\t\t\t\tcase UnreferencedState.Inactive:\n\t\t\t\t\treturn this.configs.inactiveTimeoutMs;\n\t\t\t\tcase UnreferencedState.TombstoneReady:\n\t\t\t\t\treturn this.configs.tombstoneTimeoutMs;\n\t\t\t\tcase UnreferencedState.SweepReady:\n\t\t\t\t\treturn (\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs &&\n\t\t\t\t\t\tthis.configs.tombstoneTimeoutMs + this.configs.sweepGracePeriodMs\n\t\t\t\t\t);\n\t\t\t\tdefault:\n\t\t\t\t\treturn undefined;\n\t\t\t}\n\t\t})();\n\t\tconst { persistedGcFeatureMatrix, ...configs } = this.configs;\n\t\tconst unrefEventProps = {\n\t\t\ttrackedId,\n\t\t\ttype: nodeType,\n\t\t\tunrefTime: nodeStateTracker?.unreferencedTimestampMs ?? -1,\n\t\t\tage:\n\t\t\t\tnodeStateTracker !== undefined\n\t\t\t\t\t? currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs\n\t\t\t\t\t: -1,\n\t\t\ttimeout,\n\t\t\tisTombstoned,\n\t\t\t...tagCodeArtifacts({ id: untaggedId, fromId: untaggedFromId }),\n\t\t\t...otherNodeUsageProps,\n\t\t\t...this.createContainerMetadata,\n\t\t\tgcConfigs: { ...configs, ...persistedGcFeatureMatrix },\n\t\t} satisfies Omit<IUnreferencedEventProps, \"state\" | \"usageType\"> &\n\t\t\ttypeof otherNodeUsageProps;\n\n\t\t// If the node that is used is tombstoned, log a tombstone telemetry.\n\t\tif (isTombstoned) {\n\t\t\tthis.logTombstoneUsageTelemetry(unrefEventProps, nodeType, usageType, packagePath);\n\t\t}\n\n\t\t// After logging tombstone telemetry, if the node's unreferenced state is not tracked, there is nothing\n\t\t// else to log.\n\t\tif (nodeStateTracker === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = nodeStateTracker.state;\n\t\tconst uniqueEventId = `${state}-${untaggedId}-${usageType}`;\n\n\t\tif (!this.shouldLogNonActiveEvent(nodeType, usageType, nodeStateTracker, uniqueEventId)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Add the unique event id so that we don't generate a log for this event again in this session.\n\t\tthis.loggedUnreferencedEvents.add(uniqueEventId);\n\n\t\t// For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.\n\t\t// For non-summarizer client, log the event now since GC won't run on it. This may result in false positives\n\t\t// but it's a good signal nonetheless and we can consume it with a grain of salt.\n\t\t// Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.\n\t\t// SweepReady errors are usages of Objects that will be deleted by GC Sweep!\n\t\tif (this.isSummarizerClient) {\n\t\t\tthis.pendingEventsQueue.push({\n\t\t\t\t...unrefEventProps, // Note: Contains some properties from INodeUsageProps as well\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t});\n\t\t} else {\n\t\t\t// For non-summarizer clients, only log \"Loaded\" type events since these objects may not be loaded in the\n\t\t\t// summarizer clients if they are based off of user actions (such as scrolling to content for these objects)\n\t\t\t// Events generated:\n\t\t\t// InactiveObject_Loaded, SweepReadyObject_Loaded\n\t\t\tif (usageType === \"Loaded\") {\n\t\t\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\t\t\tunrefEventProps;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\t\t\tstack: generateStack(),\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Logs telemetry when a tombstoned object is changed, revived or loaded.\n\t */\n\tprivate logTombstoneUsageTelemetry(\n\t\tunrefEventProps: Omit<IUnreferencedEventProps, \"state\" | \"usageType\">,\n\t\tnodeType: GCNodeType,\n\t\tusageType: NodeUsageType,\n\t\tpackagePath?: readonly string[],\n\t): void {\n\t\t// This will log the following events:\n\t\t// GC_Tombstone_DataStore_Requested, GC_Tombstone_DataStore_Changed, GC_Tombstone_DataStore_Revived\n\t\t// GC_Tombstone_SubDataStore_Requested, GC_Tombstone_SubDataStore_Changed, GC_Tombstone_SubDataStore_Revived\n\t\t// GC_Tombstone_Blob_Requested, GC_Tombstone_Blob_Changed, GC_Tombstone_Blob_Revived\n\t\tconst { id, fromId, headers, gcConfigs, additionalProps, ...detailedProps } =\n\t\t\tunrefEventProps;\n\t\tconst eventUsageName = usageType === \"Loaded\" ? \"Requested\" : usageType;\n\t\tconst event = {\n\t\t\teventName: `GC_Tombstone_${nodeType}_${eventUsageName}`,\n\t\t\t...tagCodeArtifacts({ pkg: packagePath?.join(\"/\") }),\n\t\t\tstack: generateStack(),\n\t\t\tid,\n\t\t\tfromId,\n\t\t\theaders: { ...headers },\n\t\t\tdetails: { ...detailedProps, ...additionalProps }, // Also includes some properties from INodeUsageProps type\n\t\t\tgcConfigs,\n\t\t};\n\n\t\tif (\n\t\t\tusageType === \"Loaded\" &&\n\t\t\tthis.configs.throwOnTombstoneLoad &&\n\t\t\t!headers?.allowTombstone\n\t\t) {\n\t\t\tthis.mc.logger.sendErrorEvent(event);\n\t\t} else {\n\t\t\tthis.mc.logger.sendTelemetryEvent(event);\n\t\t}\n\t}\n\n\t/**\n\t * Log all new references or outbound routes in the current graph that haven't been explicitly notified to GC.\n\t * The principle is that every new reference or outbound route must be notified to GC via the\n\t * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.\n\t *\n\t * In more simple terms:\n\t * Missing Explicit References = Current References - Previous References - Explicitly Added References;\n\t *\n\t * @param currentGCData - The GC data (reference graph) from the current GC run.\n\t * @param previousGCData - The GC data (reference graph) from the previous GC run.\n\t * @param explicitReferences - New references added explicity between the previous and the current run.\n\t */\n\tpublic logIfMissingExplicitReferences(\n\t\tcurrentGCData: IGarbageCollectionData,\n\t\tpreviousGCData: IGarbageCollectionData,\n\t\texplicitReferences: Map<string, string[]>,\n\t\tlogger: ITelemetryLoggerExt,\n\t): void {\n\t\tfor (const [nodeId, currentOutboundRoutes] of Object.entries(currentGCData.gcNodes)) {\n\t\t\tconst previousRoutes = previousGCData.gcNodes[nodeId] ?? [];\n\t\t\tconst explicitRoutes = explicitReferences.get(nodeId) ?? [];\n\n\t\t\t/**\n\t\t\t * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have\n\t\t\t * explicit references should be added to missing explicit routes list.\n\t\t\t * 2. Only include data store and blob routes since GC only works for these two.\n\t\t\t * Note: Due to a bug with de-duped blobs, only adding data store routes for now.\n\t\t\t * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be\n\t\t\t * explicit routes to them.\n\t\t\t */\n\t\t\tconst missingExplicitRoutes: string[] = [];\n\t\t\tfor (const route of currentOutboundRoutes) {\n\t\t\t\tconst nodeType = this.getNodeType(route);\n\t\t\t\tif (\n\t\t\t\t\t(nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob) &&\n\t\t\t\t\t!nodeId.startsWith(route) &&\n\t\t\t\t\t!previousRoutes.includes(route) &&\n\t\t\t\t\t!explicitRoutes.includes(route)\n\t\t\t\t) {\n\t\t\t\t\tmissingExplicitRoutes.push(route);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (missingExplicitRoutes.length > 0) {\n\t\t\t\t// Send as Generic not Error since there are known corner cases where this will fire.\n\t\t\t\t// E.g. If an old client re-references a node via an attach op (that doesn't include GC Data)\n\t\t\t\tlogger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"gcUnknownOutboundReferences\",\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tid: nodeId,\n\t\t\t\t\t\troutes: JSON.stringify(missingExplicitRoutes),\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Log events that are pending in pendingEventsQueue. This is called after GC runs in the summarizer client\n\t * so that the state of an unreferenced node is updated.\n\t */\n\tpublic async logPendingEvents(logger: ITelemetryLoggerExt): Promise<void> {\n\t\t// Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at\n\t\t// summary time they are then logged.\n\t\t// Events generated:\n\t\t// InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived\n\t\t// SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived\n\t\tfor (const eventProps of this.pendingEventsQueue) {\n\t\t\tconst {\n\t\t\t\tusageType,\n\t\t\t\tstate,\n\t\t\t\tid,\n\t\t\t\tfromId,\n\t\t\t\theaders,\n\t\t\t\tgcConfigs,\n\t\t\t\tadditionalProps,\n\t\t\t\t...detailedProps\n\t\t\t} = eventProps;\n\t\t\t/**\n\t\t\t * Revived event is logged only if the node is active. If the node is not active, the reference to it was\n\t\t\t * from another unreferenced node and this scenario is not interesting to log.\n\t\t\t * Loaded and Changed events are logged only if the node is not active. If the node is active, it was\n\t\t\t * revived and a Revived event will be logged for it.\n\t\t\t */\n\t\t\tconst nodeStateTracker = this.getNodeStateTracker(detailedProps.trackedId); // Note: This is never SubDataStore path\n\t\t\tconst active =\n\t\t\t\tnodeStateTracker === undefined || nodeStateTracker.state === UnreferencedState.Active;\n\t\t\tif ((usageType === \"Revived\") === active) {\n\t\t\t\tconst pkg = await this.getNodePackagePath(eventProps.id.value);\n\t\t\t\tconst fromPkg = eventProps.fromId\n\t\t\t\t\t? await this.getNodePackagePath(eventProps.fromId.value)\n\t\t\t\t\t: undefined;\n\t\t\t\tconst event = {\n\t\t\t\t\teventName: `${state}Object_${usageType}`,\n\t\t\t\t\tid,\n\t\t\t\t\tfromId,\n\t\t\t\t\theaders: { ...headers },\n\t\t\t\t\tdetails: { ...detailedProps, ...additionalProps },\n\t\t\t\t\tgcConfigs,\n\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\tpkg: pkg?.join(\"/\"),\n\t\t\t\t\t\tfromPkg: fromPkg?.join(\"/\"),\n\t\t\t\t\t}),\n\t\t\t\t};\n\n\t\t\t\t// These are logged as generic events and not errors because there can be false positives. The Tombstone\n\t\t\t\t// and Delete errors are separately logged and are reliable.\n\t\t\t\tlogger.sendTelemetryEvent(event);\n\t\t\t}\n\t\t}\n\t\tthis.pendingEventsQueue = [];\n\t}\n}\n"]}
@@ -3,9 +3,13 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { UnreferencedState } from "./gcDefinitions.js";
6
- /** The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting */
6
+ /**
7
+ * The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting
8
+ */
7
9
  export declare class UnreferencedStateTrackerMap extends Map<string, UnreferencedStateTracker> {
8
- /** Delete the given key, and stop tracking if that node was actually unreferenced */
10
+ /**
11
+ * Delete the given key, and stop tracking if that node was actually unreferenced
12
+ */
9
13
  delete(key: string): boolean;
10
14
  }
11
15
  /**
@@ -14,32 +18,57 @@ export declare class UnreferencedStateTrackerMap extends Map<string, Unreference
14
18
  */
15
19
  export declare class UnreferencedStateTracker {
16
20
  readonly unreferencedTimestampMs: number;
17
- /** The time after which node transitions to Inactive state. */
21
+ /**
22
+ * The time after which node transitions to Inactive state.
23
+ */
18
24
  private readonly inactiveTimeoutMs;
19
- /** The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled. */
25
+ /**
26
+ * The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled.
27
+ */
20
28
  private readonly tombstoneTimeoutMs;
21
- /** The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined) */
29
+ /**
30
+ * The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined)
31
+ */
22
32
  private readonly sweepGracePeriodMs;
23
33
  private _state;
24
34
  get state(): UnreferencedState;
25
- /** Timer to indicate when an unreferenced object is considered Inactive */
35
+ /**
36
+ * Timer to indicate when an unreferenced object is considered Inactive
37
+ */
26
38
  private readonly inactiveTimer;
27
- /** Timer to indicate when an unreferenced object is Tombstone-Ready */
39
+ /**
40
+ * Timer to indicate when an unreferenced object is Tombstone-Ready
41
+ */
28
42
  private readonly tombstoneTimer;
29
- /** Timer to indicate when an unreferenced object is Sweep-Ready */
43
+ /**
44
+ * Timer to indicate when an unreferenced object is Sweep-Ready
45
+ */
30
46
  private readonly sweepTimer;
31
47
  constructor(unreferencedTimestampMs: number,
32
- /** The time after which node transitions to Inactive state. */
48
+ /**
49
+ * The time after which node transitions to Inactive state.
50
+ */
33
51
  inactiveTimeoutMs: number,
34
- /** The current reference timestamp used to track how long this node has been unreferenced for. */
52
+ /**
53
+ * The current reference timestamp used to track how long this node has been unreferenced for.
54
+ */
35
55
  currentReferenceTimestampMs: number,
36
- /** The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled. */
56
+ /**
57
+ * The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled.
58
+ */
37
59
  tombstoneTimeoutMs: number | undefined,
38
- /** The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined) */
60
+ /**
61
+ * The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined)
62
+ */
39
63
  sweepGracePeriodMs: number);
64
+ /**
65
+ * Updates the unreferenced state based on the provided timestamp.
66
+ */
40
67
  updateTracking(currentReferenceTimestampMs: number): void;
41
68
  private clearTimers;
42
- /** Stop tracking this node. Reset the unreferenced timers and state, if any. */
69
+ /**
70
+ * Stop tracking this node. Reset the unreferenced timers and state, if any.
71
+ */
43
72
  stopTracking(): void;
44
73
  }
45
74
  //# sourceMappingURL=gcUnreferencedStateTracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gcUnreferencedStateTracker.d.ts","sourceRoot":"","sources":["../../src/gc/gcUnreferencedStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAoBvD,2HAA2H;AAC3H,qBAAa,2BAA4B,SAAQ,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC;IACrF,qFAAqF;IACrF,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAM5B;AAED;;;GAGG;AACH,qBAAa,wBAAwB;aAcnB,uBAAuB,EAAE,MAAM;IAC/C,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAGlC,8GAA8G;IAC9G,OAAO,CAAC,QAAQ,CAAC,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AEpC;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA4B;IAC1D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4B;gBAGtC,uBAAuB,EAAE,MAAM;IAC/C;;OAEG;IACc,iBAAiB,EAAE,MAAM;IAC1C;;OAEG;IACH,2BAA2B,EAAE,MAAM;IACnC;;OAEG;IACc,kBAAkB,EAAE,MAAM,GAAG,SAAS;IACvD;;OAEG;IACc,kBAAkB,EAAE,MAAM;IA2C5C;;OAEG;IACI,cAAc,CAAC,2BAA2B,EAAE,MAAM,GAAG,IAAI;IA4ChE,OAAO,CAAC,WAAW;IAMnB;;OAEG;IACI,YAAY,IAAI,IAAI;CAI3B"}
@@ -5,7 +5,9 @@
5
5
  import { assert, Timer } from "@fluidframework/core-utils/internal";
6
6
  import { validatePrecondition } from "@fluidframework/telemetry-utils/internal";
7
7
  import { UnreferencedState } from "./gcDefinitions.js";
8
- /** A wrapper around common-utils Timer that requires the timeout when calling start/restart */
8
+ /**
9
+ * A wrapper around common-utils Timer that requires the timeout when calling start/restart
10
+ */
9
11
  class TimerWithNoDefaultTimeout extends Timer {
10
12
  constructor(callback) {
11
13
  // The default timeout/handlers will never be used since start/restart pass overrides below
@@ -21,9 +23,13 @@ class TimerWithNoDefaultTimeout extends Timer {
21
23
  super.restart(timeoutMs, this.callback);
22
24
  }
23
25
  }
24
- /** The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting */
26
+ /**
27
+ * The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting
28
+ */
25
29
  export class UnreferencedStateTrackerMap extends Map {
26
- /** Delete the given key, and stop tracking if that node was actually unreferenced */
30
+ /**
31
+ * Delete the given key, and stop tracking if that node was actually unreferenced
32
+ */
27
33
  delete(key) {
28
34
  // Stop tracking so as to clear out any running timers.
29
35
  this.get(key)?.stopTracking();
@@ -40,13 +46,21 @@ export class UnreferencedStateTracker {
40
46
  return this._state;
41
47
  }
42
48
  constructor(unreferencedTimestampMs,
43
- /** The time after which node transitions to Inactive state. */
49
+ /**
50
+ * The time after which node transitions to Inactive state.
51
+ */
44
52
  inactiveTimeoutMs,
45
- /** The current reference timestamp used to track how long this node has been unreferenced for. */
53
+ /**
54
+ * The current reference timestamp used to track how long this node has been unreferenced for.
55
+ */
46
56
  currentReferenceTimestampMs,
47
- /** The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled. */
57
+ /**
58
+ * The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled.
59
+ */
48
60
  tombstoneTimeoutMs,
49
- /** The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined) */
61
+ /**
62
+ * The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined)
63
+ */
50
64
  sweepGracePeriodMs) {
51
65
  this.unreferencedTimestampMs = unreferencedTimestampMs;
52
66
  this.inactiveTimeoutMs = inactiveTimeoutMs;
@@ -79,7 +93,9 @@ export class UnreferencedStateTracker {
79
93
  });
80
94
  this.updateTracking(currentReferenceTimestampMs);
81
95
  }
82
- /* Updates the unreferenced state based on the provided timestamp. */
96
+ /**
97
+ * Updates the unreferenced state based on the provided timestamp.
98
+ */
83
99
  updateTracking(currentReferenceTimestampMs) {
84
100
  const unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;
85
101
  // Below we will set the appropriate timer (or none). Any running timers are superceded by the new currentReferenceTimestampMs
@@ -115,7 +131,9 @@ export class UnreferencedStateTracker {
115
131
  this.tombstoneTimer.clear();
116
132
  this.sweepTimer.clear();
117
133
  }
118
- /** Stop tracking this node. Reset the unreferenced timers and state, if any. */
134
+ /**
135
+ * Stop tracking this node. Reset the unreferenced timers and state, if any.
136
+ */
119
137
  stopTracking() {
120
138
  this.clearTimers();
121
139
  this._state = UnreferencedState.Active;
@@ -1 +1 @@
1
- {"version":3,"file":"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AAI,CAAC,kBAAkB,GAAG,sBAAsB,CAAC,CAAC;YAC/E,CAAC;YACD,OAAO;QACR,CAAC;QAED,qGAAqG;QACrG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,CAAC;IAC7E,CAAC;IAEO,WAAW;QAClB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,gFAAgF;IACzE,YAAY;QAClB,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC;IACxC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Timer } from \"@fluidframework/core-utils/internal\";\nimport { validatePrecondition } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { UnreferencedState } from \"./gcDefinitions.js\";\n\n/** A wrapper around common-utils Timer that requires the timeout when calling start/restart */\nclass TimerWithNoDefaultTimeout extends Timer {\n\tconstructor(private readonly callback: () => void) {\n\t\t// The default timeout/handlers will never be used since start/restart pass overrides below\n\t\tsuper(0, () => {\n\t\t\tthrow new Error(\"DefaultHandler should not be used\");\n\t\t});\n\t}\n\n\tstart(timeoutMs: number) {\n\t\tsuper.start(timeoutMs, this.callback);\n\t}\n\n\trestart(timeoutMs: number): void {\n\t\tsuper.restart(timeoutMs, this.callback);\n\t}\n}\n\n/** The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting */\nexport class UnreferencedStateTrackerMap extends Map<string, UnreferencedStateTracker> {\n\t/** Delete the given key, and stop tracking if that node was actually unreferenced */\n\tdelete(key: string): boolean {\n\t\t// Stop tracking so as to clear out any running timers.\n\t\tthis.get(key)?.stopTracking();\n\t\t// Delete the node as we don't need to track it any more.\n\t\treturn super.delete(key);\n\t}\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 tombstoned or deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n\tprivate _state: UnreferencedState = UnreferencedState.Active;\n\tpublic get state(): UnreferencedState {\n\t\treturn this._state;\n\t}\n\n\t/** Timer to indicate when an unreferenced object is considered Inactive */\n\tprivate readonly inactiveTimer: TimerWithNoDefaultTimeout;\n\t/** Timer to indicate when an unreferenced object is Tombstone-Ready */\n\tprivate readonly tombstoneTimer: TimerWithNoDefaultTimeout;\n\t/** Timer to indicate when an unreferenced object is Sweep-Ready */\n\tprivate readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n\tconstructor(\n\t\tpublic readonly unreferencedTimestampMs: number,\n\t\t/** The time after which node transitions to Inactive state. */\n\t\tprivate readonly inactiveTimeoutMs: number,\n\t\t/** The current reference timestamp used to track how long this node has been unreferenced for. */\n\t\tcurrentReferenceTimestampMs: number,\n\t\t/** The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled. */\n\t\tprivate readonly tombstoneTimeoutMs: number | undefined,\n\t\t/** The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined) */\n\t\tprivate readonly sweepGracePeriodMs: number,\n\t) {\n\t\tvalidatePrecondition(\n\t\t\tthis.tombstoneTimeoutMs === undefined ||\n\t\t\t\tthis.tombstoneTimeoutMs >= this.inactiveTimeoutMs,\n\t\t\t\"inactiveTimeoutMs must not be greater than the tombstoneTimeoutMs\",\n\t\t);\n\n\t\tthis.sweepTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer && !this.tombstoneTimer.hasTimer,\n\t\t\t\t0x863 /* inactiveTimer or tombstoneTimer still running after sweepTimer fired! */,\n\t\t\t);\n\t\t});\n\n\t\tthis.tombstoneTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.TombstoneReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer,\n\t\t\t\t0x864 /* inactiveTimer still running after tombstoneTimer fired! */,\n\t\t\t); // aka 0x3b1\n\n\t\t\tif (this.sweepGracePeriodMs > 0) {\n\t\t\t\t// After the node becomes tombstone ready, start the sweep timer after which the node will be ready for sweep.\n\t\t\t\tthis.sweepTimer.restart(this.sweepGracePeriodMs);\n\t\t\t} else {\n\t\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\t}\n\t\t});\n\n\t\tthis.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\t// After the node becomes inactive, start the tombstone timer after which the node will be ready for tombstone.\n\t\t\tif (this.tombstoneTimeoutMs !== undefined) {\n\t\t\t\tthis.tombstoneTimer.restart(this.tombstoneTimeoutMs - this.inactiveTimeoutMs);\n\t\t\t}\n\t\t});\n\n\t\tthis.updateTracking(currentReferenceTimestampMs);\n\t}\n\n\t/* Updates the unreferenced state based on the provided timestamp. */\n\tpublic updateTracking(currentReferenceTimestampMs: number) {\n\t\tconst unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n\t\t// Below we will set the appropriate timer (or none). Any running timers are superceded by the new currentReferenceTimestampMs\n\t\tthis.clearTimers();\n\n\t\t// If the node has been unreferenced long enough, update the state to SweepReady.\n\t\tif (\n\t\t\tthis.tombstoneTimeoutMs !== undefined &&\n\t\t\tunreferencedDurationMs >= this.tombstoneTimeoutMs + this.sweepGracePeriodMs\n\t\t) {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced long enough, update the state to TombstoneReady.\n\t\t// Also, start a timer for the remainder of the sweep delay.\n\t\tif (\n\t\t\tthis.tombstoneTimeoutMs !== undefined &&\n\t\t\tunreferencedDurationMs >= this.tombstoneTimeoutMs\n\t\t) {\n\t\t\tthis._state = UnreferencedState.TombstoneReady;\n\n\t\t\tthis.sweepTimer.restart(\n\t\t\t\tthis.tombstoneTimeoutMs + this.sweepGracePeriodMs - unreferencedDurationMs,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced for long enough, update the state to inactive.\n\t\t// Also, start a timer for the remainder of the tombstone timeout.\n\t\tif (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\tif (this.tombstoneTimeoutMs !== undefined) {\n\t\t\t\tthis.tombstoneTimer.restart(this.tombstoneTimeoutMs - unreferencedDurationMs);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n\t\tthis.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n\t}\n\n\tprivate clearTimers() {\n\t\tthis.inactiveTimer.clear();\n\t\tthis.tombstoneTimer.clear();\n\t\tthis.sweepTimer.clear();\n\t}\n\n\t/** Stop tracking this node. Reset the unreferenced timers and state, if any. */\n\tpublic stopTracking() {\n\t\tthis.clearTimers();\n\t\tthis._state = UnreferencedState.Active;\n\t}\n}\n"]}
1
+ {"version":3,"file":"gcUnreferencedStateTracker.js","sourceRoot":"","sources":["../../src/gc/gcUnreferencedStateTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;GAEG;AACH,MAAM,yBAA0B,SAAQ,KAAK;IAC5C,YAA6B,QAAoB;QAChD,2FAA2F;QAC3F,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;YACb,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACtD,C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C,MAAM,CAAC;IACxC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Timer } from \"@fluidframework/core-utils/internal\";\nimport { validatePrecondition } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { UnreferencedState } from \"./gcDefinitions.js\";\n\n/**\n * A wrapper around common-utils Timer that requires the timeout when calling start/restart\n */\nclass TimerWithNoDefaultTimeout extends Timer {\n\tconstructor(private readonly callback: () => void) {\n\t\t// The default timeout/handlers will never be used since start/restart pass overrides below\n\t\tsuper(0, () => {\n\t\t\tthrow new Error(\"DefaultHandler should not be used\");\n\t\t});\n\t}\n\n\tstart(timeoutMs: number): void {\n\t\tsuper.start(timeoutMs, this.callback);\n\t}\n\n\trestart(timeoutMs: number): void {\n\t\tsuper.restart(timeoutMs, this.callback);\n\t}\n}\n\n/**\n * The collection of UnreferencedStateTrackers for all unreferenced nodes. Ensures stopTracking is called when deleting\n */\nexport class UnreferencedStateTrackerMap extends Map<string, UnreferencedStateTracker> {\n\t/**\n\t * Delete the given key, and stop tracking if that node was actually unreferenced\n\t */\n\tdelete(key: string): boolean {\n\t\t// Stop tracking so as to clear out any running timers.\n\t\tthis.get(key)?.stopTracking();\n\t\t// Delete the node as we don't need to track it any more.\n\t\treturn super.delete(key);\n\t}\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 tombstoned or deleted by the sweep phase.\n */\nexport class UnreferencedStateTracker {\n\tprivate _state: UnreferencedState = UnreferencedState.Active;\n\tpublic get state(): UnreferencedState {\n\t\treturn this._state;\n\t}\n\n\t/**\n\t * Timer to indicate when an unreferenced object is considered Inactive\n\t */\n\tprivate readonly inactiveTimer: TimerWithNoDefaultTimeout;\n\t/**\n\t * Timer to indicate when an unreferenced object is Tombstone-Ready\n\t */\n\tprivate readonly tombstoneTimer: TimerWithNoDefaultTimeout;\n\t/**\n\t * Timer to indicate when an unreferenced object is Sweep-Ready\n\t */\n\tprivate readonly sweepTimer: TimerWithNoDefaultTimeout;\n\n\tconstructor(\n\t\tpublic readonly unreferencedTimestampMs: number,\n\t\t/**\n\t\t * The time after which node transitions to Inactive state.\n\t\t */\n\t\tprivate readonly inactiveTimeoutMs: number,\n\t\t/**\n\t\t * The current reference timestamp used to track how long this node has been unreferenced for.\n\t\t */\n\t\tcurrentReferenceTimestampMs: number,\n\t\t/**\n\t\t * The time after which node transitions to TombstoneReady state; undefined if session expiry is disabled.\n\t\t */\n\t\tprivate readonly tombstoneTimeoutMs: number | undefined,\n\t\t/**\n\t\t * The delay from TombstoneReady to SweepReady (only applies if tombstoneTimeoutMs is defined)\n\t\t */\n\t\tprivate readonly sweepGracePeriodMs: number,\n\t) {\n\t\tvalidatePrecondition(\n\t\t\tthis.tombstoneTimeoutMs === undefined ||\n\t\t\t\tthis.tombstoneTimeoutMs >= this.inactiveTimeoutMs,\n\t\t\t\"inactiveTimeoutMs must not be greater than the tombstoneTimeoutMs\",\n\t\t);\n\n\t\tthis.sweepTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer && !this.tombstoneTimer.hasTimer,\n\t\t\t\t0x863 /* inactiveTimer or tombstoneTimer still running after sweepTimer fired! */,\n\t\t\t);\n\t\t});\n\n\t\tthis.tombstoneTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.TombstoneReady;\n\t\t\tassert(\n\t\t\t\t!this.inactiveTimer.hasTimer,\n\t\t\t\t0x864 /* inactiveTimer still running after tombstoneTimer fired! */,\n\t\t\t); // aka 0x3b1\n\n\t\t\tif (this.sweepGracePeriodMs > 0) {\n\t\t\t\t// After the node becomes tombstone ready, start the sweep timer after which the node will be ready for sweep.\n\t\t\t\tthis.sweepTimer.restart(this.sweepGracePeriodMs);\n\t\t\t} else {\n\t\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\t}\n\t\t});\n\n\t\tthis.inactiveTimer = new TimerWithNoDefaultTimeout(() => {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\t// After the node becomes inactive, start the tombstone timer after which the node will be ready for tombstone.\n\t\t\tif (this.tombstoneTimeoutMs !== undefined) {\n\t\t\t\tthis.tombstoneTimer.restart(this.tombstoneTimeoutMs - this.inactiveTimeoutMs);\n\t\t\t}\n\t\t});\n\n\t\tthis.updateTracking(currentReferenceTimestampMs);\n\t}\n\n\t/**\n\t * Updates the unreferenced state based on the provided timestamp.\n\t */\n\tpublic updateTracking(currentReferenceTimestampMs: number): void {\n\t\tconst unreferencedDurationMs = currentReferenceTimestampMs - this.unreferencedTimestampMs;\n\n\t\t// Below we will set the appropriate timer (or none). Any running timers are superceded by the new currentReferenceTimestampMs\n\t\tthis.clearTimers();\n\n\t\t// If the node has been unreferenced long enough, update the state to SweepReady.\n\t\tif (\n\t\t\tthis.tombstoneTimeoutMs !== undefined &&\n\t\t\tunreferencedDurationMs >= this.tombstoneTimeoutMs + this.sweepGracePeriodMs\n\t\t) {\n\t\t\tthis._state = UnreferencedState.SweepReady;\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced long enough, update the state to TombstoneReady.\n\t\t// Also, start a timer for the remainder of the sweep delay.\n\t\tif (\n\t\t\tthis.tombstoneTimeoutMs !== undefined &&\n\t\t\tunreferencedDurationMs >= this.tombstoneTimeoutMs\n\t\t) {\n\t\t\tthis._state = UnreferencedState.TombstoneReady;\n\n\t\t\tthis.sweepTimer.restart(\n\t\t\t\tthis.tombstoneTimeoutMs + this.sweepGracePeriodMs - unreferencedDurationMs,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// If the node has been unreferenced for long enough, update the state to inactive.\n\t\t// Also, start a timer for the remainder of the tombstone timeout.\n\t\tif (unreferencedDurationMs >= this.inactiveTimeoutMs) {\n\t\t\tthis._state = UnreferencedState.Inactive;\n\n\t\t\tif (this.tombstoneTimeoutMs !== undefined) {\n\t\t\t\tthis.tombstoneTimer.restart(this.tombstoneTimeoutMs - unreferencedDurationMs);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// The node is still active. Ensure the inactive timer is running with the proper remaining duration.\n\t\tthis.inactiveTimer.restart(this.inactiveTimeoutMs - unreferencedDurationMs);\n\t}\n\n\tprivate clearTimers(): void {\n\t\tthis.inactiveTimer.clear();\n\t\tthis.tombstoneTimer.clear();\n\t\tthis.sweepTimer.clear();\n\t}\n\n\t/**\n\t * Stop tracking this node. Reset the unreferenced timers and state, if any.\n\t */\n\tpublic stopTracking(): void {\n\t\tthis.clearTimers();\n\t\tthis._state = UnreferencedState.Active;\n\t}\n}\n"]}
package/lib/gc/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection.js";
6
+ export { computeTombstoneTimeout } from "./gcConfigs.js";
6
7
  export { nextGCVersion, defaultInactiveTimeoutMs, defaultSweepGracePeriodMs, defaultSessionExpiryDurationMs, GCNodeType, gcTestModeKey, gcGenerationOptionName, GCFeatureMatrix, GCVersion, gcVersionUpgradeToV4Key, IGarbageCollectionRuntime, IGarbageCollector, IGarbageCollectorConfigs, IGarbageCollectorCreateParams, IGCMetadata, IGCMetadata_Deprecated, IGCNodeUpdatedProps, IGCResult, IGCRuntimeOptions, IMarkPhaseStats, ISweepPhaseStats, IGCStats, oneDayMs, runSessionExpiryKey, stableGCVersion, UnreferencedState, disableThrowOnTombstoneLoadKey, GarbageCollectionMessage, GarbageCollectionMessageType, ISweepMessage, } from "./gcDefinitions.js";
7
8
  export { cloneGCData, concatGarbageCollectionStates, getGCVersionInEffect, unpackChildNodesGCDetails, urlToGCNodePath, } from "./gcHelpers.js";
8
9
  export { runGarbageCollection } from "./gcReferenceGraphAlgorithm.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,EAC5B,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,GACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EACV,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,SAAS,EACT,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAC9B,wBAAwB,EACxB,4BAA4B,EAC5B,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,GACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,cAAc,EACd,qBAAqB,EACrB,sBAAsB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC"}
package/lib/gc/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { GarbageCollector } from "./garbageCollection.js";
6
+ export { computeTombstoneTimeout } from "./gcConfigs.js";
6
7
  export { nextGCVersion, defaultInactiveTimeoutMs, defaultSweepGracePeriodMs, defaultSessionExpiryDurationMs, GCNodeType, gcTestModeKey, gcGenerationOptionName, gcVersionUpgradeToV4Key, oneDayMs, runSessionExpiryKey, stableGCVersion, UnreferencedState, disableThrowOnTombstoneLoadKey, GarbageCollectionMessageType, } from "./gcDefinitions.js";
7
8
  export { cloneGCData, concatGarbageCollectionStates, getGCVersionInEffect, unpackChildNodesGCDetails, urlToGCNodePath, } from "./gcHelpers.js";
8
9
  export { runGarbageCollection } from "./gcReferenceGraphAlgorithm.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EACV,aAAa,EACb,sBAAsB,EAGtB,uBAAuB,EAavB,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAE9B,4BAA4B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAOtE,OAAO,EACN,cAAc,EACd,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection.js\";\nexport {\n\tnextGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSweepGracePeriodMs,\n\tdefaultSessionExpiryDurationMs,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcGenerationOptionName,\n\tGCFeatureMatrix,\n\tGCVersion,\n\tgcVersionUpgradeToV4Key,\n\tIGarbageCollectionRuntime,\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCMetadata_Deprecated,\n\tIGCNodeUpdatedProps,\n\tIGCResult,\n\tIGCRuntimeOptions,\n\tIMarkPhaseStats,\n\tISweepPhaseStats,\n\tIGCStats,\n\toneDayMs,\n\trunSessionExpiryKey,\n\tstableGCVersion,\n\tUnreferencedState,\n\tdisableThrowOnTombstoneLoadKey,\n\tGarbageCollectionMessage,\n\tGarbageCollectionMessageType,\n\tISweepMessage,\n} from \"./gcDefinitions.js\";\nexport {\n\tcloneGCData,\n\tconcatGarbageCollectionStates,\n\tgetGCVersionInEffect,\n\tunpackChildNodesGCDetails,\n\turlToGCNodePath,\n} from \"./gcHelpers.js\";\nexport { runGarbageCollection } from \"./gcReferenceGraphAlgorithm.js\";\nexport {\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n} from \"./gcSummaryDefinitions.js\";\nexport {\n\tgcStateBlobKey,\n\tGCSummaryStateTracker,\n\tIGCSummaryTrackingData,\n} from \"./gcSummaryStateTracker.js\";\nexport { GCTelemetryTracker } from \"./gcTelemetry.js\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gc/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,8BAA8B,EAC9B,UAAU,EACV,aAAa,EACb,sBAAsB,EAGtB,uBAAuB,EAavB,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,8BAA8B,EAE9B,4BAA4B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EACX,6BAA6B,EAC7B,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAOtE,OAAO,EACN,cAAc,EACd,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { GarbageCollector } from \"./garbageCollection.js\";\nexport { computeTombstoneTimeout } from \"./gcConfigs.js\";\nexport {\n\tnextGCVersion,\n\tdefaultInactiveTimeoutMs,\n\tdefaultSweepGracePeriodMs,\n\tdefaultSessionExpiryDurationMs,\n\tGCNodeType,\n\tgcTestModeKey,\n\tgcGenerationOptionName,\n\tGCFeatureMatrix,\n\tGCVersion,\n\tgcVersionUpgradeToV4Key,\n\tIGarbageCollectionRuntime,\n\tIGarbageCollector,\n\tIGarbageCollectorConfigs,\n\tIGarbageCollectorCreateParams,\n\tIGCMetadata,\n\tIGCMetadata_Deprecated,\n\tIGCNodeUpdatedProps,\n\tIGCResult,\n\tIGCRuntimeOptions,\n\tIMarkPhaseStats,\n\tISweepPhaseStats,\n\tIGCStats,\n\toneDayMs,\n\trunSessionExpiryKey,\n\tstableGCVersion,\n\tUnreferencedState,\n\tdisableThrowOnTombstoneLoadKey,\n\tGarbageCollectionMessage,\n\tGarbageCollectionMessageType,\n\tISweepMessage,\n} from \"./gcDefinitions.js\";\nexport {\n\tcloneGCData,\n\tconcatGarbageCollectionStates,\n\tgetGCVersionInEffect,\n\tunpackChildNodesGCDetails,\n\turlToGCNodePath,\n} from \"./gcHelpers.js\";\nexport { runGarbageCollection } from \"./gcReferenceGraphAlgorithm.js\";\nexport {\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n} from \"./gcSummaryDefinitions.js\";\nexport {\n\tgcStateBlobKey,\n\tGCSummaryStateTracker,\n\tIGCSummaryTrackingData,\n} from \"./gcSummaryStateTracker.js\";\nexport { GCTelemetryTracker } from \"./gcTelemetry.js\";\nexport { UnreferencedStateTracker } from \"./gcUnreferencedStateTracker.js\";\n"]}
@@ -0,0 +1,34 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IDeltaManagerFull } from "@fluidframework/container-definitions/internal";
6
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
7
+ /**
8
+ * This class ensures that we aggregate a complete batch of incoming ops before processing them. It basically ensures
9
+ * that we never start processing ops in a batch IF we do not have all ops in the batch.
10
+ */
11
+ export declare class InboundBatchAggregator {
12
+ private readonly deltaManager;
13
+ private readonly getClientId;
14
+ private readonly logger;
15
+ private pauseSequenceNumber;
16
+ private currentBatchClientId;
17
+ private localPaused;
18
+ private timePaused;
19
+ private batchCount;
20
+ constructor(deltaManager: IDeltaManagerFull, getClientId: () => string | undefined, logger: ITelemetryLoggerExt);
21
+ dispose(): void;
22
+ /**
23
+ * Callback for DeltaManager's "op" event, for us to make decision if op processing should
24
+ * be paused or not after that.
25
+ */
26
+ private readonly afterOpProcessing;
27
+ /**
28
+ * Called for each incoming op (i.e. inbound "push" notification)
29
+ */
30
+ private readonly trackPending;
31
+ private pauseQueue;
32
+ private resumeQueue;
33
+ }
34
+ //# sourceMappingURL=inboundBatchAggregator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inboundBatchAggregator.d.ts","sourceRoot":"","sources":["../src/inboundBatchAggregator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AAInF,OAAO,EACN,mBAAmB,EAInB,MAAM,0CAA0C,CAAC;AAWlD;;;GAGG;AACH,qBAAa,sBAAsB;IAQjC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM;IATxB,OAAO,CAAC,mBAAmB,CAAqB;IAChD,OAAO,CAAC,oBAAoB,CAAqB;IACjD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,UAAU,CAAK;gBAGL,YAAY,EAAE,iBAAiB,EAC/B,WAAW,EAAE,MAAM,MAAM,GAAG,SAAS,EACrC,MAAM,EAAE,mBAAmB;IAgBtC,OAAO,IAAI,IAAI;IAKtB;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CA4ChC;IAEF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CA8G3B;IAEF,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,WAAW;CA0BnB"}
@@ -0,0 +1,181 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { performance } from "@fluid-internal/client-utils";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
+ import { isRuntimeMessage } from "@fluidframework/driver-utils/internal";
8
+ import { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, } from "@fluidframework/telemetry-utils/internal";
9
+ import { pkgVersion } from "./packageVersion.js";
10
+ /**
11
+ * This class ensures that we aggregate a complete batch of incoming ops before processing them. It basically ensures
12
+ * that we never start processing ops in a batch IF we do not have all ops in the batch.
13
+ */
14
+ export class InboundBatchAggregator {
15
+ constructor(deltaManager, getClientId, logger) {
16
+ this.deltaManager = deltaManager;
17
+ this.getClientId = getClientId;
18
+ this.logger = logger;
19
+ this.localPaused = false;
20
+ this.timePaused = 0;
21
+ this.batchCount = 0;
22
+ /**
23
+ * Callback for DeltaManager's "op" event, for us to make decision if op processing should
24
+ * be paused or not after that.
25
+ */
26
+ this.afterOpProcessing = (message) => {
27
+ assert(!this.localPaused, 0x294 /* "can't have op processing paused if we are processing an op" */);
28
+ // If the inbound queue is ever empty, nothing to do!
29
+ if (this.deltaManager.inbound.length === 0) {
30
+ assert(this.pauseSequenceNumber === undefined, 0x295 /* "there should be no pending batch if we have no ops" */);
31
+ return;
32
+ }
33
+ // The queue is
34
+ // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:
35
+ // - here (processing ops until reaching start of incomplete batch)
36
+ // - in trackPending(), when queue was empty and start of batch showed up.
37
+ // 2. resumed when batch end comes in (in trackPending())
38
+ // do we have incomplete batch to worry about?
39
+ if (this.pauseSequenceNumber !== undefined) {
40
+ if (message.sequenceNumber >= this.pauseSequenceNumber) {
41
+ throw DataProcessingError.create(
42
+ // Former assert 0x296
43
+ "Incomplete batch", "InboundBatchAggregator", message, {
44
+ type: message.type,
45
+ contentType: typeof message.contents,
46
+ batch: message.metadata?.batch,
47
+ compression: message.compression,
48
+ pauseSeqNum: this.pauseSequenceNumber,
49
+ });
50
+ }
51
+ // If the next op is the start of incomplete batch, then we can't process it until it's fully in - pause!
52
+ if (message.sequenceNumber + 1 === this.pauseSequenceNumber) {
53
+ this.pauseQueue();
54
+ }
55
+ }
56
+ };
57
+ /**
58
+ * Called for each incoming op (i.e. inbound "push" notification)
59
+ */
60
+ this.trackPending = (message) => {
61
+ assert(this.deltaManager.inbound.length !== 0, 0x298 /* "we have something in the queue that generates this event" */);
62
+ assert((this.currentBatchClientId === undefined) === (this.pauseSequenceNumber === undefined), 0x299 /* "non-synchronized state" */);
63
+ const metadata = message.metadata;
64
+ // batchMetadata will be true for the message that starts a batch, false for the one that ends it, and
65
+ // undefined for all other messages.
66
+ const batchMetadata = metadata?.batch;
67
+ // Protocol messages are never part of a runtime batch of messages
68
+ if (!isRuntimeMessage(message)) {
69
+ // Protocol messages should never show up in the middle of the batch!
70
+ if (this.currentBatchClientId !== undefined) {
71
+ throw DataProcessingError.create("Received a system message during batch processing", // Formerly known as assert 0x29a
72
+ "trackPending", message, {
73
+ runtimeVersion: pkgVersion,
74
+ batchClientId:
75
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
76
+ this.currentBatchClientId === null ? "null" : this.currentBatchClientId,
77
+ pauseSequenceNumber: this.pauseSequenceNumber,
78
+ localBatch: this.currentBatchClientId === this.getClientId(),
79
+ messageType: message.type,
80
+ });
81
+ }
82
+ assert(batchMetadata === undefined, 0x29b /* "system op in a batch?" */);
83
+ assert(!this.localPaused, 0x29c /* "we should be processing ops when there is no active batch" */);
84
+ return;
85
+ }
86
+ if (this.currentBatchClientId === undefined && batchMetadata === undefined) {
87
+ assert(!this.localPaused, 0x29d /* "we should be processing ops when there is no active batch" */);
88
+ return;
89
+ }
90
+ // If we got here, the message is part of a batch. Either starting, in progress, or ending.
91
+ // If this is not the start of the batch, error out if the message was sent by a client other than the one that
92
+ // started the current batch (it should not be possible for ops from other clients to get interleaved with a batch).
93
+ if (this.currentBatchClientId !== undefined &&
94
+ this.currentBatchClientId !== message.clientId) {
95
+ throw new DataCorruptionError("OpBatchIncomplete", {
96
+ runtimeVersion: pkgVersion,
97
+ batchClientId:
98
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
99
+ this.currentBatchClientId === null ? "null" : this.currentBatchClientId,
100
+ pauseSequenceNumber: this.pauseSequenceNumber,
101
+ localBatch: this.currentBatchClientId === this.getClientId(),
102
+ localMessage: message.clientId === this.getClientId(),
103
+ ...extractSafePropertiesFromMessage(message),
104
+ });
105
+ }
106
+ // The queue is
107
+ // 1. paused only when the next message to be processed is the beginning of a batch. Done in two places:
108
+ // - in afterOpProcessing() - processing ops until reaching start of incomplete batch
109
+ // - here, when queue was empty and start of batch showed up (batchMetadata === true below).
110
+ // 2. resumed when batch end comes in (batchMetadata === false below)
111
+ if (batchMetadata) {
112
+ assert(this.currentBatchClientId === undefined, 0x29e /* "there can't be active batch" */);
113
+ assert(!this.localPaused, 0x29f /* "we should be processing ops when there is no active batch" */);
114
+ this.pauseSequenceNumber = message.sequenceNumber;
115
+ // TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
116
+ this.currentBatchClientId = message.clientId;
117
+ // Start of the batch
118
+ // Only pause processing if queue has no other ops!
119
+ // If there are any other ops in the queue, processing will be stopped when they are processed!
120
+ if (this.deltaManager.inbound.length === 1) {
121
+ this.pauseQueue();
122
+ }
123
+ }
124
+ else if (batchMetadata === false) {
125
+ assert(this.pauseSequenceNumber !== undefined, 0x2a0 /* "batch presence was validated above" */);
126
+ // Batch is complete, we can process it!
127
+ this.resumeQueue(this.pauseSequenceNumber, message);
128
+ this.pauseSequenceNumber = undefined;
129
+ this.currentBatchClientId = undefined;
130
+ }
131
+ else {
132
+ // Continuation of current batch. Do nothing
133
+ assert(this.currentBatchClientId !== undefined, 0x2a1 /* "logic error" */);
134
+ }
135
+ };
136
+ // Listen for updates and peek at the inbound
137
+ this.deltaManager.inbound.on("push", this.trackPending);
138
+ const allPending = this.deltaManager.inbound.toArray();
139
+ for (const pending of allPending) {
140
+ this.trackPending(pending);
141
+ }
142
+ // We are intentionally directly listening to the "op" to inspect system ops as well.
143
+ // If we do not observe system ops, we are likely to hit an error when system ops
144
+ // precedes start of incomplete batch.
145
+ this.deltaManager.on("op", this.afterOpProcessing);
146
+ }
147
+ dispose() {
148
+ this.deltaManager.off("op", this.afterOpProcessing);
149
+ this.deltaManager.inbound.off("push", this.trackPending);
150
+ }
151
+ pauseQueue() {
152
+ assert(!this.localPaused, 0x297 /* "always called from resumed state" */);
153
+ this.localPaused = true;
154
+ this.timePaused = performance.now();
155
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
156
+ this.deltaManager.inbound.pause();
157
+ }
158
+ resumeQueue(startBatch, messageEndBatch) {
159
+ const endBatch = messageEndBatch.sequenceNumber;
160
+ const duration = this.localPaused ? performance.now() - this.timePaused : undefined;
161
+ this.batchCount++;
162
+ if (this.batchCount % 1000 === 1) {
163
+ this.logger.sendTelemetryEvent({
164
+ eventName: "BatchStats",
165
+ sequenceNumber: endBatch,
166
+ length: endBatch - startBatch + 1,
167
+ msnDistance: endBatch - messageEndBatch.minimumSequenceNumber,
168
+ duration,
169
+ batchCount: this.batchCount,
170
+ interrupted: this.localPaused,
171
+ });
172
+ }
173
+ // Return early if no change in value
174
+ if (!this.localPaused) {
175
+ return;
176
+ }
177
+ this.localPaused = false;
178
+ this.deltaManager.inbound.resume();
179
+ }
180
+ }
181
+ //# sourceMappingURL=inboundBatchAggregator.js.map