Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-8720

mnet index upgrade causes error and stops upgrade

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8, 1.9
    • Component/s: MNet
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      It's this unique index .... when it dies everything dies. Someone else reported this in the forum recently too.

      (mysql): CREATE UNIQUE INDEX user_mneuse_uix ON user (mnethostid, username) 1062: Duplicate entry '1-s' for key 2

      adodb_mysql._execute(CREATE UNIQUE INDEX user_mneuse_uix ON user (mnethostid, username), false) % line 889, file: adodb.inc.php
      adodb_mysql.execute(CREATE UNIQUE INDEX user_mneuse_uix ON user (mnethostid, username)) % line 89, file: dmllib.php
      execute_sql(CREATE UNIQUE INDEX user_mneuse_uix ON 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

        Gliffy Diagrams

          Activity

          Hide
          dougiamas Martin Dougiamas added a comment -
          Show
          dougiamas Martin Dougiamas added a comment - Another report: http://moodle.org/mod/forum/discuss.php?d=65985
          Hide
          martinlanghoff Martín Langhoff added a comment -

          Donal - can you have a quick look at this? We haven't seen it in our test environments for some reason, bit it's happened to a couple of people already, including moodle.org

          Show
          martinlanghoff Martín Langhoff added a comment - Donal - can you have a quick look at this? We haven't seen it in our test environments for some reason, bit it's happened to a couple of people already, including moodle.org
          Hide
          donal@catalyst.net.nz Donal McMullan added a comment -

          This is weird for two reasons. One - the Duplicate entry '1-s' should not (yet) have any 1s in the mnethostid column. I'm pretty sure that all values in that column should still be zero.

          And second - disregarding the mnethostid value for a second - as the usernames in the user table should all be unique, this error should never occur! The error message suggests that there were two records in the source user table that have the username 's'.

          Bizarro world. I'd really like to see a data snapshot for this so I can repro, in case anyone feels inclined to provide one for me, I'd be really grateful (and discreet).

          Show
          donal@catalyst.net.nz Donal McMullan added a comment - This is weird for two reasons. One - the Duplicate entry '1-s' should not (yet) have any 1s in the mnethostid column. I'm pretty sure that all values in that column should still be zero. And second - disregarding the mnethostid value for a second - as the usernames in the user table should all be unique, this error should never occur! The error message suggests that there were two records in the source user table that have the username 's'. Bizarro world. I'd really like to see a data snapshot for this so I can repro, in case anyone feels inclined to provide one for me, I'd be really grateful (and discreet).
          Hide
          dougiamas Martin Dougiamas added a comment -

          That is really wierd yes. I have two users with the username s (and no other duplicates in the whole table).

          Not surprisingly the second one has never logged in so he's now deleted.

          I've no idea how this could happen but the ids are quite low, so it may be from a long-ago bug or glitch.

          Anyhow, given that at least two sites had it, can the upgrade just be made to fail a bit nicer? The fact that the index wasn't made shouldn't stop the whole upgrade.

          Show
          dougiamas Martin Dougiamas added a comment - That is really wierd yes. I have two users with the username s (and no other duplicates in the whole table). Not surprisingly the second one has never logged in so he's now deleted. I've no idea how this could happen but the ids are quite low, so it may be from a long-ago bug or glitch. Anyhow, given that at least two sites had it, can the upgrade just be made to fail a bit nicer? The fact that the index wasn't made shouldn't stop the whole upgrade.
          Hide
          donal@catalyst.net.nz Donal McMullan added a comment -

          Hi Martin(s) - I just committed a fix. I'm a bit worried about users who have duplicate usernames in the DB, but a warning and some instructions are now provided.

          Show
          donal@catalyst.net.nz Donal McMullan added a comment - Hi Martin(s) - I just committed a fix. I'm a bit worried about users who have duplicate usernames in the DB, but a warning and some instructions are now provided.
          Hide
          dougiamas Martin Dougiamas added a comment -

          Awesome, thanks, Donal! :-D

          Show
          dougiamas Martin Dougiamas added a comment - Awesome, thanks, Donal! :-D
          Hide
          andyjdavis Andrew Davis added a comment -

          Closing. This area of the code has been altered since submission but code achieving the same result is present.

          Show
          andyjdavis Andrew Davis added a comment - Closing. This area of the code has been altered since submission but code achieving the same result is present.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                31/Mar/07