[wp-hackers] Dealing with WP cron's raciness
Otto
otto at ottodestruct.com
Wed Sep 18 22:59:10 UTC 2013
On Wed, Sep 18, 2013 at 6:06 AM, David Anderson <david at wordshell.net> wrote:
> 3) Create a few processes that are continually calling wp-cron.php (two or
> more):
> while true; do wget -O - http://localhost/mydevwebsite/wp-cron.php; done
Why are you hitting the wp-cron.php file directly? WordPress doesn't
do that normally.
WordPress normally sets the doing_wp_cron transient with the current
time(), then calls wp-cron.php?doing_wp_cron=time. This is a locking
mechanism to prevent the subsequent calls after that from running.
This is not *perfect*, but it is pretty good and prevents most of the
problem you're describing. If you're calling wp-cron.php directly,
you're bypassing this mechanism, and the delay you've added to the
database will cause the locking mechanism to take longer, causing the
race issues.
-Otto
More information about the wp-hackers
mailing list