You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "njnu-seafish (via GitHub)" <gi...@apache.org> on 2025/08/21 02:29:17 UTC

[PR] [Fix 17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

njnu-seafish opened a new pull request, #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are happy that you want to help us improve DolphinScheduler! -->
   
   ## Purpose of the pull request
   
   close #17436
   
   ## Brief change log
   1. add string blank check
   2. remove redundant cancelApplication call
   
   
   ## Verify this pull request
   
   After fixing the bug, timeout kill logs:
   
   2025-08-21 09:30:25.259 INFO  [WorkerRpcServer-methodInvoker-155] - Publish TaskExecutorKillLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739825259,
     "type" : "KILL"
   }
   2025-08-21 09:30:25.302 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Begin killing task instance, processId: 1115493
   2025-08-21 09:30:25.826 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - prepare to parse pid, raw pid string: sudo(1115493)---1341.sh(1115497)---sleep(1115570)
   
   2025-08-21 09:30:26.370 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Sending SIGINT to process group: 1115493 1115497 1115570, command: sudo -u dolphinscheduler -i kill -s SIGINT 1115493 1115497 1115570
   2025-08-21 09:30:37.408 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Kill command: sudo -u dolphinscheduler -i kill -s SIGINT 1115493 1115497 1115570, timed out, still running PIDs: 1115493 1115497 1115570
   2025-08-21 09:30:37.961 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Sending SIGTERM to process group: 1115493 1115497 1115570, command: sudo -u dolphinscheduler -i kill -s SIGTERM 1115493 1115497 1115570
   2025-08-21 09:30:38.156 ERROR [exclusive-task-executor-container-worker-1] - process has failure due to timeout kill, the timeout value is:60, the taskTimeoutStrategy is:FAILED
   2025-08-21 09:30:38.157 INFO  [exclusive-task-executor-container-worker-1] - process has killed. execute path:/data01/dolphinscheduler/exec/process/1341, processId:1115493 ,exitStatusCode:-1 ,processWaitForStatus:false ,processExitValue:143
   2025-08-21 09:30:38.157 INFO  [exclusive-task-executor-container-worker-1] - Publish TaskExecutorFailedLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739838157,
     "type" : "FAILED",
     "workflowInstanceId" : 1273,
     "workflowInstanceHost" : "192.168.30.11:5678",
     "taskInstanceHost" : "192.168.30.121:1234",
     "appIds" : null,
     "endTime" : 1755739838157,
     "latestReportTime" : null
   }
   2025-08-21 09:30:38.157 INFO  [exclusive-task-executor-container-worker-1] - Publish TaskExecutorFinalizeLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739838157,
     "type" : "FINALIZE"
   }
   2025-08-21 09:30:38.676 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Successfully killed process tree using SIGTERM, processId: 1115493
   2025-08-21 09:30:38.676 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Process tree for task: 1341 is killed or already finished, pid: 1115493
   2025-08-21 09:30:38.677 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Get appIds from worker 192.168.30.121:1234, taskLogPath: /data01/dolphinscheduler/20250821/149143631011392/7/1273/1341.log
   2025-08-21 09:30:38.677 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Start finding appId in /data01/dolphinscheduler/20250821/149143631011392/7/1273/1341.log, fetch way: log 
   2025-08-21 09:30:38.677 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - The appId is empty
   2025-08-21 09:30:38.677 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-22] - Success fire TaskExecutorKillLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739825259,
     "type" : "KILL"
   } 
   2025-08-21 09:30:38.718 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-20] - Success fire TaskExecutorFailedLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739838157,
     "type" : "FAILED",
     "workflowInstanceId" : 1273,
     "workflowInstanceHost" : "192.168.30.11:5678",
     "taskInstanceHost" : "192.168.30.121:1234",
     "appIds" : null,
     "endTime" : 1755739838157,
     "latestReportTime" : null
   } 
   2025-08-21 09:30:38.768 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-21] - 
   ************************************************************************************************
   *********************************  Finalize task instance  ************************************
   ***********************************************************************************************
   2025-08-21 09:30:38.768 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-21] - FINALIZE_SESSION
   2025-08-21 09:30:38.768 INFO  [PhysicalTaskExecutorEventBusCoordinator-eventbus-coordinator-worker-21] - Success fire TaskExecutorFinalizeLifecycleEvent: {
     "taskInstanceId" : 1341,
     "eventCreateTime" : 1755739838157,
     "type" : "FINALIZE"
   } 
   
   ## Pull Request Notice
   [Pull Request Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contains incompatible change, you should also add it to `docs/docs/en/guide/upgrade/incompatible.md`
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3270138824

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [42.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3251516682

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [40.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#discussion_r2320611569


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -190,13 +191,13 @@ public TaskResponse run(IShellInterceptorBuilder iShellInterceptorBuilder,
             result.setExitStatusCode(this.process.exitValue());
 
         } else {
-            log.error("process has failure, the task timeout configuration value is:{}, ready to kill ...",
-                    taskRequest.getTaskTimeout());
+            log.error("process has failure due to timeout kill, timeout value is:{}, timeoutStrategy is:{}",
+                    taskRequest.getTaskTimeout(), taskRequest.getTaskTimeoutStrategy());
             result.setExitStatusCode(EXIT_CODE_FAILURE);
-            cancelApplication();
         }
         int exitCode = this.process.exitValue();
-        String exitLogMessage = EXIT_CODE_KILL == exitCode ? "process has killed." : "process has exited.";
+        String exitLogMessage = (EXIT_CODE_KILL == exitCode || EXIT_CODE_HARD_KILL == exitCode) ? "process has killed."
+                : "process has exited.";

Review Comment:
   > It's better to check from status in `taskExecutionContext` rather then check from the exit code, we don't care about the exit, only kill from ds then we think it's kill.
   
   Here it simply outputs the final execution status of the process, indicating whether it exited normally or was killed.
   



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3257734458

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [42.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#discussion_r2320616024


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -190,13 +191,13 @@ public TaskResponse run(IShellInterceptorBuilder iShellInterceptorBuilder,
             result.setExitStatusCode(this.process.exitValue());
 
         } else {
-            log.error("process has failure, the task timeout configuration value is:{}, ready to kill ...",
-                    taskRequest.getTaskTimeout());
+            log.error("process has failure due to timeout kill, timeout value is:{}, timeoutStrategy is:{}",
+                    taskRequest.getTaskTimeout(), taskRequest.getTaskTimeoutStrategy());
             result.setExitStatusCode(EXIT_CODE_FAILURE);
-            cancelApplication();
         }
         int exitCode = this.process.exitValue();
-        String exitLogMessage = EXIT_CODE_KILL == exitCode ? "process has killed." : "process has exited.";
+        String exitLogMessage = (EXIT_CODE_KILL == exitCode || EXIT_CODE_HARD_KILL == exitCode) ? "process has killed."
+                : "process has exited.";

Review Comment:
   OK



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3209224938

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [33.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3270134512

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [42.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on code in PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#discussion_r2312824631


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -115,13 +115,14 @@
             // Get all child processes
             String pids = getPidsStr(processId);
             String[] pidArray = PID_PATTERN.split(pids);
-            if (pidArray.length == 0) {
+            if (StringUtils.isBlank(pids) || pidArray.length == 0) {
                 log.warn("No valid PIDs found for process: {}", processId);
                 return true;
             }
 
             // Convert PID string to list of integers
-            List<Integer> pidList = Arrays.stream(pidArray).map(Integer::parseInt).collect(Collectors.toList());
+            List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank).map(Integer::parseInt)

Review Comment:
   List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank)
                       .map(s -> {
                           try {
                               return Integer.parseInt(s.trim());
                           } catch (NumberFormatException e) {
                               log.warn("Invalid PID string ignored: {}", s);
                               return null;
                           }
                       })
                       .filter(Objects::nonNull)
                       .collect(Collectors.toList());



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3251518722

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [38.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3249100752

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [40.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#discussion_r2318766846


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -115,13 +115,23 @@ public static boolean kill(@NonNull TaskExecutionContext request) {
             // Get all child processes
             String pids = getPidsStr(processId);
             String[] pidArray = PID_PATTERN.split(pids);
-            if (pidArray.length == 0) {
+            if (StringUtils.isBlank(pids) || pidArray.length == 0) {
                 log.warn("No valid PIDs found for process: {}", processId);
                 return true;
             }
 
             // Convert PID string to list of integers
-            List<Integer> pidList = Arrays.stream(pidArray).map(Integer::parseInt).collect(Collectors.toList());
+            List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank)
+                    .map(s -> {
+                        try {
+                            return Integer.parseInt(s.trim());
+                        } catch (NumberFormatException e) {
+                            log.warn("Invalid PID string ignored: {}", s);
+                            return null;

Review Comment:
   Throw exception here, catch the exception will hide the bug.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -115,13 +115,23 @@ public static boolean kill(@NonNull TaskExecutionContext request) {
             // Get all child processes
             String pids = getPidsStr(processId);
             String[] pidArray = PID_PATTERN.split(pids);
-            if (pidArray.length == 0) {
+            if (StringUtils.isBlank(pids) || pidArray.length == 0) {
                 log.warn("No valid PIDs found for process: {}", processId);
                 return true;
             }
 
             // Convert PID string to list of integers
-            List<Integer> pidList = Arrays.stream(pidArray).map(Integer::parseInt).collect(Collectors.toList());
+            List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank)
+                    .map(s -> {
+                        try {
+                            return Integer.parseInt(s.trim());
+                        } catch (NumberFormatException e) {
+                            log.warn("Invalid PID string ignored: {}", s);
+                            return null;
+                        }
+                    })
+                    .filter(Objects::nonNull)
+                    .collect(Collectors.toList());

Review Comment:
   It's better to change `getPidsStr` return a validate pid list, rather than parse the pid in up layer.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/AbstractCommandExecutor.java:
##########
@@ -190,13 +191,13 @@ public TaskResponse run(IShellInterceptorBuilder iShellInterceptorBuilder,
             result.setExitStatusCode(this.process.exitValue());
 
         } else {
-            log.error("process has failure, the task timeout configuration value is:{}, ready to kill ...",
-                    taskRequest.getTaskTimeout());
+            log.error("process has failure due to timeout kill, timeout value is:{}, timeoutStrategy is:{}",
+                    taskRequest.getTaskTimeout(), taskRequest.getTaskTimeoutStrategy());
             result.setExitStatusCode(EXIT_CODE_FAILURE);
-            cancelApplication();
         }
         int exitCode = this.process.exitValue();
-        String exitLogMessage = EXIT_CODE_KILL == exitCode ? "process has killed." : "process has exited.";
+        String exitLogMessage = (EXIT_CODE_KILL == exitCode || EXIT_CODE_HARD_KILL == exitCode) ? "process has killed."
+                : "process has exited.";

Review Comment:
   It's better to check from status in `taskExecutionContext` rather then check from the exit code, we don't care about the exit, only kill from ds then we think it's kill.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -115,13 +115,23 @@ public static boolean kill(@NonNull TaskExecutionContext request) {
             // Get all child processes
             String pids = getPidsStr(processId);
             String[] pidArray = PID_PATTERN.split(pids);
-            if (pidArray.length == 0) {
+            if (StringUtils.isBlank(pids) || pidArray.length == 0) {

Review Comment:
   if`StringUtils.isEmpty(pids)` then we don't need to execute line 117.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "njnu-seafish (via GitHub)" <gi...@apache.org>.
njnu-seafish commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3269765534

   @SbloodyS Could u plz help review when available?  Thanks.


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#discussion_r2289979621


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/ProcessUtils.java:
##########
@@ -115,13 +115,14 @@
             // Get all child processes
             String pids = getPidsStr(processId);
             String[] pidArray = PID_PATTERN.split(pids);
-            if (pidArray.length == 0) {
+            if (StringUtils.isBlank(pids) || pidArray.length == 0) {
                 log.warn("No valid PIDs found for process: {}", processId);
                 return true;
             }
 
             // Convert PID string to list of integers
-            List<Integer> pidList = Arrays.stream(pidArray).map(Integer::parseInt).collect(Collectors.toList());
+            List<Integer> pidList = Arrays.stream(pidArray).filter(StringUtils::isNotBlank).map(Integer::parseInt)

Review Comment:
   ## Missing catch of NumberFormatException
   
   Potential uncaught 'java.lang.NumberFormatException'.
   
   [Show more details](https://github.com/apache/dolphinscheduler/security/code-scanning/5522)



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3209222768

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [B Maintainability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) (required ≥ A)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarQube for IDE](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3249099236

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=17437&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [38.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437#issuecomment-3257731950

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [42.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=17437&metric=new_coverage&view=list) (required ≥ 60%)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=17437)
   
   


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Fix-17436][Workflow]Task timeout kill throw exception [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS merged PR #17437:
URL: https://github.com/apache/dolphinscheduler/pull/17437


-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org