@bastani/atomic 0.10.14 → 0.10.15-alpha.2

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 (342) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +1 -1
  3. package/dist/_shared/dist-KOELCESV.js +2 -2
  4. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  5. package/dist/_shared/lib-4PES5P4V.js +2 -2
  6. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +3 -3
  7. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +3 -3
  8. package/dist/_shared/mode-shared-2QJSCUM6.js +3 -3
  9. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  10. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  11. package/dist/_shared/{sdk-B5LEWGGI.js → sdk-OHKMDJ74.js} +27 -5
  12. package/dist/_shared/{sdk-B5LEWGGI.js.map → sdk-OHKMDJ74.js.map} +1 -1
  13. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  14. package/dist/_shared/startup-0-0-Q3MWKUK4.js +2 -2
  15. package/dist/_shared/startup-0-1-M6OWAYHH.js +2 -2
  16. package/dist/_shared/{startup-0-2-5QHPCEON.js → startup-0-2-2HUMCPKX.js} +14 -16
  17. package/dist/_shared/startup-0-2-2HUMCPKX.js.map +1 -0
  18. package/dist/_shared/startup-0-3-4ZYBYQNM.js +3 -3
  19. package/dist/_shared/startup-0-4-ZMJV547D.js +3 -3
  20. package/dist/_shared/startup-0-5-YDW47QX6.js +3 -3
  21. package/dist/_shared/startup-10-0-TDQNBDDL.js +3 -3
  22. package/dist/_shared/startup-14-0-MLX36RBG.js +1 -1
  23. package/dist/_shared/startup-15-0-YUKGAC63.js +1 -1
  24. package/dist/_shared/startup-15-1-4S7FLMNG.js +6 -30
  25. package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
  26. package/dist/_shared/startup-8-0-34CBHPZH.js +3 -3
  27. package/dist/_shared/startup-8-1-LZFXSD3Z.js +3 -3
  28. package/dist/_shared/storage-command-7MGXLJGZ.js +2 -2
  29. package/dist/_shared/storage-status-K7PX2RXA.js +3 -3
  30. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  31. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  32. package/dist/builtin/intercom/index.bundle.mjs +1 -1
  33. package/dist/builtin/intercom/package.json +1 -1
  34. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  35. package/dist/builtin/mcp/package.json +1 -1
  36. package/dist/builtin/subagents/package.json +1 -1
  37. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  38. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  39. package/dist/builtin/web-access/package.json +1 -1
  40. package/dist/cli/auth-cli.code.js +1 -1
  41. package/dist/cli/auth-cli.impl.js +3 -3
  42. package/dist/cli/auth-cli.js +3 -3
  43. package/dist/cli/blueprint-command.impl.js +3 -3
  44. package/dist/cli/blueprint-command.js +3 -3
  45. package/dist/cli/intercom-command.code.js +3 -3
  46. package/dist/cli/intercom-command.impl.js +3 -3
  47. package/dist/cli/intercom-command.js +3 -3
  48. package/dist/cli/list-models.impl.js +3 -3
  49. package/dist/cli/list-models.js +3 -3
  50. package/dist/cli/session-picker.code.js +1 -1
  51. package/dist/cli/session-picker.impl.js +3 -3
  52. package/dist/cli/session-picker.js +3 -3
  53. package/dist/cli/startup-ui.code.js +1 -1
  54. package/dist/cli/startup-ui.impl.js +3 -3
  55. package/dist/cli/startup-ui.js +3 -3
  56. package/dist/cli/storage-command.impl.js +3 -3
  57. package/dist/cli/storage-command.js +3 -3
  58. package/dist/cli/storage-search-session.code.js +1 -1
  59. package/dist/cli/storage-search-session.impl.js +3 -3
  60. package/dist/cli/storage-search-session.js +3 -3
  61. package/dist/cli/team-command.code.js +1 -1
  62. package/dist/cli/team-command.impl.js +3 -3
  63. package/dist/cli/team-command.js +3 -3
  64. package/dist/cli.js +2 -2
  65. package/dist/core/compaction/compactor.d.ts +0 -8
  66. package/dist/core/debug.impl.js +3 -3
  67. package/dist/core/debug.js +3 -3
  68. package/dist/core/export-html/card-projection.impl.js +3 -3
  69. package/dist/core/export-html/card-projection.js +3 -3
  70. package/dist/core/export-html/index.code.js +2 -2
  71. package/dist/core/export-html/index.impl.js +3 -3
  72. package/dist/core/export-html/index.js +3 -3
  73. package/dist/core/export-html/json-spans.impl.js +3 -3
  74. package/dist/core/export-html/json-spans.js +3 -3
  75. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  76. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  77. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  78. package/dist/core/export-html/tool-renderer.js +3 -3
  79. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  80. package/dist/core/extensions/jiti-loader.js +3 -3
  81. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  82. package/dist/core/extensions/jiti-static-loader.js +3 -3
  83. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  84. package/dist/core/extensions/loader-host-modules.js +3 -3
  85. package/dist/core/intercom-broker-control-host.code.js +1 -1
  86. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  87. package/dist/core/intercom-broker-control-host.js +3 -3
  88. package/dist/core/intercom-broker-control.code.js +2 -2
  89. package/dist/core/intercom-broker-control.impl.js +3 -3
  90. package/dist/core/intercom-broker-control.js +3 -3
  91. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  92. package/dist/core/package-manager-storage-adapters.js +3 -3
  93. package/dist/core/sdk.code.js +1 -1
  94. package/dist/core/sdk.impl.js +3 -3
  95. package/dist/core/sdk.js +3 -3
  96. package/dist/core/session-manager-core.js +3 -3
  97. package/dist/core/session-manager-list.impl.js +3 -3
  98. package/dist/core/session-manager-list.js +3 -3
  99. package/dist/core/session-manager.impl.js +3 -3
  100. package/dist/core/session-manager.js +3 -3
  101. package/dist/core/session-storage.impl.js +3 -3
  102. package/dist/core/session-storage.js +3 -3
  103. package/dist/core/storage/index.js +2 -2
  104. package/dist/core/storage/node-sqlite-thread.js +2 -2
  105. package/dist/core/storage/node-sqlite.js +2 -2
  106. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  107. package/dist/core/storage/offline-snapshot-file.js +3 -3
  108. package/dist/core/storage/provider.js +2 -2
  109. package/dist/core/storage/selection.js +2 -2
  110. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  111. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  112. package/dist/core/storage/session/branch-fork-source.js +3 -3
  113. package/dist/core/storage/session/card-view.impl.js +3 -3
  114. package/dist/core/storage/session/card-view.js +3 -3
  115. package/dist/core/storage/session/child-reader.code.js +2 -2
  116. package/dist/core/storage/session/child-reader.impl.js +3 -3
  117. package/dist/core/storage/session/child-reader.js +3 -3
  118. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  119. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  120. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  121. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  122. package/dist/core/storage/session/expanded-child-details.js +3 -3
  123. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  124. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  125. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  126. package/dist/core/storage/session/fork-row-index.js +3 -3
  127. package/dist/core/storage/session/fork-staging.code.js +1 -1
  128. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  129. package/dist/core/storage/session/fork-staging.js +3 -3
  130. package/dist/core/storage/session/fork-window.code.js +2 -2
  131. package/dist/core/storage/session/fork-window.impl.js +3 -3
  132. package/dist/core/storage/session/fork-window.js +3 -3
  133. package/dist/core/storage/session/history-pages.impl.js +3 -3
  134. package/dist/core/storage/session/history-pages.js +3 -3
  135. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  136. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  137. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  138. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  139. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  140. package/dist/core/storage/session/memory-session-store.js +3 -3
  141. package/dist/core/storage/session/pinned-branch-resume.code.js +2 -2
  142. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  143. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  144. package/dist/core/storage/session/released-history-files.code.js +1 -1
  145. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  146. package/dist/core/storage/session/released-history-files.js +3 -3
  147. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  148. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  149. package/dist/core/storage/session/session-resume.impl.js +3 -3
  150. package/dist/core/storage/session/session-resume.js +3 -3
  151. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  152. package/dist/core/storage/session/snapshot-cut.js +3 -3
  153. package/dist/core/storage/session/snapshot-history.code.js +2 -2
  154. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  155. package/dist/core/storage/session/snapshot-history.js +3 -3
  156. package/dist/core/storage/session/sql-session-store.code.js +1 -1
  157. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  158. package/dist/core/storage/session/sql-session-store.js +3 -3
  159. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  160. package/dist/core/storage/session/tree-outline.js +3 -3
  161. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  162. package/dist/core/storage/session/tree-presentation.js +3 -3
  163. package/dist/core/storage/storage-status.impl.js +3 -3
  164. package/dist/core/storage/storage-status.js +3 -3
  165. package/dist/core/storage/team.impl.js +3 -3
  166. package/dist/core/storage/team.js +3 -3
  167. package/dist/core/structured-output/index.code.js +1 -1
  168. package/dist/core/structured-output/index.impl.js +3 -3
  169. package/dist/core/structured-output/index.js +3 -3
  170. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  171. package/dist/core/tasks/task-completion-entry.js +3 -3
  172. package/dist/core/tasks/task-file-history.code.js +2 -2
  173. package/dist/core/tasks/task-file-history.impl.js +3 -3
  174. package/dist/core/tasks/task-file-history.js +3 -3
  175. package/dist/core/tasks/task-reference-archive.code.js +2 -2
  176. package/dist/core/tasks/task-reference-archive.js +3 -3
  177. package/dist/core/tasks/task-reference-identity.js +3 -3
  178. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  179. package/dist/core/tasks/task-reference-stream.js +3 -3
  180. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  181. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  182. package/dist/core/tasks/task-view-source.impl.js +3 -3
  183. package/dist/core/tasks/task-view-source.js +3 -3
  184. package/dist/core/tools/read-url.impl.js +3 -3
  185. package/dist/core/tools/read-url.js +3 -3
  186. package/dist/core/worktree-snapshot/blob-store.js +2 -2
  187. package/dist/core/worktree-snapshot/errors.code.js +1 -1
  188. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  189. package/dist/core/worktree-snapshot/errors.js +3 -3
  190. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  191. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  192. package/dist/extensions/codemode/execute.impl.js +3 -3
  193. package/dist/extensions/codemode/execute.js +3 -3
  194. package/dist/extensions/codemode/renderer.impl.js +3 -3
  195. package/dist/extensions/codemode/renderer.js +3 -3
  196. package/dist/extensions/mcp/cli.code.js +1 -1
  197. package/dist/extensions/mcp/cli.impl.js +3 -3
  198. package/dist/extensions/mcp/cli.js +3 -3
  199. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  200. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  201. package/dist/extensions/mcp/cli.lazy.js +3 -3
  202. package/dist/extensions/mcp/runtime.code.js +1 -1
  203. package/dist/extensions/mcp/runtime.impl.js +3 -3
  204. package/dist/extensions/mcp/runtime.js +3 -3
  205. package/dist/index.d.ts +21 -1
  206. package/dist/index.js +2 -2
  207. package/dist/main-first-time-setup.code.js +1 -1
  208. package/dist/main-first-time-setup.impl.js +3 -3
  209. package/dist/main-first-time-setup.js +3 -3
  210. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  211. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  212. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  213. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  214. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  215. package/dist/modes/print-mode.js +1 -1
  216. package/dist/package-manager-cli.code.js +2 -2
  217. package/dist/package-manager-cli.impl.js +3 -3
  218. package/dist/package-manager-cli.js +3 -3
  219. package/dist/startup-files.json +1 -1
  220. package/dist/startup-stages/6.js +1 -1
  221. package/dist/utils/startup-database-spare.code.js +1 -1
  222. package/dist/utils/startup-database-spare.impl.js +3 -3
  223. package/dist/utils/startup-database-spare.js +3 -3
  224. package/dist/utils/tools-manager.impl.js +3 -3
  225. package/dist/utils/tools-manager.js +3 -3
  226. package/docs/background-tasks/reference.md +182 -0
  227. package/docs/background-tasks.md +98 -405
  228. package/docs/build.md +67 -27
  229. package/docs/changelog.mdx +11 -1
  230. package/docs/codemode.md +108 -39
  231. package/docs/compaction/branch-summaries.md +54 -0
  232. package/docs/compaction/custom-compactors.md +161 -0
  233. package/docs/compaction/memory-compaction.md +77 -0
  234. package/docs/compaction/reference.md +86 -38
  235. package/docs/compaction.md +51 -252
  236. package/docs/computer-use.md +169 -321
  237. package/docs/containerization.md +71 -57
  238. package/docs/custom-provider/api-reference.md +119 -25
  239. package/docs/custom-provider/oauth.md +114 -132
  240. package/docs/custom-provider/override.md +37 -27
  241. package/docs/custom-provider/registration.md +107 -83
  242. package/docs/custom-provider/streaming.md +85 -71
  243. package/docs/custom-provider.md +85 -52
  244. package/docs/development.md +39 -29
  245. package/docs/docs.json +80 -67
  246. package/docs/environment-variables.md +94 -44
  247. package/docs/extensions/api-reference.md +86 -43
  248. package/docs/extensions/authoring.md +162 -154
  249. package/docs/extensions/events.md +80 -25
  250. package/docs/extensions/examples.md +90 -85
  251. package/docs/extensions/ui.md +206 -82
  252. package/docs/extensions.md +79 -108
  253. package/docs/getting-started/authentication.md +67 -36
  254. package/docs/getting-started/first-session.md +53 -43
  255. package/docs/getting-started/installation.md +117 -90
  256. package/docs/getting-started/project-instructions.md +48 -34
  257. package/docs/guides/configuration.md +82 -20
  258. package/docs/guides/non-interactive.md +66 -24
  259. package/docs/guides/resume-on-any-machine.md +135 -82
  260. package/docs/guides/team-setup.md +114 -105
  261. package/docs/guides.md +76 -32
  262. package/docs/herdr.md +16 -17
  263. package/docs/how-atomic-works.md +140 -0
  264. package/docs/index.md +58 -44
  265. package/docs/intercom/operations.md +141 -151
  266. package/docs/intercom/reference.md +85 -108
  267. package/docs/intercom.md +84 -145
  268. package/docs/json.md +120 -67
  269. package/docs/keybindings.md +85 -49
  270. package/docs/libraries/agent-core.md +137 -275
  271. package/docs/libraries/ai.md +100 -84
  272. package/docs/libraries/codemode.md +210 -300
  273. package/docs/libraries/schema.md +59 -53
  274. package/docs/libraries/storage-postgres.md +49 -35
  275. package/docs/libraries/telemetry.md +153 -354
  276. package/docs/libraries/tui.md +265 -393
  277. package/docs/libraries.md +42 -26
  278. package/docs/llama-cpp.md +171 -161
  279. package/docs/mcp-servers.md +90 -51
  280. package/docs/models/choose-a-model.md +188 -0
  281. package/docs/models/reference.md +74 -30
  282. package/docs/models.md +153 -88
  283. package/docs/orchestration/migrating-workflows.md +23 -16
  284. package/docs/orchestration/patterns.md +39 -44
  285. package/docs/orchestration.md +65 -26
  286. package/docs/packages/authoring.md +51 -29
  287. package/docs/packages/reference.md +42 -21
  288. package/docs/packages.md +69 -58
  289. package/docs/programmatic.md +118 -24
  290. package/docs/prompt-templates.md +84 -83
  291. package/docs/providers/reference.md +43 -48
  292. package/docs/providers.md +219 -451
  293. package/docs/quickstart.md +140 -120
  294. package/docs/reference/cli.md +135 -97
  295. package/docs/reference.md +20 -19
  296. package/docs/rpc/examples.md +76 -20
  297. package/docs/rpc/extension-ui.md +64 -38
  298. package/docs/rpc/protocol.md +361 -110
  299. package/docs/rpc.md +57 -17
  300. package/docs/sdk/reference.md +409 -534
  301. package/docs/sdk/storage.md +53 -13
  302. package/docs/sdk/structured-decisions.md +82 -56
  303. package/docs/sdk/web-server.md +57 -43
  304. package/docs/sdk.md +106 -84
  305. package/docs/security.md +42 -64
  306. package/docs/session-format.md +62 -38
  307. package/docs/sessions.md +99 -214
  308. package/docs/settings.md +165 -195
  309. package/docs/shell-aliases.md +9 -6
  310. package/docs/skills/authoring.md +69 -48
  311. package/docs/skills/reference.md +51 -20
  312. package/docs/skills.md +99 -148
  313. package/docs/slash-commands.md +129 -0
  314. package/docs/storage/custom-adapters.md +160 -85
  315. package/docs/storage/jsonl.md +81 -66
  316. package/docs/storage/postgres/pgbouncer.md +120 -126
  317. package/docs/storage/postgres/tuning.md +120 -143
  318. package/docs/storage/postgres.md +314 -330
  319. package/docs/storage/sqlite.md +71 -42
  320. package/docs/storage.md +298 -302
  321. package/docs/subagents/authoring.md +55 -38
  322. package/docs/subagents/reference.md +73 -33
  323. package/docs/subagents.md +119 -187
  324. package/docs/terminal-setup.md +51 -39
  325. package/docs/themes/reference.md +23 -19
  326. package/docs/themes.md +142 -127
  327. package/docs/tmux.md +47 -55
  328. package/docs/tools.md +147 -109
  329. package/docs/tui/reference.md +166 -214
  330. package/docs/tui.md +196 -341
  331. package/docs/usage.md +118 -138
  332. package/docs/verification.md +79 -51
  333. package/docs/web-access.md +121 -101
  334. package/docs/windows.md +26 -27
  335. package/docs/worktree-snapshots/reference.md +245 -0
  336. package/docs/worktree-snapshots.md +71 -259
  337. package/package.json +8 -8
  338. package/dist/_shared/startup-0-2-5QHPCEON.js.map +0 -1
  339. package/docs/guides/intercom.md +0 -32
  340. package/docs/guides/orchestration.md +0 -28
  341. package/docs/guides/subagents.md +0 -37
  342. package/docs/termux.md +0 -118
@@ -1,57 +1,51 @@
1
1
  ---
2
- title: "Run many agents on PostgreSQL with PgBouncer"
2
+ title: "Use PgBouncer with PostgreSQL"
3
3
  sidebarTitle: "PgBouncer"
4
- description: "Put PgBouncer between Atomic and PostgreSQL when your agents need more connections than the server allows, with a complete configuration, checks, and fixes for common errors."
4
+ description: "Run PgBouncer in transaction mode between Atomic and PostgreSQL when agent processes exceed the server's connection limit, with TLS, SCRAM auth, pool sizing, and checks."
5
5
  ---
6
6
 
7
- PgBouncer is a small server that sits between Atomic and PostgreSQL. Thousands of connections from Atomic go to PgBouncer, and PgBouncer runs their work over a few dozen connections to PostgreSQL. Use it when your agents need more connections than PostgreSQL allows.
7
+ PgBouncer is a lightweight connection pooler that sits between Atomic and PostgreSQL. Thousands of client connections from Atomic terminate at PgBouncer, which multiplexes their transactions over a few dozen server connections to PostgreSQL.
8
8
 
9
- This guide assumes you already set up the database and roles as in [PostgreSQL setup](/storage/postgres). It uses these names, which you replace with your own:
9
+ This guide builds on [PostgreSQL setup](/storage/postgres) and uses these placeholder names:
10
10
 
11
- | Name | Meaning |
11
+ | Placeholder | Meaning |
12
12
  | --- | --- |
13
- | `db.example.com` | The PostgreSQL server's host name |
14
- | `pgbouncer.example.com` | The PgBouncer server's host name |
15
- | `atomic` | The database Atomic uses |
16
- | `atomic_runtime` | The runtime role, which every Atomic machine logs in as |
17
- | `pgbouncer_auth` | A role PgBouncer uses only to look up passwords |
13
+ | `db.example.com` | PostgreSQL server hostname |
14
+ | `pgbouncer.example.com` | PgBouncer server hostname |
15
+ | `atomic` | Atomic database name |
16
+ | `atomic_runtime` | Runtime role that agent machines connect as |
17
+ | `pgbouncer_auth` | Restricted lookup role PgBouncer uses to verify passwords |
18
18
 
19
19
  ## When you need PgBouncer
20
20
 
21
- Every connection an Atomic process opens counts against PostgreSQL's `max_connections`. [Count the connections Atomic needs](/storage/postgres#count-the-connections-atomic-needs) with this rule:
21
+ Every connection an Atomic process opens counts against PostgreSQL's `max_connections` ([count your connections](/storage/postgres#count-the-connections-atomic-needs)):
22
22
 
23
- - An agent process uses up to `maxConnections` plus `readerMaxConnections`.
24
- - An Intercom broker uses the same, plus 1 for wake-ups.
23
+ - **Agent process:** up to `maxConnections + readerMaxConnections`
24
+ - **Intercom broker:** up to `maxConnections + readerMaxConnections + 1` (for wake-ups)
25
25
 
26
- Add these up over every machine. If the server cannot give every process at least 2 connections for `maxConnections`, you need PgBouncer.
26
+ If PostgreSQL cannot spare at least `maxConnections: 2` per process across your fleet, deploy PgBouncer.
27
27
 
28
- For example, 150 CI runners each run one agent process and one Intercom broker. That is 300 processes, of which 150 are brokers. The server has `max_connections = 300`, 3 slots reserved for administrators, and 10 connections used by other clients, so 287 are left for Atomic. With the smallest settings, `maxConnections: 1` and `readerMaxConnections: 0`, the processes need 300 × 1 + 150 = 450 connections. That is more than the server has.
29
-
30
- With PgBouncer, those 300 processes connect to PgBouncer instead. The 150 brokers keep one direct connection each for wake-ups, which leaves 287 − 150 = 137 for PgBouncer. The configuration below shares 85 connections to PostgreSQL between all 300 processes: a pool of 80 plus 5 in reserve. With the brokers' connections, that is 235, which fits in 287.
28
+ **Example:** 150 CI runners each run 1 agent and 1 Intercom broker (300 processes, 150 brokers) against a server with `max_connections = 300`, 3 reserved admin slots, and 10 non-Atomic clients (287 slots available). Even at `maxConnections: 1` and `readerMaxConnections: 0`, the fleet needs `300 + 150 = 450` connections. With PgBouncer, all 300 processes connect to PgBouncer, the 150 brokers hold 1 direct wake-up connection each (`287 − 150 = 137` slots left), and PgBouncer multiplexes all 300 processes over an 85-connection server pool (`80 + 5` reserve, totaling 235 server connections).
31
29
 
32
30
  ## How Atomic works with PgBouncer
33
31
 
34
- **Transaction mode.** Run PgBouncer in transaction mode. In this mode, PgBouncer lends a connection to PostgreSQL to a client for one transaction, then gives it to the next client. Atomic works this way:
35
-
36
- - Settings that Atomic changes, such as the schema it uses and its time limits, last only for the transaction that set them.
37
- - Locks that Atomic takes are released when the transaction ends.
38
- - A statement outside a transaction is a transaction of its own.
39
-
40
- So nothing Atomic does depends on keeping the same connection to PostgreSQL between transactions. Do not use statement mode, which breaks transactions.
32
+ **Transaction mode.** Run PgBouncer with `pool_mode = transaction`. PgBouncer lends a PostgreSQL backend connection to a client for one transaction and returns it to the pool as soon as the transaction commits or rolls back. Atomic scopes every session setting (`search_path`, timeouts) and advisory lock to the transaction, so nothing depends on pinning a backend connection between transactions.
41
33
 
42
- **Wake-ups need a direct connection.** An Intercom broker learns about new messages through PostgreSQL's `LISTEN` command. `LISTEN` only works on a connection that stays with the broker, and transaction mode does not keep one. So point the `listenUrl` setting straight at PostgreSQL. Each broker then holds one direct connection for wake-ups, and all other work goes through PgBouncer.
34
+ <Warning>
35
+ Never use `pool_mode = statement` with Atomic—statement pooling breaks multi-statement transactions.
36
+ </Warning>
43
37
 
44
- If you leave out `listenUrl`, Atomic notices that it is behind a pooler and stops waiting for wake-ups. Brokers then check the database for new messages every half second instead of every 5 seconds. Messages still arrive, a little later, and the database gets more queries.
38
+ **Direct wake-ups via `listenUrl`.** Intercom brokers receive instant message notices via PostgreSQL `LISTEN`/`NOTIFY`, which requires a persistent backend connection that transaction pooling cannot maintain. Point `listenUrl` directly at PostgreSQL so each broker opens one direct `atomic-listen` connection while all other queries flow through PgBouncer.
45
39
 
46
- **Prepared statements.** A prepared statement is a query that PostgreSQL parses and plans once, then runs many times. Atomic can keep its frequent queries prepared, which saves the server work, but only if the pooler keeps track of them. PgBouncer 1.21 and later does, when its `max_prepared_statements` setting is above `0`. PgBouncer 1.24 and later set it to 200 by default.
40
+ If you omit `listenUrl`, Atomic detects the pooler and falls back to polling wake-up hints every 0.5 seconds (instead of instant notifications with a 5-second hint poll and 30-second backup outbox scan). Messages still arrive, at slightly higher latency and query volume.
47
41
 
48
- Atomic checks on its first connection whether it is talking to such a PgBouncer, and turns prepared statements on only if it is. You do not need to set anything:
42
+ **Prepared statements.** PostgreSQL plans a prepared statement once and reuses the plan. PgBouncer 1.21+ tracks prepared statements across transaction pooling when `max_prepared_statements > 0` (PgBouncer 1.24+ defaults this to `200`). Atomic probes PgBouncer on its first connection and configures prepared statements automatically:
49
43
 
50
- - **PgBouncer 1.21 or later with `max_prepared_statements` above `0`:** on.
51
- - **Anything else:** off. That includes PgBouncer before 1.21, PgBouncer with `max_prepared_statements = 0`, Supabase's Supavisor, and any pooler Atomic cannot identify. Off is the safe choice, because a pooler that loses prepared statements makes queries fail.
52
- - **A pooler on a port other than 6432 or 6543:** Atomic may not notice it. Set `listenUrl`, which a pooler needs for wake-ups anyway, or `maxPreparedStatements: 0`.
44
+ - **PgBouncer 1.21+ with `max_prepared_statements > 0`:** enabled automatically.
45
+ - **Older PgBouncer, `max_prepared_statements = 0`, Supavisor, or unknown poolers:** disabled automatically to avoid missing-statement errors.
46
+ - **Pooler on a port other than `6432` or `6543`:** Atomic may not infer a pooler automatically—set `listenUrl` or `maxPreparedStatements: 0`.
53
47
 
54
- Atomic's `maxPreparedStatements` setting overrides this. Set it to `0` to keep prepared statements off, or to `256` to turn them on without the check. If you change PgBouncer's `max_prepared_statements` to `0` while Atomic runs, the next query that needs a lost statement fails once and runs again, and Atomic stops preparing statements until it restarts.
48
+ Setting `maxPreparedStatements` explicitly overrides auto-detection (`0` forces off, `256` forces on). If PgBouncer's `max_prepared_statements` is later lowered to `0` at runtime, Atomic retries the failed query once and disables prepared statements for the remainder of the process.
55
49
 
56
50
  ```text
57
51
  agent processes ──> PgBouncer :6432 ──> PostgreSQL :5432
@@ -63,25 +57,25 @@ Intercom brokers ──> PgBouncer :6432 ──> PostgreSQL :5432
63
57
 
64
58
  ### Connection limits
65
59
 
66
- PostgreSQL needs room for:
60
+ Size PostgreSQL's `max_connections` (requires restart) to cover:
67
61
 
68
- - PgBouncer's connections: its pool size plus its reserve pool, `default_pool_size` plus `reserve_pool_size` in the configuration below.
69
- - One wake-up connection per Intercom broker.
70
- - Administrators, monitoring, and other applications.
62
+ - PgBouncer's server pool (`default_pool_size + reserve_pool_size`)
63
+ - One wake-up connection per Intercom broker (when using `listenUrl`)
64
+ - Administrators, monitoring, and other applications
71
65
 
72
- Set `max_connections` to at least their sum. Changing it needs a restart of PostgreSQL. On a managed service, change the server parameter in the service's console.
73
-
74
- To stop Atomic's runtime role from taking every slot, you can cap it. The cap counts every connection the role opens, including PgBouncer's connections for that role. Set it to PgBouncer's pool plus one wake-up connection per broker, plus a margin. In the example in [When you need PgBouncer](#when-you-need-pgbouncer), that is 85 + 150 = 235, plus a margin:
66
+ Cap `atomic_runtime` so a runaway fleet cannot exhaust admin slots. The cap includes both PgBouncer's pooled connections for `atomic_runtime` and direct broker wake-up connections (for the 150-runner example: `85 + 150 = 235`, plus margin):
75
67
 
76
68
  ```sql
77
69
  ALTER ROLE atomic_runtime CONNECTION LIMIT 250;
78
70
  ```
79
71
 
80
- Raise the cap if PgBouncer logs `too many connections for role "atomic_runtime"`.
72
+ Raise this cap if PgBouncer logs `too many connections for role "atomic_runtime"`.
81
73
 
82
74
  ### A role for password lookups
83
75
 
84
- PgBouncer checks each client's password against the one PostgreSQL stores, so you do not keep a second copy of every password. It runs a lookup query as a role that can do nothing else. Creating that lookup needs a superuser. On a managed service without one, use the service's own pooler instead, or list each role's password in PgBouncer's `auth_file`. As a superuser, connected to the `atomic` database, run:
76
+ Instead of duplicating user passwords in PgBouncer, configure `auth_query` with a restricted lookup role (`pgbouncer_auth`). Creating this function requires a superuser; on managed services without superuser access, use the provider's built-in pooler or list roles in PgBouncer's `auth_file`.
77
+
78
+ Connected to the `atomic` database as a superuser, run:
85
79
 
86
80
  ```sql
87
81
  CREATE ROLE pgbouncer_auth LOGIN PASSWORD '<auth role password>';
@@ -101,15 +95,11 @@ REVOKE ALL ON FUNCTION pgbouncer.get_auth(text) FROM PUBLIC;
101
95
  GRANT EXECUTE ON FUNCTION pgbouncer.get_auth(text) TO pgbouncer_auth;
102
96
  ```
103
97
 
104
- The function runs with the rights of the superuser who created it, so `pgbouncer_auth` can read one password at a time without reading the password table itself. It returns only the roles you list, never a superuser, so no one can log in through PgBouncer as any other role. List every role your Atomic machines log in as. Declare the result with `RETURNS TABLE`, as above. PgBouncer refuses a lookup that returns a row of empty values, and logs `auth_query response contained null user name`.
105
-
106
- When you change a role's password with `ALTER ROLE`, PgBouncer uses the new one at once. You do not need to reload it.
107
-
108
- Passwords must use SCRAM, PostgreSQL's default since version 14. Check with `SHOW password_encoding;`, which should say `scram-sha-256`.
98
+ `SECURITY DEFINER` lets `pgbouncer_auth` look up only the allowlisted non-superuser roles without direct access to `pg_authid`. List every role Atomic machines log in as, and keep `RETURNS TABLE`—a scalar/record null row causes PgBouncer to log `auth_query response contained null user name`. Password changes via `ALTER ROLE` take effect immediately without reloading PgBouncer. Verify SCRAM encoding with `SHOW password_encoding;` (`scram-sha-256`).
109
99
 
110
100
  ### Who may connect
111
101
 
112
- PostgreSQL's `pg_hba.conf` file decides which hosts may log in. Allow PgBouncer's address, and the machines that run Intercom brokers for their wake-up connections, over TLS:
102
+ Allow PgBouncer, agent hosts (for direct `listenUrl` wake-ups), and your migration host over TLS in `pg_hba.conf`, then reload with `SELECT pg_reload_conf();`:
113
103
 
114
104
  ```text
115
105
  # TYPE DATABASE USER ADDRESS METHOD
@@ -119,11 +109,11 @@ hostssl atomic atomic_runtime 10.0.2.0/24 scram-sha-256
119
109
  hostssl atomic atomic_owner 10.0.3.10/32 scram-sha-256
120
110
  ```
121
111
 
122
- Here `10.0.1.5` is PgBouncer, `10.0.2.0/24` is the network of the agent machines, and `10.0.3.10` is the machine you run `atomic storage migrate` on. Run `atomic storage migrate` against PostgreSQL directly, on port 5432, not through PgBouncer. Reload PostgreSQL after editing the file, for example with `SELECT pg_reload_conf();`.
112
+ Here `10.0.1.5` is PgBouncer, `10.0.2.0/24` is the agent subnet, and `10.0.3.10` runs `atomic storage migrate` directly against PostgreSQL on port `5432` (never through PgBouncer).
123
113
 
124
114
  ## Configure PgBouncer
125
115
 
126
- This configuration is for PgBouncer 1.21 or later, the first version that keeps prepared statements. Save it as `/etc/pgbouncer/pgbouncer.ini`:
116
+ Save this configuration (for PgBouncer 1.21+) as `/etc/pgbouncer/pgbouncer.ini`:
127
117
 
128
118
  ```ini
129
119
  ;; Which databases PgBouncer offers, and where each one really is.
@@ -183,29 +173,31 @@ query_wait_timeout = 120
183
173
  stats_users = pgbouncer_auth
184
174
  ```
185
175
 
186
- Save the lookup role's password as `/etc/pgbouncer/userlist.txt`, readable only by the user PgBouncer runs as:
176
+ Save `pgbouncer_auth`'s password in `/etc/pgbouncer/userlist.txt`, readable only by the PgBouncer service user:
187
177
 
188
178
  ```text
189
179
  "pgbouncer_auth" "<auth role password>"
190
180
  ```
191
181
 
192
- PgBouncer needs this password in readable form, because it logs in to PostgreSQL with it. Every other role's password stays only in PostgreSQL.
182
+ Only `pgbouncer_auth` needs its password in `userlist.txt`; all other role passwords remain solely inside PostgreSQL.
193
183
 
194
184
  ### Choose the pool sizes
195
185
 
196
- - **`default_pool_size`**: how many connections to PostgreSQL PgBouncer opens for Atomic's role. It can be at most what PostgreSQL can spare: `max_connections`, minus the reserved slots, minus one per Intercom broker for wake-ups, minus other clients, minus `reserve_pool_size`. In the example in [When you need PgBouncer](#when-you-need-pgbouncer), that is 137 − 5 = 132. More is not always faster. The [PostgreSQL wiki](https://wiki.postgresql.org/wiki/Number_Of_Database_Connections) suggests about twice the number of CPU cores as a starting point, for example 32 on a 16-core server. The configuration above uses 80, for a server of about 40 cores. Raise it while `cl_waiting` in `SHOW POOLS` stays above `0` and the server's CPU has room. A database far from the agents needs a larger pool than a nearby one, because each transaction holds its connection while it waits for the network.
197
- - **`reserve_pool_size`**: a few extra connections for bursts. PgBouncer lends them only after a client has waited `reserve_pool_timeout` seconds.
198
- - **`max_db_connections`**: a cap on all of PgBouncer's connections to the database. Set it to `default_pool_size` plus `reserve_pool_size`.
199
- - **`max_client_conn`**: how many connections PgBouncer accepts from clients. Connections to PgBouncer are cheap, so set it well above the number of Atomic processes times their pools. Each client connection uses a file descriptor, so raise the PgBouncer server's open-file limit (`ulimit -n`, or `LimitNOFILE` in a systemd unit) above `max_client_conn`.
200
- - **Lock waits hold connections.** A transaction that waits for a lock keeps its PostgreSQL connection while it waits, so waits can fill the pool. If `cl_waiting` climbs while `sv_active` sits at the cap, raise `default_pool_size` and `max_db_connections`, as far as `max_connections` allows.
186
+ - **`default_pool_size`:** Server connections PgBouncer opens for `atomic_runtime`. Must not exceed PostgreSQL's remaining capacity (`max_connections` minus reserved slots, broker wake-ups, other clients, and `reserve_pool_size`—132 in the 150-runner example). Start near 2× server CPU cores (for example `32` on a 16-core server; `80` above assumes ~40 cores) and raise only if `cl_waiting > 0` in `SHOW POOLS` while PostgreSQL CPU has headroom. Higher network latency between agents and PostgreSQL requires a slightly larger pool.
187
+ - **`reserve_pool_size`:** Burst slots lent after a client waits `reserve_pool_timeout` seconds.
188
+ - **`max_db_connections`:** Hard cap on total server connections for `atomic` (`default_pool_size + reserve_pool_size`).
189
+ - **`max_client_conn`:** Client connections accepted by PgBouncer. Set well above `processes × (maxConnections + readerMaxConnections)`, and raise the OS open-file limit (`ulimit -n` / `LimitNOFILE`) above `max_client_conn`.
190
+ - **Lock waits hold pool slots:** Transactions waiting on locks retain their PostgreSQL backend connection. If `cl_waiting` climbs while `sv_active` hits the cap, raise `default_pool_size` and `max_db_connections` within `max_connections`.
201
191
 
202
- With PgBouncer in front, keep Atomic's `maxConnections` at its default of 8 or higher. Atomic's connections only reach PgBouncer, which queues them for its pool.
192
+ Behind PgBouncer, keep Atomic's `maxConnections` at its default of `8` or higher—PgBouncer queues client transactions for its server pool.
203
193
 
204
194
  ### Start PgBouncer
205
195
 
206
- Start PgBouncer with the configuration file, for example `pgbouncer -d /etc/pgbouncer/pgbouncer.ini`, or through your distribution's service, `systemctl restart pgbouncer`. After a change to the file, reload it from PgBouncer's console with `RELOAD;`.
196
+ Start PgBouncer (`pgbouncer -d /etc/pgbouncer/pgbouncer.ini` or `systemctl restart pgbouncer`). After subsequent edits to `pgbouncer.ini`, run `RELOAD;` on PgBouncer's admin console.
207
197
 
208
- The Ubuntu and Debian service starts PgBouncer with a limit of 1024 open files, which is too low for `max_client_conn = 5000`. PgBouncer logs `kernel file descriptor limit: 1024` at start. Raise the limit with a systemd drop-in, then restart:
198
+ <Warning>
199
+ **Ubuntu and Debian default `LimitNOFILE=1024`.** The distro unit starts PgBouncer with only 1,024 file descriptors—too low for `max_client_conn = 5000` (logged as `kernel file descriptor limit: 1024`). Raise the limit with a systemd drop-in, then run `systemctl daemon-reload && systemctl restart pgbouncer`:
200
+ </Warning>
209
201
 
210
202
  ```ini
211
203
  # /etc/systemd/system/pgbouncer.service.d/limits.conf
@@ -213,37 +205,41 @@ The Ubuntu and Debian service starts PgBouncer with a limit of 1024 open files,
213
205
  LimitNOFILE=16384
214
206
  ```
215
207
 
216
- Run `systemctl daemon-reload` and `systemctl restart pgbouncer` after creating the file.
217
-
218
- If PgBouncer runs on the database server and connects to PostgreSQL as `127.0.0.1`, the server's certificate does not name that address. Use `server_tls_sslmode = verify-ca` there, which checks the certificate authority without the host name, or connect by the name the certificate carries.
208
+ <Note>
209
+ If PgBouncer runs on the PostgreSQL host and connects via `127.0.0.1`, PostgreSQL's certificate typically does not include `127.0.0.1`. Use `server_tls_sslmode = verify-ca`, or connect via the hostname on the server certificate.
210
+ </Note>
219
211
 
220
212
  ## Configure Atomic
221
213
 
222
- Point `url` at PgBouncer and `listenUrl` at PostgreSQL. Both use the runtime role and the same password. On each machine:
223
-
224
- 1. Join the database through PgBouncer:
225
-
226
- ```bash
227
- (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
228
- atomic storage join 'postgresql://atomic_runtime@pgbouncer.example.com:6432/atomic' --password-file ~/atomic-db-password
229
- rm ~/atomic-db-password # atomic storage join keeps its own copy
230
- ```
231
-
232
- 2. Add `listenUrl`, which `atomic storage join` has no option for, to the `storage` setting it wrote:
233
-
234
- ```bash
235
- jq '.storage.options.listenUrl = "postgresql://atomic_runtime@db.example.com:5432/atomic"' ~/.atomic/agent/settings.json > ~/.atomic/agent/settings.json.new \
236
- && mv ~/.atomic/agent/settings.json.new ~/.atomic/agent/settings.json
237
- ```
238
-
239
- 3. Restart Intercom, and check that `atomic storage status` reports `wake-ups: LISTEN/NOTIFY`:
240
-
241
- ```bash
242
- atomic intercom restart
243
- atomic storage status
244
- ```
245
-
246
- The setting in `~/.atomic/agent/settings.json` then looks like this. `atomic storage join` created the password file and chose its name, shown here as `storage-token.28ab7041-05e2-4ad5-80af-854329035d8c`. The path is relative to `~/.atomic`:
214
+ Point `url` at PgBouncer and `listenUrl` directly at PostgreSQL (both use `atomic_runtime` and the same password). On each agent machine:
215
+
216
+ <Steps>
217
+ <Step title="Join the database through PgBouncer">
218
+ ```bash
219
+ (umask 077; printf 'Runtime password: '; read -rs password; printf '\n'; printf '%s' "$password" > ~/atomic-db-password)
220
+ atomic storage join 'postgresql://atomic_runtime@pgbouncer.example.com:6432/atomic' --password-file ~/atomic-db-password
221
+ rm ~/atomic-db-password # atomic storage join keeps its own copy
222
+ ```
223
+ </Step>
224
+ <Step title="Add listenUrl to ~/.atomic/agent/settings.json">
225
+ `atomic storage join` does not set `listenUrl`, so add the direct PostgreSQL endpoint:
226
+
227
+ ```bash
228
+ jq '.storage.options.listenUrl = "postgresql://atomic_runtime@db.example.com:5432/atomic"' ~/.atomic/agent/settings.json > ~/.atomic/agent/settings.json.new \
229
+ && mv ~/.atomic/agent/settings.json.new ~/.atomic/agent/settings.json
230
+ ```
231
+ </Step>
232
+ <Step title="Restart Intercom and verify wake-ups">
233
+ ```bash
234
+ atomic intercom restart
235
+ atomic storage status
236
+ ```
237
+
238
+ Confirm `atomic storage status` reports `wake-ups: LISTEN/NOTIFY`.
239
+ </Step>
240
+ </Steps>
241
+
242
+ The resulting `~/.atomic/agent/settings.json` entry looks like this (keep the exact `storage-token.<id>` filename that `atomic storage join` created on your machine; `storage-token.example` is a placeholder):
247
243
 
248
244
  ```json
249
245
  {
@@ -254,14 +250,14 @@ The setting in `~/.atomic/agent/settings.json` then looks like this. `atomic sto
254
250
  "listenUrl": "postgresql://atomic_runtime@db.example.com:5432/atomic",
255
251
  "maxConnections": 8
256
252
  },
257
- "secrets": { "password": { "file": "agent/storage-token.28ab7041-05e2-4ad5-80af-854329035d8c" } }
253
+ "secrets": { "password": { "file": "agent/storage-token.example" } }
258
254
  }
259
255
  }
260
256
  ```
261
257
 
262
- Atomic checks the certificate and host name of both PgBouncer and PostgreSQL. If PgBouncer's certificate comes from a private certificate authority, add `?sslrootcert=/path/to/root.crt` to `url`. See [TLS](/storage/postgres#tls).
258
+ Atomic verifies the certificate and hostname of both PgBouncer and PostgreSQL; append `?sslrootcert=/path/to/root.crt` if signed by a private CA (see [TLS](/storage/postgres#tls)).
263
259
 
264
- The same options in an SDK app:
260
+ Equivalent SDK configuration:
265
261
 
266
262
  ```typescript
267
263
  import { openPostgresDatabase } from "@bastani/atomic-storage-postgres";
@@ -276,28 +272,26 @@ const database = await openPostgresDatabase({
276
272
 
277
273
  ## Check that it works
278
274
 
279
- **Atomic.** Run `atomic storage status` on an agent machine. It should report `wake-ups: LISTEN/NOTIFY`, or `wake-ups: connecting` for a few seconds after a restart. If it reports `wake-ups: polling only, notifications do not pass the URL's transaction pooler`, `listenUrl` is missing or points at PgBouncer.
275
+ **Atomic:** Run `atomic storage status` on an agent host and confirm `wake-ups: LISTEN/NOTIFY` (or `wake-ups: connecting` immediately after restart). If it shows `polling only, notifications do not pass the URL's transaction pooler`, check that `listenUrl` points directly to PostgreSQL.
280
276
 
281
- **PgBouncer.** Connect to PgBouncer's console, a built-in database named `pgbouncer`, as a role listed in `stats_users`:
277
+ **PgBouncer:** Inspect the `atomic` / `atomic_runtime` row via PgBouncer's console:
282
278
 
283
279
  ```bash
284
280
  psql -h pgbouncer.example.com -p 6432 -U pgbouncer_auth pgbouncer -c 'SHOW POOLS'
285
281
  ```
286
282
 
287
- `SHOW POOLS` prints one row per database and role. In the row for `atomic` and `atomic_runtime`:
288
-
289
- | Column | Meaning | What to look for |
283
+ | Column | Meaning | Healthy value |
290
284
  | --- | --- | --- |
291
- | `cl_active` | Clients connected to PgBouncer | Roughly the number of Atomic connections. |
292
- | `cl_waiting` | Clients waiting for a PostgreSQL connection | `0` most of the time. A number that stays above `0` means the pool is too small or the server too slow. |
293
- | `sv_active` | PostgreSQL connections running a transaction | At most `default_pool_size` plus `reserve_pool_size`. |
294
- | `sv_idle` | PostgreSQL connections ready for the next transaction | Some idle connections are normal. |
295
- | `maxwait` | How many seconds the oldest waiting client has waited | Below a second. Higher values mean clients queue for the pool. |
296
- | `pool_mode` | The pool mode | `transaction` |
285
+ | `cl_active` | Client connections to PgBouncer | Roughly total Atomic client pool connections |
286
+ | `cl_waiting` | Clients waiting for a PostgreSQL backend | `0` most of the time; sustained `> 0` indicates pool saturation or slow queries |
287
+ | `sv_active` | Active PostgreSQL server connections | At most `default_pool_size + reserve_pool_size` |
288
+ | `sv_idle` | Ready PostgreSQL server connections | Some idle connections are normal |
289
+ | `maxwait` | Seconds the oldest waiting client has waited | `< 1` second |
290
+ | `pool_mode` | Active pooling mode | `transaction` |
297
291
 
298
- `SHOW CLIENTS` lists each client connection, and `SHOW STATS` shows queries and wait times per database.
292
+ Use `SHOW CLIENTS` and `SHOW STATS` for per-client details and query/wait totals.
299
293
 
300
- **PostgreSQL.** As an administrator, count the connections by application and state. PgBouncer's connections report Atomic's application name `atomic`, and each broker's wake-up connection reports `atomic-listen`:
294
+ **PostgreSQL:** Verify pooled (`atomic`) and direct wake-up (`atomic-listen`) counts on the database server:
301
295
 
302
296
  ```sql
303
297
  SELECT application_name, state, count(*)
@@ -307,38 +301,38 @@ GROUP BY 1, 2
307
301
  ORDER BY 3 DESC;
308
302
  ```
309
303
 
310
- The `atomic` connections should stay at or below PgBouncer's pool size, and there should be one `atomic-listen` connection per broker.
304
+ `atomic` connections should stay at or below PgBouncer's `max_db_connections`, with one `atomic-listen` connection per broker.
311
305
 
312
306
  ## Common errors
313
307
 
314
- Atomic reports these as `StorageUnavailableError` or `StorageTransientError`. The message below is the error's cause, which Atomic prints with the error.
308
+ Atomic wraps these causes in `StorageUnavailableError` or `StorageTransientError`:
315
309
 
316
310
  | Message | Cause | Fix |
317
311
  | --- | --- | --- |
318
- | `no more connections allowed (max_client_conn)` | More clients connected to PgBouncer than `max_client_conn` allows. | Raise `max_client_conn`, and the open-file limit with it. |
319
- | `query_wait_timeout` | A client waited `query_wait_timeout` seconds for a PostgreSQL connection. | Check `cl_waiting` and `maxwait` in `SHOW POOLS`. Raise `default_pool_size` if PostgreSQL has room, or look for long transactions with the queries in [Tuning](/storage/postgres#check-the-effect). |
320
- | `SSL required` | Atomic connected without TLS. Atomic leaves TLS off for addresses on the same machine, such as `localhost`. | Add `?sslmode=verify-full&sslrootcert=/path/to/root.crt` to `url`. |
321
- | `SASL authentication failed` | The password is wrong, the role does not exist, or the database is not listed in `[databases]`. | Check the password file, the role, and the database name. Check that the lookup function exists in that database. |
322
- | `wake-ups: polling only, notifications do not pass the URL's transaction pooler` in `atomic storage status` | `listenUrl` is missing or points at PgBouncer. | Set `listenUrl` to PostgreSQL's own address. |
323
- | `too many connections for role "atomic_runtime"` | The role's `CONNECTION LIMIT` is lower than PgBouncer's pool plus the brokers' wake-up connections. | Raise the limit, or lower `default_pool_size`. |
324
- | `sorry, too many clients already` | PostgreSQL's `max_connections` is lower than PgBouncer's pool plus the wake-up and other connections. | Raise `max_connections`, or lower `default_pool_size` and `max_db_connections`. |
325
- | `prepared statement "atomic_…" does not exist` | Atomic sends prepared statements, but PgBouncer does not keep them: it is older than 1.21, or `max_prepared_statements` is `0`. Atomic turns them on by itself only behind a PgBouncer that keeps them, so this follows setting `maxPreparedStatements` by hand, or changing `max_prepared_statements` while Atomic runs. | Set `max_prepared_statements` above `0` in PgBouncer, or set `maxPreparedStatements` to `0` in Atomic. |
326
- | `unsupported startup parameter: <name>` | A client sent a connection setting that PgBouncer does not forward. Atomic sends only `application_name`, which PgBouncer forwards. | Add the name to `ignore_startup_parameters` for other clients that need it, such as `extra_float_digits` for Java clients. Never add `application_name`. |
327
- | `bouncer config error`, with `auth_query response contained null user name` in PgBouncer's log | The lookup function returned a row of empty values for an unknown role. | Declare the function with `RETURNS TABLE`, as in [A role for password lookups](#a-role-for-password-lookups). |
328
- | `kernel file descriptor limit: 1024` in PgBouncer's log | The service's open-file limit is below `max_client_conn`. | Raise `LimitNOFILE`, as in [Start PgBouncer](#start-pgbouncer). |
312
+ | `no more connections allowed (max_client_conn)` | Client connections exceeded `max_client_conn`. | Raise `max_client_conn` and `LimitNOFILE`. |
313
+ | `query_wait_timeout` | Client waited past `query_wait_timeout` for a server connection. | Check `cl_waiting` / `maxwait` in `SHOW POOLS`, raise `default_pool_size` if PostgreSQL has capacity, or check [active waits](/storage/postgres#check-the-effect). |
314
+ | `SSL required` | Connected without TLS (Atomic skips TLS for `localhost` by default). | Append `?sslmode=verify-full&sslrootcert=/path/to/root.crt` to `url`. |
315
+ | `SASL authentication failed` | Wrong password, unknown role, missing `[databases]` entry, or missing `pgbouncer.get_auth`. | Verify password, role allowlist, database entry, and lookup function. |
316
+ | `wake-ups: polling only, notifications do not pass the URL's transaction pooler` | `listenUrl` is unset or points at PgBouncer. | Point `listenUrl` directly at PostgreSQL. |
317
+ | `too many connections for role "atomic_runtime"` | Role `CONNECTION LIMIT` is below PgBouncer's pool plus broker wake-ups. | Raise `CONNECTION LIMIT` or lower `default_pool_size`. |
318
+ | `sorry, too many clients already` | PostgreSQL `max_connections` is too low for pool + wake-ups + other clients. | Raise `max_connections` or lower `default_pool_size` and `max_db_connections`. |
319
+ | `prepared statement "atomic_…" does not exist` | Prepared statements forced on behind a pooler that drops them, or `max_prepared_statements` was zeroed at runtime. | Set `max_prepared_statements > 0` in PgBouncer 1.21+, or set `maxPreparedStatements: 0` in Atomic. |
320
+ | `unsupported startup parameter: <name>` | Another client sent a startup parameter PgBouncer does not forward (Atomic sends only `application_name`). | Add that parameter to `ignore_startup_parameters` (never add `application_name`). |
321
+ | `bouncer config error` / `auth_query response contained null user name` | `pgbouncer.get_auth` returned a null row for an unknown role. | Declare with `RETURNS TABLE` as in [A role for password lookups](#a-role-for-password-lookups). |
322
+ | `kernel file descriptor limit: 1024` | Service `LimitNOFILE` is below `max_client_conn`. | Raise `LimitNOFILE` (see [Start PgBouncer](#start-pgbouncer)). |
329
323
 
330
324
  ## Managed services
331
325
 
332
- These services include a pooler of their own. Check the service's documentation for its current host names and ports.
333
-
334
- - **Supabase.** The shared pooler, Supavisor, runs transaction mode on port 6543. Point `url` at port 6543 and `listenUrl` at the direct connection on port 5432. Supavisor does not keep prepared statements, so leave `maxPreparedStatements` unset. Atomic keeps them off there, because it does not identify Supavisor as a PgBouncer that keeps them.
335
- - **Neon.** The pooled host name ends in `-pooler` and runs PgBouncer in transaction mode. Point `url` at the pooled host and `listenUrl` at the same host name without `-pooler`.
336
- - **Azure Database for PostgreSQL Flexible Server.** Turn on the built-in PgBouncer with the `pgbouncer.enabled` server parameter, on General Purpose and Memory Optimized tiers. It listens on port 6432 of the same host. Point `listenUrl` at port 5432.
337
- - **Amazon RDS Proxy.** RDS Proxy does not pass `LISTEN`, so point `listenUrl` at the database instance's own endpoint. RDS Proxy listens on port 5432, where Atomic does not expect a pooler, so also set `maxPreparedStatements: 0`.
326
+ | Provider | Pooled endpoint (`url`) | Direct endpoint (`listenUrl`) | Prepared statements |
327
+ | --- | --- | --- | --- |
328
+ | **Supabase** | Supavisor transaction mode on port `6543` | Direct host on port `5432` | Leave `maxPreparedStatements` unset (auto-disabled behind Supavisor) |
329
+ | **Neon** | `-pooler` host (PgBouncer transaction mode) | Same host without `-pooler` | Auto-detected |
330
+ | **Azure Flexible Server** | Built-in PgBouncer (`pgbouncer.enabled`) on port `6432` | Same host on port `5432` | Auto-detected |
331
+ | **Amazon RDS Proxy** | Proxy endpoint (port `5432`) | DB instance endpoint | Set `maxPreparedStatements: 0` explicitly (port `5432` does not auto-detect a pooler) |
338
332
 
339
333
  ## Related pages
340
334
 
341
- - [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents): count connections and size `maxConnections`.
342
- - [Tune PostgreSQL for many agents](/storage/postgres/tuning): the server-side settings that go with PgBouncer.
343
- - [Connection poolers](/storage/postgres#connection-poolers) and [Wake-ups](/storage/postgres#wake-ups) on the PostgreSQL setup page.
344
- - [PgBouncer's configuration reference](https://www.pgbouncer.org/config.html).
335
+ - [Tuning for many concurrent agents](/storage/postgres#tuning-for-many-concurrent-agents): connection arithmetic and `maxConnections` sizing.
336
+ - [Tune PostgreSQL for many agents](/storage/postgres/tuning): server memory, `pg_stat_statements`, autovacuum, and `lz4` compression.
337
+ - [Connection poolers](/storage/postgres#connection-poolers) and [Wake-ups](/storage/postgres#wake-ups).
338
+ - [PgBouncer configuration reference](https://www.pgbouncer.org/config.html).