Skip to content

Query Frontend: apply default_priority to metadata queries - #7942

Open
arpitjain099 wants to merge 1 commit into
cortexproject:masterfrom
arpitjain099:fix/metadata-query-default-priority
Open

arpitjain099 wants to merge 1 commit into
cortexproject:masterfrom
arpitjain099:fix/metadata-query-default-priority

Conversation

@arpitjain099

Copy link
Copy Markdown

What this PR does:

rejectQueryOrSetPriority splits on operation. The expression branch takes the first matching priority and then falls back to queryPriority.DefaultPriority. The metadata branch does neither: there is no fallback after the loop, and its break leaves only the inner loop, so a later matching priority overwrites an earlier one.

SetPriority is what flips PriorityAssigned, and both schedulerRequest.Priority() and request.Priority() return a hardcoded 0 when LoadPriority reports false. So /api/v1/labels, /api/v1/series and /api/v1/label/<name>/values are enqueued at 0 rather than at the tenant's default_priority. With default_priority: -1 and a priority: 0 class holding reserved_queriers, they land in the reserved class. The priority label of cortex_query_scheduler_queue_length reports 0 for them as well, and the query log drops the field.

#7128 extended query priority to operations beyond query and query_range, and the default fallback did not come across with it. This mirrors the expression branch: return nil on a match, SetPriority(DefaultPriority) after the loop. The branch also covers /api/v1/metadata and any other non-query path, so those pick up the default too.

Testing:

Test_rejectQueryOrSetPriorityShouldSetDefaultPriorityWhenNoAttributeMatches configures a single query_range priority that none of its four probes match, and asserts each one receives default_priority: 5. The three metadata cases fail on master with actual: 0. The instant-query case passes either way and is there as a control. The package goes from 166 passing with 4 failures to 170 passing, and tripperware, scheduler and frontend are green with the change, built with netgo slicelabels.

Which issue(s) this PR fixes:
N/A

Checklist

  • Tests updated
  • Documentation added (no config, flag or documented behaviour change)
  • CHANGELOG.md updated
  • docs/configuration/v1-guarantees.md updated if this PR introduces experimental flags (no new flags)

Prepared with the assistance of generative AI, reviewed and tested by me.

The metadata branch of rejectQueryOrSetPriority never fell back to the
tenant's default priority, so /api/v1/labels, /series and /label/*/values
were enqueued at a hardcoded 0. Its break also left only the inner loop, so
the last matching priority won where the expression branch takes the first.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099
arpitjain099 requested a review from a team as a code owner November 17, 2026 15:05

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant