-
Bug
-
Resolution: Fixed
-
Minor
-
3.9.12, 3.10.9, 3.11.5
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
-
MOODLE_311_STABLE
-
MDL-74183-master -
On large sites with high levels of activity, you can run into a situation where the completion_daily_task task fetches the list of completions it needs to create, and while it is working, some other activity in the system has caused the completion to be created, leading to a write error due to duplicate entry:
Execute scheduled task: Completion mark as started (core\task\completion_daily_task)
|
... started 10:55:42. Current memory use 15MB.
|
Marking users as started
|
Marked started user 123 in course 2
|
...
|
Marked started user 234 in course 4
|
... used 54 dbqueries
|
... used 175.30935502052 seconds
|
Scheduled task failed: Completion mark as started (core\task\completion_daily_task),Error writing to database (Duplicate entry '345-6' for key 'mdl_courcomp_usecou_uix'
|
INSERT INTO mdl_course_completions (userid,course,timeenrolled,timestarted,timecompleted,reaggregate) VALUES(?,?,?,?,?,?)
|
[array (
|
0 => '345',
|
1 => '6',
|
2 => '1647012239',
|
3 => 0,
|
4 => NULL,
|
5 => 1647014317,
|
)])
|
Debug info:
|
Duplicate entry '345-6' for key 'mdl_courcomp_usecou_uix'
|
INSERT INTO mdl_course_completions (userid,course,timeenrolled,timestarted,timecompleted,reaggregate) VALUES(?,?,?,?,?,?)
|
[array (
|
0 => '345',
|
1 => '6',
|
2 => '1647012239',
|
3 => 0,
|
4 => NULL,
|
5 => 1647014317,
|
)]
|
Backtrace:
|
* 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 334 of /completion/data_object.php: call to mysqli_native_moodle_database->insert_record()
|
* line 236 of /completion/completion_completion.php: call to data_object->insert()
|
* line 117 of /completion/completion_completion.php: call to completion_completion->_save()
|
* line 124 of /lib/classes/task/completion_daily_task.php: call to completion_completion->mark_enrolled()
|
* line 253 of /lib/cronlib.php: call to core\task\completion_daily_task->execute()
|
* line 167 of /admin/cli/scheduled_task.php: call to cron_run_inner_scheduled_task()
|