Jump to content

Maximum execution time of 300 seconds exceeded in codeignitor DB_active_rec.php


Recommended Posts

Im using code ignitor and Im getting the following error when i run my script .

 

PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /system/system_2.1.3/database/DB_active_rec.php on line 1979

 

protected function _reset_run($ar_reset_items)

    {

        foreach ($ar_reset_items as $item => $default_value)  (line no 1979)

        {

            if ( ! in_array($item, $this->ar_store_array))

            {

                $this->$item = $default_value;

            }

        }

    }

 

 

.. In my db  im having about 1000 records in a table and im polling every 3 seconds in my script to read from db . And im getting the error at every 20th minute .

 

Can anyone pls help ..

 

 

 

Link to comment
Share on other sites

Im using the codeignitor php framework which has the files DB_active_rec.php , db_driver.php , mysql_driver.php ... And everytime im getting same error but in these different  files at different line number . hence Im sure tht reading too much data from database causing this error .. but cant even guess why and where exactly it happens   .. And since those files are written by code ignitor im finding it difficult to debug too .. :(

Link to comment
Share on other sites

You say you're polling every 3 seconds? Are these separate requests to the file or are you using sleep in your script then re-running the query? If the latter is the case then I'd expect max execution time to cause the problem in which case use PHP CLI where there's no execution cutoff as this is enforced by Apache.

 

Another possibility is that the query is running slow. This would cause a bottleneck on the database layer which would get progressively worse as time went on essentially causing a backlog of queries. Eventually, the database wold be too busy responding to older requests causing the most recent to time out. A possible solution to this would be to install memcache which flushes when you know a new record is added.

 

Sorry I couldn't give you a great deal more explanation but it's speculation until we see exactly what you're doing.  

Link to comment
Share on other sites

Before you go and start modifying php.ini settings (which are there for a reason) you should probably profile your code and see what's actually exhausting the max timeout.

I've never seen before someone to have a problem with execution script time on the local server.

I have a problem with that to godaddy, they limit my php script up to 150 sec, so even I created my own php.ini file and the values (master and local) are changed to 300 sec nothing happened.

I asked them few times about this issue and nobody knows the answer :confused:

Link to comment
Share on other sites

I'm with Maq. Verify exactly where the problem is. But, with respect to the above code, why on earth would you loop through an array for something like that when there are built-in functions that would make it much simpler. I see one thing in the code that doesn't make sense - which DaveyK alluded to. You are only finding the first item that does not exist in the array instead of checking all that are unassigned. Not sure if that is your intent or not. If so this shoudl suffice

 

 

protected function _reset_run($ar_reset_items)
{
    //Get the array of keys
    $ar_reset_keys = array_keys($ar_reset_items);

    //Get the list of keys that are not in this->ar_store_array
    $unassigned_keys = array_diff($ar_reset_keys, $this->ar_store_array);

    if(count($unassigned_keys))
    {
        //Use first unassigned key to add value to $this->$item
        $first_unassigned_key = array_shift($unassigned_keys);
        $this->$item = $ar_reset_keys[$first_unassigned_key];
    }
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.