diff --git a/snuba/web/constants.py b/snuba/web/constants.py index ce4153885a..b7d9dc3256 100644 --- a/snuba/web/constants.py +++ b/snuba/web/constants.py @@ -16,6 +16,8 @@ *CLICKHOUSE_TYPING_ERROR_CODES, # queries that can never return the amount of data requested by the user are not an internal error ErrorCodes.MEMORY_LIMIT_EXCEEDED, + # query exceeded the max_bytes_to_read limit set by an allocation policy + ErrorCodes.TOO_MANY_BYTES, } NON_RETRYABLE_CLICKHOUSE_ERROR_CODES = { diff --git a/snuba/web/db_query.py b/snuba/web/db_query.py index 2a17a3f84c..90698a8ed4 100644 --- a/snuba/web/db_query.py +++ b/snuba/web/db_query.py @@ -476,12 +476,6 @@ def _raw_query( elif isinstance(cause, ClickhouseError): error_code = cause.code status = get_query_status_from_error_codes(error_code) - if error_code == ErrorCodes.TOO_MANY_BYTES: - calculated_cause = RateLimitExceeded( - "Query scanned more than the allocated amount of bytes", - quota_allowance=stats["quota_allowance"], - ) - with configure_scope() as scope: fingerprint = ["{{default}}", str(cause.code), dataset_name] if error_code not in constants.CLICKHOUSE_SYSTEMATIC_FAILURES: diff --git a/tests/test_snql_api.py b/tests/test_snql_api.py index 32dcb4e170..c7f0647339 100644 --- a/tests/test_snql_api.py +++ b/tests/test_snql_api.py @@ -1329,12 +1329,9 @@ def test_allocation_policy_max_bytes_to_read(self) -> None: } ), ) - assert response.status_code == 429 - - assert ( - response.json["error"]["message"] - == "Query scanned more than the allocated amount of bytes" - ) + assert response.status_code == 400 + assert response.json["error"]["type"] == "clickhouse" + assert response.json["error"]["code"] == 307 expected_quota_allowance = { "details": { @@ -1373,7 +1370,7 @@ def test_allocation_policy_max_bytes_to_read(self) -> None: }, } - assert response.json["quota_allowance"] == expected_quota_allowance + assert response.json["stats"]["quota_allowance"] == expected_quota_allowance def test_allocation_policy_violation(self) -> None: with patch(