Browse Source

Fix the invalidate task instance never be deleted (#13091)

3.2.0-release
Wenjun Ruan 2 years ago committed by GitHub
parent
commit
fed1e85fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java
  2. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java
  3. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/TaskInstanceDao.java
  4. 5
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskInstanceDaoImpl.java
  5. 6
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml
  6. 2
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
  7. 21
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java

8
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java

@ -816,11 +816,9 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
try {
processService.removeTaskLogFile(processInstanceId);
} catch (Exception ignore) {
} catch (Exception ex) {
// ignore
logger.warn(
"Remove task log file exception, projectCode:{}, ProcessDefinitionCode{}, processInstanceId:{}.",
projectCode, processInstance.getProcessDefinitionCode(), processInstanceId);
logger.warn("Remove task log file exception, processInstanceId:{}.", processInstanceId, ex);
}
// delete database cascade
@ -828,7 +826,7 @@ public class ProcessInstanceServiceImpl extends BaseServiceImpl implements Proce
processService.deleteAllSubWorkProcessByParentId(processInstanceId);
processService.deleteWorkProcessMapByParentId(processInstanceId);
processService.deleteWorkTaskInstanceByProcessInstanceId(processInstanceId);
taskInstanceDao.deleteByWorkflowInstanceId(processInstanceId);
if (delete > 0) {
logger.info(

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java

@ -153,4 +153,6 @@ public interface TaskInstanceMapper extends BaseMapper<TaskInstance> {
List<TaskInstance> loadAllInfosNoRelease(@Param("processInstanceId") int processInstanceId,
@Param("status") int status);
void deleteByWorkflowInstanceId(@Param("workflowInstanceId") int workflowInstanceId);
}

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/TaskInstanceDao.java

@ -87,4 +87,6 @@ public interface TaskInstanceDao {
*/
List<TaskInstance> findTaskInstanceByIdList(List<Integer> idList);
void deleteByWorkflowInstanceId(int workflowInstanceId);
}

5
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/TaskInstanceDaoImpl.java

@ -167,4 +167,9 @@ public class TaskInstanceDaoImpl implements TaskInstanceDao {
return taskInstanceMapper.selectBatchIds(idList);
}
@Override
public void deleteByWorkflowInstanceId(int workflowInstanceId) {
taskInstanceMapper.deleteByWorkflowInstanceId(workflowInstanceId);
}
}

6
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.xml

@ -330,4 +330,10 @@
where instance.process_instance_id = #{processInstanceId}
and que.status = #{status}
</select>
<delete id="deleteByWorkflowInstanceId">
delete
from t_ds_task_instance
where process_instance_id = #{workflowInstanceId}
</delete>
</mapper>

2
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -83,8 +83,6 @@ public interface ProcessService {
void removeTaskLogFile(Integer processInstanceId);
void deleteWorkTaskInstanceByProcessInstanceId(int processInstanceId);
void recurseFindSubProcess(long parentCode, List<Long> ids);
Tenant getTenantForProcess(int tenantId, int userId);

21
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java

@ -527,27 +527,6 @@ public class ProcessServiceImpl implements ProcessService {
}
}
/**
* recursive delete all task instance by process instance id
*/
@Override
public void deleteWorkTaskInstanceByProcessInstanceId(int processInstanceId) {
ProcessInstance processInstance = processInstanceMapper.selectById(processInstanceId);
List<TaskInstance> taskInstanceList =
taskInstanceDao.findValidTaskListByProcessId(processInstanceId, processInstance.getTestFlag());
if (CollectionUtils.isEmpty(taskInstanceList)) {
return;
}
List<Integer> taskInstanceIdList = new ArrayList<>();
for (TaskInstance taskInstance : taskInstanceList) {
taskInstanceIdList.add(taskInstance.getId());
}
taskInstanceMapper.deleteBatchIds(taskInstanceIdList);
}
/**
* recursive query sub process definition id by parent id.
*

Loading…
Cancel
Save