0

I am working on a legacy system with Symfony 2 where I am fetching about 60k documents from an Oracle database with the following code block:

$rows = $query->fetchAll(\PDO::FETCH_ASSOC);

The problem is that I am getting the following error:

PHP Fatal error: Maximum execution time of 60 seconds exceeded in ...\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\OCI8\OCI8Statement.php on line 216

The problem is that I can't find any documentation on how I could extend the runtime. I found the parameter oci_set_call_timeout but I don't know how to configure it from Symfony. Also, I extended the PHP execution timeout as indicated by this answer just to rule it out, since I am certain that it is a DB timeout, and didn't work either.

I have also tried doing:

while($row = $query->fetch()) {}

But it also throws me timeout. If I narrow the query it works, the problem is that it is a function called in many, many places with dynamic queries, so changing SQL queries is not an option. I can think of two workable solutions:

  1. Extend the timeout
  2. Find a way to reset that timeout so that I can execute the while($row = $query->fetch()) {} statement without problems.

Neither of the two ways I found by looking in the official documentation or on the internet. If someone could shed some light on the subject I would appreciate it.

Genarito
  • 3,027
  • 5
  • 27
  • 53
  • Does this answer your question? [Fatal error: Maximum execution time of 30 seconds exceeded](https://stackoverflow.com/questions/5164930/fatal-error-maximum-execution-time-of-30-seconds-exceeded) – Dharman Aug 13 '21 at 20:20
  • Symfony is written in PHP. If your PHP code is processing for longer than 60 seconds and this is expected, then you can extend PHP's max execution time – Dharman Aug 13 '21 at 20:21
  • @Dharman Unfortunately no, I already tried changing that parameter to 5 minutes and it still shows the 60 seconds error. – Genarito Aug 13 '21 at 20:22
  • In the line that fails, there's a call to the `oci_fetch_array` function. So I think I setting `oci_set_call_timeout` from Symfony would be a good approach – Genarito Aug 13 '21 at 20:23
  • @Dharman Symfony uses the Driver that makes that call. I'm just copying and pasting the line that's throwing the timeout – Genarito Aug 13 '21 at 20:26
  • I don't know OCI very well, but I would be very surprised if it could trigger PHP timeout. In fact, I am not aware of any PHP extension that can do that. PHP timeout can be only thrown by PHP. If OCI timeouts then it would throw `OCI8Exception`. So my initial answer still stands. – Dharman Aug 13 '21 at 20:33
  • Thanks! But I've checked my `php.ini` and `max_execution_time` was set to `30` and the error says `60`. I changed it to `300`, I've checked the value using `phpinfo()` and the error still says `60`, so unfortunately it didn't solve my problem. – Genarito Aug 13 '21 at 20:37
  • Did you restart the server? Instead put `set_time_limit(300);` before your DB code and check if it makes any difference. Symfony might be setting its own value – Dharman Aug 13 '21 at 20:40
  • I'll give it a try calling `set_time_limit` and I'll let you know! Thank you! – Genarito Aug 13 '21 at 20:46
  • 1
    There are multiple timeouts that can be applied in various configurations that you would to check. eg: Apache/NGNIX, PHP-FPM. PHP Safe-Mode etc. Some public shared hosts [enforce the timeouts and do not allow them to be overridden](https://stackoverflow.com/questions/8377137/set-time-limit0-and-maximum-execution-time-php). You would receive a different exception from Doctrine if the oci timeout was being reached, rather than a Fatal Error. – Will B. Aug 14 '21 at 05:00

0 Answers0