Skip to content

fix: DB connection resilience — retry logic, parallel queries, PgBouncer compat#1989

Closed
EmmaLouise2018 wants to merge 2 commits intomainfrom
EmmaLouise2018/fix-deployments
Closed

fix: DB connection resilience — retry logic, parallel queries, PgBouncer compat#1989
EmmaLouise2018 wants to merge 2 commits intomainfrom
EmmaLouise2018/fix-deployments

Conversation

@EmmaLouise2018
Copy link
Copy Markdown
Contributor

@EmmaLouise2018 EmmaLouise2018 commented Apr 8, 2026

Summary

  • Adds retry logic (3 attempts with linear backoff) to seat-request-reminders scheduled job so transient DB connection timeouts don't silently skip the hourly check
  • Parallelizes the two independent queries in findStaleSeatRequests() via Promise.all, halving timeout exposure
  • Moves statement_timeout=30000 from Pool startup options to a per-connection SET handler for PgBouncer compatibility

Root Cause

  • seat-request-reminders calls findStaleSeatRequests() with no retry — a single DB timeout causes the check to fail until the next hourly interval
  • The two queries in findStaleSeatRequests() ran sequentially, doubling the window for connection drops
  • PR fix: DB outage resilience — statement timeout + 503 health check #1983 added options: '-c statement_timeout=30000' to the Pool constructor, but PgBouncer rejects startup parameters

Test Plan

  • Unit tests pass (563/563)
  • TypeScript compiles clean
  • Deploy to Fly.io and verify seat-request-reminders no longer logs connection timeout errors
  • Verify migration release command succeeds (PgBouncer compat)

…parameter

Fly.io's managed Postgres (behind PgBouncer) rejects statement_timeout
as a startup parameter in the connection options string. Move the 30s
query timeout to a pool.on("connect") handler so it's set via SET after
connection establishment, which is universally supported.
@EmmaLouise2018 EmmaLouise2018 requested a review from bokelley April 8, 2026 04:47
@EmmaLouise2018 EmmaLouise2018 changed the title fix: use per-connection SET for statement_timeout (PgBouncer compat) fix: DB connection resilience — retry logic, parallel queries, PgBouncer compat Apr 8, 2026
@EmmaLouise2018 EmmaLouise2018 force-pushed the EmmaLouise2018/fix-deployments branch from 6df7677 to 624084c Compare April 8, 2026 04:49
…ries

Transient DB connection timeouts caused the hourly seat-request reminder
check to fail silently until the next interval. This adds a 3-attempt
retry with linear backoff around findStaleSeatRequests(), and runs the
two independent queries in parallel via Promise.all to halve the timeout
exposure window.
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.

1 participant