Magento 2: CronJob bug? MySQL is always running at 30% usage and many php processes are running
My best guess,
See this at stackexchange and this at github. The issue somehow appears as some cronjobs aren't indicated as completed. It freaked me out for quite some time.
The quick diagnosis to see if you have the issue is to run below query and if it comes back with more than a 1200-1500 or so, you likely have the issue:
select count(*) from cron_schedule;
The quick fix is to delete most of the stuff that have status running in cron_schedule:
delete from cron_schedule where scheduled_at < date_sub(now(), interval 1 hour);
To avoid recurrence, establish a cron-job that periodically deletes the stuck jobs. Below job can be added in cron-tab. However, if you have it on a shared server, the MySQL password and username will be visible by other users running top -c and similar and it is not advisable, read more on guidelines for password security.
* */8 * * * <path_to_mysql_binary_dir>/mysql -u<sql_user> -p'<sql_user_pass>' <database_name> -e "delete from cron_schedule where scheduled_at < date_sub(now(), interval 1 hour)";
Adjust the * * * * * to fit the frequency, I don't see the need to run it very often, as I still haven't faced the same issue again after months of doing the quick fix.