: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(postgres): treat Supavisor's auth_query secret-check timeout as a transient drop (#74952)
Tom Owers09f2573464a8
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 d349f9959883..bddb75621bdd 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@@ -228,6 +228,17 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (# ("password authentication failed", "SASL authentication failed"), and exclude the volatile# millisecond value."authentication did not complete within",+ # Supavisor authenticates a tenant with no static user record by running an `auth_query` against+ # the tenant's own backend database to fetch/cache the password secret used to validate the+ # client's credentials. If that secret isn't cached yet (e.g. right after Supavisor starts+ # managing the tenant) and the backend is briefly slow to answer, Supavisor's own wait for the+ # secret times out and it refuses the connect with a bare OperationalError carrying its+ # "(EAUTHQUERY)" code: "FATAL: (EAUTHQUERY) auth_query secret check timed out". This is a race in+ # the pooler's own bookkeeping, not a rejection of the credentials, so a fresh connect once the+ # secret is cached typically succeeds — recover by reconnecting rather than failing the whole+ # activity. Match the stable code, distinct from genuine credential-rejection wordings+ # ("password authentication failed", "SASL authentication failed").+ "(eauthquery)",# 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 4313fae5129b..4b5246f38bbb 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@@ -1532,6 +1532,14 @@ class TestIsConnectionDroppedError:psycopg.errors.ConnectionFailure("Failed to connect to database: authentication did not complete within 15000ms"),+ # Supavisor's own auth_query secret lookup (used to authenticate a tenant with no static+ # user record) times out waiting for the backend, reporting a bare OperationalError+ # carrying its "(EAUTHQUERY)" code. A race in the pooler's bookkeeping, not a credential+ # rejection — transient and recovers once the secret is cached.+ psycopg.OperationalError(+ 'connection failed: connection to server at "10.0.0.1", port 5432 failed: '+ "FATAL: (EAUTHQUERY) auth_query secret check timed out"+ ),# 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