Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum execution time of 300 seconds exceeded in pcntl_fork()

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

like image 315
Pentium10 Avatar asked May 17 '14 08:05

Pentium10


People also ask

What is the default execution time set in Set_time_limit ()?

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.

How do you increase the maximum execution time of 30 seconds exceeded?

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.

What is the maximum execution time in PHP?

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.


1 Answers

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?

like image 138
Tamer Tas Avatar answered Oct 21 '22 23:10

Tamer Tas