Skip to content

: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.

fix(data-warehouse): stop retrying snowflake resource monitor quota errors (#120448)

Tom Owerse2f795e6faac
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.py
index 6b46df43e300..10ba088de0fc 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
@@ -324,6 +324,10 @@ class SnowflakeSource(SQLSource[SnowflakeSourceConfig], ResumableSource[Snowflak
# warehouse is missing/suspended or the role lacks USAGE on it — it just leaves the session
# warehouse unset. Retrying can never succeed until the customer fixes the grant or warehouse.
"No active warehouse selected in the current session": "No active warehouse is available for this connection. Check that the configured warehouse exists, is running, and that the connecting role has USAGE on it, then resync.",
+ # Snowflake error 090073 (22000): the warehouse can't resume because the customer's resource
+ # monitor used its credit quota. Only the customer can fix it, so retrying never succeeds.
+ # The query id and names are volatile, so we match the stable phrase.
+ "cannot be resumed because resource monitor": "Your Snowflake warehouse can't resume because its resource monitor has used its credit quota. Raise the quota or wait for it to reset, then resync.",
# Snowflake error 090105 (22000): the session has no current database, so the first query
# that references an unqualified object (our `information_schema` listing query) fails. The
# connector doesn't fail at connect time when the configured database is missing or the role
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.py
index 50e449cf45a7..ccc53c880fc7 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
@@ -1019,6 +1019,34 @@ class TestSnowflakeSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"No-active-warehouse error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg,expected_non_retryable",
+ [
+ (
+ "090073 (22000): 01c00000-0000-0000-0000-000000000000: Warehouse 'EXAMPLE_WH' cannot be resumed "
+ "because resource monitor 'EXAMPLE_MONITOR' has exceeded its quota.",
+ True,
+ ),
+ (
+ "Warehouse 'EXAMPLE_WH' cannot be resumed because resource monitor 'EXAMPLE_MONITOR' has exceeded its quota.",
+ True,
+ ),
+ ("090001 (22000): 01c00000-0000-0000-0000-000000000000: Warehouse 'EXAMPLE_WH' cannot be resumed.", False),
+ (
+ "000606 (57P03): 01c00000-0000-0000-0000-000000000000: Statement reached its statement or warehouse timeout.",
+ False,
+ ),
+ ],
+ )
+ def test_resource_monitor_quota_is_non_retryable_only_for_that_error(
+ self, source, error_msg, expected_non_retryable
+ ):
+ non_retryable = source.get_non_retryable_errors()
+ matches = [message for pattern, message in non_retryable.items() if pattern in error_msg]
+ assert bool(matches) is expected_non_retryable
+ if expected_non_retryable:
+ assert all(message is not None and "resource monitor" in message for message in matches)
+
@pytest.mark.parametrize(
"error_msg",
[