Saving quiz caching takes a long time and crashes

Saving quiz caching takes a long time and crashes

by Michael Ko -
Number of replies: 12

Hi (I hope this is the right board), 

I have a problem: whenever a quiz is saved, some sort of course caching seems to occur that causes the script to eventually time out, and the quiz is not saved.

We are running Moodle 2.8.1. This problem did not happen previously on Moodle 2.6.2.

I already posted about this in the quiz board but the issue could not be resolved: https://moodle.org/mod/forum/discuss.php?d=275473. It was suggested that it could be a concurrent access problem, but I definitely only have one tab open when adding the quiz.

The problem occurs on both the copy on my local Windows 7 machine and the live production site with multiple web servers:

[17-Dec-2014 06:55:07 Europe/Berlin] PHP Fatal error:  Maximum execution time of 750 seconds exceeded in C:\xampp\htdocs\lms28\cache\classes\loaders.php on line 542

It sometimes works when I set the execution time above 20 minutes... but we cannot use this as a solution.

Does anyone have any ideas about the cause of this problem and how it can be fixed? We have been able to work for a month without making a new quiz but we will need to very soon. The page module (as well as our custom module) does not have this problem.


Thank you in advance!

Average of ratings: -
In reply to Michael Ko

Re: Saving quiz caching takes a long time and crashes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Nothing to do with caching.

It is to do with Atto auto-save interacting badly with Session locking.

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

Thanks for the advice.

I've looked into the concept of session locking. Is there any way this can be fixed without hacking apart the code? We need to auto-save progress for students in quiz attempts. I've tried setting the autosaveperiod to both 10 and 40 and neither way worked.

In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

I have also tried renaming the lib/editor/atto/autosave-ajax.php file and this did not fix the problem

In reply to Michael Ko

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

The problem has been isolated to one particular course.

Is there any reason why this could be happening?

In reply to Michael Ko

Re: Saving quiz caching takes a long time and crashes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That is different about that course/quiz?

In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

Well, the course I want to add the quiz to has about 300-500 activities, but the course it works with has about 5.

The course doesn't have any other problems that I can see though.

In reply to Michael Ko

Re: Saving quiz caching takes a long time and crashes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That should not make much difference.

Until you can get us an error message, or something, I don't think there is much we can say.

In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

The issue is we are not getting any error message. Only the php timeout message.

I checked the database activity while this is happening. There are heaps of queries being executed on the mdl_grade_grades table:

"UPDATE mdl_grade_grades SET aggregationstatus = $25 WHERE itemid IN ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23) AND userid = $24"

Then there's other queries like these:

"INSERT INTO mdl_grade_grades_history (itemid,userid,rawgrade,rawgrademax,rawgrademin,rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported,overridden,excluded,timemodified,feedback,feedbackformat,information,informationformat,action,oldid,sour (...)"

"UPDATE mdl_grade_grades SET aggregationweight = $3 WHERE itemid = $1 AND userid = $2"

Our mdl_grade_grades table has about 2.3 million records.


I have traced this to course/modlib.php, where it looks like this (around line 340):

rebuild_course_cache($course->id, true);

    if ($hasgrades) {

        grade_regrade_final_grades($course->id);

    }


So my question is, why is all of this regrading going on when I add a new quiz - we didn't have this issue in 2.6.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

Commenting out the regrade line causes the quiz to be added instantly, but then the regrading is done again on the quiz/view page.

In reply to Michael Ko

Re: Saving quiz caching takes a long time and crashes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

As I said above, there were major Gradebook changes in Moodle 2.8. I wish someone who worked on those changes would comment here. I did try to bring it to their attention. I will do so again.

See also MDL-47911. It looks like they hit this on this site, but fudged their way around this.

In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

Thank you, I look forward to seeing how this goes.

For now I've disabled grade_regrade_final_grades so we can at least add quizzes in the meantime.

In reply to Tim Hunt

Re: Saving quiz caching takes a long time and crashes

by Michael Ko -

I have also tried disabling the atto editor.