I have some agents running, and after several weeks of normal mode, suddenly we get:
Maximum execution time of 300 seconds exceeded
on a line that is
$this->pids[$next_child] = pcntl_fork();
also we have:
[root@a ~]# ulimit -u
385913
[root@a ~]# ps ax | wc -l
400
[root@a ~]# cat /proc/sys/kernel/pid_max
4194303
strace shows
poll([{fd=4, events=POLLIN|POLLPRI|POLLHUP}], 1, 1000) = 0 (Timeout)
we are on php5.4 centos, could it be a PHP bug? or what could be wrong?
update
2 years after still having this error, since then we upgraded to php5.6 then to php7, and now to php7.3.1
The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php. ini . When called, set_time_limit() restarts the timeout counter from zero.
Log in to cPanel using your credentials. Navigate to the Software section and click on the MultiPHP INI Editor. In the new window, select your domain from the dropdown menu, locate the max_execution_time PHP directive, and change the value associated with it to 300.
One important aspect of PHP programs is that the maximum time taken to execute a script is 30 seconds. The time limit varies depending on the hosting companies but the maximum execution time is between 30 to 60 seconds.
This error is a bit cryptic. So, we must do some debugging to get to the bottom of the issue.
Note: Rather than concentrating on the function pcntl_fork
or PHP bugs. I'll concentrate on this being a system resource issue. Because, the line it throwing the error contains fork. We'll see where it goes from there
The error might be a bug or unimportant. To test this add ini_set('MAX_EXECUTION_TIME', -1);
to the very top of your script. If your script runs as intended without any problems, then it is true. If not, then we should examine the behavior. If your agents start having problems serving clients around the time they would normal throw the error, that might mean the error meant something along the lines of resources not being enough. If that's not the case you should examine the behavior of the agents so you can learn more about the cause of the issue.
The error might be related to the size of Active URL cache being too high if you are using it from what I've heard.
If the problem still persists, you need to provide more information about your environment and configurations so that we can help you.
Question: Are you by any chance using Magento?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With