Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Jim Angel -
Number of replies: 17

Should I be worried about the following output when upgrading (and migrating) Moodle? I can click continue and things appear to work.

qtype_ddimageortext

Debug info: Table 'mdl_qtype_ddimageortext' already exists
CREATE TABLE mdl_qtype_ddimageortext (
id BIGINT(10) NOT NULL auto_increment,
questionid BIGINT(10) NOT NULL DEFAULT 0,
shuffleanswers SMALLINT(4) NOT NULL DEFAULT 1,
correctfeedback LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
correctfeedbackformat TINYINT(2) NOT NULL DEFAULT 0,
partiallycorrectfeedback LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
partiallycorrectfeedbackformat TINYINT(2) NOT NULL DEFAULT 0,
incorrectfeedback LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
incorrectfeedbackformat TINYINT(2) NOT NULL DEFAULT 0,
shownumcorrect TINYINT(2) NOT NULL DEFAULT 0,
CONSTRAINT PRIMARY KEY (id)
, KEY mdl_qtypddim_que2_ix (questionid)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE = utf8_general_ci
COMMENT='Defines drag and drop (text or images onto a background imag'
;
CREATE TABLE mdl_qtype_ddimageortext_drops (
id BIGINT(10) NOT NULL auto_increment,
questionid BIGINT(10) NOT NULL DEFAULT 0,
no BIGINT(10) NOT NULL DEFAULT 0,
xleft BIGINT(10) NOT NULL DEFAULT 0,
ytop BIGINT(10) NOT NULL DEFAULT 0,
choice BIGINT(10) NOT NULL DEFAULT 0,
label LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
CONSTRAINT PRIMARY KEY (id)
, KEY mdl_qtypddimdrop_que2_ix (questionid)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE = utf8_general_ci
COMMENT='Drop boxes'
;
CREATE TABLE mdl_qtype_ddimageortext_drags (
id BIGINT(10) NOT NULL auto_increment,
questionid BIGINT(10) NOT NULL DEFAULT 0,
no BIGINT(10) NOT NULL DEFAULT 0,
draggroup BIGINT(10) NOT NULL DEFAULT 0,
infinite SMALLINT(4) NOT NULL DEFAULT 0,
label LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
CONSTRAINT PRIMARY KEY (id)
, KEY mdl_qtypddimdrag_que2_ix (questionid)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE = utf8_general_ci
COMMENT='Images to drag. Actual file names are not stored here we use'
Error code: ddlexecuteerror
Stack trace:
  • line 449 of /lib/dml/moodle_database.php: ddl_change_structure_exception thrown
  • line 905 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 76 of /lib/ddl/database_manager.php: call to mysqli_native_moodle_database->change_database_structure()
  • line 412 of /lib/ddl/database_manager.php: call to database_manager->execute_sql_arr()
  • line 364 of /lib/ddl/database_manager.php: call to database_manager->install_from_xmldb_structure()
  • line 508 of /lib/upgradelib.php: call to database_manager->install_from_xmldb_file()
  • line 1647 of /lib/upgradelib.php: call to upgrade_plugins()
  • line 677 of /admin/index.php: call to upgrade_noncore()

Average of ratings: -
In reply to Jim Angel

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

'ddimageortext' is an optional plugin and there isn't a version listed for 3.0 so that might have something to do with it. All the same, make sure you have the latest possible version of your optional plugins installed.

In reply to Jim Angel

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

There are a few question types that were moved to core when 3.0 came out.  Unfortunately, the installer does not account for those of us that installed those question types prior.

I am surprised that you are able to continue - this normally stalls the installer totally.

The fix is to find those tables, and rename them to something else.  Then rerun the installer.  It will create the new tables.  Check your old versions of those questions and see if they still work.  If they are missing, you might need to delete the new table (which should not have any data in it) and then rename the old table back again.

In reply to Emma Richardson

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

That's a bit of  an oversight IMO

In reply to Howard Miller

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Stuart Mealor -

Is this verified?

That when upgrading to Moodle 3 if those question types were already plugins that the upgrade will fail ?

If the plugins are removed, and then the site is updated, do the existing question all work again (in core) ?  I can think of clients that will not want to lose these !

Considered how many sites use these question plugins I think there needs to be clarity here ?  Maybe there is and I've just missed it ?

In reply to Stuart Mealor

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Don't know, but I'm running 2.9 sites in exactly that position. It's gone on my "need to check this" list. I'll be *very* unhappy if it's true angry

In reply to Stuart Mealor

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Don't remove the plugins through the moodle interface as that will delete the database entries.  Follow my instructions for the database fix.

Unfortunately, I cannot answer the question for sure about your old questions as I don't believe I actually had any questions of that type when I did my upgrade.  There have been several posts about the problem so I am sure someone out there has the answer of whether the questions are restored.


A quick way to check would be to compare the old table structure to the new one.  If it is the same (which I suspect it is) then renaming the old table back to its original name once the upgrade has completed should allow all your questions to be restored correctly.


In reply to Emma Richardson

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Don't let this post scare you. It is wrong.

If you previously had the drag-drop question types installed, the the upgrade to 3.0 will work just fine. It will upgrade the question types from the version you had installed to the version shipped with 3.0.

So, this was not an oversight. We thougth about it, and tested it before the release. Since the release, many people have successfully upgraded without problems (including all the OU Moodle sites.)

Now, given the post that started this thread, and what what Emma says, there must be some cases where the upgrade does not go smoothly. But, anyone who has been involved in Moodle for a long time knows that sometimes upgrades fail. Normally that is caused by the site you are upgrading being in a funny state to start with (though mostly the upgrade process is designed to be fault-tolerant enough to deal with things). Anyway, what you do in this case is that you invesitate the problem, diagnose it, then fix it. Same as usual.
Average of ratings: Useful (3)
In reply to Tim Hunt

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

That is good to hear.  I apologize for my presumption that this had not been addressed.  Having had the issue myself and seeing others with the issue, I figured it was just one of those things to be dealt with at upgrade time!

In reply to Tim Hunt

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Stuart Mealor -

That's awesome news Tim - thanks for clarifying and the work that went into doing this (shows how amazing the Moodle developers are!) - and we can refer people to your post now smile

Presumably we would just remove these question plugins that were installed previously once the upgrade has been verified.

Stu

In reply to Stuart Mealor

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

This is not amazing. This it just routine.

I am not sure about your presumption. How do you normally upgrade a Moodle site. Anyway, you certainly don't want to remove these plugins, either before, or after the upgrade. If you do the upgrade right, then the question types that come as part of Moodle 3.0 will take the place of the plugins you had previously installed manually. (The new plugins will upgrade the old ones.) It is just that they now come as part of the standard Moodle download, rather than having to be downloaded and installed/upgraded separately.

In reply to Tim Hunt

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Stuart Mealor -

One person's routine is another person's amazing sometimes I guess wink

So the new plugins, included in core, upgrade the existing installed plugins.  OK that's clear now, thanks.  It wasn't clear because this "plugin being is now supplied in core" isn't something that happens too often as far as I'm aware, not in terms of functions that a teacher sees I think.

Thanks anyway smile

Stu

In reply to Jim Angel

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm going to shift this to the quiz forum. Hopefully Tim can let us know the position. 

In reply to Jim Angel

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Jim Angel -

UPDATE: After scratching my head and reading some of these posts- I dropped the database on our testing instance (+ rebuilt our staging VMand re-ran the installer. It appeared to have went smoothly after that.


The one thing that strikes me as odd, is that the upgrade takes forever and appears froze even though the site is spinning. If it wasn't for the query "SHOW FULL PROCESSLIST;" I would have been here asking for help. The "SHOW FULL PROCESSLIST;" mysql query will let you see the current executed query and time spent on it. I wrote a dirty bash script that I can watch. I plan to deep dive into my configuration shortly.

In reply to Jim Angel

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Gerard Cuello Adell -

I got the same error as you, but I did the upgrade process from command line (admin/cli/upgrade.php). In my case, the upgrade was stopped.

I have done this migration process periodically (each month) from 2.4 to last 3.0 available version.  And until now with 3.0.3+(Build: 20160407) I didn't get this error.


As you can see below It happens after qtype_calculatedsimple  process:

-->qtype_calculatedmulti
++ Success ++
-->qtype_calculatedsimple
++ Success ++
-->qtype_ddimageortext
!!! DDL sql execution error !!!
!! Table 'mdl_qtype_ddimageortext' already exists
CREATE TABLE mdl_qtype_ddimageortext (
.....
.....

Error code: ddlexecuteerror !!
!! Stack trace: * line 449 of /lib/dml/moodle_database.php: ddl_change_structure_exception thrown
* line 905 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
* line 76 of /lib/ddl/database_manager.php: call to mysqli_native_moodle_database->change_database_structure()
* line 412 of /lib/ddl/database_manager.php: call to database_manager->execute_sql_arr()
* line 364 of /lib/ddl/database_manager.php: call to database_manager->install_from_xmldb_structure()
* line 508 of /lib/upgradelib.php: call to database_manager->install_from_xmldb_file()
* line 1647 of /lib/upgradelib.php: call to upgrade_plugins()
* line 171 of /admin/cli/upgrade.php: call to upgrade_noncore()

Any idea about why does it happens ?

Thanks in advance!

In reply to Gerard Cuello Adell

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

This happened to me. The reason was I had already added the question type, ddimageortext and a couple others, to my Moodle, and the question types was now being added to core Moodle.

The way I got past the point was to delete the question plugin (I had my questions backed up) so the upgrade could then proceed. Once I finished the upgrade, I imported my questions of that type back into my Moodle.

In reply to AL Rachels

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Gerard Cuello Adell -

The odd thing is that before upgrade I checked that types are not installed.

I also tried to restore the whole database before process with the upgrade again.

Now, with the upgrade stopped, when I try to run the upgrde, I get inmediatly the same error...


Gerard

In reply to Gerard Cuello Adell

Re: Upgrade 2.8 -> 3.0 MySQL Error (but completes upgrade)

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

This is because when you first attempted the upgrade, the tables were created.  If you did not have the plugins prior to the upgrade, there should be no problem with deleting the tables manually and then rerunning the upgrade.