timothy-e commented on code in PR #18946:
URL: https://github.com/apache/pinot/pull/18946#discussion_r3554984040
##########
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:
Another great catch, thanks Xiang! Update the PR
--
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]