My Moodle Has Stopped Working!

My Moodle Has Stopped Working!

by Alec Armstrong -
Number of replies: 12

Hi - I have a site mrarmstrongvle.net.  However, on Sunday it mysteriously stopped working.  To be precise I get an error message "Error reading from database".  (I note that I can still login as admin user.)

I have made no changes to the Moodle at all.  I contacted the people who run the server and they said that there is nothing wrong at their end or with the database.  They said that this is very likely to be a script error in Moodle (possibly a plugin error) and I should try disabling the plugins one by one!  The problem is I can't see how one can do this (without uninstalling them) and there are a very large number of plugins!!

I would be grateful if anyone could give me some ideas as to how I can correct this problem.

I note I am using Moodle version 3.0.2

Thank you for any comments.

Average of ratings: -
In reply to Alec Armstrong

Re: My Moodle Has Stopped Working!

by Usman Asar -
Picture of Plugin developers Picture of Testers

Alec, your site loading is way too slow, I wonder if it has to do with sites coming from UK or is it your own server. regarding your error, if it's opening admin login, means something to do with plug-in that is being rendered at frontage, as your admin log-in screen does show use of Clean Theme, if you aren't using clean theme by default, then start with changing theme, and then look out for plug-ins that load with the FrontPage.

Alternatively, restore DB to earlier date (say before Sunday), assuming you'd been taking backups

In reply to Usman Asar

Re: My Moodle Has Stopped Working!

by Alec Armstrong -

Thank you very much for taking the time to write.

The site is served by Protonhosting.  They informed me the problems are a Moodle script error.

I checked the Moodle and found that it is using Clean Theme by default.

I am not aware of the Database being backed up.

Is there any where on Moodle that will show what plugins are in use with the front page?  Otherwise any ideas next?

Thank you again for any comments.

In reply to Alec Armstrong

Re: My Moodle Has Stopped Working!

by Colin Fraser -
Picture of Documentation writers Picture of Testers

As you can still login as admin user, turn on the Debugging messages. Go to Site Admin > Development > Debugging and set Debug Messages to "ALL:..." This will help analyse the problem. This is the first thing to do when an error of this magnitude occurs. And don't forget to reset when you have finished. 

In reply to Colin Fraser

Re: My Moodle Has Stopped Working!

by Alec Armstrong -

Hi - thanks for taking the time to post.  I have enabled the debugging.  After running the site (via the index page) I get the following message:

Does this provide any clues?

Thank you for any comments.

Error reading from database
Debug info: MySQL server has gone away
SELECT value FROM mdl_cache_flags WHERE flagtype = ? AND name = ? AND expiry >= ? AND timemodified > ?
[array (
0 => 'userpreferenceschanged',
1 => '2',
2 => 1461183584,
3 => 1461183456,
)]
Error code: dmlreadexception
Stack trace:
  • line 443 of /lib/dml/moodle_database.php: dml_read_exception thrown
  • line 1080 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
  • line 1480 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 1553 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
  • line 1534 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
  • line 1677 of /lib/moodlelib.php: call to moodle_database->get_field_select()
  • line 1790 of /lib/moodlelib.php: call to get_cache_flag()
  • line 2012 of /lib/moodlelib.php: call to check_user_preferences_loaded()
  • line 260 of /blocks/moodleblock.class.php: call to get_user_preferences()
  • line 973 of /lib/blocklib.php: call to block_base->get_content_for_output()
  • line 1025 of /lib/blocklib.php: call to block_manager->create_block_contents()
  • line 474 of /lib/outputrenderers.php: call to block_manager->ensure_content_created()
  • line 39 of /theme/bootstrapbase/renderers/core_renderer.php: call to core_renderer->standard_head_html()
  • line 52 of /theme/clean/layout/columns3.php: call to theme_bootstrapbase_core_renderer->standard_head_html()
  • line 1016 of /lib/outputrenderers.php: call to include()
  • line 946 of /lib/outputrenderers.php: call to core_renderer->render_page_layout()
  • line 164 of /my/index.php: call to core_renderer->header()

In reply to Alec Armstrong

Re: My Moodle Has Stopped Working!

by Ken Task -
Picture of Particularly helpful Moodlers

First of all, Usman and/or Colin both would have told you this ... I just happened to be 'passing by' ....

Yep, seen it before.  It's a setting for MySQL that needs to be tweaked upwards.   

The official MySQL reference:

https://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html

translated ... moodle is trying to send too much data to the DB server.  It errors out by saying 'am not here anymore'.   You see "Server has gone away".

Fix: increase max_packets_allowed in my.cnf (config for the MySQL server) on your DB server.  Default for max_packets_allowed is 16M and whatever you are doing requires more than that.   Suggest increasing to at least double that ... 32M

If this is hosted on a shared hosting package, contact provider.   If it's hosted on a VPS, consult with provider docs to see where you could add the setting for MySQL server.

Changes in settings to DB server will require restart of the DB service.

'spirit of sharing', Ken

Average of ratings: Useful (2)
In reply to Ken Task

Re: My Moodle Has Stopped Working!

by Usman Asar -
Picture of Plugin developers Picture of Testers

Ken, your passing by was for a reason, for I dont know about Colin, but I certainly would have scratched my head for few mins, but thanks to yours and Visvanath's expertise that we small people end up learning something new.

In reply to Usman Asar

Re: My Moodle Has Stopped Working!

by Ken Task -
Picture of Particularly helpful Moodlers

Ohhhhh, you a sooooo kind ... and will go far in higher ed! ;)

Hmmmmm ... never, never, should one think of themselves as 'small'!

How about ... we can learn from one another! ;)

'spirit of sharing', Ken

In reply to Ken Task

Re: My Moodle Has Stopped Working!

by Colin Fraser -
Picture of Documentation writers Picture of Testers

 surprise   Yep, and I would've taken longer than Usman, Ken. Good pickup.

In reply to Ken Task

Re: My Moodle Has Stopped Working!

by Usman Asar -
Picture of Plugin developers Picture of Testers

Thank You for kind words, really appreciated! higher education is something that never satisfied my appetite, though holding 3 Masters already definitely not looking for Doctorate, but will not mind another Masters related to E-learning in few years time, just looking for universities ranking higher than my last M.Sc from Manchester, this what I had been doing ever since stepped  into higher education, every new degree should be from institute ranking higher than previous one.

Surely we learn from each other, specially on this community for I may haven't learned about moodle that much as I have learned about other things coming as side-orders to moodle, specially loved the part where one time stoppers ask for something, later that post is extended by relevant and irrelevant discussions by regulars.

In reply to Ken Task

Re: My Moodle Has Stopped Working!

by Alec Armstrong -

Hi - thank you for your idea.  However, I have been informed that the max_packets_allowed was set at 256M which is much bigger than the 16M figure suggested.  I have also had the database restored to an earlier version, but unfortunately the same problem remains!  In fact now I cannot login as admin user.

So, I am now completely stuck!!!  The only comment I can add is that I am not aware of having changed any of the plugins before the problems started.  I note that I was having trouble getting people to register for the website as the registration email was not going out smoothly.  I assumed this was due to Moodle using my email address to send out the registration emails (as I am administrator user) with my personal email service provided by AOL.  I also tried using my school email address but no emails were received or sent back at all.

In reply to Alec Armstrong

Re: My Moodle Has Stopped Working!

by Usman Asar -
Picture of Plugin developers Picture of Testers

Alec, you can as well try getting moodle and moodledata restored to same date, which DB was  restored to, as moodle does not only depends on database, but combination of all three. Lets hope that it will let you re-use your site again.

In reply to Alec Armstrong

Re: My Moodle Has Stopped Working!

by Ken Task -
Picture of Particularly helpful Moodlers

Yikes!   That's not sounding good at all, but ...

There's a table in Moodle that has grown too large me thinks.

Moodle 3 should be set to use files as sessions rather than database.   See if there is a sessions directory in moodledata.    If there is not, it means, for some reason, sessions are being recorded in the DB.   So IF there were no sessions directory with files in it, add this to the config.php file:

$CFG->dbsessions=0;

That tells Moodle to use the sessions directory in Moodledata rather than DB.  Moodle will create a sessions directory if not present.

This next one involves some decision as we as SQL ... we need to find the largest table in the DB.

Have a feeling it might be a log table.

This query will generate a listing of all the tables and show size of them:


SELECT table_name AS "Table", round(((data_length + index_length) / 1024 / 1024), 2) as TEST FROM information_schema.TABLES WHERE table_schema = "moodle30" ORDER BY TEST;

Change the moodle30 you see above to your DB name ... more likely it's 'moodle' but you can see that in the config.php file in the moodle code directory.

On a moodle30 site that's not used much the following shows:

Table    TEST  ↑
mdl_tool_customlang 13.55
mdl_question_answers 6.77
mdl_question 5.44
mdl_files 3.25
mdl_page 2.53
mdl_logstore_standard_log 2.42

Of the top 6 tables in size you can see mdl_logstore_standard_log is one of the largest and one that could be truncated ... ie, data removed from it. This would mean, however, you've lost the history of whatever actions it was tracking.   Stuff like user 2 logged on, etc..

Me thinks you might not need to keep that info in this case and could do without.

Don't know what's in your DB so run the query ... or get provider to do it for you so you can collect some information to share back here.

BTW, I just tested on a 3.0 site and truncating that table had no ill affect on the site ... I could login and could see actions being recorded in the table.

'spirit of sharing', Ken