: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): propagate a dropped connection during the duplicate-key check (#80207)
Tom Owers988d16230b03
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 27586739bfcd..97d5db656490 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@@ -1038,6 +1038,12 @@ class RedshiftImplementation(SQLSourceImplementation[RedshiftSourceConfig, psycoreturn row is not Noneexcept psycopg.errors.QueryCanceled:raise+ except psycopg.OperationalError:+ # A connection-level failure (e.g. the SSL connection dropping mid-query) means the+ # probe never ran — swallowing it as "no duplicate keys" would be a false negative.+ # Propagate it so the activity's retry path handles it; these are transient and stay+ # retryable. Mirrors the equivalent Postgres source.+ raiseexcept Exception as e:# A Redshift system-requested query abort (error code 1020, "system requested abort")# is the cluster's WLM/QMR cancelling the query — the same transient, non-actionablediff --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 c801d99d8f14..c79b4cfbc3b4 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@@ -794,6 +794,20 @@ class TestHasDuplicatePrimaryKeys:assert impl.has_duplicate_primary_keys(cursor, "public", "t", ["id"], logger) is Falsemock_capture.assert_called_once()+ def test_operational_error_is_propagated(self, impl, cursor, logger):+ # A connection-level failure (e.g. the SSL connection dropping mid-query) means the probe+ # never ran — swallowing it as "no duplicate keys" would be a false negative, so it must+ # propagate instead of being reported to error tracking and defaulted to False.+ cursor.execute.side_effect = psycopg.OperationalError(+ "consuming input failed: SSL connection has been closed unexpectedly"+ )+ with patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.redshift.redshift.capture_exception"+ ) as mock_capture:+ with pytest.raises(psycopg.OperationalError):+ impl.has_duplicate_primary_keys(cursor, "public", "t", ["id"], logger)+ mock_capture.assert_not_called()+def test_system_requested_abort_is_not_reported(self, impl, cursor, logger):# Redshift WLM/QMR aborts (code 1020, "system requested abort") surface as `InternalError_`# and are expected, non-actionable noise — skip gracefully without reporting to error tracking.