@rocicorp/zero 1.12.0-canary.5 → 1.12.0-canary.7

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 (414) hide show
  1. package/out/replicache/src/btree/node.js +1 -1
  2. package/out/replicache/src/deleted-clients.d.ts.map +1 -1
  3. package/out/replicache/src/deleted-clients.js +2 -1
  4. package/out/replicache/src/deleted-clients.js.map +1 -1
  5. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  6. package/out/replicache/src/kv/sqlite-store.js +7 -3
  7. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  8. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  9. package/out/replicache/src/replicache-impl.js +17 -14
  10. package/out/replicache/src/replicache-impl.js.map +1 -1
  11. package/out/z2s/src/compiler.js +3 -3
  12. package/out/z2s/src/compiler.js.map +1 -1
  13. package/out/zero/package.js +11 -11
  14. package/out/zero/package.js.map +1 -1
  15. package/out/zero-cache/src/auth/write-authorizer.js +9 -2
  16. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  17. package/out/zero-cache/src/config/zero-config.js +2 -2
  18. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  19. package/out/zero-cache/src/server/change-streamer.js +33 -9
  20. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  21. package/out/zero-cache/src/services/change-source/common/replica-restore.js.map +1 -1
  22. package/out/zero-cache/src/services/change-source/pg/change-source-init.js +49 -24
  23. package/out/zero-cache/src/services/change-source/pg/change-source-init.js.map +1 -1
  24. package/out/zero-cache/src/services/change-source/pg/change-source.js +64 -7
  25. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  26. package/out/zero-cache/src/services/change-source/pg/fork-request.js +54 -0
  27. package/out/zero-cache/src/services/change-source/pg/fork-request.js.map +1 -0
  28. package/out/zero-cache/src/services/change-source/pg/replication-slots.js +6 -0
  29. package/out/zero-cache/src/services/change-source/pg/replication-slots.js.map +1 -1
  30. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +1 -0
  31. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  32. package/out/zero-cache/src/services/change-source/protocol/current/status.d.ts +3 -0
  33. package/out/zero-cache/src/services/change-source/protocol/current/status.d.ts.map +1 -1
  34. package/out/zero-cache/src/services/change-source/protocol/current/status.js +2 -1
  35. package/out/zero-cache/src/services/change-source/protocol/current/status.js.map +1 -1
  36. package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts +1 -0
  37. package/out/zero-cache/src/services/change-source/protocol/current/upstream.d.ts.map +1 -1
  38. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js +6 -6
  39. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.js.map +1 -1
  40. package/out/zero-cache/src/services/change-streamer/backup-monitor.js +55 -20
  41. package/out/zero-cache/src/services/change-streamer/backup-monitor.js.map +1 -1
  42. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js +27 -8
  43. package/out/zero-cache/src/services/change-streamer/change-streamer-service.js.map +1 -1
  44. package/out/zero-cache/src/services/change-streamer/change-streamer.js.map +1 -1
  45. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js +80 -11
  46. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.js.map +1 -1
  47. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.js.map +1 -1
  48. package/out/zero-cache/src/services/change-streamer/replica-poller.js.map +1 -1
  49. package/out/zero-cache/src/services/change-streamer/server-start-metrics.js +42 -0
  50. package/out/zero-cache/src/services/change-streamer/server-start-metrics.js.map +1 -0
  51. package/out/zero-cache/src/services/change-streamer/subscriber.js +5 -4
  52. package/out/zero-cache/src/services/change-streamer/subscriber.js.map +1 -1
  53. package/out/zero-cache/src/services/mutagen/mutagen.js +1 -2
  54. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  55. package/out/zero-cache/src/services/view-syncer/view-syncer.js +19 -2
  56. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  57. package/out/zero-client/src/client/version.js +1 -1
  58. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  59. package/out/zero-protocol/src/ast.js +2 -1
  60. package/out/zero-protocol/src/ast.js.map +1 -1
  61. package/out/zero-protocol/src/down.d.ts +27 -27
  62. package/out/zero-protocol/src/inspect-down.d.ts +81 -81
  63. package/out/zero-protocol/src/up.d.ts +60 -60
  64. package/package.json +11 -11
  65. package/out/shared/src/cache.d.ts +0 -22
  66. package/out/shared/src/cache.d.ts.map +0 -1
  67. package/out/shared/src/custom-key-map.d.ts +0 -26
  68. package/out/shared/src/custom-key-map.d.ts.map +0 -1
  69. package/out/shared/src/custom-key-set.d.ts +0 -25
  70. package/out/shared/src/custom-key-set.d.ts.map +0 -1
  71. package/out/shared/src/logging-test-utils.d.ts +0 -12
  72. package/out/shared/src/logging-test-utils.d.ts.map +0 -1
  73. package/out/shared/src/queue.d.ts +0 -53
  74. package/out/shared/src/queue.d.ts.map +0 -1
  75. package/out/shared/src/ring-buffer.d.ts +0 -42
  76. package/out/shared/src/ring-buffer.d.ts.map +0 -1
  77. package/out/shared/src/sorted-entries.d.ts +0 -2
  78. package/out/shared/src/sorted-entries.d.ts.map +0 -1
  79. package/out/zero/src/server/change-streamer.d.ts +0 -2
  80. package/out/zero/src/server/change-streamer.d.ts.map +0 -1
  81. package/out/zero/src/server/main.d.ts +0 -2
  82. package/out/zero/src/server/main.d.ts.map +0 -1
  83. package/out/zero/src/server/reaper.d.ts +0 -2
  84. package/out/zero/src/server/reaper.d.ts.map +0 -1
  85. package/out/zero/src/server/replicator.d.ts +0 -2
  86. package/out/zero/src/server/replicator.d.ts.map +0 -1
  87. package/out/zero/src/server/syncer.d.ts +0 -2
  88. package/out/zero/src/server/syncer.d.ts.map +0 -1
  89. package/out/zero-cache/src/auth/jwt.d.ts +0 -12
  90. package/out/zero-cache/src/auth/jwt.d.ts.map +0 -1
  91. package/out/zero-cache/src/auth/load-permissions.d.ts +0 -17
  92. package/out/zero-cache/src/auth/load-permissions.d.ts.map +0 -1
  93. package/out/zero-cache/src/auth/write-authorizer.d.ts +0 -28
  94. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +0 -1
  95. package/out/zero-cache/src/config/server-context.d.ts +0 -16
  96. package/out/zero-cache/src/config/server-context.d.ts.map +0 -1
  97. package/out/zero-cache/src/custom/fetch.d.ts +0 -38
  98. package/out/zero-cache/src/custom/fetch.d.ts.map +0 -1
  99. package/out/zero-cache/src/custom/metrics.d.ts +0 -31
  100. package/out/zero-cache/src/custom/metrics.d.ts.map +0 -1
  101. package/out/zero-cache/src/custom-queries/transform-query.d.ts +0 -68
  102. package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +0 -1
  103. package/out/zero-cache/src/db/create.d.ts +0 -12
  104. package/out/zero-cache/src/db/create.d.ts.map +0 -1
  105. package/out/zero-cache/src/db/delete-lite-db.d.ts +0 -2
  106. package/out/zero-cache/src/db/delete-lite-db.d.ts.map +0 -1
  107. package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
  108. package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
  109. package/out/zero-cache/src/db/migration-lite.d.ts +0 -78
  110. package/out/zero-cache/src/db/migration-lite.d.ts.map +0 -1
  111. package/out/zero-cache/src/db/migration.d.ts +0 -80
  112. package/out/zero-cache/src/db/migration.d.ts.map +0 -1
  113. package/out/zero-cache/src/db/pg-copy-binary.d.ts +0 -101
  114. package/out/zero-cache/src/db/pg-copy-binary.d.ts.map +0 -1
  115. package/out/zero-cache/src/db/pg-copy.d.ts +0 -30
  116. package/out/zero-cache/src/db/pg-copy.d.ts.map +0 -1
  117. package/out/zero-cache/src/db/pg-type-parser.d.ts +0 -15
  118. package/out/zero-cache/src/db/pg-type-parser.d.ts.map +0 -1
  119. package/out/zero-cache/src/db/transaction-pool.d.ts +0 -205
  120. package/out/zero-cache/src/db/transaction-pool.d.ts.map +0 -1
  121. package/out/zero-cache/src/db/warmup.d.ts +0 -4
  122. package/out/zero-cache/src/db/warmup.d.ts.map +0 -1
  123. package/out/zero-cache/src/observability/events.d.ts +0 -15
  124. package/out/zero-cache/src/observability/events.d.ts.map +0 -1
  125. package/out/zero-cache/src/observability/log-throttle.d.ts +0 -44
  126. package/out/zero-cache/src/observability/log-throttle.d.ts.map +0 -1
  127. package/out/zero-cache/src/server/anonymous-otel-start.d.ts +0 -21
  128. package/out/zero-cache/src/server/anonymous-otel-start.d.ts.map +0 -1
  129. package/out/zero-cache/src/server/change-streamer.d.ts +0 -3
  130. package/out/zero-cache/src/server/change-streamer.d.ts.map +0 -1
  131. package/out/zero-cache/src/server/inspector-delegate.d.ts +0 -71
  132. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +0 -1
  133. package/out/zero-cache/src/server/main.d.ts +0 -3
  134. package/out/zero-cache/src/server/main.d.ts.map +0 -1
  135. package/out/zero-cache/src/server/otel-diag-logger.d.ts +0 -16
  136. package/out/zero-cache/src/server/otel-diag-logger.d.ts.map +0 -1
  137. package/out/zero-cache/src/server/otel-start.d.ts +0 -3
  138. package/out/zero-cache/src/server/otel-start.d.ts.map +0 -1
  139. package/out/zero-cache/src/server/priority-op.d.ts +0 -8
  140. package/out/zero-cache/src/server/priority-op.d.ts.map +0 -1
  141. package/out/zero-cache/src/server/reaper.d.ts +0 -3
  142. package/out/zero-cache/src/server/reaper.d.ts.map +0 -1
  143. package/out/zero-cache/src/server/replicator.d.ts +0 -10
  144. package/out/zero-cache/src/server/replicator.d.ts.map +0 -1
  145. package/out/zero-cache/src/server/slot-keeper.d.ts +0 -26
  146. package/out/zero-cache/src/server/slot-keeper.d.ts.map +0 -1
  147. package/out/zero-cache/src/server/syncer-assigner.d.ts +0 -14
  148. package/out/zero-cache/src/server/syncer-assigner.d.ts.map +0 -1
  149. package/out/zero-cache/src/server/syncer.d.ts +0 -3
  150. package/out/zero-cache/src/server/syncer.d.ts.map +0 -1
  151. package/out/zero-cache/src/server/worker-dispatcher.d.ts +0 -17
  152. package/out/zero-cache/src/server/worker-dispatcher.d.ts.map +0 -1
  153. package/out/zero-cache/src/services/analyze.d.ts +0 -9
  154. package/out/zero-cache/src/services/analyze.d.ts.map +0 -1
  155. package/out/zero-cache/src/services/change-source/change-source.d.ts +0 -32
  156. package/out/zero-cache/src/services/change-source/change-source.d.ts.map +0 -1
  157. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts +0 -57
  158. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +0 -1
  159. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts +0 -55
  160. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +0 -1
  161. package/out/zero-cache/src/services/change-source/common/init-cleanup.d.ts +0 -24
  162. package/out/zero-cache/src/services/change-source/common/init-cleanup.d.ts.map +0 -1
  163. package/out/zero-cache/src/services/change-source/common/replica-restore.d.ts +0 -115
  164. package/out/zero-cache/src/services/change-source/common/replica-restore.d.ts.map +0 -1
  165. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts +0 -14
  166. package/out/zero-cache/src/services/change-source/common/replica-schema.d.ts.map +0 -1
  167. package/out/zero-cache/src/services/change-source/custom/change-source.d.ts +0 -25
  168. package/out/zero-cache/src/services/change-source/custom/change-source.d.ts.map +0 -1
  169. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.d.ts +0 -14
  170. package/out/zero-cache/src/services/change-source/pg/backfill-metadata.d.ts.map +0 -1
  171. package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts +0 -36
  172. package/out/zero-cache/src/services/change-source/pg/backfill-stream.d.ts.map +0 -1
  173. package/out/zero-cache/src/services/change-source/pg/change-source-init.d.ts +0 -65
  174. package/out/zero-cache/src/services/change-source/pg/change-source-init.d.ts.map +0 -1
  175. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +0 -115
  176. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +0 -1
  177. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -155
  178. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +0 -1
  179. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts +0 -17
  180. package/out/zero-cache/src/services/change-source/pg/logical-replication/binary-reader.d.ts.map +0 -1
  181. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.d.ts +0 -28
  182. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.d.ts.map +0 -1
  183. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput.types.d.ts +0 -76
  184. package/out/zero-cache/src/services/change-source/pg/logical-replication/pgoutput.types.d.ts.map +0 -1
  185. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts +0 -169
  186. package/out/zero-cache/src/services/change-source/pg/logical-replication/stream.d.ts.map +0 -1
  187. package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts +0 -16
  188. package/out/zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.d.ts.map +0 -1
  189. package/out/zero-cache/src/services/change-source/pg/replication-slot-health.d.ts +0 -15
  190. package/out/zero-cache/src/services/change-source/pg/replication-slot-health.d.ts.map +0 -1
  191. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts +0 -127
  192. package/out/zero-cache/src/services/change-source/pg/replication-slots.d.ts.map +0 -1
  193. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +0 -9
  194. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +0 -1
  195. package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts +0 -68
  196. package/out/zero-cache/src/services/change-source/protocol/backfill-progress.d.ts.map +0 -1
  197. package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts +0 -72
  198. package/out/zero-cache/src/services/change-streamer/backfill-state-tracker.d.ts.map +0 -1
  199. package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts +0 -50
  200. package/out/zero-cache/src/services/change-streamer/backfill-state.d.ts.map +0 -1
  201. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts +0 -14
  202. package/out/zero-cache/src/services/change-streamer/backup-cleanup-monitor-factory.d.ts.map +0 -1
  203. package/out/zero-cache/src/services/change-streamer/backup-monitor.d.ts +0 -18
  204. package/out/zero-cache/src/services/change-streamer/backup-monitor.d.ts.map +0 -1
  205. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts +0 -98
  206. package/out/zero-cache/src/services/change-streamer/broadcast.d.ts.map +0 -1
  207. package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts +0 -34
  208. package/out/zero-cache/src/services/change-streamer/change-log-codec.d.ts.map +0 -1
  209. package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts +0 -34
  210. package/out/zero-cache/src/services/change-streamer/change-log-compare-digest.d.ts.map +0 -1
  211. package/out/zero-cache/src/services/change-streamer/change-log-initializer.d.ts +0 -158
  212. package/out/zero-cache/src/services/change-streamer/change-log-initializer.d.ts.map +0 -1
  213. package/out/zero-cache/src/services/change-streamer/change-log-transaction-hash.d.ts +0 -19
  214. package/out/zero-cache/src/services/change-streamer/change-log-transaction-hash.d.ts.map +0 -1
  215. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -78
  216. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +0 -1
  217. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts +0 -143
  218. package/out/zero-cache/src/services/change-streamer/change-streamer-service.d.ts.map +0 -1
  219. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -586
  220. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +0 -1
  221. package/out/zero-cache/src/services/change-streamer/drain-tracker.d.ts +0 -24
  222. package/out/zero-cache/src/services/change-streamer/drain-tracker.d.ts.map +0 -1
  223. package/out/zero-cache/src/services/change-streamer/error-type-enum.d.ts +0 -15
  224. package/out/zero-cache/src/services/change-streamer/error-type-enum.d.ts.map +0 -1
  225. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts +0 -49
  226. package/out/zero-cache/src/services/change-streamer/forwarder.d.ts.map +0 -1
  227. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts +0 -53
  228. package/out/zero-cache/src/services/change-streamer/litestream-sync-requester.d.ts.map +0 -1
  229. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.d.ts +0 -88
  230. package/out/zero-cache/src/services/change-streamer/litestream3-prometheus-poller.d.ts.map +0 -1
  231. package/out/zero-cache/src/services/change-streamer/replica-poller.d.ts +0 -15
  232. package/out/zero-cache/src/services/change-streamer/replica-poller.d.ts.map +0 -1
  233. package/out/zero-cache/src/services/change-streamer/restore-admission.d.ts +0 -243
  234. package/out/zero-cache/src/services/change-streamer/restore-admission.d.ts.map +0 -1
  235. package/out/zero-cache/src/services/change-streamer/schema/init.d.ts +0 -6
  236. package/out/zero-cache/src/services/change-streamer/schema/init.d.ts.map +0 -1
  237. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts +0 -152
  238. package/out/zero-cache/src/services/change-streamer/schema/tables.d.ts.map +0 -1
  239. package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts +0 -11
  240. package/out/zero-cache/src/services/change-streamer/shard-sampling.d.ts.map +0 -1
  241. package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts +0 -92
  242. package/out/zero-cache/src/services/change-streamer/snapshot-message.d.ts.map +0 -1
  243. package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts +0 -36
  244. package/out/zero-cache/src/services/change-streamer/snapshot-reservations.d.ts.map +0 -1
  245. package/out/zero-cache/src/services/change-streamer/snapshot.d.ts +0 -22
  246. package/out/zero-cache/src/services/change-streamer/snapshot.d.ts.map +0 -1
  247. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts +0 -99
  248. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-catchup.d.ts.map +0 -1
  249. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts +0 -83
  250. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-comparator.d.ts.map +0 -1
  251. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-purge-scheduler.d.ts +0 -121
  252. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-purge-scheduler.d.ts.map +0 -1
  253. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts +0 -73
  254. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-read-router.d.ts.map +0 -1
  255. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts +0 -62
  256. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-reader.d.ts.map +0 -1
  257. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts +0 -114
  258. package/out/zero-cache/src/services/change-streamer/sqlite-change-log-writer.d.ts.map +0 -1
  259. package/out/zero-cache/src/services/change-streamer/storer.d.ts +0 -276
  260. package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +0 -1
  261. package/out/zero-cache/src/services/change-streamer/subscribe.d.ts +0 -485
  262. package/out/zero-cache/src/services/change-streamer/subscribe.d.ts.map +0 -1
  263. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts +0 -194
  264. package/out/zero-cache/src/services/change-streamer/subscriber.d.ts.map +0 -1
  265. package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts +0 -52
  266. package/out/zero-cache/src/services/change-streamer/upstream-acker.d.ts.map +0 -1
  267. package/out/zero-cache/src/services/limiter/sliding-window-limiter.d.ts +0 -57
  268. package/out/zero-cache/src/services/limiter/sliding-window-limiter.d.ts.map +0 -1
  269. package/out/zero-cache/src/services/litestream/commands.d.ts +0 -77
  270. package/out/zero-cache/src/services/litestream/commands.d.ts.map +0 -1
  271. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -78
  272. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
  273. package/out/zero-cache/src/services/litestream/metrics.d.ts +0 -31
  274. package/out/zero-cache/src/services/litestream/metrics.d.ts.map +0 -1
  275. package/out/zero-cache/src/services/litestream/restore-progress.d.ts +0 -24
  276. package/out/zero-cache/src/services/litestream/restore-progress.d.ts.map +0 -1
  277. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -40
  278. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +0 -1
  279. package/out/zero-cache/src/services/mutagen/pusher.d.ts +0 -63
  280. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +0 -1
  281. package/out/zero-cache/src/services/replicator/change-log-db.d.ts +0 -368
  282. package/out/zero-cache/src/services/replicator/change-log-db.d.ts.map +0 -1
  283. package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts +0 -56
  284. package/out/zero-cache/src/services/replicator/change-log-stream-writer.d.ts.map +0 -1
  285. package/out/zero-cache/src/services/replicator/change-processor.d.ts +0 -37
  286. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +0 -1
  287. package/out/zero-cache/src/services/replicator/drain-handler.d.ts +0 -82
  288. package/out/zero-cache/src/services/replicator/drain-handler.d.ts.map +0 -1
  289. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts +0 -25
  290. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +0 -1
  291. package/out/zero-cache/src/services/replicator/notifier.d.ts +0 -9
  292. package/out/zero-cache/src/services/replicator/notifier.d.ts.map +0 -1
  293. package/out/zero-cache/src/services/replicator/replication-status.d.ts +0 -71
  294. package/out/zero-cache/src/services/replicator/replication-status.d.ts.map +0 -1
  295. package/out/zero-cache/src/services/replicator/replicator.d.ts +0 -86
  296. package/out/zero-cache/src/services/replicator/replicator.d.ts.map +0 -1
  297. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts +0 -55
  298. package/out/zero-cache/src/services/replicator/reporter/recorder.d.ts.map +0 -1
  299. package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts +0 -132
  300. package/out/zero-cache/src/services/replicator/sqlite-change-log-observability.d.ts.map +0 -1
  301. package/out/zero-cache/src/services/replicator/sqlite-change-log-purger.d.ts +0 -120
  302. package/out/zero-cache/src/services/replicator/sqlite-change-log-purger.d.ts.map +0 -1
  303. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +0 -111
  304. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +0 -1
  305. package/out/zero-cache/src/services/run-ast.d.ts +0 -39
  306. package/out/zero-cache/src/services/run-ast.d.ts.map +0 -1
  307. package/out/zero-cache/src/services/runner.d.ts +0 -19
  308. package/out/zero-cache/src/services/runner.d.ts.map +0 -1
  309. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts +0 -17
  310. package/out/zero-cache/src/services/view-syncer/active-users-gauge.d.ts.map +0 -1
  311. package/out/zero-cache/src/services/view-syncer/advancement-metrics.d.ts +0 -26
  312. package/out/zero-cache/src/services/view-syncer/advancement-metrics.d.ts.map +0 -1
  313. package/out/zero-cache/src/services/view-syncer/batch-pacer.d.ts +0 -79
  314. package/out/zero-cache/src/services/view-syncer/batch-pacer.d.ts.map +0 -1
  315. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +0 -97
  316. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +0 -1
  317. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts +0 -18
  318. package/out/zero-cache/src/services/view-syncer/client-schema.d.ts.map +0 -1
  319. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts +0 -184
  320. package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts.map +0 -1
  321. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts +0 -22
  322. package/out/zero-cache/src/services/view-syncer/cvr-purger.d.ts.map +0 -1
  323. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +0 -128
  324. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +0 -1
  325. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -294
  326. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +0 -1
  327. package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts +0 -81
  328. package/out/zero-cache/src/services/view-syncer/deferred-writes-budget.d.ts.map +0 -1
  329. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +0 -45
  330. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +0 -1
  331. package/out/zero-cache/src/services/view-syncer/e2e-serving-lag.d.ts +0 -53
  332. package/out/zero-cache/src/services/view-syncer/e2e-serving-lag.d.ts.map +0 -1
  333. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
  334. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
  335. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
  336. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
  337. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +0 -34
  338. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +0 -1
  339. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +0 -296
  340. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +0 -1
  341. package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts +0 -7
  342. package/out/zero-cache/src/services/view-syncer/plan-warnings.d.ts.map +0 -1
  343. package/out/zero-cache/src/services/view-syncer/push-cost.d.ts +0 -132
  344. package/out/zero-cache/src/services/view-syncer/push-cost.d.ts.map +0 -1
  345. package/out/zero-cache/src/services/view-syncer/push-cutoff.d.ts +0 -55
  346. package/out/zero-cache/src/services/view-syncer/push-cutoff.d.ts.map +0 -1
  347. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts +0 -28
  348. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +0 -1
  349. package/out/zero-cache/src/services/view-syncer/query-shape.d.ts +0 -25
  350. package/out/zero-cache/src/services/view-syncer/query-shape.d.ts.map +0 -1
  351. package/out/zero-cache/src/services/view-syncer/query-stats.d.ts +0 -89
  352. package/out/zero-cache/src/services/view-syncer/query-stats.d.ts.map +0 -1
  353. package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts +0 -90
  354. package/out/zero-cache/src/services/view-syncer/row-record-cache.d.ts.map +0 -1
  355. package/out/zero-cache/src/services/view-syncer/row-set-signature.d.ts +0 -17
  356. package/out/zero-cache/src/services/view-syncer/row-set-signature.d.ts.map +0 -1
  357. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts +0 -86
  358. package/out/zero-cache/src/services/view-syncer/schema/cvr.d.ts.map +0 -1
  359. package/out/zero-cache/src/services/view-syncer/schema/init.d.ts +0 -5
  360. package/out/zero-cache/src/services/view-syncer/schema/init.d.ts.map +0 -1
  361. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +0 -563
  362. package/out/zero-cache/src/services/view-syncer/schema/types.d.ts.map +0 -1
  363. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
  364. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
  365. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +0 -420
  366. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +0 -1
  367. package/out/zero-cache/src/services/view-syncer/tracer.d.ts +0 -2
  368. package/out/zero-cache/src/services/view-syncer/tracer.d.ts.map +0 -1
  369. package/out/zero-cache/src/services/view-syncer/ttl-clock.d.ts +0 -10
  370. package/out/zero-cache/src/services/view-syncer/ttl-clock.d.ts.map +0 -1
  371. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +0 -133
  372. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +0 -1
  373. package/out/zero-cache/src/types/downstream.d.ts +0 -11
  374. package/out/zero-cache/src/types/downstream.d.ts.map +0 -1
  375. package/out/zero-cache/src/types/error-with-level.d.ts +0 -9
  376. package/out/zero-cache/src/types/error-with-level.d.ts.map +0 -1
  377. package/out/zero-cache/src/types/pg-patch.d.ts +0 -21
  378. package/out/zero-cache/src/types/pg-patch.d.ts.map +0 -1
  379. package/out/zero-cache/src/types/pg-versions.d.ts +0 -3
  380. package/out/zero-cache/src/types/pg-versions.d.ts.map +0 -1
  381. package/out/zero-cache/src/types/poke-chunk.d.ts +0 -18
  382. package/out/zero-cache/src/types/poke-chunk.d.ts.map +0 -1
  383. package/out/zero-cache/src/types/streams.d.ts +0 -115
  384. package/out/zero-cache/src/types/streams.d.ts.map +0 -1
  385. package/out/zero-cache/src/types/subscription.d.ts +0 -197
  386. package/out/zero-cache/src/types/subscription.d.ts.map +0 -1
  387. package/out/zero-cache/src/workers/connect-params.d.ts +0 -28
  388. package/out/zero-cache/src/workers/connect-params.d.ts.map +0 -1
  389. package/out/zero-cache/src/workers/connection.d.ts +0 -77
  390. package/out/zero-cache/src/workers/connection.d.ts.map +0 -1
  391. package/out/zero-cache/src/workers/replicator.d.ts +0 -57
  392. package/out/zero-cache/src/workers/replicator.d.ts.map +0 -1
  393. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +0 -14
  394. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +0 -1
  395. package/out/zero-cache/src/workers/syncer.d.ts +0 -67
  396. package/out/zero-cache/src/workers/syncer.d.ts.map +0 -1
  397. package/out/zero-events/src/index.d.ts +0 -27
  398. package/out/zero-events/src/index.d.ts.map +0 -1
  399. package/out/zero-events/src/json.d.ts +0 -20
  400. package/out/zero-events/src/json.d.ts.map +0 -1
  401. package/out/zero-events/src/status.d.ts +0 -144
  402. package/out/zero-events/src/status.d.ts.map +0 -1
  403. package/out/zqlite/src/database-storage.d.ts +0 -43
  404. package/out/zqlite/src/database-storage.d.ts.map +0 -1
  405. package/out/zqlite/src/explain-queries.d.ts +0 -4
  406. package/out/zqlite/src/explain-queries.d.ts.map +0 -1
  407. package/out/zqlite/src/internal/sql-inline.d.ts +0 -13
  408. package/out/zqlite/src/internal/sql-inline.d.ts.map +0 -1
  409. package/out/zqlite/src/resolve-scalar-subqueries.d.ts +0 -72
  410. package/out/zqlite/src/resolve-scalar-subqueries.d.ts.map +0 -1
  411. package/out/zqlite/src/sqlite-cost-model.d.ts +0 -17
  412. package/out/zqlite/src/sqlite-cost-model.d.ts.map +0 -1
  413. package/out/zqlite/src/sqlite-stat-fanout.d.ts +0 -121
  414. package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +0 -1
@@ -1,155 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- import type { JSONObject } from '../../../../../shared/src/bigint-json.ts';
3
- import type { DownloadStatus } from '../../../../../zero-events/src/status.ts';
4
- import { Database } from '../../../../../zqlite/src/db.ts';
5
- import type { IndexSpec, PublishedTableSpec } from '../../../db/specs.ts';
6
- import { type PostgresDB } from '../../../types/pg.ts';
7
- import type { ShardConfig } from '../../../types/shards.ts';
8
- import { ReplicationStatusPublisher } from '../../replicator/replication-status.ts';
9
- import type { InitCleanup } from '../common/init-cleanup.ts';
10
- import { type ReplicaState } from './schema/shard.ts';
11
- export type InitialSyncOptions = {
12
- tableCopyWorkers: number;
13
- profileCopy?: boolean | undefined;
14
- textCopy?: boolean | undefined;
15
- replicationSlotFailover?: boolean | undefined;
16
- installPartialIndexTriggers?: boolean | undefined;
17
- /**
18
- * When set, run initial sync in "shadow" mode for verification: skip all
19
- * upstream mutations (no replication slot, no addReplica, no dropShard, no
20
- * slot drop on failure), suppress status events, and optionally sample
21
- * rows from each table via TABLESAMPLE BERNOULLI + LIMIT. The caller is
22
- * responsible for providing (and discarding) a throwaway SQLite `tx`.
23
- */
24
- shadow?: {
25
- /** 0 < rate <= 1. When 1, no TABLESAMPLE clause is added. */
26
- sampleRate: number;
27
- /**
28
- * LIMIT N cap appended after TABLESAMPLE. Required: shadow sync is
29
- * for verification only, so every run must commit to a row budget.
30
- */
31
- maxRowsPerTable: number;
32
- } | undefined;
33
- };
34
- export type ReplicaOptions = {
35
- epoch: number;
36
- backupV5: boolean;
37
- /**
38
- * Whether the replica's slot is acked only after transactions are stored in
39
- * the PG change log (see `pgChangeLog` in `ReplicaState`). Defaults to
40
- * false, i.e. unknown.
41
- */
42
- pgChangeLog: boolean;
43
- };
44
- /** Server context to store with the initial sync metadata for debugging. */
45
- export type ServerContext = JSONObject;
46
- /**
47
- * @returns The {@link ReplicaState} of the initialized replica, or `undefined`
48
- * for a shadow sync.
49
- */
50
- export declare function initialSync(lc: LogContext, shard: ShardConfig, tx: Database, upstreamURI: string, syncOptions: InitialSyncOptions, context: ServerContext, { epoch, backupV5, pgChangeLog }?: ReplicaOptions, cleanup?: InitCleanup): Promise<ReplicaState | undefined>;
51
- export type ShadowSyncOptions = {
52
- sampleRate: number;
53
- maxRowsPerTable: number;
54
- /**
55
- * Parent directory for the throwaway SQLite replica. Defaults to the OS
56
- * tmpdir. Primarily for tests that need to isolate the scratch directory.
57
- */
58
- parentDir?: string | undefined;
59
- };
60
- /**
61
- * Exercises the initial-sync code path against a sample of rows from every
62
- * published table, writing into a throwaway SQLite database that is deleted
63
- * when the run ends. Produces zero upstream mutations: no replication slot,
64
- * no `addReplica`, no `dropShard`, no status events.
65
- *
66
- * Intended to be invoked periodically so that if a customer ever needs a
67
- * full reset, we have recent confidence that `initialSync` still works.
68
- * The shard must already be initialized upstream.
69
- */
70
- export declare function shadowInitialSync(lc: LogContext, shard: ShardConfig, upstreamURI: string, shadow: ShadowSyncOptions, context: ServerContext, syncOptions?: Pick<InitialSyncOptions, 'textCopy'>): Promise<void>;
71
- /**
72
- * Creates the `indices`, publishing progress before each one.
73
- *
74
- * @returns The milliseconds spent creating the indexes, excluding the time
75
- * spent publishing progress.
76
- *
77
- * Exported for testing.
78
- */
79
- export declare function createLiteIndices(lc: LogContext, tx: Database, indices: IndexSpec[], statusPublisher: ReplicationStatusPublisher): Promise<number>;
80
- /**
81
- * Runs structural assertions over a just-synced replica and throws if any
82
- * fail. Only called in shadow mode — a successful return means the replica
83
- * is schema-complete, row-count consistent, and its column metadata is in
84
- * sync with its lite schema.
85
- *
86
- * Note: this intentionally does NOT verify ZQL-queryability. Tables that
87
- * `computeZqlSpecs` drops (no PK / no all-NOT-NULL unique index, unsupported
88
- * column types, etc.) are silently skipped in production too — there's
89
- * nothing shadow-specific about them, so failing here would diverge from
90
- * prod over an upstream-schema condition prod accepts.
91
- *
92
- * Exported for testing.
93
- */
94
- export declare function verifyShadowReplica(lc: LogContext, db: Database, published: {
95
- tables: PublishedTableSpec[];
96
- indexes: IndexSpec[];
97
- }, rowsByTable: ReadonlyMap<string, number>): void;
98
- /**
99
- * The row filter of the table's publications, as a parenthesized boolean
100
- * expression, or `null` if the table is published without a filter.
101
- */
102
- export declare function publicationRowFilter(table: PublishedTableSpec): string | null;
103
- export declare const INSERT_BATCH_SIZE = 50;
104
- export type DownloadStatements = {
105
- select: string;
106
- getTotalRows: string;
107
- getTotalBytes: string;
108
- };
109
- /**
110
- * Returns the SELECT column expressions for binary COPY, casting columns
111
- * without a known binary decoder to `::text`.
112
- */
113
- export declare function makeBinarySelectExprs(table: PublishedTableSpec, cols: string[]): string[];
114
- /**
115
- * Orders the downloaded rows, and optionally restricts them to a suffix of
116
- * that order. Used by resumable backfills; see `backfill-resume.ts`.
117
- */
118
- export type DownloadOrder = {
119
- /**
120
- * The `ORDER BY` expression, e.g. from `orderByRowKey()`. If unset, the
121
- * natural order of the scan is used (e.g. physical order for `ctid`-based
122
- * resumption).
123
- */
124
- readonly by?: string | undefined;
125
- /**
126
- * A boolean SQL expression restricting the download to rows after a mark,
127
- * e.g. from `resumeWhere()`. It is ANDed with the publication row filter,
128
- * and applies to the row and byte totals as well, so that a resumed run
129
- * reports the progress of what remains.
130
- */
131
- readonly after?: string | undefined;
132
- };
133
- export declare function makeDownloadStatements(table: PublishedTableSpec, cols: string[], sampleRate?: number | undefined, maxRowsPerTable?: number | undefined, selectExprs?: string[] | undefined, order?: DownloadOrder | undefined): DownloadStatements;
134
- type DownloadState = {
135
- spec: PublishedTableSpec;
136
- status: DownloadStatus;
137
- };
138
- type CopyFormat = 'binary' | 'text';
139
- type InitialSyncMode = 'initial' | 'shadow';
140
- type InitialSyncMetricAttrs = {
141
- syncMode: InitialSyncMode;
142
- copyFormat: CopyFormat;
143
- };
144
- export declare const COPY_METRIC_BATCH_BYTES: number;
145
- export declare function createCopyMetricBatcher(record: (bytes: number, chunks: number) => void): {
146
- add(chunkBytes: number): void;
147
- flush: () => void;
148
- };
149
- export declare function initialSyncCopyMetrics(attrs: InitialSyncMetricAttrs): {
150
- add(chunkBytes: number): void;
151
- flush: () => void;
152
- };
153
- export declare function getInitialDownloadState(lc: LogContext, sql: PostgresDB, spec: PublishedTableSpec, skipTotals: boolean): Promise<DownloadState>;
154
- export {};
155
- //# sourceMappingURL=initial-sync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"initial-sync.d.ts","sourceRoot":"","sources":["../../../../../../../zero-cache/src/services/change-source/pg/initial-sync.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,0CAA0C,CAAC;AAGzE,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,iCAAiC,CAAC;AAoBzD,OAAO,KAAK,EAAC,SAAS,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAcxE,OAAO,EAEL,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAEL,0BAA0B,EAC3B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAO3D,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,EA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AAE,EACd,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,EAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,EACpC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,EAClC,KAAK,CAAC,EAAE,aAAa,GAAG,SAAS,GAChC,kBAAkB,CAkCpB;AAED,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,KAAK,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AACpC,KAAK,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5C,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AA4BF,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AAoFvD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;oBAe7B,MAAM;;EASzB;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB;oBAXhD,MAAM;;EAmBzB;AA6GD,wBAAsB,uBAAuB,CAC3C,EAAE,EAAE,UAAU,EACd,GAAG,EAAE,UAAU,EACf,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,OAAO,GAClB,OAAO,CAAC,aAAa,CAAC,CA2CxB"}
@@ -1,17 +0,0 @@
1
- export declare class BinaryReader {
2
- #private;
3
- constructor(b: Uint8Array);
4
- readUint8(): number;
5
- readInt16(): number;
6
- readInt32(): number;
7
- readString(): string;
8
- decodeText(strBuf: Uint8Array): string;
9
- read(n: number): Uint8Array<ArrayBufferLike>;
10
- checkSize(n: number): void;
11
- array<T>(length: number, fn: () => T): T[];
12
- readLsn(): string | null;
13
- readTime(): bigint;
14
- readUint64(): bigint;
15
- readUint32(): number;
16
- }
17
- //# sourceMappingURL=binary-reader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"binary-reader.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/logical-replication/binary-reader.ts"],"names":[],"mappings":"AAMA,qBAAa,YAAY;;IAIvB,YAAY,CAAC,EAAE,UAAU,EAExB;IAED,SAAS,WAIR;IAED,SAAS,WAIR;IAED,SAAS,WASR;IAED,UAAU,WAYT;IAED,UAAU,CAAC,MAAM,EAAE,UAAU,UAE5B;IAED,IAAI,CAAC,CAAC,EAAE,MAAM,+BAIb;IAED,SAAS,CAAC,CAAC,EAAE,MAAM,QAKlB;IAED,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAEzC;IAGD,OAAO,kBAWN;IAED,QAAQ,WAGP;IAED,UAAU,WAIT;IAED,UAAU,WAET;CACF"}
@@ -1,28 +0,0 @@
1
- export type TypeParser = (val: string) => unknown;
2
- import type { TypeParsers } from '../../../../db/pg-type-parser.ts';
3
- import type { Message, MessageRelation } from './pgoutput.types.ts';
4
- export declare class PgoutputParser {
5
- #private;
6
- _typeCache: Map<number, {
7
- typeSchema: string;
8
- typeName: string;
9
- }>;
10
- _relationCache: Map<number, MessageRelation>;
11
- constructor(typeParsers: TypeParsers);
12
- parse(buf: Buffer): Message;
13
- private msgBegin;
14
- private msgOrigin;
15
- private msgType;
16
- private msgRelation;
17
- private readRelationReplicaIdentity;
18
- private readRelationColumn;
19
- private msgInsert;
20
- private msgUpdate;
21
- private msgDelete;
22
- private readKeyTuple;
23
- private readTuple;
24
- private msgTruncate;
25
- private msgMessage;
26
- private msgCommit;
27
- }
28
- //# sourceMappingURL=pgoutput-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pgoutput-parser.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/logical-replication/pgoutput-parser.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAElD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAElE,OAAO,KAAK,EACV,OAAO,EAOP,eAAe,EAKhB,MAAM,qBAAqB,CAAC;AAE7B,qBAAa,cAAc;;IACzB,UAAU;oBAAgC,MAAM;kBAAY,MAAM;OAAK;IACvE,cAAc,+BAAsC;IAIpD,YAAY,WAAW,EAAE,WAAW,EAEnC;IAMM,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CA4BjC;IAED,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,OAAO;IAWf,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,kBAAkB;IAmB1B,OAAO,CAAC,SAAS;IAgBjB,OAAO,CAAC,SAAS;IA6BjB,OAAO,CAAC,SAAS;IAsBjB,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,SAAS;IAwCjB,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,SAAS;CASlB"}
@@ -1,76 +0,0 @@
1
- export type Message = MessageBegin | MessageCommit | MessageDelete | MessageInsert | MessageMessage | MessageOrigin | MessageRelation | MessageTruncate | MessageType | MessageUpdate;
2
- export interface MessageBegin {
3
- tag: 'begin';
4
- commitLsn: string | null;
5
- commitTime: bigint;
6
- xid: number;
7
- }
8
- export interface MessageCommit {
9
- tag: 'commit';
10
- flags: number;
11
- commitLsn: string | null;
12
- commitEndLsn: string | null;
13
- commitTime: bigint;
14
- }
15
- export interface MessageDelete {
16
- tag: 'delete';
17
- relation: MessageRelation;
18
- key: Record<string, any> | null;
19
- old: Record<string, any> | null;
20
- }
21
- export interface MessageInsert {
22
- tag: 'insert';
23
- relation: MessageRelation;
24
- new: Record<string, any>;
25
- }
26
- export interface MessageMessage {
27
- tag: 'message';
28
- flags: number;
29
- transactional: boolean;
30
- messageLsn: string | null;
31
- prefix: string;
32
- content: Uint8Array;
33
- }
34
- export interface MessageOrigin {
35
- tag: 'origin';
36
- originLsn: string | null;
37
- originName: string;
38
- }
39
- export interface MessageRelation {
40
- tag: 'relation';
41
- relationOid: number;
42
- schema: string;
43
- name: string;
44
- replicaIdentity: 'default' | 'nothing' | 'full' | 'index';
45
- columns: RelationColumn[];
46
- keyColumns: string[];
47
- }
48
- export interface RelationColumn {
49
- name: string;
50
- flags: number;
51
- typeOid: number;
52
- typeMod: number;
53
- typeSchema: string | null;
54
- typeName: string | null;
55
- parser: (raw: any) => any;
56
- }
57
- export interface MessageTruncate {
58
- tag: 'truncate';
59
- cascade: boolean;
60
- restartIdentity: boolean;
61
- relations: MessageRelation[];
62
- }
63
- export interface MessageType {
64
- tag: 'type';
65
- typeOid: number;
66
- typeSchema: string;
67
- typeName: string;
68
- }
69
- export interface MessageUpdate {
70
- tag: 'update';
71
- relation: MessageRelation;
72
- key: Record<string, any> | null;
73
- old: Record<string, any> | null;
74
- new: Record<string, any>;
75
- }
76
- //# sourceMappingURL=pgoutput.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pgoutput.types.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/logical-replication/pgoutput.types.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GACf,YAAY,GACZ,aAAa,GACb,aAAa,GACb,aAAa,GACb,cAAc,GACd,aAAa,GACb,eAAe,GACf,eAAe,GACf,WAAW,GACX,aAAa,CAAC;AAElB,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,G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M,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,UAAU,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,eAAe,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,QAAQ,CAAC;IACd,QAAQ,EAAE,eAAe,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1B"}
@@ -1,169 +0,0 @@
1
- import { Readable } from 'node:stream';
2
- import type { LogContext } from '@rocicorp/logger';
3
- import postgres from 'postgres';
4
- import type { SlotKeeperConfig } from '../../../../server/slot-keeper.ts';
5
- import { type PostgresDB } from '../../../../types/pg.ts';
6
- import { type Worker } from '../../../../types/processes.ts';
7
- import { type Sink, type Source } from '../../../../types/streams.ts';
8
- import type { Message } from './pgoutput.types.ts';
9
- export declare const DEFAULT_RETRIES_IF_REPLICATION_SLOT_ACTIVE = 5;
10
- export type StreamMessage = [
11
- lsn: bigint,
12
- Message | {
13
- tag: 'keepalive';
14
- shouldRespond: boolean;
15
- }
16
- ];
17
- type SourceWithPendingQueue<T> = Source<T> & {
18
- queued: number;
19
- };
20
- export declare function createReplicationSessionFor(db: PostgresDB, applicationName: string): postgres.Sql<{}>;
21
- export declare function subscribe(lc: LogContext, db: PostgresDB, slot: string, publications: string[], lsn: bigint, retriesIfReplicationSlotActive?: number, applicationName?: string, inboundTimeoutOverrideMs?: number | undefined): Promise<{
22
- messages: SourceWithPendingQueue<StreamMessage>;
23
- acks: Sink<bigint>;
24
- }>;
25
- /**
26
- * Measures how long upstream takes to decode the WAL between the slot's
27
- * `restart_lsn` and the start of the stream, during which the stream
28
- * delivers nothing but keepalives. This span can be large, e.g. for a slot
29
- * that was created (or last acked) long before the requested start LSN.
30
- *
31
- * The walsender streams from `max(lsn, confirmed_flush_lsn)`, but must
32
- * decode from `restart_lsn` to rebuild its transaction state. The decode is
33
- * considered complete upon the first message at or past the start:
34
- * * any XLogData message, since only transactions committed after the
35
- * start are sent, or
36
- * * a keepalive at or past the start. Keepalives report the decoding
37
- * position, except for the first one of the stream, which reports the
38
- * slot's `confirmed_flush_lsn` and is thus ignored if it is at or past the
39
- * start.
40
- *
41
- * Note that on an idle upstream, a walsender whose start is already
42
- * confirmed may not send a keepalive until other WAL is written or the
43
- * periodic keepalive (`wal_sender_timeout / 2`) is due, so the measured
44
- * time is an upper bound when completed by a keepalive.
45
- */
46
- export declare class InitialDecodeTracker {
47
- #private;
48
- static start(lc: LogContext, session: postgres.Sql, slot: string, lsn: bigint): Promise<InitialDecodeTracker>;
49
- constructor(lc: LogContext, lsn: bigint, restartLSN: bigint | undefined, confirmedFlushLSN: bigint | undefined, startTime: number);
50
- /**
51
- * Observes a received message, returning the elapsed decode time (ms) if
52
- * this message completed the initial decode.
53
- */
54
- observe([lsn, msg]: StreamMessage, now: number): number | undefined;
55
- }
56
- /**
57
- * Derives the timings for the replication liveness timer from the server's
58
- * `wal_sender_timeout` (in milliseconds).
59
- *
60
- * Postgres treats `wal_sender_timeout = 0` as "disabled": it will neither
61
- * terminate an idle wal sender nor emit the periodic keepalives it otherwise
62
- * sends at roughly `wal_sender_timeout / 2`. Every timing below is derived from
63
- * that interval, so a disabled timeout disables the liveness machinery entirely
64
- * (`enabled: false`). Otherwise the derived thresholds would all collapse to 0,
65
- * inverting the intended meaning: the inbound watchdog would fire on the very
66
- * first tick and destroy the stream, while the timer itself would busy-spin at
67
- * a 0ms interval — together producing a continuous reconnect storm.
68
- *
69
- * An `inboundTimeoutOverrideMs` (when positive) replaces the default
70
- * `2x wal_sender_timeout` inbound threshold. The two timeouts protect
71
- * different parties with asymmetric false-positive costs: `wal_sender_timeout`
72
- * is the server reaping dead clients (a false positive there costs a cheap
73
- * reconnect), while the inbound watchdog tears down the stream and replays the
74
- * in-flight transaction — expensive, and self-defeating when the wal sender is
75
- * legitimately silent for long stretches (e.g. decoding through WAL from
76
- * unpublished tables, or assembling a large transaction that pgoutput only
77
- * sends at commit). Operators who don't own the server setting (e.g. managed
78
- * or operator-provisioned Postgres with an aggressive cluster-wide
79
- * `wal_sender_timeout`) can widen the client-side fuse independently.
80
- *
81
- * The override has no effect when `wal_sender_timeout` is disabled (0): the
82
- * server then sends no periodic keepalives, so inbound silence is normal even
83
- * on an idle healthy connection and any silence-based watchdog would
84
- * false-positive.
85
- *
86
- * https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-WAL-SENDER-TIMEOUT
87
- */
88
- export declare function computeLivenessTimings(walSenderTimeoutMs: number, inboundTimeoutOverrideMs?: number | undefined): {
89
- enabled: boolean;
90
- manualKeepaliveTimeout: number;
91
- inboundTimeoutMs: number;
92
- timerIntervalMs: number;
93
- };
94
- /**
95
- * Pure decision for the inbound-liveness watchdog, given the time since the
96
- * last inbound message, the timeout threshold, and the number of messages
97
- * currently queued downstream (see {@link SourceWithPendingQueue.queued}).
98
- *
99
- * A non-empty downstream queue means we have received data we haven't yet
100
- * consumed: the reason we aren't receiving *more* is our own back-pressure, not
101
- * upstream silence. In that case we `resetWindow` (treat the backlog as
102
- * liveness evidence) rather than counting the stall against the connection.
103
- * This both suppresses false timeouts during back-pressure and — crucially —
104
- * keeps `lastReceivedTime` fresh so the drain transition (queue emptying after
105
- * a long stall) doesn't fire the watchdog against a stale timestamp on the very
106
- * next tick.
107
- *
108
- * Only when the queue is empty (consumption has caught up, so reading — and
109
- * thus keepalives — should be flowing again) does an over-threshold gap
110
- * indicate a genuinely dead inbound half.
111
- */
112
- export declare function evaluateInboundLiveness({ sinceLastReceived, inboundTimeoutMs, queued, }: {
113
- sinceLastReceived: number;
114
- inboundTimeoutMs: number;
115
- queued: number;
116
- }): {
117
- resetWindow: boolean;
118
- timedOut: boolean;
119
- };
120
- export declare function startReplicationStream(lc: LogContext, session: postgres.Sql, slot: string, publications: string[], lsn: bigint, maxAttempts?: number): Promise<[Readable, import("stream").Writable]>;
121
- /**
122
- * Starts a "dummy" replication session for the specified `slot` which:
123
- * * does not consume any records
124
- * * keeps the session alive by sending status messages at the starting LSN
125
- *
126
- * This essentially reserves the replication slot for this process by marking
127
- * it as "active" in pg_replication_slots, allowing replication slot cleanup
128
- * logic to distinguish a new-but-initializing replication slot from one that
129
- * has been abandoned / orphaned.
130
- *
131
- * When initialization (e.g. initial-sync) has finished, the server should take
132
- * over the replication slot using pg_terminate_backend, which will close the
133
- * session.
134
- *
135
- * Note that caller should not close the supplied `session`, as that will
136
- * also terminate the dummy replication session.
137
- */
138
- export declare class SlotReservationHandle extends Readable {
139
- #private;
140
- constructor(worker: Worker);
141
- _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
142
- end(timeoutMs?: number): Promise<void>;
143
- }
144
- export declare function endSession(session?: Readable): Promise<void>;
145
- export type PgConnectionConfig = {
146
- host?: string | string[] | undefined;
147
- port?: number | number[] | undefined;
148
- path?: string | undefined;
149
- database?: string | undefined;
150
- user?: string | undefined;
151
- pass?: string | null | undefined;
152
- ssl?: boolean | string | {
153
- rejectUnauthorized?: boolean | undefined;
154
- } | undefined;
155
- };
156
- export declare function extractConnectionConfig(session: postgres.Sql): PgConnectionConfig;
157
- /**
158
- * Starts a "dummy" replication session for the specified `slot` which:
159
- * * does not consume any records
160
- * * keeps the session alive by sending status messages at the starting LSN
161
- *
162
- * Runs in a separate process with its own event loop and connection reconnect
163
- * loop to prevent slot drop races during heavy initial sync table copy or
164
- * SQLite index building.
165
- */
166
- export declare function keepSlotActiveUntilTakenOver(lc: LogContext, config: SlotKeeperConfig): Promise<Readable>;
167
- export declare function makeAck(lsn: bigint): Buffer;
168
- export {};
169
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/logical-replication/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAC;AAMrC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,QAA2C,MAAM,UAAU,CAAC;AAInE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAC,KAAK,UAAU,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAc,KAAK,MAAM,EAAC,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAO,KAAK,IAAI,EAAE,KAAK,MAAM,EAAC,MAAM,8BAA8B,CAAC;AAK1E,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,0CAA0C,IAAI,CAAC;AAE5D,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM;IACX,OAAO,GAAG;QAAC,GAAG,EAAE,WAAW,CAAC;QAAC,aAAa,EAAE,OAAO,CAAA;KAAC;CACrD,CAAC;AAKF,KAAK,sBAAsB,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,UAAU,EACd,eAAe,EAAE,MAAM,oB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AAC,EACA,OAAO,GACP,MAAM,GACN;QAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KAAC,GAC1C,SAAS,CAAC;CACf,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,QAAQ,CAAC,GAAG,GACpB,kBAAkB,CAkBpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,CAChD,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,QAAQ,CAAC,CAqCnB;AAyBD,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU3C"}
@@ -1,16 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- import type { PostgresDB } from '../../../types/pg.ts';
3
- import type { ShardID } from '../../../types/shards.ts';
4
- type Options = {
5
- inactiveSlotCleanupTimeoutMs?: number | undefined;
6
- pollIntervalMs?: number | undefined;
7
- };
8
- export declare class ReplicationSlotCleanupMonitor {
9
- #private;
10
- constructor(lc: LogContext, shard: ShardID, upstream: PostgresDB, upstreamPgServerVersionNum: number, currentSlot: string, { inactiveSlotCleanupTimeoutMs, pollIntervalMs }?: Options);
11
- start(): void;
12
- stop(): void;
13
- getSlotsToCleanup(now: Date): Promise<string[]>;
14
- }
15
- export {};
16
- //# sourceMappingURL=replication-slot-cleanup-monitor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replication-slot-cleanup-monitor.d.ts","sourceRoot":"","sources":["../../../../../../../zero-cache/src/services/change-source/pg/replication-slot-cleanup-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,0BAA0B,CAAC;AAItD,KAAK,OAAO,GAAG;IACb,4BAA4B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClD,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAKF,qBAAa,6BAA6B;;IAkCxC,YACE,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,UAAU,EACpB,0BAA0B,EAAE,MAAM,EAClC,WAAW,EAAE,MAAM,EACnB,EAAC,4BAA4B,EAAE,cAAc,EAAC,GAAE,OAAY,EAW7D;IAED,KAAK,SAYJ;IAED,IAAI,SAIH;IAiBK,iBAAiB,CAAC,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqEpD;CACF"}
@@ -1,15 +0,0 @@
1
- import type { LogContext } from '@rocicorp/logger';
2
- import type { PostgresDB } from '../../../types/pg.ts';
3
- declare const SLOT_HEALTH_STATUSES: readonly ['ok', 'unreserved', 'lost', 'missing', 'unknown'];
4
- export type SlotHealthStatus = (typeof SLOT_HEALTH_STATUSES)[number];
5
- export type SlotHealthRow = {
6
- readonly restartLSN: string | null;
7
- readonly walStatus: string | null;
8
- readonly retainedWalBytes: number | null;
9
- readonly safeWalBytes: number | null;
10
- };
11
- export declare function slotHealthStatus(row: Pick<SlotHealthRow, 'restartLSN' | 'walStatus'> | undefined): SlotHealthStatus;
12
- export declare function registerReplicationSlotHealthMetrics(lc: LogContext, db: PostgresDB, slot: string, isStopped: () => boolean): void;
13
- export declare function queryReplicationSlotHealth(db: PostgresDB, slot: string): Promise<SlotHealthRow | undefined>;
14
- export {};
15
- //# sourceMappingURL=replication-slot-health.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replication-slot-health.d.ts","sourceRoot":"","sources":["../../../../../../../zero-cache/src/services/change-source/pg/replication-slot-health.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAErD,QAAA,MAAM,oBAAoB,YACxB,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,SAAS,EACT,SAAS,CACD,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CACtC,CAAC;AAEF,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,GAAG,WAAW,CAAC,GAAG,SAAS,GAC/D,gBAAgB,CAgBlB;AAED,wBAAgB,oCAAoC,CAClD,EAAE,EAAE,UAAU,EACd,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,OAAO,GACvB,IAAI,CAoCN;AAwBD,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,UAAU,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAapC"}
@@ -1,127 +0,0 @@
1
- import type { Readable } from 'node:stream';
2
- import type { LogContext } from '@rocicorp/logger';
3
- import postgres from 'postgres';
4
- import { type PostgresDB } from '../../../types/pg.ts';
5
- import { type ShardID } from '../../../types/shards.ts';
6
- import { type ReplicaStage } from './schema/replica-stage-enum.ts';
7
- import { type BackupOptions, type ReplicaState } from './schema/shard.ts';
8
- export type ReplicationSlot = {
9
- slot_name: string;
10
- consistent_point: string;
11
- snapshot_name: string;
12
- output_plugin: string;
13
- };
14
- export type ReplicationSlotResult<T> = {
15
- slot: ReplicationSlot;
16
- capturedSnapshot: T;
17
- initialSession: Readable;
18
- replica: ReplicaState;
19
- };
20
- export type ReservedSlot = {
21
- slot: string;
22
- reservation: Readable;
23
- replica: ReplicaState;
24
- };
25
- export type CreateSlotSpec = {
26
- slotName: string;
27
- failover?: boolean;
28
- temporary?: boolean;
29
- lockTimeout?: number | undefined;
30
- diagnosticsDB?: PostgresDB | undefined;
31
- };
32
- export declare const CREATE_REPLICATION_SLOT_TIMEOUT_MS = 60000;
33
- /** Thrown when the client-side timeout for creating a slot is reached. */
34
- export declare class SlotCreationTimeoutError extends Error {
35
- readonly name = "SlotCreationTimeoutError";
36
- }
37
- export declare function createReplicationSlot(lc: LogContext, session: postgres.Sql, { slotName, failover, temporary, lockTimeout, diagnosticsDB, }: CreateSlotSpec): Promise<ReplicationSlot>;
38
- /**
39
- * Best-effort logging of what a timed out CREATE_REPLICATION_SLOT was waiting
40
- * on: the walsender's wait event and blocking pids, and the oldest
41
- * transactions holding an xid. Slot creation waits for every such transaction
42
- * on the instance (in all databases), each with its own lock_timeout, so a
43
- * chain of overlapping transactions can exceed the client-side timeout
44
- * without the lock_timeout ever firing.
45
- *
46
- * Query text is deliberately omitted since it can contain row values.
47
- *
48
- * Exported for testing.
49
- */
50
- export declare function logSlotCreationBlockers(lc: LogContext, sql: PostgresDB, walsenderPID: number, slotName: string): Promise<void>;
51
- export type CreateReplicaAndSlotOptions = {
52
- lockTimeout?: number | undefined;
53
- maxBlockedMs?: number | undefined;
54
- retryDelayMs?: number | undefined;
55
- };
56
- /**
57
- * Replica and slot creation involves several sessions for proper
58
- * coordination with other replica management logic:
59
- *
60
- * * A dedicated session acquires a (session-level) advisory lock for
61
- * replica slot management. This is the same lock that cleanup logic
62
- * acquires before cleaning up replication slots. The lock is held
63
- * outside of a transaction so that the session is not "idle in
64
- * transaction" while slot creation waits on upstream transactions,
65
- * which some upstreams terminate (e.g. idle_in_transaction_session_timeout).
66
- * * With the lock held, a new replication slot is created in a
67
- * replication session. The API of CREATE_REPLICATION_SLOT is such
68
- * that it cannot be done in a transaction, and cannot be followed by
69
- * any writes, or else its snapshot (which is needed for initial sync)
70
- * would be invalidated.
71
- * * Once the slot is created, the slot and replica information are recorded
72
- * in the `replicas` table before releasing the lock.
73
- *
74
- * Slot creation waits for all transactions on the upstream instance that
75
- * hold an xid, so it can be blocked by long-running transactions. A blocked
76
- * attempt is abandoned (see {@link CREATE_REPLICATION_SLOT_TIMEOUT_MS}) and
77
- * retried in-process, as it leaves no durable state: the `replicas` row is
78
- * only inserted after the slot has been created. Retries continue until the
79
- * slot is created or until `maxBlockedMs` has elapsed, after which the error
80
- * is thrown.
81
- *
82
- * This locking ensures that:
83
- * 1. multiple replication managers attempting to create a replication slot
84
- * will not use the same name for the replication slot (which is selected
85
- * from a pool of reused names).
86
- * 2. Running replication managers (which use an earlier replica of a lower
87
- * rank) will not delete the new slot during their cleanup logic, since
88
- * the slot will belong to a replica of a higher rank.
89
- *
90
- * When the replication slot is created, `captureSnapshot` callback is first
91
- * run while the snapshot at the consistent point is available. The callback
92
- * must capture the snapshot in postgres (e.g. `SET TRANSACTION SNAPSHOT`)
93
- * in order to use it. Once the callback completes, a placeholder replication
94
- * session (i.e. that does not consume any messages) is started, in order to
95
- * reserve the slot by mark it "active", effectively distinguishing the
96
- * initializing session from a failed or abandoned session.
97
- *
98
- * Note that starting the replication session releases the initial snapshot,
99
- * which is why the callback must capture it synchronously, before the
100
- * replication session is started.
101
- *
102
- * The placeholder replication session is closed when the
103
- * PostgresChangeSource takes over the slot to process the stream in earnest.
104
- * It is also returned for cleanup in the case of failures (and for control
105
- * in unit tests).
106
- *
107
- * For replica's created in the `Restore` stage, the `generation` is
108
- * initialized to an empty string instead of the slot's consistent point,
109
- * since the slot is not being used for initial sync. It is the
110
- * responsibiliy of the caller to call {@link initRestoreReplica} when
111
- * the source replica has been selected for restoring, which will carry
112
- * over the `generation` and other relevant values from the source.
113
- */
114
- export declare function createReplicaAndSlot<T>(lc: LogContext, sql: PostgresDB, sessionName: string, shard: ShardID, epoch: number, replicaID: string, failover: boolean, backupOptions: BackupOptions, captureSnapshot: (snapshot: string) => Promise<T>, stage: ReplicaStage, { lockTimeout, maxBlockedMs, retryDelayMs, }?: CreateReplicaAndSlotOptions): Promise<ReplicationSlotResult<T>>;
115
- /**
116
- * Claims the inactive slot of the given replica for use by this task, opening
117
- * a replication session to mark it as active. The process should follow up by
118
- * taking over the slot via the PostgresChangeSource.
119
- *
120
- * The replica is identified by its ID (and not just its slot) because rows of
121
- * replicas whose slots were dropped outside of zero-cache's control may share
122
- * the slot name.
123
- */
124
- export declare function claimSlotForResumption(lc: LogContext, sql: PostgresDB, shard: ShardID, _sessionName: string, { id: replicaID, slot }: Pick<ReplicaState, 'id' | 'slot'>): Promise<ReservedSlot | null>;
125
- export declare function dropInactiveSlotsAndReplicas(lc: LogContext, sql: PostgresDB, shard: ShardID, slots: string[]): Promise<void>;
126
- export declare function slotPoolSuffix(n: number): string;
127
- //# sourceMappingURL=replication-slots.d.ts.map