Testing and QA

 
 
Picture of kathy hooper
1062: Duplicate entry '1-kh8866' for key 3
 
Hi
We are running 1.7+ and lately it has been running frustratingly slow. Seeing that things couldn't get any worse I decided to upgrade to 1.8 beta - thinking that this might sort out any database problems. However the upgrade stalls and gives the following message


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

adodb_mysql._execute(CREATE UNIQUE INDEX mdl_user_mneuse_uix ON mdl_user (mnethostid, username), false) % line 889, file: adodb.inc.php
adodb_mysql.execute(CREATE UNIQUE INDEX mdl_user_mneuse_uix ON mdl_user (mnethostid, username)) % line 89, file: dmllib.php
execute_sql(CREATE UNIQUE INDEX mdl_user_mneuse_uix ON mdl_user (mnethostid, username), true) % line 1899, file: dmllib.php
execute_sql_arr(Array[1], true, true) % line 1080, file: ddllib.php
add_index(Object:xmldbtable, Object:xmldbindex) % line 342, file: upgrade.php

ErrorScroll to next warning

Scroll to previous warning Main Upgrade failed! See lib/db/upgrade.php


Scroll to continue button


Is anyone able to advise me how to fix this problem? Is there a table that I could simply delete and reinstall without loosing user data. I don't know much about databases but am good at tinkering, I just need to know where to start.
thanks
kathy
 
Average of ratings: -
Mugshot
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
Hi Kathy - can you tell me the result of the query:
select count(id) from mdl_user where username='kh8866';

The result should be an integer - if it's greater than 1, then that will explain your problem.

It looks like the database is trying to create an index on (mnethostid, username) and it's failing because the username 'kh8866' occurs twice in your database. It's difficult to see how this would be possible - usernames should be unique, after all - but that seems to be what is happening.

Thanks!

 
Average of ratings: -
Picture of kathy hooper
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
Hi Donal
Thanks for responding, the result is 9, and when I checked on that name in the user table it was there 9 times! Just this year we have enroled our students with ldap, I know it is throwing up errors when I turn on debugging, maybe something is happening at that end.
kathy
 
Average of ratings: -
Mugshot
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
Hi Kathy...

I created a page on the docs site that covers this issue:
http://docs.moodle.org/en/DuplicateUsernames

I also committed a change to the Moodle code that allows upgrades to continue if duplicate usernames exist in the user table, but I think that in the long run, duplicate usernames could cause some tricky bugs, and it is "strongly advised" ;) that you should resolve the duplicates in your DB.

The query I added to the docs will help you identify any other usernames that have been added to your DB more than once.

Sorry you've been having problems with your Moodle - I hope it's not too much hassle to fix.
 
Average of ratings: -
Mugshot
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
One more question - when you did the enrolment of users via LDAP, which version of Moodle was that? 1.6, 1.7 or 1.8??

I want to have a look at the LDAP code and see if there's anything strange in there which could be encouraging it to create duplicate user records.

Thanks!
 
Average of ratings: -
Picture of kathy hooper
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
Thanks for that Donal. The version was 1.7+ . We are still running it so I will copy the error messages and post them here
kathy
 
Average of ratings: -
Picture of kathy hooper
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
here are the errors

Notice: Undefined variable: module in C:\XAMPP\xampp\htdocs\lib\moodlelib.php on line 5340

this is one that shows up all the time



these ones happen with the ldap users

Notice: Undefined index: office in C:\XAMPP\xampp\htdocs\auth\ldap\lib.php on line 129

Notice: Undefined index: office in C:\XAMPP\xampp\htdocs\auth\ldap\lib.php on line 138

Notice: Undefined index: desc in C:\XAMPP\xampp\htdocs\auth\ldap\lib.php on line 129

Notice: Undefined index: desc in C:\XAMPP\xampp\htdocs\auth\ldap\lib.php on line 138

Warning: Cannot modify header information - headers already sent by (output started at C:\XAMPP\xampp\htdocs\auth\ldap\lib.php:129) in C:\XAMPP\xampp\htdocs\lib\moodlelib.php on line 2125
 
Average of ratings: -
Martin in black and white
Re: 1062: Duplicate entry '1-kh8866' for key 3
Group DevelopersGroup Documentation writersGroup Moodle HQGroup Particularly helpful MoodlersGroup Testers
This issue is being tracked here: MDL-8720
 
Average of ratings: -
Picture of kathy hooper
Re: 1062: Duplicate entry '1-kh8866' for key 3
 
Thanks Martin, I'm relieved to know we arn't unique smile
kathy
 
Average of ratings: -