Ticket #3713 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Missing wp-cron.php might put huge stress on the Server

Reported by: Jan Assigned to: anonymous
Priority: high Milestone: 2.1.1
Component: General Version: 2.1
Severity: critical Keywords: has-patch wp-cron cron recursive call heavy load server scheduler
Cc:

Description (Last modified by foolswisdom)

It happened to me when I forgot uploading wp-cron.php after updating to 2.1.

The Scheduler tried to reach wp-cron.php which wasn't found. The request was therefore directed to index.php, recursively triggering the scheduler again.

I noticed when I received a mail from my hoster about shutting my site down because it caused too much load on the server.

Now this shouldn't happen under normal circumstances but the effect is quite severe when it happens. Issues with .htaccess could cause this too. I haven't completely checked out the cron mechanism yet but this seems weakly designed somehow.

A quick solution that comes to my mind right now would be to check for the GET Path before triggering the call to the wp-cron.php. If we are already handling a wp-cron request, something must have gone wrong and wp-cron should not be called again in the current session. This is an ugly hack, I hope someone comes up with something smarter.

EXAMPLE OF SYMPTOM:

mar jan 30 11:22:45 CET 2007 : sainteli04 : Query 12 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |
mar jan 30 11:22:45 CET 2007 : sainteli04 : Query 12 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |
mar jan 30 11:22:45 CET 2007 : sainteli04 : Query 12 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |
mar jan 30 11:22:45 CET 2007 : sainteli04 : Query 12 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |
mar jan 30 11:22:45 CET 2007 : sainteli04 : Query 11 SELECT option_value
FROM cv_options WHERE option_name =
'siteurl'                                    |
mar jan 30 11:22:47 CET 2007 : sainteli04 : Killed 15 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:47 CET 2007 : sainteli04 : Killed 15 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:47 CET 2007 : sainteli04 : Killed 15 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:47 CET 2007 : sainteli04 : Killed 15 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |
mar jan 30 11:22:50 CET 2007 : sainteli04 : Killed 17 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:50 CET 2007 : sainteli04 : Killed 17 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:50 CET 2007 : sainteli04 : Killed 17 SELECT   cv_posts.*
FROM cv_posts  WHERE 1=1  AND post_name = 'wp-cronphp' AND (post_type =
'post')  |
mar jan 30 11:22:50 CET 2007 : sainteli04 : Killed 17 SELECT option_name,
option_value FROM cv_options WHERE autoload =
'yes'                              |

Attachments

wp-cron-prevent-infinite-loop.php (421 bytes) - added by markjaquith on 01/29/07 19:09:29.

Change History

01/29/07 19:09:10 changed by markjaquith

  • priority changed from normal to high.
  • severity changed from normal to critical.
  • milestone set to 2.1.1.

Ouch. Nasty bug. Thanks for the nice report.

Actually, I don't really have a problem with your solution. Check my (untested) patch. Is this what you meant?

01/29/07 19:09:29 changed by markjaquith

  • attachment wp-cron-prevent-infinite-loop.php added.

01/29/07 20:51:16 changed by Jan

Yes, that's what I had on my mind.

01/30/07 01:04:59 changed by charleshooper

  • keywords changed from wp-cron cron recursive call heavy load server scheduler to has-patch wp-cron cron recursive call heavy load server scheduler.

01/30/07 13:06:58 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

(In [4834]) Prevent a missing wp-cron.php from causing an infinite loop. Props jan. fixes #3713

01/30/07 13:08:19 changed by markjaquith

  • status changed from closed to reopened.
  • resolution deleted.

That was a commit for /trunk/ but this needs to be fixed for 2.1.1

Would like another set of eyes on this before putting it into 2.1.1

01/30/07 15:51:33 changed by foolswisdom

  • description changed.

01/30/07 15:52:11 changed by foolswisdom

  • description changed.

01/31/07 06:00:10 changed by markjaquith

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [4850]) Prevent a missing wp-cron.php from causing an infinite loop. Props jan. fixes #3713

03/17/07 19:35:04 changed by trisweb

I just want to add a comment to this, not reopen. This kind of behavior can also be caused by the Bad Behavior plugin placing wp-cron.php in its blacklist, thereby 403'ing local requests to it.

Not sure if WordPress wants to block this possible condition, but even though I consider it a bug in Bad Behavior and have notified the developer, I suggest we find the cause of the infinite request loop and stop it. As a general rule, preventing Apache from crashing even in obscure cases is a Good Thing.

I've done a write-up here if anyone's curious.

http://www.trisweb.com/archives/2007/03/17/wordpress-wp-cronphp-and-bad-behavior-apache-crash/

Let me know if you want me to open a new bug. Thanks.