: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): recover transient proxy auth-timeout connects in-process (#67032)
Tom Owerse27738d17711
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 f920b90327c7..f893b2b570d6 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@@ -192,6 +192,15 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (# "{:error, :etimedout}". Same transient class as the libpq drops above — recover by# reconnecting. The Erlang-tuple wording is the stable, low-false-positive signal."{:error, :etimedout}",+ # Neon's proxy reports a compute that didn't finish waking from scale-to-zero before the+ # auth handshake deadline as a ConnectionFailure (SQLSTATE 08006, an OperationalError):+ # "Failed to connect to database: authentication did not complete within <n>ms". The wake is+ # transient (a suspended compute reactivates in seconds), so a fresh connect after a short+ # backoff succeeds — recover by reconnecting rather than failing the whole activity. Match the+ # timeout phrasing, which is distinct from the permanent credential-rejection wordings+ # ("password authentication failed", "SASL authentication failed"), and exclude the volatile+ # millisecond value.+ "authentication did not complete within",)# Supavisor (Supabase's connection pooler) doesn't surface a dropped upstream connection with adiff --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 b74b773b6c9c..ead589d2d902 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@@ -1062,6 +1062,11 @@ class TestIsConnectionDroppedError:# ConnectionFailure (08006, an OperationalError) carrying the Erlang-tuple reason# "{:error, :etimedout}" — a transient drop the in-process recovery must catch.psycopg.errors.ConnectionFailure("Failed to connect to database: {:error, :etimedout}"),+ # Neon's proxy reports a compute that didn't wake from scale-to-zero before the auth+ # deadline as a ConnectionFailure — a transient drop the in-process recovery must catch.+ psycopg.errors.ConnectionFailure(+ "Failed to connect to database: authentication did not complete within 15000ms"+ ),],)def test_connection_dropped_errors_are_detected(self, error):