Skip to content

fix: publish final Dart reports before result completion - #20293

Open
FrankChen021 wants to merge 12 commits into
apache:masterfrom
FrankChen021:codex/fix-dart-report-publication
Open

FrankChen021 wants to merge 12 commits into
apache:masterfrom
FrankChen021:codex/fix-dart-report-publication

Conversation

@FrankChen021

Copy link
Copy Markdown
Member

Description

Publish the final controller report before notifying the completion listener, and serve it while the controller is still registered. Keep removal of the active entry and retention of its report under the same lock used by completed-report lookups.

This closes two report-publication windows: stale live counters after result completion, and a missing report during registry transfer. PR #20291 CI observed missing stage-zero counters immediately after a successful Dart query. The integration test is unchanged.

Validation

  • 22 controller lifecycle and registry tests passed, including two concurrent-reader tests.
  • Disabling final-report publication makes the completion-listener regression fail; restoring it passes.
  • Checkstyle passed.

Release note

Make final Dart query reports available when query results finish, without a temporary missing-report window during retention.

Review

  • Self-reviewed, including concurrency behavior.
  • Added regression tests.

Copilot AI lite review requested due to automatic review settings September 8, 2026 06:30
@github-actions github-actions Bot added Area - Batch Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The concurrency and publication-order changes are covered by targeted regression tests, with only a minor test maintainability nit identified.

Pull request overview

This PR improves Dart MSQ report publication timing and registry atomicity so that final controller reports are visible immediately when query results complete, without a transient “stale counters” or “missing report” window during deregistration/retention.

Changes:

  • Publish a finalized TaskReport.ReportMap from ControllerHolder before invoking the completion listener, and serve it via the registry while the controller remains registered.
  • Make controller removal and completed-report retention atomic with completed-report lookups by synchronizing these operations on the same lock.
  • Add regression tests covering visibility of the final report during the completion callback and lookup behavior during concurrent deregistration.
File summaries
File Description
multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerHolder.java Publishes and serves a final report snapshot prior to completion callback execution.
multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/DartControllerRegistry.java Ensures atomic deregistration/report retention relative to completed-report lookups; serves final reports while still registered.
multi-stage-query/src/test/java/org/apache/druid/msq/exec/ControllerHolderTest.java Adds regression coverage for final-report visibility during completion listener execution.
multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/DartControllerRegistryTest.java Adds concurrency test ensuring lookups wait for report publication during deregistration.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Review deferred: GitHub currently reports this PR as conflicting with master.

Current head: 063eab0c2b20b8e5a37ade204696083916f7a867 (codex/fix-dart-report-publication). Please resolve the conflicts with master and push the updated head so the changes can be reviewed later.

Reviewed 0 of 0 changed files; review was deferred before preparation.


This is an automated review by Codex GPT-5.6-Luna(max)

…rt-publication

# Conflicts:
#	indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorManagerTest.java

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have reviewed the code for correctness, edge cases, concurrency, security, and integration risks; no issues found.

Reviewed 4 of 4 changed files.


This is an automated review by Codex GPT-5.6-Luna(max)

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have reviewed the code for correctness, edge cases, concurrency, security, and integration risks; no issues found.

Reviewed 4 of 4 changed files.


This is an automated review by Codex GPT-5.6-Luna(max)

Comment thread multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerHolder.java Outdated
@FrankChen021
FrankChen021 requested a review from gianm September 12, 2026 15:20

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🟡 Changes recommended

The normal completion path is correct: ControllerImpl publishes a final report through an AtomicReference before delegating completion, and registry removal/retention is serialized with completed-report reads. One lifecycle gap remains for cancellation before the controller thread starts: the synthetic canceled report is not holder-visible while the completion callback runs, and the holder monitor prevents the fallback lookup from acquiring the state it needs. This can leave the report unavailable for the duration of a slow or blocked callback.

Reviewed 7 of 7 changed files: all 5 production files and both modified test files, starting with the incremental diff and then rechecking the full current diff, surrounding lifecycle code, registry lookup/retention paths, all Controller implementations and call sites, and the prior reviewed head. No prior actionable MergeLens findings remained open.

Validation: static inspection only; no build or test commands were run.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

This is an automated review by Codex GPT-5.6-Luna(max)

After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.

Comment thread multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerHolder.java Outdated

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🟢 Approval recommended

The report-publication and registry-transfer changes are consistent across the current head. The combined controller accessor returns the final report once it is atomically published and otherwise returns the live snapshot; pre-run cancellation now exposes a synthetic report without holding the holder monitor during the completion callback; and registry removal/retention is serialized with completed-report lookups. I found no concrete correctness, lifecycle, concurrency, security, data-loss, API-compatibility, or missing-test issue requiring action. The prior pre-run cancellation finding is resolved in this head.

Reviewed 9 of 9 changed files:

  • multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/DartControllerRegistry.java
  • multi-stage-query/src/main/java/org/apache/druid/msq/exec/CaptureReportQueryListener.java
  • multi-stage-query/src/main/java/org/apache/druid/msq/exec/Controller.java
  • multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerHolder.java
  • multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerImpl.java
  • multi-stage-query/src/main/java/org/apache/druid/msq/rpc/ControllerResource.java
  • multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/DartControllerRegistryTest.java
  • multi-stage-query/src/test/java/org/apache/druid/msq/exec/ControllerHolderTest.java
  • multi-stage-query/src/test/java/org/apache/druid/msq/indexing/client/ControllerChatHandlerTest.java

Validation: git diff --check 33f7f77..eed7dd2 passed; no build, test, dependency-install, or formatter commands were run.


This is an automated review by Codex GPT-5.6-Luna(max)

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

Labels

Area - Batch Ingestion Area - Ingestion Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants