apache / apache/dolphinscheduler
[Improvement][Dependent Task] Optimize sub-workflow dependency logic
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 5.1k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 29
Description
### Search before asking
- [x] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
This is an extended issue for #16768 and #16776 to solve the scheduling time dependency issue.
The main problem is that dependent tasks query `WorkflowInstance` by `scheduleTime`, but sub-workflows do not have this value.
Recursively finding the main workflow is not a good approach, and iterating through all levels of sub-workflows from the main workflow is also inefficient—both may cause database performance issues.
Therefore, there should always be a key or value to directly determine the time and start action that workflows have.
For this reason, I propose creating a new object called `Action` to record the original workflow start information.
```mermaid
erDiagram
"[*Action]" {
int id
enum actionType
date submittedTime
}
"WorkflowInstance" {
int actionId FK
}
"TaskInstance" {
int workflowInstanceId FK
}
"WorkflowInstance" }|--|| "[*Action]" : ""
"TaskInstance" }|--|| "WorkflowInstance" : ""
```
Use `Action` addresses two issues:
1. Reducing database pressure: The dependent node first filters actions by submittedTime, then queries workflow-instances using (testFlag, code, actionId). This reduces table scans and optimizes index usage (previously on testFlag, code, scheduleTime/startTime).
2. Fixing dependency logic: Prevents null scheduleTime comparisons (in manual schedules), making the behavior more robust.
With the action object, the dependent node now query tasks always based on a fixed timestamp, not the node task's real `startTime`.
### Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
Contributor guide
Assessment
This issue has not been assessed yet.