This is an automated email from the ASF dual-hosted git repository.

seawinde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 44034b2456c [fix](job scheduler) Record task finish time on execution 
failure (#66232)
44034b2456c is described below

commit 44034b2456c3104aa0e38b3d40044554960c1640
Author: yujun <[email protected]>
AuthorDate: Thu Jul 30 14:59:48 2026 +0800

    [fix](job scheduler) Record task finish time on execution failure (#66232)
    
    ### What problem does this PR solve?
    
    When a task fails through the execution exception path,
    `AbstractTask.runTask()` calls the no-argument `onFail()`, which marked
    the task FAILED without recording `finishTimeMs`. MTMV failed refresh
    tasks therefore exposed an empty FinishTime and could not calculate
    DurationMs.
    
    relate PR:   #27703
    
    ### What changes were made?
    
    - Record `finishTimeMs` when `AbstractTask.onFail()` transitions a task
    to FAILED.
    - Add a regression unit test covering the `runTask()` exception path and
    preserving the error message.
    
    ### Testing
    
    - `AbstractJobStatusTest`: 13 tests passed.
---
 .../org/apache/doris/job/task/AbstractTask.java    |  1 +
 .../doris/job/base/AbstractJobStatusTest.java      | 23 ++++++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java 
b/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
index 4e2ac653cf7..9cf70edb655 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
@@ -71,6 +71,7 @@ public abstract class AbstractTask implements Task {
             return false;
         }
         status = TaskStatus.FAILED;
+        setFinishTimeMs(System.currentTimeMillis());
         if (!isCallable()) {
             return false;
         }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/job/base/AbstractJobStatusTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/job/base/AbstractJobStatusTest.java
index faf39164fc3..588aae4c0ca 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/job/base/AbstractJobStatusTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/job/base/AbstractJobStatusTest.java
@@ -66,6 +66,18 @@ class AbstractJobStatusTest {
         }
     }
 
+    private static class FailingTask extends DummyTask {
+        FailingTask(long taskId) {
+            super(taskId);
+            setJobId(1L);
+        }
+
+        @Override
+        public void run() throws JobException {
+            throw new JobException("task failed");
+        }
+    }
+
     private static class DummyJob extends AbstractJob<DummyTask, Void> {
         private final List<DummyTask> history = new ArrayList<>();
 
@@ -131,6 +143,17 @@ class AbstractJobStatusTest {
         Assertions.assertEquals(JobStatus.PENDING, job.getJobStatus());
     }
 
+    @Test
+    void testTaskFailureSetsFinishTime() throws Exception {
+        FailingTask task = new FailingTask(100L);
+
+        task.runTask();
+
+        Assertions.assertEquals(TaskStatus.FAILED, task.getStatus());
+        Assertions.assertNotNull(task.getFinishTimeMs());
+        Assertions.assertEquals("task failed", task.getErrMsg());
+    }
+
     @Test
     void testPendingFromRunning() throws Exception {
         DummyJob job = new DummyJob(JobStatus.RUNNING);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to