Moodle
  1. Moodle
  2. MDL-25248

1.9->2.x upgrade: Unknown error upgrading mod_resource to version 2009062600, can not continue

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.2.11
    • Component/s: Unknown
    • Labels:
      None
    • Environment:
      cPanel access.
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      1/ install 1.9.x and all different resource types
      2/ add several more resources
      3/ go to DB and change the last two course_modules.instance fields to point to different resource (one from the same, other from different course)
      4/ upgrade to 2.2.x
      5/ verify the resources were upgraded correctly

      Show
      1/ install 1.9.x and all different resource types 2/ add several more resources 3/ go to DB and change the last two course_modules.instance fields to point to different resource (one from the same, other from different course) 4/ upgrade to 2.2.x 5/ verify the resources were upgraded correctly
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE
    • Pull from Repository:
    • Rank:
      5132

      Description

      Giving error during upgrade process.

      • line 154 of /lib/upgradelib.php: upgrade_exception thrown
      • line 107 of /mod/resource/db/upgrade.php: call to upgrade_mod_savepoint()
      • 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 302 of /admin/index.php: call to upgrade_noncore()

        Issue Links

          Activity

          Hide
          Petr Škoda added a comment -

          Hello,

          the upgrade stops because there is a serious inconsistency in resource tables. Did you encounter any other problem during the upgrade? Did you install any contrib module in 1.9 or modified any files?

          Petr Skoda

          Show
          Petr Škoda added a comment - Hello, the upgrade stops because there is a serious inconsistency in resource tables. Did you encounter any other problem during the upgrade? Did you install any contrib module in 1.9 or modified any files? Petr Skoda
          Hide
          Timothy Guy added a comment -

          No problems or errors during install.
          I do have a couple of added modules, but my other install with the same modules upgraded. I will try to backup and restore to a clean 1.9 install and then upgrade.

          Show
          Timothy Guy added a comment - No problems or errors during install. I do have a couple of added modules, but my other install with the same modules upgraded. I will try to backup and restore to a clean 1.9 install and then upgrade.
          Hide
          Luca De Andreis added a comment -

          When update from 1.9.10+ to 2.0.1+ all clean, only Feedback (1.9.10) extension.... process crash with "Unknown error upgrading mod_resource to version 2009062600, can not continue. When upgrading to Moodle 2.0".
          Server is Debian Squeeze, Apache 2.2 & DB on PostgreSQL.

          Any idea ?

          Thanks Luca

          Show
          Luca De Andreis added a comment - When update from 1.9.10+ to 2.0.1+ all clean, only Feedback (1.9.10) extension.... process crash with "Unknown error upgrading mod_resource to version 2009062600, can not continue. When upgrading to Moodle 2.0". Server is Debian Squeeze, Apache 2.2 & DB on PostgreSQL. Any idea ? Thanks Luca
          Hide
          Bruno Vernier added a comment -

          I had the same error. But just prior to that error, I had an error with a duplicate in resource_old which I traced to a resource that was repeated twice with the same instance number in a same course. Deleting both (in the 1.9 database) and recreating one fixed the problem... but I had to restart the upgrade from 1.9.11 to 2.0.2 from scratch

          there were 4 of these duplicate situations which I could get one by one by re-running the upgrade from scratch (very long because very big database) or by using this shell script, FWIW

          for i in

          {1..500}

          do
          mysql -p moodle -e "select count as c,id,course from mdl_course_modules where course=$i and module=12 group by instance order by c;"
          done

          and looking for 2's in the first column and then looking at the instance , then the corresponding record in mdl_resource and find the culprit to delete both instances in that course (and recreate it)

          Show
          Bruno Vernier added a comment - I had the same error. But just prior to that error, I had an error with a duplicate in resource_old which I traced to a resource that was repeated twice with the same instance number in a same course. Deleting both (in the 1.9 database) and recreating one fixed the problem... but I had to restart the upgrade from 1.9.11 to 2.0.2 from scratch there were 4 of these duplicate situations which I could get one by one by re-running the upgrade from scratch (very long because very big database) or by using this shell script, FWIW for i in {1..500} do mysql -p moodle -e "select count as c,id,course from mdl_course_modules where course=$i and module=12 group by instance order by c;" done and looking for 2's in the first column and then looking at the instance , then the corresponding record in mdl_resource and find the culprit to delete both instances in that course (and recreate it)
          Hide
          Brent Lee added a comment -

          I had a non null issue with this table or the _old table during upgrade.

          Show
          Brent Lee added a comment - I had a non null issue with this table or the _old table during upgrade.
          Hide
          Brent Lee added a comment -

          Is there something I can provide to help with this issue?

          Show
          Brent Lee added a comment - Is there something I can provide to help with this issue?
          Hide
          A.J. Colianni added a comment -

          Just wanted to add my voice that I have run into this in updating my 1.9.12+ site to 2.1. I am going to start the upgrade over again and more carefully document the steps I have taken in attempting to debug it.

          I can say that it seems to be a mismatch with what version of mod_resource we had, and what steps the code has taken to prepare for the upgrade. It does not seem that resource_old was properly prepared, with the data copied over from resource.

          If anyone is actively working on this one, please let me know what I can do to help, otherwise I will back up, start my upgrade again and add some more info to this thread.

          Show
          A.J. Colianni added a comment - Just wanted to add my voice that I have run into this in updating my 1.9.12+ site to 2.1. I am going to start the upgrade over again and more carefully document the steps I have taken in attempting to debug it. I can say that it seems to be a mismatch with what version of mod_resource we had, and what steps the code has taken to prepare for the upgrade. It does not seem that resource_old was properly prepared, with the data copied over from resource. If anyone is actively working on this one, please let me know what I can do to help, otherwise I will back up, start my upgrade again and add some more info to this thread.
          Hide
          Carl Heath added a comment -

          I was upgrading a site from 1.9.5 to 2.1 today and ran into this error. After a little digging I found that in the mod/resource/db/upgradelib.php the upgrade process is trying to create a new table resource_old and copying a lot from the resource table into it, and that query has a problem (at least for my install) it tries to copy a field summary from resource table into an intro field in resource_old except when I looked into the db I found there is no summary field but an intro field in the resource table. So, I updated the sql statement at line 253-256 and changed the r.summary to r.intro and the upgrade process went past this point without error.

          Show
          Carl Heath added a comment - I was upgrading a site from 1.9.5 to 2.1 today and ran into this error. After a little digging I found that in the mod/resource/db/upgradelib.php the upgrade process is trying to create a new table resource_old and copying a lot from the resource table into it, and that query has a problem (at least for my install) it tries to copy a field summary from resource table into an intro field in resource_old except when I looked into the db I found there is no summary field but an intro field in the resource table. So, I updated the sql statement at line 253-256 and changed the r.summary to r.intro and the upgrade process went past this point without error.
          Hide
          A.J. Colianni added a comment -

          Thanks Carl, I will make that change in my code and attempt the upgrade again. I'll let you know the results!

          Show
          A.J. Colianni added a comment - Thanks Carl, I will make that change in my code and attempt the upgrade again. I'll let you know the results!
          Hide
          Chris Gibson added a comment - - edited

          I'm persistently getting the same error as A.J.
          I'm trying a test upgrade from 1.9.13 to 2.1
          I finally got an upgrade to work using a combination of Carl's fix and hunting the duplicate resources by repeatedly running

          "INSERT INTO mdl_resource_old (oldid, course, name, type, reference, intro, introformat, alltext, popup, options, timemodified, cmid)
          SELECT r.id, r.course, r.name, r.type, r.reference, r.intro, 0, r.alltext, r.popup, r.options, r.timemodified, cm.id
          FROM mdl_resource r LEFT JOIN mdl_course_modules cm ON (r.id = cm.instance AND cm.module = '11');"

          and then deleting the reported duplicate keys.
          Bruno's code did not work for me, alas, (even after I changed the module=12 to module=11).

          Show
          Chris Gibson added a comment - - edited I'm persistently getting the same error as A.J. I'm trying a test upgrade from 1.9.13 to 2.1 I finally got an upgrade to work using a combination of Carl's fix and hunting the duplicate resources by repeatedly running "INSERT INTO mdl_resource_old (oldid, course, name, type, reference, intro, introformat, alltext, popup, options, timemodified, cmid) SELECT r.id, r.course, r.name, r.type, r.reference, r.intro, 0, r.alltext, r.popup, r.options, r.timemodified, cm.id FROM mdl_resource r LEFT JOIN mdl_course_modules cm ON (r.id = cm.instance AND cm.module = '11');" and then deleting the reported duplicate keys. Bruno's code did not work for me, alas, (even after I changed the module=12 to module=11).
          Hide
          Glenn Ansley added a comment -

          Re the duplicate ID. We are finding this while prepping to upgrade a 1.9.13 to 2.1. Our installation started as 1.7.something ages ago. We attempted a group by and that relieved the duplicate key issue but it resulted in missing resources (as we anticipated). We are now trying the suggestion to remove the unique key mentioned in the other ticket but I anticipate this being an issue further down the script because Moodle will eventually count rows between resource_old and resource. When it compares, if they are off it aborts... but I may tackle that problem later.

          The honest solution here - and what we will probably have to do eventually - is to create a script that cleans up the duplicates in course_modules that are breaking the 1:1 relationship with resource. This will have to be a standalone script fired prior to upgrade.

          Show
          Glenn Ansley added a comment - Re the duplicate ID. We are finding this while prepping to upgrade a 1.9.13 to 2.1. Our installation started as 1.7.something ages ago. We attempted a group by and that relieved the duplicate key issue but it resulted in missing resources (as we anticipated). We are now trying the suggestion to remove the unique key mentioned in the other ticket but I anticipate this being an issue further down the script because Moodle will eventually count rows between resource_old and resource. When it compares, if they are off it aborts... but I may tackle that problem later. The honest solution here - and what we will probably have to do eventually - is to create a script that cleans up the duplicates in course_modules that are breaking the 1:1 relationship with resource. This will have to be a standalone script fired prior to upgrade.
          Hide
          Lawrence N added a comment -

          I too have this problem. where do we start to debug this?

          I have MyISAM and maybe that could be a cause? I'll try again with innodb this time

          Show
          Lawrence N added a comment - I too have this problem. where do we start to debug this? I have MyISAM and maybe that could be a cause? I'll try again with innodb this time
          Hide
          Ben Steeples added a comment -

          We've made some progress on this...

          Most of the 'mod_resource to 2009062600' errors are caused by the first few steps in /mod/resource/db/upgrade.php, where the mod_resource table structure is altered and then copied into mod_resource_old.

          Things to watch out for:

          Even if you fix these, there have already been changes to the mod_resource table, so 'Continue'ing the upgrade procedure and re-running the mod_resource upgrade almost always fails again, because:

          • mdl_resource_old already exists;
          • mdl_resource.summary has been renamed to mdl_resource.intro;
          • mdl_resource.introformat column already exists;
            You can easily fix these by dropping and renaming the appropriate columns, and then altering the version number in mdl_modules, for the 'resource' module. This should re-run the mdl_resource procedure from scratch.

          I'm not a great PHP programmer, but it would be great if the upgrade.php performed some more tests before moving on. The 'are the number of records in mdl_resource and mdl_resource_old the same?' test often happens way after the actual error has taken place, and is quite undescriptive.

          Show
          Ben Steeples added a comment - We've made some progress on this... Most of the 'mod_resource to 2009062600' errors are caused by the first few steps in /mod/resource/db/upgrade.php, where the mod_resource table structure is altered and then copied into mod_resource_old. Things to watch out for: NULL values in mdl_resource fields (intro, alltext, reference); Duplicate values in mdl_course_modules (in our example, for module=13, fixed by Bruno's suggestion); MSSQL having row length errors in mdl_resource when dropping and adding fields (see http://stackoverflow.com/questions/2139365/cannot-create-a-row-of-size-8074-which-is-greater-than-the-allowable-maximum-row ); Even if you fix these, there have already been changes to the mod_resource table, so 'Continue'ing the upgrade procedure and re-running the mod_resource upgrade almost always fails again, because: mdl_resource_old already exists; mdl_resource.summary has been renamed to mdl_resource.intro; mdl_resource.introformat column already exists; You can easily fix these by dropping and renaming the appropriate columns, and then altering the version number in mdl_modules, for the 'resource' module. This should re-run the mdl_resource procedure from scratch. I'm not a great PHP programmer, but it would be great if the upgrade.php performed some more tests before moving on. The 'are the number of records in mdl_resource and mdl_resource_old the same?' test often happens way after the actual error has taken place, and is quite undescriptive.
          Hide
          Susan Mangan added a comment -

          I'm upgrading from 1.9.16 to 2.2 and have the exact same error. Also encountered similar errors previous to this as others have re: duplicates, mdl_resource_old, etc. trying to work through each one as it comes up ... we also started with early db version 1.5 or 1.6.

          Show
          Susan Mangan added a comment - I'm upgrading from 1.9.16 to 2.2 and have the exact same error. Also encountered similar errors previous to this as others have re: duplicates, mdl_resource_old, etc. trying to work through each one as it comes up ... we also started with early db version 1.5 or 1.6.
          Hide
          Petras Virzintas added a comment -

          I have the same error upgrading from 1.9.13 to 2.2.

          I have successfully upgraded one database but the second one has this "brick wall" problem.

          Rgds
          Petras

          Show
          Petras Virzintas added a comment - I have the same error upgrading from 1.9.13 to 2.2. I have successfully upgraded one database but the second one has this "brick wall" problem. Rgds Petras
          Hide
          Jean-Francois Belisle added a comment -

          I had the same problem and finally resolve it !!

          First, after having this error message, you'll need to revert the following tables:
          mdl_resource
          mdl_course_modules

          And change back de value of the resource module in the mdl_modules table.

          I have run the following query:

          SELECT r.id, r.course, r.name, r.type, r.reference, r.summary, 0, r.alltext, r.popup, r.options, r.timemodified, cm.id
          FROM mdl_resource r
          LEFT JOIN mdl_course_modules cm
          ON r.id = cm.instance
          WHERE cm.id is null

          and deleted the corresponding records in the mdl_course_modules tables

          Make sure you don't have any NULL in mdl_resource (intro, alltext, reference).

          And restart the upgrade !

          Good luck

          Show
          Jean-Francois Belisle added a comment - I had the same problem and finally resolve it !! First, after having this error message, you'll need to revert the following tables: mdl_resource mdl_course_modules And change back de value of the resource module in the mdl_modules table. I have run the following query: SELECT r.id, r.course, r.name, r.type, r.reference, r.summary, 0, r.alltext, r.popup, r.options, r.timemodified, cm.id FROM mdl_resource r LEFT JOIN mdl_course_modules cm ON r.id = cm.instance WHERE cm.id is null and deleted the corresponding records in the mdl_course_modules tables Make sure you don't have any NULL in mdl_resource (intro, alltext, reference). And restart the upgrade ! Good luck
          Hide
          Petr Škoda added a comment -

          Thanks, I suppose the solution would be as described right above - find resource records without matching course_modules entry. I suppose either somebody deleted the record by hacking DB directly or there was some problem in older Moodle 1.x

          Show
          Petr Škoda added a comment - Thanks, I suppose the solution would be as described right above - find resource records without matching course_modules entry. I suppose either somebody deleted the record by hacking DB directly or there was some problem in older Moodle 1.x
          Hide
          Petr Škoda added a comment -

          Hello,

          my patch should undo the resource hard-linking hacks some people used in 1.x. It should resolve some other inconsistencies too.

          Thanks for the report and feedback here.

          Petr

          Show
          Petr Škoda added a comment - Hello, my patch should undo the resource hard-linking hacks some people used in 1.x. It should resolve some other inconsistencies too. Thanks for the report and feedback here. Petr
          Hide
          Dan Poltawski added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Dan Poltawski added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Dan Poltawski added a comment -

          Hi Petr,

          I think the testing instructions need to be a bit more thorough on this, I was trying to improve them myself, but then I realised I didn't really know what I was asking for.

          Can I ask you to be more explicit in the testing instructions about:

          1. Creating a number of resources to test both this fix and that it doesn't introduce a regression
          2. Exactly what db fields to manipulate
          Show
          Dan Poltawski added a comment - Hi Petr, I think the testing instructions need to be a bit more thorough on this, I was trying to improve them myself, but then I realised I didn't really know what I was asking for. Can I ask you to be more explicit in the testing instructions about: Creating a number of resources to test both this fix and that it doesn't introduce a regression Exactly what db fields to manipulate
          Hide
          CiBoT added a comment -

          Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.

          Show
          CiBoT added a comment - Moving this reopened issue out from current integration. Please, re-submit it for integration once ready.
          Hide
          Petr Škoda added a comment -

          cm->instance means course_modules.instance field

          Show
          Petr Škoda added a comment - cm->instance means course_modules.instance field
          Hide
          Dan Poltawski added a comment -

          Well, I would still prefer more detail here about setting up the resources, but we'll see how the tester gets on.

          Integrated to 22 thaks

          Show
          Dan Poltawski added a comment - Well, I would still prefer more detail here about setting up the resources, but we'll see how the tester gets on. Integrated to 22 thaks
          Hide
          Rossiani Wijaya added a comment -

          This is working as expected.

          Tested for 2.2.

          Test passed.

          Show
          Rossiani Wijaya added a comment - This is working as expected. Tested for 2.2. Test passed.
          Hide
          Marina Glancy added a comment -

          Thanks for your awesome work! This has now become a part of Moodle.

          Closing as fixed!

          Show
          Marina Glancy added a comment - Thanks for your awesome work! This has now become a part of Moodle. Closing as fixed!

            People

            • Votes:
              13 Vote for this issue
              Watchers:
              18 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: