: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): retry Supavisor pooler connect timeouts in-process (#64680)
Tom Owers466061a21435
diff --git a/posthog/temporal/data_imports/sources/postgres/postgres.py b/posthog/temporal/data_imports/sources/postgres/postgres.pyindex a21ec4f86483..9e7efa83774e 100644--- a/posthog/temporal/data_imports/sources/postgres/postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/postgres.py@@ -154,6 +154,12 @@ _CONNECTION_DROPPED_ERROR_SUBSTRINGS = (# raises this from inside a wait, e.g. the commit at the end of get_connection).# Same transient dead-socket class as the libpq drops above — recover by reconnecting."the connection is lost",+ # Supabase's Supavisor pooler reports a transient failure to reach the upstream backend (TCP+ # timeout while the backend is briefly unreachable — failover, idle cull, restart) as a+ # ConnectionFailure (SQLSTATE 08006, an OperationalError) carrying the Erlang-tuple reason+ # "{: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}",)# Supavisor (Supabase's connection pooler) doesn't surface a dropped upstream connection with adiff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex 3af6269d448f..2bac406f4e60 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -752,6 +752,10 @@ class TestIsConnectionDroppedError:psycopg.errors.InternalError_("(EDBHANDLEREXITED) connection to database closed. Check logs for more information"),+ # Supavisor reports a transient timeout reaching the upstream backend as a+ # 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}"),],)def test_connection_dropped_errors_are_detected(self, error):