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

Backup fails when restoring completion data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.1
    • Component/s: Activity completion, Backup
    • Labels:
    • Environment:
      qa.moodle.net
    • Testing Instructions:
      Hide

      To test, you need a sample backup file that used to demonstrate the problem. (I attached one to this bug, but if you have a better one, use that.)

      1. Restore backup leaving all options default

      (there is no step 2)

      If it doesn't get a database error then probably the change worked. (Ideally you would also test that the correct values were restored; I did a bit of testing of this already, it's not possible unless you know what the original tickbox values were supposed to be.)

      Show
      To test, you need a sample backup file that used to demonstrate the problem. (I attached one to this bug, but if you have a better one, use that.) 1. Restore backup leaving all options default (there is no step 2) If it doesn't get a database error then probably the change worked. (Ideally you would also test that the correct values were restored; I did a bit of testing of this already, it's not possible unless you know what the original tickbox values were supposed to be.)
    • Workaround:
      Hide

      Uncheck the option "Include user completion details" at step 3 of the restore process.

      Show
      Uncheck the option "Include user completion details" at step 3 of the restore process.
    • Affected Branches:
      MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull Master Branch:
      MDL-28116-master

      Description

      During a QA test of backup and restore of grade categories and calculated grades, I struck a problem restoring a backup that included completion data.

      During the final restore step the restore fails and the following error is reported.

      Debug info: Duplicate entry '4-69' for key 'mdl_courmoducomp_usecou_uix'
      INSERT INTO mdl_course_modules_completion (userid,completionstate,viewed,timemodified,coursemoduleid) VALUES(?,?,?,?,?)
      [array (
      0 => '4',
      1 => '1',
      2 => '0',
      3 => 1309411185,
      4 => 69,
      )]
      Stack trace:
      line 396 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 878 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 920 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      line 2238 of /backup/moodle2/restore_stepslib.php: call to mysqli_native_moodle_database->insert_record()
      line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_userscompletion_structure_step->process_completion()
      line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
      line 125 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 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
      line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
      line ? of unknownfile: call to progressive_parser->end_tag()
      line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
      line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
      line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
      line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
      line 179 of /backup/moodle2/restore_activity_task.class.php: call to base_task->execute()
      line 148 of /backup/util/plan/base_plan.class.php: call to restore_activity_task->execute()
      line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
      line 302 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
      line 144 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
      line 45 of /backup/restore.php: call to restore_ui->execute()

      Replication instructions:

      1. Create a backup which includes completion data (or use the attached backup)
      2. On the Settings, expand Course administration and click Restore
      3. Check that setting to restore as a new course and, pick a category and click Next
      4. Proceed through the steps with the default options

      The restore failed at the last step (step 6).

      If, when replicating this on another site (other than qa.moodle.net), the restore succeeds, repeat the restore process a second time. It looks like the conflict comes about with duplicates in the course completion table.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quen Sam Marshall
                Reporter:
                salvetore Michael de Raadt
                Integrator:
                Eloy Lafuente (stronk7)
                Tester:
                Tim Hunt
                Participants:
                Component watchers:
                Sam Marshall, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Adrian Greeve, Mihail Geshoski, Peter Dias
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  1/Jul/11