Skip to content

Commit 70eb7c6

Browse files
Deep Patelclaude
authored andcommitted
Fix: add timeout check to single-thread fast path in BaseSingleBlockCombineOperator
The getNextBlockSingleThread() fast path was missing the timeout protection present in the original mergeResults() method. A stalled segment operator could block indefinitely with no deadline enforcement. Fix: check System.currentTimeMillis() >= endTimeMs before invoking each segment operator. If the deadline is exceeded, return a timeout results block immediately. This mirrors the waitTimeMs <= 0 guard in mergeResults(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0fd547c commit 70eb7c6

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

pinot-core/src/main/java/org/apache/pinot/core/operator/combine/BaseSingleBlockCombineOperator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,20 @@ protected BaseResultsBlock getNextBlock() {
7878

7979
/// Processes all segments sequentially on the calling thread when only one task is needed.
8080
/// Avoids all concurrency overhead: no ExecutorService submission, no Phaser, no BlockingQueue, no atomics.
81+
/// Respects the query deadline: if the timeout is exceeded before a segment operator is invoked, a timeout
82+
/// results block is returned immediately rather than blocking indefinitely on a stalled operator.
8183
@SuppressWarnings("unchecked")
8284
private BaseResultsBlock getNextBlockSingleThread() {
8385
ThreadResourceSnapshot resourceSnapshot = new ThreadResourceSnapshot();
8486
T mergedBlock = null;
87+
long endTimeMs = _queryContext.getEndTimeMs();
8588
try {
8689
for (int i = 0; i < _numOperators; i++) {
90+
// Check timeout before invoking each segment operator so we respect the query deadline
91+
// even if a segment operator blocks for a long time (mirrors mergeResults() timeout logic).
92+
if (System.currentTimeMillis() >= endTimeMs) {
93+
return attachExecutionStats(getTimeoutResultsBlock(i));
94+
}
8795
Operator operator = _operators.get(i);
8896
T resultsBlock;
8997
try {

0 commit comments

Comments
 (0)