diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/flowtask/AlterScheduleTask.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/flowtask/AlterScheduleTask.java index a855a672a9..0237b114a0 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/flowtask/AlterScheduleTask.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/schedule/flowtask/AlterScheduleTask.java @@ -114,10 +114,7 @@ protected AlterScheduleResult start(Long taskId, TaskService taskService, Delega taskService.fail(taskId, 0, taskResult); log.warn("Alter schedule failed,error={}", e.getMessage()); return taskResult; - } finally { - AlterScheduleTraceContextHolder.clear(); } - } @Override @@ -134,6 +131,7 @@ protected boolean isFailure() { protected void onFailure(Long taskId, TaskService taskService) { log.warn("Alter schedule failed, taskId={}", taskId); super.callback(getFlowInstanceId(), getTargetTaskInstanceId(), FlowNodeStatus.FAILED, null); + AlterScheduleTraceContextHolder.clear(); } @Override @@ -141,12 +139,14 @@ protected void onSuccessful(Long taskId, TaskService taskService) { log.info("Alter schedule succeed, taskId={}", taskId); super.callback(getFlowInstanceId(), getTargetTaskInstanceId(), FlowNodeStatus.COMPLETED, null); updateFlowInstanceStatus(FlowStatus.EXECUTION_SUCCEEDED); + AlterScheduleTraceContextHolder.clear(); } @Override protected void onTimeout(Long taskId, TaskService taskService) { log.warn("Alter schedule timeout, taskId={}", taskId); super.callback(getFlowInstanceId(), getTargetTaskInstanceId(), FlowNodeStatus.EXPIRED, null); + AlterScheduleTraceContextHolder.clear(); } @Override @@ -157,6 +157,7 @@ protected void onProgressUpdate(Long taskId, TaskService taskService) { @Override protected boolean cancel(boolean mayInterruptIfRunning, Long taskId, TaskService taskService) { taskService.cancel(taskId); + AlterScheduleTraceContextHolder.clear(); return true; }