Database Deadlock when upgrading Moodle

Database Deadlock when upgrading Moodle

by Rolf Cper -
Number of replies: 6

Hello expert,
Three months ago I had Moodle 3.0 running, but something went wrong when trying to update Poodll.
Ever since, I cannot get Moodle to run anymore because of 'Error reading from database'.
I have tried two ways to get a new Moodle environment working with all my old courses running properly:
a) I tried to use the newest version of Moodle (v3.4.0.) and connect it to my old database (of Moodle v3.0 in MySQL v5.7) in order to get access to all my course content (It took me years of effort creating them).
b) I tried to extract the content (and layout/makeup) of my courses (from Moodle 3.0 in MySQL) and import them into a clean Moodle database (from Moodle 3.4.0.) in order to avoid previous persistent database errors.
Both a) and b) lead to many errors:

ad a)
I start in my Test-environment with http://localhost:83/install.php . (I can login as administrator.)
At the beginning of upgrading procedure (http://localhost:83/admin/index.php?lang=en), I will see that:
1) 411 plugins need to be updated ('plugins acquiring attention').
Every time I click on the button 'Upgrade Moodle database now' the procedure crashes with 'Error reading from database', for example qtype_essay, with some debug_info and stack trace.
I go back to the previous page (http://localhost:83/admin/index.php?lang=en) and one less 'plugin acquires attention'.
Should I do these steps 411 times, and then eventually end with the same 'Error reading from database' ?

2) Several plugins are missing ('Additional Missing from disk!') in my Test-environment, such as:
groupselect 2017061302
user_bookmarks 2016100800
poodllz 2014102100 (crippled version of Poodll, mentioned in the old database that I cannot get rid of/erase).
wordcount 2014051200
analytics 2017031300
mobile 2015111114 (see item 3).
Should I download each separate zip-file of these plugins and copy the unzipped folder to the local-directory of Moodle, before I upgrade?

3) 1 update available needs to be installed: mobile 2015111114 Additional Missing from disk! There is a new version 2017111300 available! Release 3.4.340 .
After I click on 'Install this update' it
How do I get rid of the plugins that seem to cause errors, at the beginning of the upgrading procedure (to Moodle 3.4.0)?

4) 11 plugins have the status 'To be deleted'.
5) 43 plugins have the status 'To be installed'.

Summary: The plugins Mobile and Poodllz seem to cause trouble. The error 'Error reading from database' keeps on returning.

ad b) Extract existing courses from old, crippled database:
I do not know which are all the correct tables.
How do I use the tool HeidiSQL to extract (all) the correct tables within Moodle 3.0 database, so I can import them in Moodle 3.4.0. DB?
Which tables should I at least export/import (how many tables)?
If I succeed in extracting/exporting the correct data, can I overwrite the similar file (.frm) in the new database?

Does anyone have any advice on how to go about?

Friendly regards,
Rolf Snijders

PHP 7.0.9 on WIMP

Average of ratings: -
In reply to Rolf Cper

Re: Database Deadlock when upgrading Moodle

by William Stewart -

Rolf,

I can't speak to all of the questions/issues you posted, however, the issue you are describing sounds familiar so please see if it makes sense.


Poodll (the filter) is a relatively large plugin, something around 50Mb. Moodle does some code validation to all plugins when they are installed but this sometimes takes much longer for Poodll. Most other plugins are relatively small at kilobytes or even a single Mb. This is the max_execution_time in your PHP settings. The default I believe is 30. 

To avoid the timeout (or deadlock as you call it) which is a fatal error, you need to adjust the max_execution_time to 300. 

This is not my advice, but rather, this is the advice from Justin Hunt who is the developer of Poodll. This is in the Poodll documentation here: https://poodll.com/docs/increasing-phps-max_execution_time/.


The "something went wrong when trying to update Poodll" sounds exactly like the max_execution time issue described above. This happened to me in the past (well, I'm not the only one it has happened to) but I've not had an issue since changing the max_execution_value to 300. Moreover, if some other task requires more time (like upgrading Moodle), it can benefit as well. You need to adjust this value in your php.ini file and then reboot your server for it to take effect.


If you are connecting your old Moodle database to a new Moodle environment, it will just trigger the upgrade command since the old database is referencing an older version of Moodle, and potentially older plugins, etc.

The additional missing from disk simply means you do not have the plugin files in your Moodle directory in the right places-you need to make sure you copy everything that is 3rd party over prior to upgrading (so to answer your question to that, yes, yes you need to!).

To install the new plugins, you need to remove the older plugin directory.


Overall it seems like you might need some more experience with the upgrade process. I know that Rick Jerz has some great videos of how to do all of this and hopefully, he can share some links to them here. I know I benefitted from one of his "how to upgrade" videos a couple years ago when I was new to administering Moodle.

In reply to William Stewart

Re: Database Deadlock when upgrading Moodle

by Rolf Cper -

Hello William,
Thank you for your answer.
Actually, I do not want Poodll-plugin anymore in a new upgrade of Moodle, but because I try to connect a new Moodle version to the old database,
I keep on getting stuck because of the 'Error reading from database' message during any action whatsoever.
So, I should rephrase my question:
How do I get rid of all references to Poodll in the old database, in order to suppress the 'Error reading from database' message, before I start the upgrading of Moodle?
[I will use the database management-tool called HeidiSQL (Windows desktop software) to approach the old Moodle-database.]

Friendly regards,
Rolf

In reply to Rolf Cper

Re: Database Deadlock when upgrading Moodle

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

Do you not have a backup from prior to the poodll upgrade?  On the original site, what state is that in?  Can you get to anything?

In reply to Rolf Cper

Re: Database Deadlock when upgrading Moodle

by William Stewart -

Rolf,


My suggestion is precisely what Emma mentioned-do you have a backup you can restore prior to the Poodll timeout? This is really the only thing I think you can do-restore a backup.

In reply to William Stewart

Re: Database Deadlock when upgrading Moodle

by Rolf Cper -

Hello Emma and William,

The back-up mechanism overwrites every week the old backup, so it is not useful anymore to regain the database-situation prior to the crash.

The lesson I learnt is that I should make a special backup in a different folder, every time I update a plugin, or upgrade Moodle web-application.

Regards,
Rolf

In reply to Rolf Cper

Re: Database Deadlock when upgrading Moodle

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

And what is the status of the live site - can you get to anything at all?  Have you tried removing the poodll folder in the original site and see if that maybe brings it back?  Also, delete the cache and localcache from the moodleDATA folder, not the moodle folder.