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

Error writing to database on 1.9.8+ upgrade to 2.0.1+

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.2
    • Component/s: Resource
    • Labels:
    • Environment:
      PHP 5.2.13, MySQL 5.0.91, Linux
    • Database:
      MySQL
    • Difficulty:
      Moderate
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      When updating from 1.9.8+ to 2.0.1 the installation is blocked by this error.

      mod_resource
      Error writing to database
      More information about this error
      Debug info: Column 'instanceid' cannot be null
      INSERT INTO mdl_context (contextlevel,instanceid,depth) VALUES(?,?,?)
      [array (
      0 => 70,
      1 => NULL,
      2 => 4,
      )]
      Stack trace:

      • line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown
      • line 859 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      • line 901 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
      • line 1891 of /lib/accesslib.php: call to mysqli_native_moodle_database->insert_record()
      • line 2223 of /lib/accesslib.php: call to create_context()
      • line 70 of /lib/resourcelib.php: call to get_context_instance()
      • line 133 of /mod/resource/db/upgradelib.php: call to resourcelib_try_file_migration()
      • line 181 of /mod/resource/db/upgrade.php: call to resource_20_migrate()
      • line 490 of /lib/upgradelib.php: call to xmldb_resource_upgrade()
      • line 265 of /lib/upgradelib.php: call to upgrade_plugins_modules()
      • line 1352 of /lib/upgradelib.php: call to upgrade_plugins()
      • line 290 of /admin/index.php: call to upgrade_noncore()

        Gliffy Diagrams

          Activity

          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Moved to stable backlog, leaving assigned to Petr.

          Thanks for the report!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Moved to stable backlog, leaving assigned to Petr. Thanks for the report!
          Hide
          skodak Petr Skoda added a comment -

          It looks like the resource table contains invalid records with missing course module id. I am going to add extra check that skips the problematic errors.

          Show
          skodak Petr Skoda added a comment - It looks like the resource table contains invalid records with missing course module id. I am going to add extra check that skips the problematic errors.
          Hide
          skodak Petr Skoda added a comment -

          I think I tracked it down, I have added a test that skips invalid resource database records.

          The fix should be available in the next weekly build.

          Petr

          Show
          skodak Petr Skoda added a comment - I think I tracked it down, I have added a test that skips invalid resource database records. The fix should be available in the next weekly build. Petr
          Hide
          dippitydip Mike Grew added a comment -

          Hi Petr, if this is under review, is the fix still available in the new weekly build? Thanks and great work.

          Show
          dippitydip Mike Grew added a comment - Hi Petr, if this is under review, is the fix still available in the new weekly build? Thanks and great work.
          Hide
          dongsheng Dongsheng Cai added a comment -

          Tested, worked.

          Thanks!

          Show
          dongsheng Dongsheng Cai added a comment - Tested, worked. Thanks!
          Hide
          dippitydip Mike Grew added a comment -

          Is this available in the current weekly?

          Show
          dippitydip Mike Grew added a comment - Is this available in the current weekly?
          Hide
          dongsheng Dongsheng Cai added a comment -

          Hi, Mike,

          It is sitting in integration at the moment, and will be merged to weekly release.

          Show
          dongsheng Dongsheng Cai added a comment - Hi, Mike, It is sitting in integration at the moment, and will be merged to weekly release.
          Hide
          dippitydip Mike Grew added a comment - - edited

          Hi, this isn't fixed. I just tried the lastest weekly build, that has the MDL-26117 fix included and I get the same error:

          ------------------------------------------------------------------------------------------------------
          mod_resource

          Error writing to database

          More information about this error
          Debug info: Column 'instanceid' cannot be null
          INSERT INTO mdl_context (contextlevel,instanceid,depth) VALUES(?,?,?)
          [array (
          0 => 70,
          1 => NULL,
          2 => 4,
          )]
          Stack trace:

          • line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown
          • line 859 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
          • line 901 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
          • line 1891 of /lib/accesslib.php: call to mysqli_native_moodle_database->insert_record()
          • line 2223 of /lib/accesslib.php: call to create_context()
          • line 70 of /lib/resourcelib.php: call to get_context_instance()
          • line 133 of /mod/resource/db/upgradelib.php: call to resourcelib_try_file_migration()
          • line 181 of /mod/resource/db/upgrade.php: call to resource_20_migrate()
          • line 526 of /lib/upgradelib.php: call to xmldb_resource_upgrade()
          • line 265 of /lib/upgradelib.php: call to upgrade_plugins_modules()
          • line 1403 of /lib/upgradelib.php: call to upgrade_plugins()
          • line 290 of /admin/index.php: call to upgrade_noncore()
            --------------------------------------------------------------------------------------------------------
          Show
          dippitydip Mike Grew added a comment - - edited Hi, this isn't fixed. I just tried the lastest weekly build, that has the MDL-26117 fix included and I get the same error: ------------------------------------------------------------------------------------------------------ mod_resource Error writing to database More information about this error Debug info: Column 'instanceid' cannot be null INSERT INTO mdl_context (contextlevel,instanceid,depth) VALUES(?,?,?) [array ( 0 => 70, 1 => NULL, 2 => 4, )] Stack trace: line 394 of /lib/dml/moodle_database.php: dml_write_exception thrown line 859 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 901 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() line 1891 of /lib/accesslib.php: call to mysqli_native_moodle_database->insert_record() line 2223 of /lib/accesslib.php: call to create_context() line 70 of /lib/resourcelib.php: call to get_context_instance() line 133 of /mod/resource/db/upgradelib.php: call to resourcelib_try_file_migration() line 181 of /mod/resource/db/upgrade.php: call to resource_20_migrate() line 526 of /lib/upgradelib.php: call to xmldb_resource_upgrade() line 265 of /lib/upgradelib.php: call to upgrade_plugins_modules() line 1403 of /lib/upgradelib.php: call to upgrade_plugins() line 290 of /admin/index.php: call to upgrade_noncore() --------------------------------------------------------------------------------------------------------
          Hide
          skodak Petr Skoda added a comment -

          No, you did not use latest weekly build because resourcelib_try_file_migration call is now on line 139 or 105, please try again. Thanks.

          Petr

          Show
          skodak Petr Skoda added a comment - No, you did not use latest weekly build because resourcelib_try_file_migration call is now on line 139 or 105, please try again. Thanks. Petr

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                21/Feb/11