1062: Duplicate entry '1-kh8866' for key 3

Re: 1062: Duplicate entry '1-kh8866' for key 3

by Jessica Gramp -
Number of replies: 0
Picture of Moodle HQ Picture of Plugin developers

I was getting a similar error with the following message when trying to restore Turnitin assignments to a course.

I think it was because we had changed all our email addresses to nobody@domain.com and Turnitin relies on the email address to know who is who. So I changed the email address back and it restored with no error.

While the email address remained as nobody@domain.com I got the following error:


Error writing to database
More information about this error
Debug info: Duplicate entry '1-rehkmle' for key 'mdl_user_mneuse_uix'
INSERT INTO mdl_user (city,auth,username,lang,confirmed,lastip,timecreated,timemodified,mnethostid,calendartype,maildisplay,mailformat,maildigest,autosubscribe,trackforums) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
[array (
0 => '',
1 => 'manual',
2 => 'rehkmle',
3 => 'en',
4 => 1,
5 => '128.40.14.135',
6 => 1443606504,
7 => 1443606504,
8 => '1',
9 => 'gregorian',
10 => '2',
11 => '1',
12 => '0',
13 => '1',
14 => '0',
)]
Error code: dmlwriteexception
Stack trace:
line 446 of /lib/dml/moodle_database.php: dml_write_exception thrown
line 1164 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
line 1210 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
line 96 of /user/lib.php: call to mysqli_native_moodle_database->insert_record()
line 4093 of /lib/moodlelib.php: call to user_create_user()
line 94 of /mod/turnitintool/backup/moodle2/restore_turnitintool_stepslib.php: call to create_user_record()
line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_turnitintool_activity_structure_step->process_turnitintool_courses()
line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
line 91 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 195 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
line 177 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
line 167 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 333 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 184 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
line 111 of /backup/restore.php: call to restore_ui->execute()