njnu-seafish commented on code in PR #17696:
URL:
https://github.com/apache/dolphinscheduler/pull/17696#discussion_r2575693750
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java:
##########
@@ -105,30 +108,49 @@ public void handle(TaskCallBack taskCallBack) throws
TaskException {
}
String proceduerSql = formatSql(sqlParamsMap, paramsMap);
// call method
- try (CallableStatement stmt =
connection.prepareCall(proceduerSql)) {
+ try (CallableStatement tmpStatement =
connection.prepareCall(proceduerSql)) {
+ sessionStatement = tmpStatement;
// set timeout
- setTimeout(stmt);
+ setTimeout(tmpStatement);
// outParameterMap
- Map<Integer, Property> outParameterMap =
getOutParameterMap(stmt, sqlParamsMap, paramsMap);
+ Map<Integer, Property> outParameterMap =
getOutParameterMap(tmpStatement, sqlParamsMap, paramsMap);
- stmt.executeUpdate();
+ tmpStatement.executeUpdate();
// print the output parameters to the log
- printOutParameter(stmt, outParameterMap);
+ printOutParameter(tmpStatement, outParameterMap);
setExitStatusCode(EXIT_CODE_SUCCESS);
}
} catch (Exception e) {
+ if (exitStatusCode == TaskConstants.EXIT_CODE_KILL) {
+ log.info("procedure task has been killed");
+ return;
+ }
setExitStatusCode(EXIT_CODE_FAILURE);
log.error("procedure task error", e);
throw new TaskException("Execute procedure task failed", e);
}
}
@Override
- public void cancel() throws TaskException {
-
+ public void cancel() {
+ Statement stmt = this.sessionStatement;
+ if (stmt != null) {
+ try {
+ log.debug("Try to cancel this procedure task");
+ stmt.cancel();
+ setExitStatusCode(TaskConstants.EXIT_CODE_KILL);
+ log.debug("this procedure task was canceled");
+ } catch (SQLException ex) {
+ log.warn("Failed to cancel stored procedure (driver/DB may not
support it)", ex);
+ throw new TaskException("Cancel http task failed", ex);
Review Comment:
> The error message refers to "http task" but this is a procedure task. The
message should be "Cancel procedure task failed" instead of "Cancel http task
failed".
nice
--
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]