:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-imports): retry postgres connects blocked by a pooler credential circuit breaker (#80237)
Tom Owers7ad56d1a337e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.pyindex f402abd3d702..9ce7725b8a76 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/postgres.py@@ -247,6 +247,16 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (# activity. Match the stable code, distinct from genuine credential-rejection wordings# ("password authentication failed", "SASL authentication failed")."(eauthquery)",+ # Supavisor caches the per-tenant database credentials it needs to authenticate and proxy+ # connections; when it can't fetch them (e.g. its own metadata store is briefly unreachable) it+ # retries internally and, after exhausting those attempts, trips an internal circuit breaker+ # that rejects new connects outright rather than retrying forever: a bare OperationalError+ # carrying "(ECIRCUITBREAKER) failed to retrieve database credentials after multiple attempts,+ # new connections are temporarily blocked". Same class as EAUTHQUERY above — the pooler's own+ # bookkeeping failing, not a rejection of the client's credentials — and the breaker resets once+ # the fetch succeeds again, so a fresh connect after backoff typically recovers. Match the+ # stable code, distinct from genuine credential-rejection wordings.+ "(ecircuitbreaker)",# pgcat (a Rust Postgres pooler) refuses to hand out a backend when every server in the pool is# currently banned/down — a failed health check bans a server and pgcat auto-unbans it after# `ban_time` — reporting it as SQLSTATE 58000 ("could not get connection from the pool -diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.pyindex ebf08cf37888..ea0abdec9801 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py@@ -1682,6 +1682,15 @@ class TestIsConnectionDroppedError:'connection failed: connection to server at "10.0.0.1", port 5432 failed: '"FATAL: (EAUTHQUERY) auth_query secret check timed out"),+ # Supavisor's own credential fetch fails repeatedly and trips its internal circuit+ # breaker, rejecting new connects with a bare OperationalError carrying its+ # "(ECIRCUITBREAKER)" code. Same transient pooler-bookkeeping class as EAUTHQUERY —+ # recovers once the breaker resets — so the reconnect must catch it.+ psycopg.OperationalError(+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: '+ "FATAL: (ECIRCUITBREAKER) failed to retrieve database credentials after multiple "+ "attempts, new connections are temporarily blocked"+ ),# pgcat refuses to hand out a backend when every pooled server is banned/down, reporting# it as SQLSTATE 58000 (psycopg's SystemError, an OperationalError) rather than the# Supavisor XX000 InternalError_ codes above. Transient — a banned server rejoins on a