Skip to content

Commit f234ff0

Browse files
JNSimbaYour Name
authored andcommitted
[fix](job) fix StreamingInsertJob incorrectly counting canceled tasks (#61894)
## What problem does this PR solve? Problem Summary: - `StreamingInsertJob` does not support manual task cancellation - `cancelAllTasks()` is only triggered internally when job is STOPPED or PAUSED, meaning the task was interrupted passively - Change `canceledTaskCount.incrementAndGet()` in `cancelAllTasks()`, when task is running `canceledTaskCount` need incr
1 parent aee9b0b commit f234ff0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/streaming/StreamingInsertJob.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,15 @@ public void cancelAllTasks(boolean needWaitCancelComplete) throws JobException {
437437
if (runningStreamTask == null) {
438438
return;
439439
}
440+
// Check status before cancel: if the task was still active (RUNNING or PENDING),
441+
// count it as canceled. If already in a terminal state (e.g. FAILED), it was
442+
// already counted by onStreamTaskFail(), so skip to avoid double-counting.
443+
boolean wasActive = TaskStatus.RUNNING.equals(runningStreamTask.getStatus())
444+
|| TaskStatus.PENDING.equals(runningStreamTask.getStatus());
440445
runningStreamTask.cancel(needWaitCancelComplete);
441-
canceledTaskCount.incrementAndGet();
446+
if (wasActive) {
447+
canceledTaskCount.incrementAndGet();
448+
}
442449
} finally {
443450
lock.writeLock().unlock();
444451
}

0 commit comments

Comments
 (0)