Skip to content

[codex] Add query progress reporting#18649

Open
xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:codex/query-progress
Open

[codex] Add query progress reporting#18649
xiangfu0 wants to merge 1 commit into
apache:masterfrom
xiangfu0:codex/query-progress

Conversation

@xiangfu0
Copy link
Copy Markdown
Contributor

@xiangfu0 xiangfu0 commented Jun 2, 2026

Summary

Adds query progress reporting for long-running Pinot queries across the broker, controller, server, V1 execution, V2 execution, query console, and Pinot CLI.

The progress model reports processed work units over total work units. V1 uses server segment progress; V2 estimates work from multi-stage operators and stage execution progress. The controller exposes progress by clientQueryId, the query console polls it while a query is running, and the CLI can poll and render a single-line progress bar for interactive terminals.

User impact

  • Query console now shows numeric query progress while a query is in RUNNING state.
  • pinot-cli supports --progress-interval-ms and config key progress-interval-ms.
  • CLI progress is disabled with --progress-interval-ms=0 and is only rendered for interactive terminals, so redirected output/logs stay clean.
  • README includes usage notes and V1/V2 quickstart sample queries.

Screenshot

Query console progress while a V2 quickstart query is running:

Query console progress bar showing 14.3% and 1/7 work units

Notes

The CLI injects a generated clientQueryId as a quoted query option so progress polling can correlate the client request with running query state.

Validation

  • ./mvnw -pl pinot-controller,pinot-clients/pinot-cli -am -DskipTests -DskipITs -Dmaven.javadoc.skip=true compile
  • ./mvnw -pl pinot-spi -Dtest=QueryProgressStatsTest test
  • ./mvnw -pl pinot-query-runtime -am -Dtest=OpChainSchedulerServiceTest -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -pl pinot-core -am -Dtest=InstanceRequestHandlerTest -Dsurefire.failIfNoSpecifiedTests=false test
  • ./mvnw -pl pinot-clients/pinot-cli -DskipTests -DskipITs -Dmaven.javadoc.skip=true package
  • spotless:apply, license:format, license:check, and checkstyle:check on affected modules
  • git diff --check
  • Local quickstart smoke test with query console and Pinot CLI progress query

Copy link
Copy Markdown
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 end-to-end query progress reporting for long-running Pinot queries, exposing a unified progress model (processed work units / total work units) across SSE (segment-based) and MSE (operator/stage-based) execution paths, and surfacing it via REST/gRPC, Query Console UI, and Pinot CLI.

Changes:

  • Introduces QueryProgressStats in pinot-spi, plus progress counters in QueryExecutionContext.
  • Implements progress tracking and retrieval across servers/brokers/controller (including new REST endpoints and a new gRPC Progress RPC for MSE).
  • Adds polling + rendering in Query Console and an interactive CLI progress line / progress bar.

Reviewed changes

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

Show a summary per file
File Description
pinot-spi/src/test/java/org/apache/pinot/spi/query/QueryProgressStatsTest.java Adds unit tests for percent calculation, aggregation, JSON round-trip, and execution context accumulation.
pinot-spi/src/main/java/org/apache/pinot/spi/query/QueryProgressStats.java New progress stats model with JSON support, aggregation, and derived percent.
pinot-spi/src/main/java/org/apache/pinot/spi/query/QueryExecutionContext.java Adds atomic progress counters and APIs to mutate/read progress.
pinot-server/src/main/java/org/apache/pinot/server/api/resources/QueryResource.java Adds server REST endpoint to fetch per-query progress and aggregate OFFLINE/REALTIME.
pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/executor/OpChainSchedulerServiceTest.java Adds test coverage for progress tracking on completed op-chains.
pinot-query-runtime/src/main/java/org/apache/pinot/query/service/server/QueryServer.java Adds gRPC Progress RPC handler for MSE worker progress.
pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/QueryDispatcher.java Adds broker-side dispatch logic to query MSE workers for progress and aggregate responses.
pinot-query-runtime/src/main/java/org/apache/pinot/query/service/dispatch/DispatchClient.java Adds client call implementation for the new gRPC progress RPC.
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/QueryRunner.java Exposes execution-context tracking and progress retrieval via OpChainSchedulerService.
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/server/ServerPlanRequestUtils.java Plumbs a shared QueryExecutionContext into leaf-stage ServerQueryRequests for progress attribution.
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/executor/OpChainSchedulerService.java Tracks execution contexts and increments processed work units on op-chain completion/failure.
pinot-core/src/test/java/org/apache/pinot/core/transport/InstanceRequestHandlerTest.java Updates tests for renamed/cached execution-context retrieval API.
pinot-core/src/main/java/org/apache/pinot/core/transport/InstanceRequestHandler.java Uses cached execution context and exposes server-side progress stats lookup.
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java Uses cached execution context when opening QueryThreadContext.
pinot-core/src/main/java/org/apache/pinot/core/query/request/ServerQueryRequest.java Adds execution-context caching + setter to support shared context plumbing.
pinot-core/src/main/java/org/apache/pinot/core/query/executor/ServerQueryExecutorV1Impl.java Adds total segment accounting to drive SSE progress denominators.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/SortedGroupByCombineOperator.java Marks segments as processed during combine execution to advance progress.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/SequentialSortedGroupByCombineOperator.java Marks segments as processed for sequential sorted group-by combine.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/MinMaxValueBasedSelectionOrderByCombineOperator.java Marks segments as processed (including skipped segments) for progress accuracy.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/GroupByCombineOperator.java Marks processed segments during group-by combine.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseSingleBlockCombineOperator.java Marks segments as processed when producing results blocks.
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseCombineOperator.java Adds shared helper to increment processed-segment progress via thread context.
pinot-controller/src/main/resources/app/requests/index.ts Adds Query Console API call for controller clientQueryId progress endpoint.
pinot-controller/src/main/resources/app/pages/Query.tsx Adds clientQueryId injection, progress polling, and progress UI (numbers + bar).
pinot-controller/src/main/resources/app/Models.ts Adds QueryProgressStats type to UI model definitions.
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotRunningQueryResource.java Adds controller REST endpoint to fetch progress by clientQueryId by polling brokers.
pinot-common/src/main/proto/worker.proto Adds gRPC Progress RPC and request/response messages for MSE worker progress.
pinot-clients/pinot-cli/src/main/java/org/apache/pinot/cli/PinotCli.java Adds CLI progress polling/rendering, config + flag, and clientQueryId injection.
pinot-clients/pinot-cli/README.md Documents CLI/query-console progress behavior and usage examples.
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java Tracks MSE execution contexts and aggregates broker+server progress for MSE queries.
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java Routes broker progress requests to MSE handler first, then SSE handler.
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandler.java Extends broker handler interface with getQueryProgressStats(...).
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java Implements SSE progress retrieval by polling servers’ new progress endpoint.
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java Adds default getQueryProgressStats(...) method stub + precondition for clientQueryId mapping.
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java Adds broker REST endpoint to fetch progress by internal requestId or clientQueryId.

Comment on lines +407 to +414
const progressTimer = window.setInterval(async () => {
try {
const response = await getClientQueryProgress(clientQueryId, QUERY_PROGRESS_POLL_INTERVAL_MS);
setQueryProgress(response.data);
} catch (error) {
// The query might not be registered yet, or may already have completed.
}
}, QUERY_PROGRESS_POLL_INTERVAL_MS);
Comment on lines +392 to +395
if (errMsgs.size() > 0) {
throw new Exception("Unexpected responses from servers: " + StringUtils.join(errMsgs, ","));
}
return serverProgressStats.isEmpty() ? null : QueryProgressStats.aggregate(serverProgressStats);
Comment on lines +449 to +452
if (errMsgs.size() > 0) {
throw new Exception("Unexpected responses from brokers: " + StringUtils.join(errMsgs, ","));
}
return null;
@xiangfu0 xiangfu0 force-pushed the codex/query-progress branch 3 times, most recently from 6cb4cc3 to d601f43 Compare June 2, 2026 06:25
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 37.83069% with 235 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.34%. Comparing base (edfbf69) to head (44ae161).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
...oller/api/resources/PinotRunningQueryResource.java 0.00% 47 Missing ⚠️
...sthandler/BaseSingleStageBrokerRequestHandler.java 0.00% 38 Missing ⚠️
.../pinot/query/service/dispatch/QueryDispatcher.java 0.00% 35 Missing ⚠️
...pinot/broker/api/resources/PinotClientRequest.java 0.00% 27 Missing ⚠️
...ache/pinot/server/api/resources/QueryResource.java 0.00% 26 Missing ⚠️
...requesthandler/MultiStageBrokerRequestHandler.java 5.26% 18 Missing ⚠️
...apache/pinot/query/service/server/QueryServer.java 23.80% 16 Missing ⚠️
...r/requesthandler/BrokerRequestHandlerDelegate.java 0.00% 6 Missing ⚠️
...uery/runtime/executor/OpChainSchedulerService.java 84.84% 3 Missing and 2 partials ⚠️
...e/pinot/core/transport/InstanceRequestHandler.java 85.18% 2 Missing and 2 partials ⚠️
... and 5 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18649      +/-   ##
============================================
- Coverage     64.39%   64.34%   -0.06%     
  Complexity     1291     1291              
============================================
  Files          3364     3366       +2     
  Lines        207935   208439     +504     
  Branches      32467    32542      +75     
============================================
+ Hits         133906   134123     +217     
- Misses        63255    63533     +278     
- Partials      10774    10783       +9     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-21 64.34% <37.83%> (-0.06%) ⬇️
temurin 64.34% <37.83%> (-0.06%) ⬇️
unittests 64.34% <37.83%> (-0.06%) ⬇️
unittests1 56.81% <66.50%> (+0.01%) ⬆️
unittests2 37.08% <7.93%> (-0.06%) ⬇️

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.

@xiangfu0 xiangfu0 force-pushed the codex/query-progress branch from d601f43 to 1940943 Compare June 2, 2026 09:17
@xiangfu0 xiangfu0 marked this pull request as ready for review June 2, 2026 10:48
Copy link
Copy Markdown
Contributor Author

@xiangfu0 xiangfu0 left a comment

Choose a reason for hiding this comment

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

Found one high-signal issue; see inline comment.

@xiangfu0 xiangfu0 force-pushed the codex/query-progress branch from 1940943 to 5dda15c Compare June 2, 2026 20:13
@xiangfu0 xiangfu0 force-pushed the codex/query-progress branch from 5dda15c to 44ae161 Compare June 2, 2026 20:22
Copy link
Copy Markdown
Contributor Author

@xiangfu0 xiangfu0 left a comment

Choose a reason for hiding this comment

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

Found 1 high-signal issue; see inline comment.

if (deadline.isExpired()) {
LOGGER.debug("Timed out waiting for progress response for query: {}", requestId);
}
return progressStatsList.isEmpty() ? null : QueryProgressStats.aggregate(progressStatsList);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This returns an aggregate over only the servers that responded before the deadline. If one server is still running or transiently unreachable, its unfinished work disappears from the denominator and the broker can report 100% even though the query is still blocked on that server. Please avoid returning a partial aggregate here: either fail/mark progress unknown when any targeted server is missing, or retain last-known totals so missing servers do not shrink the denominator.

@gortiz gortiz self-requested a review June 3, 2026 15:22
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