Bug #22900
closedEasy Appointments plugin creates thousands of cronjobs
0%
Description
While looking into https://redmine.gc.cuny.edu/issues/21964#note-36, I've discovered that the Easy Appointments plugin has been creating thousands of cronjobs since the last maintenance release update on May 27th due to not checking for the existence of their cronjob before scheduling another job.
This has created a large backlog in Cavalcade, our scheduled tasks runner, of about four days. Their plugin has more than 670,000 jobs in the backlog!
> select site,hook,count(*) from wp_cavalcade_jobs where hook = 'easyapp_hourly_event' and status = 'waiting' group by site order by count(*); +-------+----------------------+----------+ | site | hook | count(*) | +-------+----------------------+----------+ | 25751 | easyapp_hourly_event | 2 | | 22688 | easyapp_hourly_event | 5 | | 26672 | easyapp_hourly_event | 20 | | 23078 | easyapp_hourly_event | 21 | | 26673 | easyapp_hourly_event | 22 | | 28741 | easyapp_hourly_event | 66 | | 25076 | easyapp_hourly_event | 69 | | 26910 | easyapp_hourly_event | 170 | | 25677 | easyapp_hourly_event | 165335 | | 22476 | easyapp_hourly_event | 166856 | | 27356 | easyapp_hourly_event | 171831 | | 34629 | easyapp_hourly_event | 173548 | +-------+----------------------+----------+ 12 rows in set (2.597 sec)
This issue was also reported on the wp.org forums here: https://wordpress.org/support/topic/easyapp_hourly_event-being-created-hundreds-of-times/.
Fortunately, there's a new release of the plugin that addresses this issue. I will commit and push the new release to production and then do some task clean up.
Updated by Raymond Hoh 15 days ago
I've updated the easy-appointments
plugin to v3.12.12.1 in https://github.com/cuny-academic-commons/cac/commit/fd95b6537720c23069b45f9cc66367d20c88dc7d and pushed the update to production.
Next, I deleted all ~670,000 'easyapp_hourly_event'
cronjobs in batches of 1000 with the following CLI script:
<?php function delete_easyapp_cronjobs( $batch_size, $counter ) { global $wpdb; $batch_size = (int) $batch_size; $wpdb->query( "delete from wp_cavalcade_jobs where hook = 'easyapp_hourly_event' and status = 'waiting' order by id limit {$batch_size}" ); $deleted_count = $batch_size * $counter; WP_CLI::log( "Deleted {$deleted_count} jobs." ); sleep( 3 ); if ( has_easyapp_cronjobs( $batch_size ) ) { delete_easyapp_cronjobs( $batch_size, ++$counter ); } else { WP_CLI::log( "Done!" ); } } function has_easyapp_cronjobs( $batch_size ) { global $wpdb; $count = $wpdb->get_var( "select count(*) from wp_cavalcade_jobs where hook = 'easyapp_hourly_event' and status = 'waiting'" ); if ( (int) $count > $batch_size ) { return true; } return false; } $limit = 1000; if ( has_easyapp_cronjobs( $limit ) ) { delete_easyapp_cronjobs( $limit, 1 ); }
Cavalcade is still behind by a few days. I'm going to let Cavalcade try and catch up and check back in before I head to bed.
Updated by Raymond Hoh 15 days ago
- Status changed from New to Resolved
Looks like the scheduled tasks queue is going to be back to normal within the next few hours.
Going to tentatively close this one out.
Update: The scheduled tasks queue is finally back to normal.