xiangfu0 commented on code in PR #18946:
URL: https://github.com/apache/pinot/pull/18946#discussion_r3553822628
##########
pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseSingleBlockCombineOperator.java:
##########
@@ -59,14 +59,22 @@ protected
BaseSingleBlockCombineOperator(ResultsBlockMerger<T> resultsBlockMerge
/// Handles exceptions here so that execution stats can be attached.
@Override
protected BaseResultsBlock getNextBlock() {
+ BaseResultsBlock mergedBlock = null;
+ Exception mergeException = null;
try {
startProcess();
- return checkTerminateExceptionAndAttachExecutionStats(mergeResults());
+ mergedBlock = mergeResults();
} catch (Exception e) {
- return createExceptionResultsBlockAndAttachExecutionStats(e, "merging
results blocks");
+ mergeException = e;
} finally {
+ // Wait for all worker threads to finish before reading execution stats.
This ensures that no worker thread is
+ // still mutating operator state (e.g. _numDocsScanned) when
attachExecutionStats() iterates over operators.
stopProcess();
}
+ if (mergeException != null) {
+ return
createExceptionResultsBlockAndAttachExecutionStats(mergeException, "merging
results blocks");
+ }
+ return checkTerminateExceptionAndAttachExecutionStats(mergedBlock);
Review Comment:
This call is now outside the `try` block that still wraps `mergeResults()`.
`BaseCombineOperator` documents that combine `nextBlock()` should return an
`ExceptionResultsBlock` instead of throwing, so any runtime failure while
checking termination or attaching execution stats can now escape the query
path. Keep the post-`stopProcess()` ordering, but run the final
stats/termination attachment through the same exception-to-results-block
handling.
--
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]