Database connection failed

Re: Database connection failed

by Rick Jerz -
Number of replies: 1
Picture of Particularly helpful Moodlers Picture of Testers

I have been having this problem too, but I have to tell you that it is really a weird problem.  

My problem is that precisely every 31 days, early morning between 3AM to 5AM, my Moodle goes down with exactly the same message.  This began when I did a fresh install of Moodle 3.0 on my VPS.  Yes, exactly 31 days (as if there is a cron job running with a /31 parameter set.  No, not on the 14th of each month, it started on Jan 11 and has continued to this current month, on 7/15.  I have learned that if I count exactly 31 day from 7/15, this problem will occur again on 8/15, and I am willing to bet anyone any dollar (US) amount that it will.

I have checked my moodle cron setting, and nothing runs exactly (an only) 31 days.  Same for my server's cron, nothing that I can detect.  I wonder if the computer that my VPS is on has something running every 31 days - so far they say no.

Here are some odd facts:

1) This only started after my clean install of Moodle in Dec 2015.  I have been running this particular VPS for 1 1/2 years with no problem until I installed my new Moodle.  This suggests that the problem has something to do with Moodle 3.0.  (I had be running Moodle 2.9 with no problem.)

2) A "graceful server reboot" of my server (from the WHM control panel) does not fix this problem!

3) A manual stop/start of the mysql database does not solve the problem!

4) My mysql error log file show nothing.

5) When the problem presents itself, I have run a "mysqladmin status" command, and it shows the database working!  This suggests that the problem might not have anything to do with the mysql database, even though this is what Moodle is reporting.

6) I fix this problem by going to my VPS's admin tools, and doing a "Restart mysql server" request.  Right after this, moodle works.

7) I have not tried doing a "Forceful Server Reboot" yet, but my guess is that this should also fix the problem.

Since I haven't changed anything on my server and have changed my Moodle (i.e., installed Moodle 3.0 from scratch) this suggests that it is some problem with Moodle.  However, when the problem occurs, I have tried running my earlier versions of moodle that are installed on the same VPS, and they too present the same error.  So this suggests that it may not be moodle.  The exactly 31 days issue suggests that it must be something on my VPS or the computer that houses my VPS.  But as I have explored my log files, I cannot detect any problem.  That the mysqladmin status show the mysql server running and that a mysql stop/start doesn't fix the problem suggests that it might not be a mysql problem, but some other problem.  Why every 31 days?

Well, I have shared at least one solution with you.

If anyone has additional thought about this, I am open to suggestions.  I am going to attach my VPS's mysql restart script, just in case someone can see something else that this restart script is doing.

I may try reposting my problem in the Hardware and Performance forum, but your post made me post here.

In reply to Rick Jerz

Why Docker ?

by john attwood -

Aside from the fact that it uses less host resources why would you want to run Moodle in Docker ?

I've attempted this but when I couldn't easily edit files inside Docker I quickly abandoned it and went back to a VM

But I'm admitting  I might be missing something here ?

I don't want to have to recreate a Docker container every time I have to edit a file...ie  php.ini. 

Additionally for me creating a VMs using VMWare or Virtualbox is much easier. It has a nice user interface even in Linux much easier.

Can someone please explain the benefits of using Docker with Moodle ? 


Thank you,

John