mqliang commented on a change in pull request #6672: URL: https://github.com/apache/incubator-pinot/pull/6672#discussion_r593458091
########## File path: pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseCombineOperator.java ########## @@ -52,77 +52,100 @@ protected final ExecutorService _executorService; protected final long _endTimeMs; + private final int _numOperators; + private final int _numThreads; + // Use a _blockingQueue to store the per-segment result + private final BlockingQueue<IntermediateResultsBlock> _blockingQueue; + // Use a Phaser to ensure all the Futures are done (not scheduled, finished or interrupted) before the main thread + // returns. We need to ensure this because the main thread holds the reference to the segments. If a segment is + // deleted/refreshed, the segment will be released after the main thread returns, which would lead to undefined + // behavior (even JVM crash) when processing queries against it. + protected final Phaser _phaser = new Phaser(1); + protected final Future[] _futures; + public BaseCombineOperator(List<Operator> operators, QueryContext queryContext, ExecutorService executorService, long endTimeMs) { _operators = operators; _queryContext = queryContext; _executorService = executorService; _endTimeMs = endTimeMs; + _numOperators = _operators.size(); + _numThreads = CombineOperatorUtils.getNumThreadsForQuery(_numOperators); + _blockingQueue = new ArrayBlockingQueue<>(_numOperators); + _futures = new Future[_numThreads]; Review comment: Thanks for pointing out this. Have fixed it in https://github.com/apache/incubator-pinot/pull/6678. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org