Cron and accesslib.php were both changed substantially in Moodle 2.2.
One bit in particular has been causing us problems since we upgraded from 2.1.x this morning. In cron-lib, there are now calls to
- context_helper::cleanup_instances(); // Line 149 of lib/cronlib.php
- context_helper::build_all_paths(false); // Line 151 of lib/cronlib.php
- context_helper::create_instances(); // Line 183 of lib/cronlib.php
At least one of thase calls was bringing down our server, but we are not 100% sure which. We commented out all three lines of code, and now running cron does not bring down the server, and we don't really want to experiment enabling them one at a time, and see which crashes our live system
So, the first purpose of this message is to ask: has anyone else seen this?
To go more specifically into what the problem was, the symptom we actually saw is that the DB query in user_accesstime_log ($DB->update_record_raw('user', $last); line 1783) was getting stuck for a long time, waiting for a lock on the user table. Since this happens on every page in the require_login function, (with a limit of only doing it once per minute for each user) lots of requests would back-up until the server got stuck.
It was only when we notced the the server was crashing every 15 minutes that we worked out that it must be something in cron getting the lock.
We are on Postgres here. We don't yet entirely understand why those context_helper calls lock the user table for so long. If we run bits of the SQL in isolation, it executes quite quickly. Looking at the logs, there is a possiblity that it is not the queries themselves that cause the problems, but instead it may be that the queries change enough rows that it triggers an auto-vacuum that locks a table for a long time. Unfortunately the information in the DB logs is inconclusive at the moment.
Another more general observation about 2.2. Before our upgrade, page loads were averagins about 0.35 seconds in 2.1.x. Now in 2.2.x they are averaging 0.5 seconds. Again, it is too early, so we have no idea why. Does anyone else have good comparative page-load times before and after an upgrade to 2.2?