Moodle
  1. Moodle
  2. MDL-35019

Upgrading to new version produces database error when file or memory limits are reached

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.19, 2.1.7, 2.2.4
    • Fix Version/s: None
    • Component/s: Installation
    • Labels:
    • Database:
      MySQL
    • Workaround:
      Hide

      See comments below.

      Show
      See comments below.
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE
    • Rank:
      43621

      Description

      Upgrading from Moodle 1.9.19+ (Build: 20120816) to 2.1.7+ (Build: 20120816), all tables are collate utf8_general_ci and charset utf8. When you pass the environment and plugin checks, this error shows up:

      System
      
      Table "upgrade_log" already exists
      
      More information about this error
      Stack trace:
      
         line 469 of /lib/ddl/database_manager.php: ddl_exception thrown
         line 93 of /lib/db/upgrade.php: call to database_manager->create_table()
         line 1418 of /lib/upgradelib.php: call to xmldb_main_upgrade()
         line 277 of /admin/index.php: call to upgrade_core()
      

      Better error detection and reporting is needed.

      See the comments below for more information about what was causing this problem.

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment - - edited

          This happens if the upgrade script gets executed concurrently or is interrupted, if that happens you need to restore backup (both database and dataroot) and retry.

          It is recommended to prevent web server access for all other users, such as stoppign apache and using CLI, htaccess deny or firewall tweak.

          Show
          Petr Škoda added a comment - - edited This happens if the upgrade script gets executed concurrently or is interrupted, if that happens you need to restore backup (both database and dataroot) and retry. It is recommended to prevent web server access for all other users, such as stoppign apache and using CLI, htaccess deny or firewall tweak.
          Hide
          Gleidson Lacerda added a comment -

          I did restore backup before upgrade and prevent external access. From cli:

          == Upgrading Moodle database from version 1.9.19+ (Build: 20120816) (2007101592.01) to 2.1.7+ (Build: 20120816) (2011070107.06) ==

          Your Moodle files have been changed, and you are about to automatically
          upgrade your server to this version:

          2.1.7+ (BUILD: 20120816) (2011070107.06)

          Once you do this you can not go back again.

          Please note that this process can take a long time.

          Are you sure you want to upgrade this server to this version?
          type y (means yes) or n (means no)
          : y
          -->System
          Default exception handler: Table "upgrade_log" already exists Debug:

          • line 469 of /lib/ddl/database_manager.php: ddl_exception thrown
          • line 93 of /lib/db/upgrade.php: call to database_manager->create_table()
          • line 1418 of /lib/upgradelib.php: call to xmldb_main_upgrade()
          • line 145 of /admin/cli/upgrade.php: call to upgrade_core()

          !!! Table "upgrade_log" already exists !!!
          !! Stack trace: * line 469 of /lib/ddl/database_manager.php: ddl_exception thrown

          • line 93 of /lib/db/upgrade.php: call to database_manager->create_table()
          • line 1418 of /lib/upgradelib.php: call to xmldb_main_upgrade()
          • line 145 of /admin/cli/upgrade.php: call to upgrade_core()
            !!
          Show
          Gleidson Lacerda added a comment - I did restore backup before upgrade and prevent external access. From cli: == Upgrading Moodle database from version 1.9.19+ (Build: 20120816) (2007101592.01) to 2.1.7+ (Build: 20120816) (2011070107.06) == Your Moodle files have been changed, and you are about to automatically upgrade your server to this version: 2.1.7+ (BUILD: 20120816) (2011070107.06) Once you do this you can not go back again. Please note that this process can take a long time. Are you sure you want to upgrade this server to this version? type y (means yes) or n (means no) : y -->System Default exception handler: Table "upgrade_log" already exists Debug: line 469 of /lib/ddl/database_manager.php: ddl_exception thrown line 93 of /lib/db/upgrade.php: call to database_manager->create_table() line 1418 of /lib/upgradelib.php: call to xmldb_main_upgrade() line 145 of /admin/cli/upgrade.php: call to upgrade_core() !!! Table "upgrade_log" already exists !!! !! Stack trace: * line 469 of /lib/ddl/database_manager.php: ddl_exception thrown line 93 of /lib/db/upgrade.php: call to database_manager->create_table() line 1418 of /lib/upgradelib.php: call to xmldb_main_upgrade() line 145 of /admin/cli/upgrade.php: call to upgrade_core() !!
          Hide
          Michael de Raadt added a comment -

          This has only been reported once before and as the result of a failed restore attempt.

          If the upgrade log table is in your DB backup, a previous upgrade may have failed. Try restoring your DB backup, removing this table, then upgrading.

          Show
          Michael de Raadt added a comment - This has only been reported once before and as the result of a failed restore attempt. If the upgrade log table is in your DB backup, a previous upgrade may have failed. Try restoring your DB backup, removing this table, then upgrading.
          Hide
          Gleidson Lacerda added a comment -

          I did upgrade from 1.9.18+ to 1.9.19+ before, but there wasn't any errors in logs (apache/php and moodle debug are configured to show notice, warning and error)

          I'll restore this 1.9.8 backup, remove table (mdl_)upgrade_log and execute update straight to 2.1.7+, is that correct?

          Show
          Gleidson Lacerda added a comment - I did upgrade from 1.9.18+ to 1.9.19+ before, but there wasn't any errors in logs (apache/php and moodle debug are configured to show notice, warning and error) I'll restore this 1.9.8 backup, remove table (mdl_)upgrade_log and execute update straight to 2.1.7+, is that correct?
          Hide
          Gleidson Lacerda added a comment -

          I did restored and upgrade again and same error happens. Also I did install a fresh one, copied structure and restored only data from previous moodle and same error happened.

          I'm doing this as root (mysql, php-cli), www-data, no difference. What else I could test to locate where's the bug?

          Show
          Gleidson Lacerda added a comment - I did restored and upgrade again and same error happens. Also I did install a fresh one, copied structure and restored only data from previous moodle and same error happened. I'm doing this as root (mysql, php-cli), www-data, no difference. What else I could test to locate where's the bug?
          Hide
          Gleidson Lacerda added a comment -

          Problem:
          This Moodle has huge videos in moodledata, almost 700mb each

          Solution to fix incomplete upgrade:

          1) Install a fresh moodle, copy his database structure to a new database
          2) Backup only data from origin moodle
          3) Restore data into new database with only structure and fix problems (delete table, create column, etc)

          Solution to upgrade:

          1) Configure PHP to handle post_max_size and upload_max_filesize enough to files in moodledata
          2) Configure PHP max_execution_time and max_input_time to '-1' (no timeout at all - dangerous, not recommended)
          3) Configure PHP memory_limit to '-1' (PHP can use all memory it takes - dangerous, not recommended)
          4) Execute upgrade from server shell as root or httpd server user (www-data, nobody, other)

          Maybe I could suggest a specific debug message for Moodle when the upgrade fails for time out or memory limit?

          Thanks Michael and Petr for your valuable time, without your help I wouldn't be able to figure this out.

          Regards

          Show
          Gleidson Lacerda added a comment - Problem: This Moodle has huge videos in moodledata, almost 700mb each Solution to fix incomplete upgrade: 1) Install a fresh moodle, copy his database structure to a new database 2) Backup only data from origin moodle 3) Restore data into new database with only structure and fix problems (delete table, create column, etc) Solution to upgrade: 1) Configure PHP to handle post_max_size and upload_max_filesize enough to files in moodledata 2) Configure PHP max_execution_time and max_input_time to '-1' (no timeout at all - dangerous, not recommended) 3) Configure PHP memory_limit to '-1' (PHP can use all memory it takes - dangerous, not recommended) 4) Execute upgrade from server shell as root or httpd server user (www-data, nobody, other) Maybe I could suggest a specific debug message for Moodle when the upgrade fails for time out or memory limit? Thanks Michael and Petr for your valuable time, without your help I wouldn't be able to figure this out. Regards
          Hide
          Gleidson Lacerda added a comment -

          This happened to specific huge data files at moodledata, there's a workaround on commentaries

          Show
          Gleidson Lacerda added a comment - This happened to specific huge data files at moodledata, there's a workaround on commentaries
          Hide
          Michael de Raadt added a comment -

          Thanks for sharing the result of your investigation.

          I've altered the summary of your report and tidied this issue up a bit.

          Please feel free to continue working with us on the issue.

          Petr: I've added you as a watcher in case you are interested.

          Show
          Michael de Raadt added a comment - Thanks for sharing the result of your investigation. I've altered the summary of your report and tidied this issue up a bit. Please feel free to continue working with us on the issue. Petr: I've added you as a watcher in case you are interested.
          Hide
          Michael de Raadt added a comment -

          Thanks for reporting this issue.

          We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported.

          If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

          Michael d.

          TW9vZGxlDQo=

          Show
          Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year. It was reported as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.5 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d. TW9vZGxlDQo=
          Hide
          Michael de Raadt added a comment -

          I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported.

          This is being done as part of a bulk annual clean-up of issues.

          If you still believe this is an issue in supported versions, please create a new issue.

          Show
          Michael de Raadt added a comment - I'm closing this issue as it has been inactive for over a year has been recorded as affecting versions that are no longer supported. This is being done as part of a bulk annual clean-up of issues. If you still believe this is an issue in supported versions, please create a new issue.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: