Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run pruning middleware before query sharding middleware #9913

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* `cortex_alertmanager_silences`
* [CHANGE] Distributor: Drop experimental `-distributor.direct-otlp-translation-enabled` flag, since direct OTLP translation is well tested at this point. #9647
* [CHANGE] Ingester: Change `-initial-delay` for circuit breakers to begin when the first request is received, rather than at breaker activation. #9842
* [CHANGE] Query-frontend: apply query pruning before query sharding instead of after. #9913
* [FEATURE] Querier: add experimental streaming PromQL engine, enabled with `-querier.query-engine=mimir`. #9367 #9368 #9398 #9399 #9403 #9417 #9418 #9419 #9420 #9482 #9504 #9505 #9507 #9518 #9531 #9532 #9533 #9553 #9558 #9588 #9589 #9639 #9641 #9642 #9651 #9664 #9681 #9717 #9719 #9724 #9874
* [FEATURE] Distributor: Add support for `lz4` OTLP compression. #9763
* [FEATURE] Query-frontend: added experimental configuration options `query-frontend.cache-errors` and `query-frontend.results-cache-ttl-for-errors` to allow non-transient responses to be cached. When set to `true` error responses from hitting limits or bad data are cached for a short TTL. #9028
Expand Down
28 changes: 14 additions & 14 deletions pkg/frontend/querymiddleware/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,20 +395,6 @@ func newQueryMiddlewares(
queryRangeMiddleware = append(queryRangeMiddleware, cfg.ExtraRangeQueryMiddlewares...)
}

if cfg.PrunedQueries {
pruneMiddleware := newPruneMiddleware(log)
queryRangeMiddleware = append(
queryRangeMiddleware,
newInstrumentMiddleware("pruning", metrics),
pruneMiddleware,
)
queryInstantMiddleware = append(
queryInstantMiddleware,
newInstrumentMiddleware("pruning", metrics),
pruneMiddleware,
)
}

if cfg.ShardedQueries {
// Inject the cardinality estimation middleware after time-based splitting and
// before query-sharding so that it can operate on the partial queries that are
Expand Down Expand Up @@ -447,6 +433,20 @@ func newQueryMiddlewares(
)
}

if cfg.PrunedQueries {
pruneMiddleware := newPruneMiddleware(log)
queryRangeMiddleware = append(
queryRangeMiddleware,
newInstrumentMiddleware("pruning", metrics),
pruneMiddleware,
)
queryInstantMiddleware = append(
queryInstantMiddleware,
newInstrumentMiddleware("pruning", metrics),
pruneMiddleware,
)
}

if cfg.MaxRetries > 0 {
retryMiddlewareMetrics := newRetryMiddlewareMetrics(registerer)
queryRangeMiddleware = append(queryRangeMiddleware, newInstrumentMiddleware("retry", metrics), newRetryMiddleware(log, cfg.MaxRetries, retryMiddlewareMetrics))
Expand Down
Loading