Repository navigation
Conversation
prometheusQueryRange() returns one row per series with all its samples, so max_result_rows did not bound the response. One wide range query could return a body large enough to run the API out of memory. Set max_result_bytes (8 MB) next to max_result_rows, like the 8 MB read limit of the HTTP backends. Closes ClickHouse#3836
|
@bcanvural is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: 67ea546 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
PR Review✅ No issues found. |
Deep Review✅ No critical issues found. This is a tight, well-scoped fix: a single ClickHouse 🟡 P2 -- recommended
🔵 P3 nitpicks (2)
Reviewers (9): correctness, testing, maintainability, project-standards, reliability, kieran-typescript, previous-comments, agent-native, learnings. Testing gaps: Error-path coverage for the result-size cap (ClickHouse rejecting the body → router 400 mapping) is absent; only the happy path and setting-forwarding are exercised. No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
|
Thanks. No code change for these:
|
Closes #3836
Problem
With
promqlBackend: table-function, PromQL queries ran withmax_result_rows(100,000) as the only result limit.prometheusQueryRange()returns one row per series with all its samples, so the row limit does not bound the size. One wide range query without aggregation returned a body too large for the API:Invalid string length, then the process was OOM-killed. The HTTP backends stop reading at 8 MB (PROMETHEUS_MAX_RESPONSE_BYTES) and fail the same query cleanly.Change
max_result_bytes(8 MB,PROMETHEUS_MAX_RESULT_BYTES) next tomax_result_rowsinPROMQL_TABLE_FUNCTION_SETTINGS. This covers range and instant queries.Limit for result exceeded, max bytes: 8.00 MiB, current bytes: 11.23 MiB.Testing
/query_rangeand/queryon the table-function path sendmax_result_bytes. Both fail without the change.TOO_MANY_ROWS_OR_BYTES(HTTP 500) before it sends any data, and the API returns the 400 above.Note
Low Risk
Defensive query limit on the PromQL table-function path; reduces OOM risk without changing auth or data models.
Overview
Adds an 8 MB byte cap (
PROMETHEUS_MAX_RESULT_BYTES) on PromQL evaluations that use the ClickHousetable-functionbackend (prometheusQuery/prometheusQueryRange). Row limits alone were unsafe because each result row is a full series with all samples, which could OOM the API on wide range queries.The limit is applied via ClickHouse
max_result_bytesinPROMQL_TABLE_FUNCTION_SETTINGS(instant and range queries). Oversized results fail with a Limit for result exceeded style error instead of crashing the process, aligning memory bounds with the existing 8 MB cap on proxied HTTP Prometheus responses.Integration tests assert
/queryand/query_rangeon the table-function path sendmax_result_bytesto ClickHouse.Reviewed by Cursor Bugbot for commit 67ea546. Bugbot is set up for automated code reviews on this repo. Configure here.