moodleou / moodle-mod_forumng

ForumNG forum module for Moodle
19 stars 20 forks source link

Error during search index rebuild #62

Open DrewGleeson opened 8 years ago

DrewGleeson commented 8 years ago

Hi

We are attempting to rebuild the search indexes which fails with the below message: `Potential coding error - active database transaction detected during request shutdown:

Do you know what can be done about this?

Thanks in advance for your time.

Best regards, Andrew Gleeson University of Edinburgh

DrewGleeson commented 8 years ago

Software versions: Moodle: 2.8.6+ (Build: 20150528) ForumNG: 2015060500 (2.8 r1) OUsearch: 2015050100

DrewGleeson commented 8 years ago

We were getting failures at various points in the search index rebuild process. The running order seemed to be as follows for us: forumng > oublog > ouwiki

If it failed during forumng, then there would be no previous message in the logs to indicate why. However, failing on either of the others we would see the following log entry before the above mentioned "Potential coding error" message: "[:error] PHP Fatal error: Maximum execution time of 300 seconds exceeded in /u01/app/moodle/moodle/cache/classes/loaders.php on line 542, referer: /local/ousearch/postinstall.php"

Looking at our PHP config the max_execution_time for our Moodle environment is set at 600 seconds. Considering this and looking further at the code, it turned out that this setting was being over-ridden by a call to set_time_limit($timelimitbefore); with a timelimitbefore value of 300. This was persisting through the rest of the index rebuild process.

Interesting note: Attempting to remove this completely (assuming that the php timout of 600 seconds would be sufficient) it failed with a "Maximum execution time of 600 seconds exceeded" ;-(

The solution for us was to simply change the timeout value on line 3445 in mod_forumng.php from 300 to 600.

Long term solution suggested in https://github.com/moodleou/moodle-local_ousearch/issues/7 was to use something like core_php_time_limit::raise() in order to only increase the time limit and not decrease it. I've not been able to find information on anything like that, although using ini_get('max_execution_time'); along with some logic to only increase this timeout if it's below a certain value could be sufficient too.

Saying that though, the "generally sufficient" 300 seconds is unfortunately not always sufficient, which is what makes this a tricky one.

For now, our solution is sufficient for us so I will close this call.

Cheers, Andrew

DrewGleeson commented 8 years ago

Actually, I think it's best to leave this one open for now as the above solution is a bit of a short-term "hacky" solution.

I'll leave it to yourselves to decide on the best way forward in the longer term.

From what we've experienced, a fairly simple solution could be to: 1 - get current php max_execution_time value 2 - if this is below 300 the set timelimitbefore to 300, else use the current environment value 3 - reset the timeout with this value inside the loop (as already being done) .... or use a core_php_time_limit::raise() type mechanism

Regards, Andrew