Skip to content

feat(snuba): handle TOO_MANY_BYTES as clickhouse error instead of 429#109747

Open
cvxluo wants to merge 1 commit intomasterfrom
cvxluo/tkrxrnrvplzu
Open

feat(snuba): handle TOO_MANY_BYTES as clickhouse error instead of 429#109747
cvxluo wants to merge 1 commit intomasterfrom
cvxluo/tkrxrnrvplzu

Conversation

@cvxluo
Copy link
Copy Markdown
Contributor

@cvxluo cvxluo commented Mar 2, 2026

Add QueryBytesScannedExceeded exception for ClickHouse error code 307 (TOO_MANY_BYTES). This is raised when a query exceeds the max_bytes_to_read limit set by an allocation policy.

…e limit

Add QueryBytesScannedExceeded exception for ClickHouse error code 307
(TOO_MANY_BYTES). This is raised when a query exceeds the max_bytes_to_read
limit set by an allocation policy, distinct from Snuba-level rate limiting.

- Add QueryBytesScannedExceeded to clickhouse_error_codes_map (code 307)
- Handle it explicitly in handle_query_errors() before the generic
  QueryExecutionError catch, returning a descriptive error message

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 2, 2026
@cvxluo cvxluo marked this pull request as ready for review March 2, 2026 23:52
@cvxluo cvxluo requested review from a team as code owners March 2, 2026 23:52
Copy link
Copy Markdown
Member

@kylemumma kylemumma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain how this is different from snuba allocation policy? Allocation policy exceeded seems like a 4xx error not a 5xx

@cvxluo
Copy link
Copy Markdown
Contributor Author

cvxluo commented Mar 12, 2026

Could you explain how this is different from snuba allocation policy? Allocation policy exceeded seems like a 4xx error not a 5xx

@onewland has more context, this is in conjunction with getsentry/snuba#7782 such that if a user runs a query that will always exceed their bytes scanned allocation policy, they get a 400 rather than a 429. not sure if we want to continue this direction though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants