Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron events cause PHP timeout #156

Open
webd-uk opened this issue Mar 19, 2024 · 3 comments
Open

Cron events cause PHP timeout #156

webd-uk opened this issue Mar 19, 2024 · 3 comments

Comments

@webd-uk
Copy link

webd-uk commented Mar 19, 2024

Hi,

We have a cron event that when run can occasionally take some time to complete, especially if previous instances have failed as there is more to do.

The site in question runs perfectly in all other aspects with object-cache.php installed however, we have since discovered that we see the following errors in debug.log ...

[19-Mar-2024 16:49:06 UTC] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790
[19-Mar-2024 16:49:06 UTC] E_ERROR: Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790
[19-Mar-2024 16:52:56 UTC] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790
[19-Mar-2024 16:52:56 UTC] E_ERROR: Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790
[19-Mar-2024 16:53:29 UTC] PHP Fatal error:  Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790
[19-Mar-2024 16:53:29 UTC] E_ERROR: Maximum execution time of 30 seconds exceeded in /wp-content/object-cache.php on line 790

When object-cache.php is deleted the issue no longer presents itself.

Why would having the object-cache.php installed introduce a PHP execution time limit?

Please advise.

Many thanks,

Oliver

@webd-uk
Copy link
Author

webd-uk commented Mar 29, 2024

As an update to this, we are trialing a fix whereby this is added before line 790 ...

if (defined('DOING_CRON')) {
    set_time_limit(0);
}

@dd32
Copy link
Member

dd32 commented Jun 20, 2024

This sounds like a cron task is reading/writing a lot of cache data, perhaps refreshing a cache, and the task simply runs into the limit during the write-to-cache section of code.

Debugging to determine why the time limit is being hit during that step, and determining if it's the fault of the object cache or other code, would be needed to move this forward.

I expect the reference of object-cache here is actually irrelevant to the originally reported problem.

@webd-uk
Copy link
Author

webd-uk commented Jul 22, 2024

Interesting. Except that you would think that the reading / writing a lot of cache data without a persistent object cache would take more time and be more likely to hit the PHP timeout. This is not the case and our fix above continues to resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants