: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(warehouse-sources): classify snowflake client-timeout cancellation as retryable (#110363)
Tom Owersb234c7c923c3
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 7a8b6b1e1e6e..7b9882c1ae3a 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@@ -412,6 +412,15 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig], ResumableSource[Snowflak# cleanly once the backend blip clears, so this is self-recovering rather than a bug.# The errno prefix is volatile, so we match the stable status text."HTTP 503: Service Unavailable",+ # Snowflake error 000604 (57014): the connector arms a client-side "timebomb" on+ # `cursor.execute()` using `network_timeout` (see `_SNOWFLAKE_QUERY_TIMEOUT_SECONDS`) and+ # cancels the query once it elapses. The metadata/listing queries (column discovery,+ # primary-key and clustering-key lookups) don't pass the long explicit per-query timeout,+ # so they inherit the shorter connection-level one — usually plenty, but a cold warehouse+ # resume or a transient backend slowdown can push a catalog scan past it. A fresh attempt+ # opens a new connection and re-executes from scratch, so this is self-recovering rather+ # than a bug. The query id in the message is volatile, so we match the stable phrase.+ "SQL execution was cancelled by the client due to a timeout",}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 c5251ba6653c..1b0f2966a29d 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@@ -1198,6 +1198,17 @@ class TestSnowflakeSourceRetryableErrors:is_retryable = any(pattern in error_msg for pattern in retryable)assert is_retryable, f"Backend service-unavailable error should be classified retryable: {error_msg}"+ def test_client_query_timeout_cancellation_is_retryable(self, source):+ # The real shape from production: a metadata-listing query (column discovery) ran past the+ # connector's client-side `network_timeout` timebomb and was cancelled. The query id is volatile.+ error_msg = (+ "000604 (57014): 01c77269-0209-c610-0090-351520cb5b97: SQL execution was cancelled by the "+ "client due to a timeout. Error message received from the server: SQL execution canceled"+ )+ retryable = source.get_retryable_errors()+ is_retryable = any(pattern in error_msg for pattern in retryable)+ assert is_retryable, f"Client-side query-timeout cancellation should be classified retryable: {error_msg}"+class TestSnowflakeValidateCredentials:@pytest.fixture