Moodle
  1. Moodle
  2. MDL-26117

Error writing to database on 1.9.8+ upgrade to 2.0.1+

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker 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
    • Rank:
      16122

      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()

        Activity

        Hide
        Eloy Lafuente (stronk7) added a comment -

        Moved to stable backlog, leaving assigned to Petr.

        Thanks for the report!

        Show
        Eloy Lafuente (stronk7) added a comment - Moved to stable backlog, leaving assigned to Petr. Thanks for the report!
        Hide
        Petr Škoda 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
        Petr Škoda 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
        Petr Škoda 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
        Petr Škoda 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
        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
        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 Cai added a comment -

        Tested, worked.

        Thanks!

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

        Is this available in the current weekly?

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

        Hi, Mike,

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

        Show
        Dongsheng Cai added a comment - Hi, Mike, It is sitting in integration at the moment, and will be merged to weekly release.
        Hide
        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
        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
        Petr Škoda 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
        Petr Škoda 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: