[FEATURE]: when a workflow is removed, not all of its children are removed.
Please read our contributor guide before creating an issue.
Also consider discussing your idea on the discussion forum first.
Describe the Feature Request
When a workflow is removed, not all of its children are removed.
Describe Preferred Solution
You could include in the removal of a workflow the search for children via parent_workflow_id to then be able to remove them together with the connected tasks.
Hi @mspasiano can you provide a sample workflow and steps to reproduce?
For example, at this point you could search for all workflows that have the incoming workflowId as parent_workflow_id and delete them by calling the same method
Inspecting the code a bit, the solution could be to store the parent_workflow_id information on the indexes and in case these are active use it to get all the child workflows. Could this be a viable solution?
I tried changing the strategy and inserting the removal of the workflow when the task responsible for starting it is removed:
if (Optional.ofNullable(task)
.map(TaskModel::getTaskType)
.filter(
s ->
s.equalsIgnoreCase(TaskType.TASK_TYPE_START_WORKFLOW)
|| s.equalsIgnoreCase(TaskType.TASK_TYPE_SUB_WORKFLOW))
.isPresent()) {
Optional.ofNullable(task.getOutputData())
.map(
stringObjectMap ->
Optional.ofNullable(stringObjectMap.get("workflowId"))
.orElseGet(task::getSubWorkflowId))
.map(String::valueOf)
.ifPresent(
workflowId -> {
try {
logger.trace("Try to delete workflow {}", workflowId);
removeWorkflow(workflowId);
} catch (NotFoundException _ex) {
logger.trace(_ex.getMessage());
}
});
}
It works, but removal is very slow. Any suggestions?