njnu-seafish commented on code in PR #17696:
URL: 
https://github.com/apache/dolphinscheduler/pull/17696#discussion_r2693351978


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java:
##########
@@ -128,7 +136,21 @@ public void handle(TaskCallBack taskCallBack) throws 
TaskException {
 
     @Override
     public void cancel() throws TaskException {
-
+        Statement stmt = this.sessionStatement;
+        if (stmt != null) {
+            try {
+                log.debug("Try to cancel this procedure task");
+                setExitStatusCode(TaskConstants.EXIT_CODE_KILL);
+                stmt.cancel();
+                log.debug("this procedure task was canceled");
+            } catch (SQLException ex) {
+                log.warn("Failed to cancel procedure task (driver/DB may not 
support it)", ex);
+                throw new TaskException("Cancel procedure task failed", ex);
+            }
+        } else {
+            log.warn(
+                    "Attempted to cancel procedure task, but no active 
statement exists. Possible reasons: task not started, already completed, or 
canceled.");
+        }

Review Comment:
   > Statement stmt = this.sessionStatement;
   >         if (stmt != null) {
   >             try {
   >                 log.info("Try to cancel this procedure task");
   >                 stmt.cancel();
   >                 setExitStatusCode(TaskConstants.EXIT_CODE_KILL);
   >                 log.info("this procedure task was canceled");
   >             } catch (SQLException ex) {
   >                 log.warn("Failed to cancel procedure task", ex);
   >                 throw new TaskException("Cancel procedure task failed", 
ex);
   >             }
   >         } else {
   >             log.info(
   >                     "Attempted to cancel procedure task, but no active 
statement exists. Possible reasons: task not started, already completed, or 
canceled.");
   >         }
   
   ok, it is better



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to