PraveenSubramaniyam Posted March 27, 2013 Share Posted March 27, 2013 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 .. Quote Link to comment Share on other sites More sharing options...
DaveyK Posted March 27, 2013 Share Posted March 27, 2013 I dont know the answer to your solution, but wouldnt it be wise to break; the foreach if you have set the correct variable? Quote Link to comment Share on other sites More sharing options...
PraveenSubramaniyam Posted March 27, 2013 Author Share Posted March 27, 2013 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 .. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted March 27, 2013 Share Posted March 27, 2013 You need to go up(increase) the value of the directive called max_execution_time in your php.ini file. The local and the master one has to have the same value. What is your hosting provider? Quote Link to comment Share on other sites More sharing options...
DaveyK Posted March 27, 2013 Share Posted March 27, 2013 You want to increase a maximum_execution_time that is already 300? I work with 30 on XAMPP o_O is that common practice? Quote Link to comment Share on other sites More sharing options...
PraveenSubramaniyam Posted March 27, 2013 Author Share Posted March 27, 2013 I tried increasing the max_execution_time value in code_ignitor settings but it happens after tht value or the whole system becomes too slow .. Code Ignitor have a setting for max_execution_time as 300 . Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted March 27, 2013 Share Posted March 27, 2013 What is the name of your hosting provider? Quote Link to comment Share on other sites More sharing options...
PraveenSubramaniyam Posted March 27, 2013 Author Share Posted March 27, 2013 I havent hosted it anywhere .. Im just running in my pc .. with apache server.. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted March 27, 2013 Share Posted March 27, 2013 Do you know what and where is the php.ini in your local system? Quote Link to comment Share on other sites More sharing options...
Maq Posted March 27, 2013 Share Posted March 27, 2013 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. Quote Link to comment Share on other sites More sharing options...
exeTrix Posted March 27, 2013 Share Posted March 27, 2013 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. Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted March 27, 2013 Share Posted March 27, 2013 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted March 27, 2013 Share Posted March 27, 2013 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]; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.