diff --git a/lang/en_utf8/mnet.php b/lang/en_utf8/mnet.php
index a1c54eb82c9..2f1f89ee107 100644
--- a/lang/en_utf8/mnet.php
+++ b/lang/en_utf8/mnet.php
@@ -37,6 +37,11 @@ $string['showlocal'] = 'Show local users';
$string['hostcoursenotfound'] = 'Host or course not found';
$string['enrollingincourse'] = 'Enrolling in course $a[0] on host $a[1]
';
+$string['duplicate_usernames'] = 'We failed to create an index on the columns \"mnethostid\" and \"username\" in your user table.
'.
+ 'This can occur when you have duplicate usernames in your user table.
'.
+ 'Your upgrade should still complete successfully. Click on the link above, and instructions on fixing'.
+ ' this problem will appear in a new window. You can attend to that at the end of the upgrade.
';
+
$string['nomodifyacl'] = 'You are not permitted to modify the MNET access control list.';
$string['recordnoexists'] = 'Record does not exist.';
$string['enterausername'] = 'Please enter a username, or a list of usernames separated by commas.';
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 992219e0b38..f7b70d1ff36 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -339,7 +339,10 @@ function xmldb_main_upgrade($oldversion=0) {
$index->setFields(array('username'));
drop_index($table, $index);
$index->setFields(array('mnethostid', 'username'));
- $result = $result && add_index($table, $index);
+ $empty_on_duplicate = add_index($table, $index);
+ if(empty($fail_on_duplicate)) {
+ notify(get_string('duplicate_usernames', 'mnet', 'http://docs.moodle.org/en/DuplicateUsernames'));
+ }
unset($table, $field, $index);