Remote execution: batch series metadata across multiple messages from queriers#15047
Merged
charleskorn merged 5 commits intomainfrom Apr 21, 2026
Merged
Remote execution: batch series metadata across multiple messages from queriers#15047charleskorn merged 5 commits intomainfrom
charleskorn merged 5 commits intomainfrom
Conversation
Contributor
|
💻 Deploy preview deleted (Mimir). |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Infinite loop when no series and zero batch size
- Changed batchSize = len(series) to batchSize = max(len(series), 1) to ensure batchSize is at least 1, preventing infinite loop when no series are returned.
- ✅ Fixed: Error message uses same value for both arguments
- Fixed error message to use cap(combinedMetadata) for expected count and len(combinedMetadata)+len(msg.Series) for actual count received.
Or push these changes by commenting:
@cursor push ff538b432d
Preview (ff538b432d)
diff --git a/pkg/frontend/v2/remoteexec.go b/pkg/frontend/v2/remoteexec.go
--- a/pkg/frontend/v2/remoteexec.go
+++ b/pkg/frontend/v2/remoteexec.go
@@ -732,7 +732,7 @@
return -1, err
}
} else if len(combinedMetadata)+len(msg.Series) > cap(combinedMetadata) {
- return -1, fmt.Errorf("expected %d series metadata, but got at least %d", len(combinedMetadata), len(combinedMetadata))
+ return -1, fmt.Errorf("expected %d series metadata, but got at least %d", cap(combinedMetadata), len(combinedMetadata)+len(msg.Series))
}
for _, s := range msg.Series {
diff --git a/pkg/querier/dispatcher.go b/pkg/querier/dispatcher.go
--- a/pkg/querier/dispatcher.go
+++ b/pkg/querier/dispatcher.go
@@ -369,7 +369,7 @@
batchSize := int(o.seriesMetadataBatchSize)
if batchSize == 0 {
// Frontend doesn't support batching metadata, so send everything in one batch.
- batchSize = len(series)
+ batchSize = max(len(series), 1)
}
// Note the slightly unusual condition: we always send at least one message, even when there are no series.You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit 22fac83. Configure here.
Contributor
tcp13equals2
left a comment
There was a problem hiding this comment.
There is a merge conflict on this branch - otherwise it looks good to me.
tcp13equals2
approved these changes
Apr 21, 2026
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.


What this PR does
This PR changes the behaviour of queriers and query-frontends to support sending batches of series metadata rather than sending all series in a single message.
This is expected to:
ResourceExhaustederrors due to queriers trying to send messages to query-frontends that are too largeWhich issue(s) this PR fixes or relates to
(none)
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.Note
Medium Risk
Changes the remote execution protobuf contract and streaming behavior for series metadata, which could affect compatibility and correctness across mixed-version deployments. The logic now aggregates multi-message metadata and enforces expected totals, so edge cases could surface in production query paths.
Overview
When remote execution is enabled, series metadata is now sent in multiple batches instead of a single potentially large message.
This adds a new experimental flag,
-query-frontend.remote-execution-series-metadata-batch-size, wires it through query-frontend config intoEvaluateQueryRequest, and updates the proto/Go types to includeseriesMetadataBatchSizeplustotalSeriesCountForNodeon metadata responses.On the querier side,
SeriesMetadataEvaluatednow chunks metadata into multipleEvaluateQueryResponseSeriesMetadatamessages (including a total count, and still emitting a message even for zero-series results). On the query-frontend side, metadata reading now loops and combines batches until the expected total is reached, with new tests covering batched metadata for instant and range vectors, and documentation/defaults updated accordingly.Reviewed by Cursor Bugbot for commit 8eb8139. Bugbot is set up for automated code reviews on this repo. Configure here.