FrankChen021 commented on code in PR #20293:
URL: https://github.com/apache/druid/pull/20293#discussion_r3999601878
##########
multi-stage-query/src/main/java/org/apache/druid/msq/exec/ControllerHolder.java:
##########
@@ -185,11 +209,22 @@ public ListenableFuture<?> runAsync(
}
}
- updateStateOnQueryComplete(reportListener.getReport());
+ reportMap = controller.finalReport();
+ if (reportMap != null) {
+ final TaskReport taskReport =
reportMap.get(MSQTaskReport.REPORT_KEY);
+ if (taskReport instanceof MSQTaskReport) {
+ final MSQTaskReportPayload report = ((MSQTaskReport)
taskReport).getPayload();
+ if (report != null) {
+ updateStateOnQueryComplete(report);
+ }
+ }
+ }
} else {
// Canceled before running.
+ final MSQTaskReportPayload canceledReport =
makeCanceledReport(cancelReason);
+ reportMap = TaskReport.buildTaskReports(new
MSQTaskReport(controller.queryId(), canceledReport));
synchronized (this) {
- reportListener.onQueryComplete(makeCanceledReport(cancelReason));
+ listener.onQueryComplete(canceledReport);
Review Comment:
[P2] Pre-run cancellation blocks report lookup
**Finding:** In the pre-run cancellation branch, `listener.onQueryComplete`
executes while holding `ControllerHolder.this`. Unlike the normal
ControllerImpl path, the synthetic `reportMap` is only a local variable, so
`getReports()` must acquire this same monitor before it can construct the
fallback. A concurrent Dart report lookup therefore blocks until the callback
returns, leaving the canceled report unavailable during the still-registered
window this change is intended to cover when the completion listener is slow or
blocked. The added regression test does not expose this because its timed
assertion failure is swallowed by the runnable's catch and the lookup proceeds
only after the lock is released.
**Suggestion:** Publish the synthetic canceled report in holder-visible
state before invoking the listener, or move the callback outside the holder
monitor after snapshotting cancellation state under the lock; add a test that
verifies the lookup completes before releasing the callback.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]