0

I'm running a small webservice that gets data from a user specified database, and some of those queries are heavy and often take longer than usual, because those rows contain base64 images and other needed stuff. When my queries take longer than 30 secs CI crashes somehow. I've tried using $this->db->_error_number(), $this->db->_error_message() and

if ($this->db->trans_status() === FALSE) {
    die('Wops, something weird happened...');
}

But none of them gives me error infos. Anybody knows how to capture those timeout errors and echo them to the user? Thanks.

EDIT:

log output:

...
DEBUG - 2015-04-10 10:34:34 --> Controller "Main" Initialized
DEBUG - 2015-04-10 10:34:34 --> Helper loaded: log_helper
DEBUG - 2015-04-10 10:34:34 --> Database Driver Class Initialized
DEBUG - 2015-04-10 10:35:04 --> Final output sent to browser
DEBUG - 2015-04-10 10:35:04 --> Total execution time: 30.0145
...
4
  • 1
    Sounds like the maximum execution time of php: php.net/manual/en/function.set-time-limit.php Commented Apr 10, 2015 at 13:29
  • Just for testing purposes, I tried setting no time limits with set_time_limit(0); but the result is the same. Commented Apr 10, 2015 at 13:36
  • Try increasing memory limit to a higher value e.g 1024 MB. Commented Apr 10, 2015 at 13:43
  • @KamranAdil, you mean in mysql config files? I did this and increased max_allowed_packet to a very high value, but the issue still persists. Commented Apr 10, 2015 at 13:56

2 Answers 2

3

Please check mysql.connect_timeout parameter in your phpinfo() and increase in in case require as this may be reason for query timeout.

You can read more about this Here

Sign up to request clarification or add additional context in comments.

1 Comment

As I mentioned in @Darius's answer, I tried to changed this value, but I see no diference. Thanks anyways.
1

Your query takes too much time. If your are using webserver(nginx or apache) hey have default timeout. In most cases it 30seconds. You can increase timeout time on your webserver.

Also check php timeout parameters in php.ini max_execution_time Or try to set_time_limit bigger directly in php code. http://php.net/manual/en/function.set-time-limit.php

1 Comment

Thanks, I tried to change max_execution_time in php.ini and I also used set_time_limit() but nothing changes. The php doc says that set_time_limit() doesn't work if safe mode is enabled, but in my php.ini it is not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.