Hi there. We have
used Moodle for many years, teaching around a thousand students at a time in a
dozen or so courses. We’re currently running Moodle 3.11.5+ (Build: 20220208).
Twice in recent weeks we have encountered a worrying situation in which student
submissions have stopped working for a few minutes, before resuming with no
intervention on our part. The errors in the Apache logs look like this:
Default exception handler: Error writing to database Debug:There were about 200 of these messages during the first event, and about 20 in the second.
Duplicate entry '154-844' for key 'mdl_grade_grades.mdl_gradgrad_useite_uix'
INSERT INTO mdl_grade_grades (itemid,userid,rawgrade,rawgrademax,rawgrademin, rawscaleid,usermodified,finalgrade,hidden,locked,locktime,exported, overridden,excluded,timecreated,timemodified,aggregationstatus,
aggregationweight)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => 844,
1 => '154',
2 => NULL,
3 => '100.00000',
4 => '0.00000',
5 => NULL,
6 => NULL,
7 => NULL,
8 => 0,
9 => 0,
10 => 0,
11 => 0,
12 => 0,
13 => 0,
14 => NULL,
15 => NULL,
16 => 'unknown',
17 => NULL,
)]
Error code: dmlwriteexception
* line 489 of /lib/dml/moodle_database.php: dml_write_exception thrown
* line 1357 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 1403 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
* line 349 of /lib/grade/grade_object.php: call to mysqli_native_moodle_database->insert_record()
* line 1033 of /lib/grade/grade_grade.php: call to grade_object->insert()
* line 653 of /lib/grade/grade_category.php: call to grade_grade->insert()
* line 541 of /lib/grade/grade_category.php: call to grade_category->aggregate_grades()
* line 809 of /lib/grade/grade_item.php: call to grade_category->generate_grades()
* line 1276 of /lib/gradelib.php: call to grade_item->regrade_final_grades()
* line 448 of /lib/gradelib.php: call to grade_regrade_final_grades()
* line 812 of /mod/quiz/lib.php: call to grade_get_grades()
* line 1212 of /mod/quiz/lib.php: call to quiz_grade_item_update()
* line 139 of /mod/quiz/lib.php: call to quiz_after_add_or_update()
* line 612 of /course/modlib.php: call to quiz_update_instance()
* line 166 of /course/modedit.php: call to update_moduleinfo()
Any suggestions as to what might be going on and how to diagnose/fix it would be greatly appreciated.
A similar problem was reported in 2017 here: https://moodle.org/mod/forum/discuss.php?d=348924 although this was ocurring during course creation, not during quiz submission.
Thanks, Joff.