Skip to content

Add metrics for serialized query response size in QueryScheduler#17710

Open
gortiz wants to merge 1 commit intoapache:masterfrom
gortiz:feature/server-to-broker-response-size
Open

Add metrics for serialized query response size in QueryScheduler#17710
gortiz wants to merge 1 commit intoapache:masterfrom
gortiz:feature/server-to-broker-response-size

Conversation

@gortiz
Copy link
Contributor

@gortiz gortiz commented Feb 16, 2026

This pull request adds new metrics tracking for server query response sizes. The main focus is on recording the size of each serialized query responsee.

Metrics enhancements:

  • Added a new meter QUERY_RESPONSE_SIZE to the ServerMeter enum to track the size (in bytes) of serialized server-to-broker responses.
  • Updated QueryScheduler to record the size of each query response using the new QUERY_RESPONSE_SIZE meter for the corresponding table.

Large response handling improvements:

  • Refactored the logic in QueryScheduler to always record the response size, and only log an exception and increment the LARGE_QUERY_RESPONSE_SIZE_EXCEPTIONS meter when the response exceeds the configured maximum size. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new server-side metric to track serialized query response sizes, and refactors QueryScheduler to record size and handle oversized responses with a dedicated exception meter.

Changes:

  • Introduced ServerMeter.QUERY_RESPONSE_SIZE to track serialized response size (bytes).
  • Updated QueryScheduler to record response size and only emit oversize exception/logging when configured thresholds are exceeded.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java Records response size and refines oversized-response handling logic.
pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java Adds the new QUERY_RESPONSE_SIZE meter definition and description.

Comment on lines +166 to +170
if (maxResponseSizeBytes != null && responseBytes != null) {
int responseSizeBytes = responseBytes.length;
String tableNameWithType = queryRequest.getTableNameWithType();
_serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.QUERY_RESPONSE_SIZE, responseSizeBytes);
if (responseSizeBytes > maxResponseSizeBytes) {
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUERY_RESPONSE_SIZE is only recorded when maxResponseSizeBytes != null, so queries without this option configured won't emit the new metric. If the goal is to track response sizes for all queries, record the metric whenever responseBytes != null, and only guard the threshold/exception handling with the maxResponseSizeBytes check.

Suggested change
if (maxResponseSizeBytes != null && responseBytes != null) {
int responseSizeBytes = responseBytes.length;
String tableNameWithType = queryRequest.getTableNameWithType();
_serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.QUERY_RESPONSE_SIZE, responseSizeBytes);
if (responseSizeBytes > maxResponseSizeBytes) {
if (responseBytes != null) {
int responseSizeBytes = responseBytes.length;
String tableNameWithType = queryRequest.getTableNameWithType();
_serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.QUERY_RESPONSE_SIZE, responseSizeBytes);
if (maxResponseSizeBytes != null && responseSizeBytes > maxResponseSizeBytes) {

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, don't we want to record the response size for all queries?

Comment on lines +144 to +146
* Size of the serialized response sent from server to broker in bytes.
*/
QUERY_RESPONSE_SIZE("bytes", false, "Size of the serialized response sent from server to broker in bytes"),
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The QUERY_RESPONSE_SIZE description says the metric is for the response "sent from server to broker", but in QueryScheduler it is recorded immediately after the first serialization and can represent a response that is later replaced with an error response when it exceeds maxResponseSizeBytes. Either move the metric recording to after the final responseBytes is determined, or adjust the description to clarify what is being measured.

Suggested change
* Size of the serialized response sent from server to broker in bytes.
*/
QUERY_RESPONSE_SIZE("bytes", false, "Size of the serialized response sent from server to broker in bytes"),
* Size of the initially serialized query response in bytes.
* Note: This may differ from the final response actually sent to the broker if the response
* is later replaced (for example, when exceeding the configured max response size).
*/
QUERY_RESPONSE_SIZE("bytes", false,
"Size of the initially serialized query response in bytes (may differ from final response sent to broker)"),

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 6.25000% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.22%. Comparing base (657e7f0) to head (ccabc31).

Files with missing lines Patch % Lines
...che/pinot/core/query/scheduler/QueryScheduler.java 0.00% 14 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17710      +/-   ##
============================================
- Coverage     63.23%   63.22%   -0.01%     
+ Complexity     1502     1501       -1     
============================================
  Files          3179     3179              
  Lines        190710   190715       +5     
  Branches      29153    29154       +1     
============================================
- Hits         120597   120589       -8     
  Misses        60746    60746              
- Partials       9367     9380      +13     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 63.20% <6.25%> (+<0.01%) ⬆️
java-21 63.17% <6.25%> (-0.01%) ⬇️
temurin 63.22% <6.25%> (-0.01%) ⬇️
unittests 63.22% <6.25%> (-0.01%) ⬇️
unittests1 55.63% <6.25%> (+<0.01%) ⬆️
unittests2 34.05% <6.25%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants