[wp-trac] [WordPress Trac] #11800: doubled execution of cron jobs

WordPress Trac noreply at wordpress.org
Sun Apr 4 06:55:44 UTC 2021


#11800: doubled execution of cron jobs
--------------------------------------+-----------------------------
 Reporter:  neoxx                     |       Owner:  westi
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  Cron API                  |     Version:  2.9.1
 Severity:  normal                    |  Resolution:
 Keywords:  dev-feedback needs-patch  |     Focuses:
--------------------------------------+-----------------------------

Comment (by opajaap):

 This is especially annoying when the cron process sends emails.

 Here is a proof of evidence that this bug still exists.
 What you see is a logfile from plugin wp photo album plus (last message on
 top) that shows that process ids 1965 and 1975 are doing the same job
 simultaneously.
 The processes can not communicate through a wp option indicating what they
 are doing because the options table is not updated immediately. So saving
 the hashvalues in an option does not work here.
 My solution to this is to write essential data indicating the job in a
 file and call clearstatcache(). If there is a second process attempting to
 do the same, it sees that in the file and can abort its execution. This
 kind of 'locking' is safe as such that it can not hang up the system (the
 'lock' does not need to be released, it will be overwritten by the next
 email job).

 It took me only a week to find this out.

 The logfile (the process ids are from getmypid() and placed between
 brackets):

 Eml: on:01.04.2021 17:06:25: cron-job (1965): Done mailing commentnotify
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Mailinglist commentprevious
 scheduled for run in 120 seconds. Args: 0, 0, 252247, , 0
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 ffb88919f374158d5ec5a63184939d1d added to sent mails
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 ffb88919f374158d5ec5a63184939d1d, Mail sent to: marc at digitalsea.co.uk
 (105190) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 ca4194fbb23e7fd80c1d31750555f1e9 added to sent mails
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 ca4194fbb23e7fd80c1d31750555f1e9, Mail sent to: rachel at digitalsea.co.uk
 (101488) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 3080ce36ffc367958b991b97abc20427 added to sent mails
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 3080ce36ffc367958b991b97abc20427, Mail sent to: joellen.popma at gmail.com
 (100641) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 b9fba1d0496a9b715a96a0906899d5d6 added to sent mails
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 b9fba1d0496a9b715a96a0906899d5d6, Mail sent to: hannah.a.j.249 at gmail.com
 (98553) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 622cbf03952ce0489f532d3d352037ab added to sent mails
 Eml: on:01.04.2021 17:06:25: cron-job (1965): Hash:
 622cbf03952ce0489f532d3d352037ab, Mail sent to: neil at digitalsea.co.uk
 (95781) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 4452147011a8668325abec4fc0a51582 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 4452147011a8668325abec4fc0a51582, Mail sent to: stephen at digitalsea.co.uk
 (84625) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Done mailing commentnotify
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Mailinglist commentprevious
 scheduled for run in 120 seconds. Args: 0, 0, 252247, , 0
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 ffb88919f374158d5ec5a63184939d1d added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 ffb88919f374158d5ec5a63184939d1d, Mail sent to: marc at digitalsea.co.uk
 (105190) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 a476d22a0401eaf26deb4e04430ebba0 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 a476d22a0401eaf26deb4e04430ebba0, Mail sent to: rebecca at digitalsea.io
 (80305) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 ca4194fbb23e7fd80c1d31750555f1e9 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 ca4194fbb23e7fd80c1d31750555f1e9, Mail sent to: rachel at digitalsea.co.uk
 (101488) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 0985dd7ea9637e2c46f75137250267c9 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Hash:
 0985dd7ea9637e2c46f75137250267c9, Mail sent to: OpaJaap at opajaap.nl (36855)
 subject: [iPhotography] Comment on photo Monday's Photoshoot, photo:
 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 3080ce36ffc367958b991b97abc20427 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 3080ce36ffc367958b991b97abc20427, Mail sent to: joellen.popma at gmail.com
 (100641) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Potential receipients:
 3643,36855,80305,84625,95781,101488,104541,105190,98553,100641, all
 subscribed potential: 36855,80305,84625,95781,98553,100641,101488,105190
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 b9fba1d0496a9b715a96a0906899d5d6 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 b9fba1d0496a9b715a96a0906899d5d6, Mail sent to: hannah.a.j.249 at gmail.com
 (98553) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1965): superusers
 Eml: on:01.04.2021 17:06:24: cron-job (1965): comment owner 100641,
 JoKayaks
 Eml: on:01.04.2021 17:06:24: cron-job (1965): photo owner 98553,
 happyhannah
 Eml: on:01.04.2021 17:06:24: cron-job (1965): admins
 3643,36855,80305,84625,95781,101488,104541,105190
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 622cbf03952ce0489f532d3d352037ab added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 622cbf03952ce0489f532d3d352037ab, Mail sent to: neil at digitalsea.co.uk
 (95781) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 4452147011a8668325abec4fc0a51582 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 4452147011a8668325abec4fc0a51582, Mail sent to: stephen at digitalsea.co.uk
 (84625) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 a476d22a0401eaf26deb4e04430ebba0 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 a476d22a0401eaf26deb4e04430ebba0, Mail sent to: rebecca at digitalsea.io
 (80305) subject: [iPhotography] Comment on photo Monday's Photoshoot,
 photo: 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 0985dd7ea9637e2c46f75137250267c9 added to sent mails
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Hash:
 0985dd7ea9637e2c46f75137250267c9, Mail sent to: OpaJaap at opajaap.nl (36855)
 subject: [iPhotography] Comment on photo Monday's Photoshoot, photo:
 183876
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Potential receipients:
 3643,36855,80305,84625,95781,101488,104541,105190,98553,100641, all
 subscribed potential: 36855,80305,84625,95781,98553,100641,101488,105190
 Eml: on:01.04.2021 17:06:24: cron-job (1975): superusers
 Eml: on:01.04.2021 17:06:24: cron-job (1975): comment owner 100641,
 JoKayaks
 Eml: on:01.04.2021 17:06:24: cron-job (1975): photo owner 98553,
 happyhannah
 Eml: on:01.04.2021 17:06:24: cron-job (1975): admins
 3643,36855,80305,84625,95781,101488,104541,105190
 Eml: on:01.04.2021 17:06:24: cron-job (1965): Doing mailing commentnotify
 for 103408 recipients. Starting id = 0
 Eml: on:01.04.2021 17:06:24: cron-job (1975): Doing mailing commentnotify
 for 103408 recipients. Starting id = 0

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


More information about the wp-trac mailing list