Repository navigation
Retry PostgreSQL queries without statement_timeout behind PgBouncer - #1323
Merged
Merged
Conversation
helpcodeai
enabled auto-merge (squash)
October 29, 2026 08:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A PostgreSQL DATABASE connector behind PgBouncer fails on every query.
executePostgrespassesstatement_timeoutin thePoolconfig, node-postgres sends it as a startup parameter, and PgBouncer answersunsupported startup parameter: statement_timeout(SQLSTATE 08P01). The connection test passes, because it does not set the timeout. Reported in #1296 after the multi-connector fix made that connector reachable.Changes
database.engine.ts:executePostgresstill setsstatement_timeout(60 s) on the server first. When the error saysunsupported startup parameter, it retries once with node-postgres' client-sidequery_timeout(same 60 s) instead. Any other error is thrown as before.runPostgres, unchanged.SET statement_timeoutafter connecting: with PgBouncer in transaction mode the setting would stay on the server connection and reach other clients.Type
Testing
Three new tests in
database.engine.spec.ts: server timeout by default, retry withquery_timeout(and nostatement_timeout) on the PgBouncer error, no retry on other errors.In
packages/backend, afternpx prisma generate:npm run lint: OK (no unrelated rewrites).npx tsc --noEmit -p tsconfig.json: OK.npm test: 800 suites passed, 4 skipped; 23,694 tests passed, 1,625 skipped.Checklist
npm test)Related Issues
Relates to #1296.