[wp-trac] [WordPress Trac] #57271: Cron unschedule / reschedule event errors

WordPress Trac noreply at wordpress.org
Sun Dec 22 23:53:37 UTC 2024


#57271: Cron unschedule / reschedule event errors
--------------------------------------+------------------------------
 Reporter:  domainsupport             |       Owner:  audrasjb
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Cron API                  |     Version:  6.0
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by liedekef):

 As a linux sysadmin, here's my opinion:
 1) linux cron schedules don't run multiple times unless asked to do so.
 Don't search that route, system cron is a proven and well established
 mechanism, it is never the cause of problems.
 2) the actual problem lies in the way wordpress handles and tracks cron
 tasks: all in 1 option. The more correct method would be:
 - create a table that holds an entry for each planned task: id, name, date
 of planned execution, reschedule info, wanted action (and any arguments I
 guess), last completed execution time
 - when cron arrives: check all entries past their due time, keep that list
 in memory, recalculate the new date of planned execution and immediately
 update the relevant rows in the table
 - execute all wanted tasks from the list in memory and set "last completed
 execution time" when an task is finished (or anything else you want to
 keep as info when an task is finished)
 - actions that no longer need to be rescheduled can be removed from the
 table
 This ensures execution of a task doesn't interfere with others updating
 the table, nor has issues if the database is not responding (which would
 at most cause an action to be executed again on the next run), nor needs
 locking mechanisms.

 (btw: this is just a quick suggestion and I know it won't be easily
 implemented and might cause issues with existing events needing migration
 etc ...)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57271#comment:90>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list