: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(snowflake): treat mid-stream connection resets as retryable (#99873)
Tom Owers41b515d971c6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.pyindex 55a4cfae22cc..3fb17d625c72 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/source.py@@ -374,6 +374,14 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig]):# so Temporal-level retries will eventually succeed. The attempt count is volatile, so we# match the stable prefix."Could not connect to Snowflake backend after",+ # requests (vendored by the connector) raises ChunkedEncodingError when the peer resets+ # the TCP connection (ECONNRESET) while streaming a query result's chunked HTTP response+ # body. This happens after the connector's own request-retry wrapper has already handed+ # back the response object, so it isn't covered by that retry budget. A fresh Temporal-level+ # retry opens a new connection and re-executes the query from scratch, which recovers+ # cleanly, so this is a self-recovering network blip rather than a bug. The errno and OS-+ # specific wrapping vary, so we match the stable requests-library wrapper phrase.+ "Connection broken: ConnectionResetError",}def reconcile_schema_metadata(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.pyindex 33790405bdbd..6ac9cf72959e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/snowflake/tests/test_snowflake.py@@ -979,6 +979,18 @@ class TestSnowflakeSourceRetryableErrors:is_retryable = any(pattern in error_msg for pattern in retryable)assert is_retryable, f"Proxy-502 backend-connection failure should be classified retryable: {error_msg}"+ def test_connection_reset_mid_stream_is_retryable(self, source):+ # The real shape from production: a ChunkedEncodingError wrapping a ConnectionResetError,+ # raised while streaming a query result's chunked HTTP body. The errno and nested quoting vary+ # by OS; the stable requests-library wrapper phrase is matched.+ error_msg = (+ "('Connection broken: ConnectionResetError(104, \"(104, 'ECONNRESET')\")', "+ "ConnectionResetError(104, \"(104, 'ECONNRESET')\"))"+ )+ retryable = source.get_retryable_errors()+ is_retryable = any(pattern in error_msg for pattern in retryable)+ assert is_retryable, f"Mid-stream connection-reset error should be classified retryable: {error_msg}"+class TestSnowflakeValidateCredentials:@pytest.fixture