Skip to content

Add controller execution time tracking to query responses #17709

Open
Akanksha-kedia wants to merge 1 commit intoapache:masterfrom
Akanksha-kedia:fix-timeseries-controller-status-field
Open

Add controller execution time tracking to query responses #17709
Akanksha-kedia wants to merge 1 commit intoapache:masterfrom
Akanksha-kedia:fix-timeseries-controller-status-field

Conversation

@Akanksha-kedia
Copy link
Contributor

…meseries responses

  • Add sendTimeSeriesRequestRaw method to handle timeseries responses without parsing as BrokerResponseNative
  • Update sendTimeSeriesRequestToBroker to use raw forwarding for both GET and POST endpoints
  • Fix GET endpoint method signature to use proper executeTimeSeriesQueryCatching parameters
  • Ensures controller preserves broker's PinotBrokerTimeSeriesResponse structure with status field
  • Resolves test failure: 'Status field should not be null in timeseries query response'

The issue was that controller was incorrectly trying to parse timeseries responses as BrokerResponseNative and add execution time, but timeseries responses use PinotBrokerTimeSeriesResponse with different structure. This fix preserves the original Prometheus-compatible response format from the broker.

Instructions:

  1. The PR has to be tagged with at least one of the following labels (*):
    1. feature
    2. bugfix
    3. performance
    4. ui
    5. backward-incompat
    6. release-notes (**)
  2. Remove these instructions before publishing the PR.

(*) Other labels to consider:

  • testing
  • dependencies
  • docker
  • kubernetes
  • observability
  • security
  • code-style
  • extension-point
  • refactor
  • cleanup

(**) Use release-notes label for scenarios like:

  • New configuration options
  • Deprecation of configurations
  • Signature changes to public methods/interfaces
  • New plugins added or old plugins removed

@Akanksha-kedia
Copy link
Contributor Author

curl -X POST http://localhost:9001/sql -H "Content-Type: application/json" -d '{"sql":"SELECT COUNT(*) FROM baseballStats"}' | jq .

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1610 100 1566 100 44 28979 814 --:--:-- --:--:-- --:--:-- 29814
{
"resultTable": {
"dataSchema": {
"columnNames": [
"count(*)"
],
"columnDataTypes": [
"LONG"
]
},
"rows": [
[
97889
]
]
},
"numRowsResultSet": 1,
"partialResult": false,
"exceptions": [],
"numGroupsLimitReached": false,
"numGroupsWarningLimitReached": false,
"timeUsedMs": 10,
"controllerExecutionTimeMs": 25,
"requestId": "1648150687000000002",
"clientRequestId": null,
"brokerId": "Broker_localhost_8099",
"numDocsScanned": 97889,
"totalDocs": 97889,
"numEntriesScannedInFilter": 0,
"numEntriesScannedPostFilter": 0,
"numServersQueried": 1,
"numServersResponded": 1,
"numSegmentsQueried": 1,
"numSegmentsProcessed": 1,
"numSegmentsMatched": 1,
"numConsumingSegmentsQueried": 0,
"numConsumingSegmentsProcessed": 0,
"numConsumingSegmentsMatched": 0,
"minConsumingFreshnessTimeMs": 0,
"numSegmentsPrunedByBroker": 0,
"numSegmentsPrunedByServer": 0,
"numSegmentsPrunedInvalid": 0,
"numSegmentsPrunedByLimit": 0,
"numSegmentsPrunedByValue": 0,
"brokerReduceTimeMs": 0,
"offlineThreadCpuTimeNs": 0,
"realtimeThreadCpuTimeNs": 0,
"offlineSystemActivitiesCpuTimeNs": 0,
"realtimeSystemActivitiesCpuTimeNs": 0,
"offlineResponseSerializationCpuTimeNs": 0,
"realtimeResponseSerializationCpuTimeNs": 0,
"offlineTotalCpuTimeNs": 0,
"realtimeTotalCpuTimeNs": 0,
"explainPlanNumEmptyFilterSegments": 0,
"explainPlanNumMatchAllFilterSegments": 0,
"traceInfo": {},
"tablesQueried": [
"baseballStats"
],
"offlineThreadMemAllocatedBytes": 0,
"realtimeThreadMemAllocatedBytes": 0,
"offlineResponseSerMemAllocatedBytes": 0,
"realtimeResponseSerMemAllocatedBytes": 0,
"offlineTotalMemAllocatedBytes": 0,
"realtimeTotalMemAllocatedBytes": 0,
"pools": [
-1
],
"rlsFiltersApplied": false,
"groupsTrimmed": false
}

(#17647 (comment))
curl -X POST http://localhost:8099/query/sql -H "Content-Type: application/json" -d '{"sql":"SELECT COUNT() FROM baseballStats"}' | jq .
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1610 100 1566 100 44 22778 640 --:--:-- --:--:-- --:--:-- 23676
{
"resultTable": {
"dataSchema": {
"columnNames": [
"count()"
],
"columnDataTypes": [
"LONG"
]
},
"rows": [
[
97889
]
]
},
"numRowsResultSet": 1,
"partialResult": false,
"exceptions": [],
"numGroupsLimitReached": false,
"numGroupsWarningLimitReached": false,
"timeUsedMs": 37,
"controllerExecutionTimeMs": -1,
"requestId": "1648150687000000004",
"clientRequestId": null,
"brokerId": "Broker_localhost_8099",
"numDocsScanned": 97889,
"totalDocs": 97889,
"numEntriesScannedInFilter": 0,
"numEntriesScannedPostFilter": 0,
"numServersQueried": 1,
"numServersResponded": 1,
"numSegmentsQueried": 1,
"numSegmentsProcessed": 1,
"numSegmentsMatched": 1,
"numConsumingSegmentsQueried": 0,
"numConsumingSegmentsProcessed": 0,
"numConsumingSegmentsMatched": 0,
"minConsumingFreshnessTimeMs": 0,
"numSegmentsPrunedByBroker": 0,
"numSegmentsPrunedByServer": 0,
"numSegmentsPrunedInvalid": 0,
"numSegmentsPrunedByLimit": 0,
"numSegmentsPrunedByValue": 0,
"brokerReduceTimeMs": 0,
"offlineThreadCpuTimeNs": 0,
"realtimeThreadCpuTimeNs": 0,
"offlineSystemActivitiesCpuTimeNs": 0,
"realtimeSystemActivitiesCpuTimeNs": 0,
"offlineResponseSerializationCpuTimeNs": 0,
"realtimeResponseSerializationCpuTimeNs": 0,
"offlineTotalCpuTimeNs": 0,
"realtimeTotalCpuTimeNs": 0,
"explainPlanNumEmptyFilterSegments": 0,
"explainPlanNumMatchAllFilterSegments": 0,
"traceInfo": {},
"tablesQueried": [
"baseballStats"
],
"offlineThreadMemAllocatedBytes": 0,
"realtimeThreadMemAllocatedBytes": 0,
"offlineResponseSerMemAllocatedBytes": 0,
"realtimeResponseSerMemAllocatedBytes": 0,
"offlineTotalMemAllocatedBytes": 0,
"realtimeTotalMemAllocatedBytes": 0,
"pools": [
-1
],
"rlsFiltersApplied": false,
"groupsTrimmed": false
}

@Akanksha-kedia
Copy link
Contributor Author

@shauryachats @xiangfu0 @Jackie-Jiang please review

@Akanksha-kedia Akanksha-kedia changed the title Fix TimeSeriesIntegrationTest: Preserve status field in controller ti… Add controller execution time tracking to query responses Feb 16, 2026
@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2026

Codecov Report

❌ Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.21%. Comparing base (9de73ec) to head (32d6387).
⚠️ Report is 43 commits behind head on master.

Files with missing lines Patch % Lines
...t/controller/api/resources/PinotQueryResource.java 0.00% 19 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #17709      +/-   ##
============================================
- Coverage     63.24%   63.21%   -0.04%     
  Complexity     1454     1454              
============================================
  Files          3176     3176              
  Lines        191002   191017      +15     
  Branches      29204    29204              
============================================
- Hits         120791   120742      -49     
- Misses        60796    60862      +66     
+ Partials       9415     9413       -2     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 63.16% <0.00%> (-0.04%) ⬇️
java-21 63.17% <0.00%> (+<0.01%) ⬆️
temurin 63.21% <0.00%> (-0.04%) ⬇️
unittests 63.20% <0.00%> (-0.04%) ⬇️
unittests1 55.58% <ø> (+0.01%) ⬆️
unittests2 34.07% <0.00%> (-0.04%) ⬇️

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.

@Akanksha-kedia
Copy link
Contributor Author

@xiangfu0 @shauryachats @Jackie-Jiang please review and merge

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

Having controllerExecutionTimeMs field in BrokerResponse is quite counter intuitive. What is the purpose of this field? To track to additional overhead of controller-broker communication?

@Akanksha-kedia
Copy link
Contributor Author

Akanksha-kedia commented Feb 18, 2026 via email

@Jackie-Jiang
Copy link
Contributor

Does it work if you add an extra field in the controller response and not modify BrokerResponse?

@shauryachats
Copy link
Collaborator

+1. @Akanksha-kedia as I mentioned in your previous PR #17647:

@Akanksha-kedia is this only for queries executed through Controller UI? If yes, could we instead consider modifying only the controller APIs to additionally bundle the controller execution time given that most of the queries would generally be through the broker itself and this increases the response size without providing any additional information for broker queries.

Additionally, if this information is only supposed to be bubbled up to the Controller UI, you can instead modify the UI code to expose the actual latency of the controller endpoint.

@Akanksha-kedia Akanksha-kedia force-pushed the fix-timeseries-controller-status-field branch from d6e986e to b889e14 Compare February 22, 2026 13:52
…g BrokerResponse

- Add controllerExecutionTimeMs as an additional field in controller SQL query responses
- Do not modify BrokerResponseNative to avoid increasing response size for direct broker queries
- Keep timeseries responses unchanged by using separate sendTimeSeriesRequestRaw method
- Fix GET endpoint method signature to use proper executeTimeSeriesQueryCatching parameters
- Ensures controller preserves broker's PinotBrokerTimeSeriesResponse structure with status field

This addresses review feedback to only add execution time for controller UI queries,
not for all broker queries, by adding the field at the controller API level rather
than modifying the shared BrokerResponseNative class.
@Akanksha-kedia Akanksha-kedia force-pushed the fix-timeseries-controller-status-field branch from b889e14 to 32d6387 Compare February 22, 2026 15:47
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.

4 participants