: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(redshift): recognize SSL EOF drops as retryable during setup (#98089)
Tom Owers57e297aa93ed
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/redshift.py b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/redshift.pyindex 82c14c82dc70..bec8806dd81e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/redshift.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/redshift.py@@ -405,12 +405,18 @@ _MAX_SETUP_CONNECTION_DROP_ATTEMPTS = 3# Substrings psycopg uses for a transient socket drop around sync setup. "the connection is lost"# is the message libpq gives when an already-open connection dies. "server closed the connection# unexpectedly" is the message when the socket dies during the connect handshake ("connection-# failed: ... server closed the connection unexpectedly"). Both are the same transient class — a-# network blip or a cluster pause/resize — and recover by reconnecting. Keep this narrow so a+# failed: ... server closed the connection unexpectedly"). "consuming input failed" is libpq's+# wrapper when the drop is detected while reading a query's response (e.g. `get_table_metadata`'s+# `information_schema.columns` lookup) rather than at connect time — it also prefixes "ssl syscall+# error", the socket-level form of a TLS drop (handshake or read EOF). All are the same transient+# class — a network blip or a cluster pause/resize — and recover by reconnecting. Mirrors the+# equivalent Postgres source's `_CONNECTION_DROPPED_ERROR_SUBSTRINGS`. Keep this narrow so a# permanent failure such as "password authentication failed" is never retried in-process._TRANSIENT_CONNECTION_DROP_SUBSTRINGS = ("the connection is lost","server closed the connection unexpectedly",+ "consuming input failed",+ "ssl syscall error",)@@ -423,7 +429,7 @@ def _is_transient_connection_drop_error(error: BaseException) -> bool:"""if not isinstance(error, psycopg.OperationalError):return False- message = str(error)+ message = str(error).lower()return any(substring in message for substring in _TRANSIENT_CONNECTION_DROP_SUBSTRINGS)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/tests/test_redshift.py b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/tests/test_redshift.pyindex 81b9030977cb..12774276bd55 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/tests/test_redshift.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/redshift/tests/test_redshift.py@@ -1390,6 +1390,17 @@ class TestIsTransientConnectionDropError:is True)+ def test_matches_consuming_input_failed_ssl_syscall_error(self):+ # Regression: a drop detected while reading a query's response (e.g. `get_table_metadata`+ # mid-probe) surfaces as "consuming input failed: SSL SYSCALL error: EOF detected" rather+ # than either message above, and previously fell through to a full Temporal activity retry.+ assert (+ _is_transient_connection_drop_error(+ psycopg.OperationalError("consuming input failed: SSL SYSCALL error: EOF detected")+ )+ is True+ )+def test_does_not_match_unrelated_operational_error(self):# A permanent, non-actionable failure that also raises OperationalError must not be# swept up by the narrow "the connection is lost" match and retried in-process.