Skip to content

feat(db-postgres): pool options, tested behind PgBouncer - #204

Merged
maritonx merged 1 commit into
mainfrom
feat/postgres-pool-options
Oct 24, 2026
Merged

maritonx merged 1 commit into
mainfrom
feat/postgres-pool-options

Conversation

@maritonx

Copy link
Copy Markdown
Owner

Closes #155 (M5, ADR-0055).

What changes

  • postgres() takes prepare, statementTimeoutMs, idleTimeoutMs, connectTimeoutMs and applicationName. Timeouts are in ms, like busyTimeoutMs of db-sqlite.
  • Connections are named easy-cms in pg_stat_activity, or PGAPPNAME when that is set. postgres.js named them postgres.js before.
  • Only the options you set are passed to postgres.js. That way the URL (?prepare=false) and the PG* variables still apply.

CI

  • New pgbouncer job runs the Postgres integration suites through PgBouncer 1.26 in transaction mode, with prepare: false.
  • The postgres job also checks application_name.

Docs

The Databases guide (EN/TH) has a new Connections section:

  • the options
  • connections = instances × max, kept under 10–20% of max_connections
  • serverless needs a pooler and a small max
  • prepare: false unless the pooler keeps prepared statements (PgBouncer does from 1.24)
  • statement_timeout goes on the role behind PgBouncer

ADR-0055 and the roadmap are updated to the …Ms names.

Verified locally (Docker: Postgres 17 + PgBouncer 1.26, transaction mode)

  • Direct connection: 350 passed.
  • Through PgBouncer with prepare: false: 349 passed; the application_name test skips there.
  • Through PgBouncer with prepare: true: also passes on 1.26. The docs only promise this from 1.24.
  • PgBouncer refuses the statement_timeout startup parameter ("unsupported startup parameter"), as the docs say.
  • pnpm turbo run test --continue 53/53, typecheck and biome ci pass.
  • e2e not run: it uses PGlite, which this PR does not change.

🤖 Generated with Claude Code

Adds `prepare`, `statementTimeoutMs`, `idleTimeoutMs`, `connectTimeoutMs`
and `applicationName` (default `PGAPPNAME`, then `easy-cms`). Only options
that are set reach postgres.js, so the URL and PG* variables still apply.

CI runs the Postgres integration suites through PgBouncer 1.26 in
transaction mode with prepared statements off. The Databases guide (EN/TH)
covers pool sizing, serverless and poolers. ADR-0055 and the roadmap use
the `…Ms` names, like `busyTimeoutMs` of the SQLite adapter.

Closes #155

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@maritonx
maritonx merged commit ebdeca3 into main Oct 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable Postgres pool and prepare, tested behind PgBouncer

1 participant