[Bug] [dolphinscheduler-service] when WorkflowExecutionStatus is READY_STOP will start into infinite loop
Search before asking
- [X] I had searched in the issues and found no similar issues.
What happened
[INFO] 2023-07-10 17:29:10.423 org.apache.dolphinscheduler.service.process.ProcessServiceImpl:[1333] - [WorkflowInstance-283163][TaskInstance-0] - Start save taskInstance to database : app_retailers_online_secondary_industry_cube_all_copy_20221018142200875, processInstance id:283163, state: WorkflowExecutionStatus{code=4, desc='ready stop'}
[ERROR] 2023-07-10 17:29:10.423 org.apache.dolphinscheduler.service.process.ProcessServiceImpl:[1307] - [WorkflowInstance-283164][TaskInstance-0] - task commit to db failed , taskCode: 7196556024840 has already retry 3 times, please check the database
[WARN] 2023-07-10 17:29:10.423 org.apache.dolphinscheduler.service.process.ProcessServiceImpl:[1599] - [WorkflowInstance-283163][TaskInstance-0] - processInstance: 283163 state was: WorkflowExecutionStatus{code=4, desc='ready stop'}, skip submit this task, taskCode: 7250396272006
[ERROR] 2023-07-10 17:29:10.423 org.apache.dolphinscheduler.service.process.ProcessServiceImpl:[1340] - [WorkflowInstance-283163][TaskInstance-0] - Save taskInstance to db error, task name:app_retailers_online_secondary_industry_cube_all_copy_20221018142200875, process id:283163 state: WorkflowExecutionStatus{code=4, desc='ready stop'}
[ERROR] 2023-07-10 17:29:10.423 org.apache.dolphinscheduler.service.process.ProcessServiceImpl:[1307] - [WorkflowInstance-283163][TaskInstance-0] - task commit to db failed , taskCode: 7250396272006 has already retry 3 times, please check the database
public TaskInstance submitTask(ProcessInstance processInstance, TaskInstance taskInstance) {
logger.info("Start save taskInstance to database : {}, processInstance id:{}, state: {}",
taskInstance.getName(),
taskInstance.getProcessInstanceId(),
processInstance.getState()); // READY_STOP
// submit to db
TaskInstance task = submitTaskInstanceToDB(taskInstance, processInstance); // start submit task instance to db
if (task == null) { // into this condition
logger.error("Save taskInstance to db error, task name:{}, process id:{} state: {} ",
taskInstance.getName(),
taskInstance.getProcessInstance().getId(),
processInstance.getState());
return null; // and will return null
}
public TaskInstance submitTaskInstanceToDB(TaskInstance taskInstance, ProcessInstance processInstance) {
WorkflowExecutionStatus processInstanceState = processInstance.getState();
if (processInstanceState.isFinished() || processInstanceState == WorkflowExecutionStatus.READY_STOP) { // return null
logger.warn("processInstance: {} state was: {}, skip submit this task, taskCode: {}",
processInstance.getId(),
processInstanceState,
taskInstance.getTaskCode());
return null;
}
public TaskInstance submitTaskWithRetry(ProcessInstance processInstance, TaskInstance taskInstance,
int commitRetryTimes, long commitInterval) {
int retryTimes = 1;
TaskInstance task = null;
while (retryTimes <= commitRetryTimes) {
try {
// submit task to db
// Only want to use transaction here
task = submitTask(processInstance, taskInstance);
if (task != null && task.getId() != null) {
break;
}
logger.error(
"task commit to db failed , taskCode: {} has already retry {} times, please check the database", // will retry again
and task submit max retry times is 5
taskInstance.getTaskCode(),
retryTimes);
Thread.sleep(commitInterval);
} catch (Exception e) {
logger.error("task commit to db failed", e);
} finally {
retryTimes += 1;
}
}
return task; // after 5 times return null
}
@Override
public boolean submitTask() {
this.taskInstance =
processService.submitTaskWithRetry(processInstance, taskInstance, maxRetryTimes, commitInterval);
if (this.taskInstance == null) {
return false; // return false
}
this.setTaskExecutionLogger();
logger.info("switch task submit success");
return true;
}
private Optional<TaskInstance> submitTaskExec(TaskInstance taskInstance) {
try {
// package task instance before submit
processService.packageTaskInstance(taskInstance, processInstance);
ITaskProcessor taskProcessor = TaskProcessorFactory.getTaskProcessor(taskInstance.getTaskType());
taskProcessor.init(taskInstance, processInstance);
if (taskInstance.getState().isRunning()
&& taskProcessor.getType().equalsIgnoreCase(Constants.COMMON_TASK_TYPE)) {
notifyProcessHostUpdate(taskInstance);
}
boolean submit = taskProcessor.action(TaskAction.SUBMIT);
if (!submit) {
logger.error("Submit standby task failed!, taskCode: {}, taskName: {}",
taskInstance.getTaskCode(),
taskInstance.getName());
return Optional.empty(); // TaskInstance is empty
}
public void submitStandByTask() throws StateEventHandleException {
...
if (!taskInstanceOptional.isPresent()) {
this.taskFailedSubmit = true;
// Remove and add to complete map and error map
if (!removeTaskFromStandbyList(task)) {
logger.error(
"Task submit failed, remove from standby list failed, workflowInstanceId: {}, taskCode: {}",
processInstance.getId(),
task.getTaskCode());
}
completeTaskMap.put(task.getTaskCode(), task.getId()); // getId is NullException
taskInstanceMap.put(task.getId(), task);
...
[ERROR] 2023-07-10 17:52:59.909 org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable:[950] - [WorkflowInstance-283162][TaskInstance-0] - Submit standby task failed!, taskCode: 7250411457542, taskName: app_retailers_online_secondary_industry_cube_all_copy_20221013173133944_copy_20221018142359512
[ERROR] 2023-07-10 17:52:59.910 org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable:[709] - [WorkflowInstance-0][TaskInstance-0] - Start workflow error
java.lang.NullPointerException: null
at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
at org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable.submitStandByTask(WorkflowExecuteRunnable.java:1864)
at org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable.submitPostNode(WorkflowExecuteRunnable.java:1370)
at org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteRunnable.call(WorkflowExecuteRunnable.java:703)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
fix before
cpu resource exhaustion in invalid log output
fix after
it looks normal. The logs also don't have a lot of invalid output
What you expected to happen
WorkflowExecutionStatus change to KILL
How to reproduce
stop a workflow
Anything else
No response
Version
3.1.x
Are you willing to submit PR?
- [x] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
how to fix i have same problem
https://github.com/apache/dolphinscheduler/pull/14499
This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.
This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.