[Bug] [dao] Scheduling a large number of tasks . Metadata database resource consumption is high
Search before asking
- [X] I had searched in the issues and found no similar issues.
What happened
使用dolphinscheduler每天调度10万级工作流,上百万任务量时,使用mysql作为元数据库,mysql压力过大
如下图,开始mysql配置为2核4g,cpu占用非常多峰刺。
然后升级mysql为8核16g,很快cpu使用率就达到100%

What you expected to happen
经过问题排查发现t_ds_task_instance,t_ds_process_instance,t_ds_relation_process_instance这三张表数据量过大,并且没有配置入口去删除数据。 而mysql cpu使用过高的的原因主要是大量相同语句查询t_ds_relation_process_instance表,查询语句如下: select id, parent_process_instance_id, parent_task_instance_id, process_instance_id from t_ds_relation_process_instance where parent_process_instance_id = 667735 and parent_task_instance_id = 2454593;
这个表没有创建合适的索引,导致每次查询会扫描全表。
所以可以对此表增加索引,可以很大程度缓解mysql压力。

How to reproduce
工作流、任务并行度为默认值,元数据库为mysql 每小时调度数百个工作流,每个工作流有数十个任务 执行一段时间会把mysql cpu占满
Anything else
No response
Version
2.0.5
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
Search before asking
- [X] I had searched in the issues and found no similar issues.
What happened
Using dolphinscheduler to schedule 100,000-level workflows per day, when using mysql as the metadata database for millions of tasks, the pressure on mysql is too high
As shown in the figure below, MySQL is initially configured with 2 cores and 4G, and the CPU usage is very high.
Then upgrade mysql to 8 cores and 16g, and soon the cpu usage will reach 100%

What you expected to happen
After troubleshooting, it was found that the data volume of the three tables t_ds_task_instance, t_ds_process_instance, and t_ds_relation_process_instance was too large, and no entry was configured to delete the data. The reason for the high usage of mysql cpu is that a large number of the same statements query the t_ds_relation_process_instance table. The query statements are as follows: select id, parent_process_instance_id, parent_task_instance_id, process_instance_id from t_ds_relation_process_instance where parent_process_instance_id = 667735 and parent_task_instance_id = 2454593;
This table does not have an appropriate index created, causing each query to scan the full table.
Therefore, you can add an index to this table, which can greatly relieve the pressure on MySQL.

How to reproduce
Workflow and task parallelism are the default values, and the metadata database is mysql Schedule hundreds of workflows per hour, each with dozens of tasks Executing for a period of time will fill up the mysql cpu
Anything else
No response
Version
2.0.5
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
Thank you for your feedback, we have received your issue, Please wait patiently for a reply.
- In order for us to understand your request as soon as possible, please provide detailed information、version or pictures.
- If you haven't received a reply for a long time, you can join our slack and send your question to channel
#troubleshooting