: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): keep transient SSL connection drops retryable (#63798)
Tom Owers0d92f325b6c0
diff --git a/posthog/temporal/data_imports/sources/postgres/source.py b/posthog/temporal/data_imports/sources/postgres/source.pyindex bc58d1b92eda..8330fffb4d38 100644--- a/posthog/temporal/data_imports/sources/postgres/source.py+++ b/posthog/temporal/data_imports/sources/postgres/source.py@@ -191,7 +191,14 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa"password authentication failed for user": None,"No primary key defined for table": None,"failed: timeout expired": None,- "SSL connection has been closed unexpectedly": None,+ # NOTE: "SSL connection has been closed unexpectedly" is intentionally NOT listed here.+ # It denotes an established SSL connection being dropped mid-stream (idle cull by a+ # pooler, failover, network blip) — a transient condition that recovers on a fresh+ # attempt. It is the SSL-flavoured sibling of the "consuming input failed" drops handled+ # by `_CONNECTION_DROPPED_ERROR_SUBSTRINGS` in postgres.py. Marking it non-retryable+ # permanently disabled syncs on a transient blip during schema discovery, which has no+ # in-process reconnect. A genuinely unsupported-SSL source fails at connect time with a+ # different message and is caught via "SSLRequiredError" / "SSL/TLS connection is required"."Address not in tenant allow_list": None,"FATAL: no such database": None,"does not exist": None,diff --git a/posthog/temporal/data_imports/sources/postgres/test_postgres.py b/posthog/temporal/data_imports/sources/postgres/test_postgres.pyindex 1651a16baa5e..af78fafa876e 100644--- a/posthog/temporal/data_imports/sources/postgres/test_postgres.py+++ b/posthog/temporal/data_imports/sources/postgres/test_postgres.py@@ -185,6 +185,10 @@ class TestPostgresSourceNonRetryableErrors:'OperationalError: connection failed: connection to server at "10.0.0.1", port 5432 failed: FATAL: MaxClientsInSessionMode: max clients reached','OperationalError: connection failed: connection to server at "10.0.0.1", port 5432 failed: FATAL: remaining connection slots are reserved for roles with the SUPERUSER attribute','OperationalError: connection failed: connection to server at "10.0.0.1", port 5432 failed: FATAL: too many connections for role "user"',+ # Mid-stream SSL/connection drops during schema discovery — the pooler culled an idle+ # connection or the socket died. A fresh attempt reconnects, so these must stay retryable.+ "consuming input failed: SSL connection has been closed unexpectedly",+ "the connection is lost",],)def test_transient_connection_errors_are_retryable(self, source, error_msg):