Repository navigation
web/api: fix query cost timeout handling, feature discovery and docs - #20031
Merged
roidelapluie merged 2 commits intoOct 20, 2026
Conversation
aknuds1
force-pushed
the
arve/roidelapluie/query-cost-api
branch
6 times, most recently
from
October 20, 2026 14:00
c28e7ba to
06df941
Compare
With query-cost enabled, the engine's deadline also covers waiting for a concurrency slot while the query is built. A query that timed out or was canceled there was reported as 400 bad_data `invalid parameter "query"`; report it as a timeout or a cancellation instead. Cap a `timeout` above the effective duration ceiling instead of rejecting it, as before the feature. The rejection also fired against --query.timeout when query_max_duration was unset, contrary to the docs. The new max_* parameters keep rejecting values above their ceilings. Reject a negative max_query_duration, which was silently ignored. For cost=true, estimate after building the query and before executing it. The estimation then counts against the query's duration limit, so the request no longer takes up to twice that limit, a malformed query fails before waiting for an estimation slot, and no finished result is held in memory while the estimation waits for a slot. Advertise the feature as `query_cost` in /api/v1/features, since the per-query overrides are silently ignored when it is off. Document that the limits apply to rule evaluation, that duration rejections are usually timeouts, the max_query_duration ceiling and how remote read degrades estimates. Test end to end that the configured limits apply only with the feature enabled and follow a reload. Signed-off-by: Arve Knudsen <[email protected]>
Fold TestQueryCostComparisonNonFatal into a table-driven TestQueryCostComparisonGating that runs on both query endpoints. Fold TestQueryCostOverrideParams into TestQueryCostEndpointParameterParity, which covers all four endpoints, and TestQueryCostDisabledIgnoresCeilings. Drop the flag-off "timeout above the ceiling is accepted" subtest: the timeout parameter is capped regardless of the flag, so it no longer tests anything specific to the feature being disabled. Signed-off-by: Arve Knudsen <[email protected]>
aknuds1
force-pushed
the
arve/roidelapluie/query-cost-api
branch
from
October 20, 2026 14:06
06df941 to
79c2445
Compare
aknuds1
marked this pull request as ready for review
October 20, 2026 14:21
aknuds1
requested review from
ArthurSens and
roidelapluie
and removed request for
a team
October 20, 2026 14:21
roidelapluie
approved these changes
Oct 20, 2026
roidelapluie
merged commit Oct 20, 2026
07c0bd2
into
prometheus:roidelapluie/query-cost-api
32 of 33 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With query-cost enabled, a query that timed out or was canceled while waiting for a query slot during construction was reported as 400
bad_data(invalid parameter "query"). Atimeoutabove--query.timeoutwas rejected even whenquery_max_durationwas unset, contrary to the docs. A negativemax_query_durationwas silently ignored. Withcost=true, the estimate had its own duration limit on top of the query's, so a request could take twice the limit, and the finished result was held in memory while the estimate waited for a slot. The features API did not report the feature, although the per-query overrides are silently ignored when it is off, and several doc statements did not match the code.Report construction timeouts and cancellations as timeouts (503) and cancellations (499). Cap the
timeoutparameter at the effective duration ceiling, as before the feature; this reverses the reject-not-clamp choice fortimeoutonly, and the newmax_*parameters keep rejecting values above their ceilings. Reject a negativemax_query_duration. Forcost=true, estimate after building the query and before executing it, so the estimate counts against the query's duration limit and a malformed query fails before any estimation. Advertise the feature asquery_costin/api/v1/features. Document that the limits apply to rule evaluation, that duration rejections are usually timeouts, themax_query_durationceiling and how remote read affects estimates; correct thesamplesReadwording and drop the claim about UI support. Add an end-to-end test that the configured limits apply only with the feature enabled and follow a config reload.Part of #20028. This PR targets
roidelapluie/query-cost-apiand contains two commits above Julien's branch: the fixes, and a separate test consolidation that can be dropped on its own.