0

I've recently switched from MySQL do MariaDB to host WP website. Everything was smooth and I even noticed speed increase (which might be just placebo ;). From then on though MariaDB started dying regularly every about week - two.

When I go back to the server this is what I have:

user@myserver:~# service mysql status
MariaDB is stopped.

But when I go to logs they're empty. I have no idea how to debug it. Any hint how to track how and why MariaDB dies would help me heaps!

1

Maybe your server goes low on memory and the OOM-killer kills the MariaDB process.

To check if it the OOM-killer, do the following:

  • grep -i oom /var/log/messages and grep -i oom /var/log/syslog
  • dmesg | grep -o oom after detecting that MariaDB crashed/was stopped.

If grep find something, chances are the OOM-killer is killing your database process.

UPDATE: as from Ralf investigation, it seems that the offending process is /usr/lib/php/sessionclean. See the bug report here

  • Thanks - that was my original thought but didn't know how to test it. None of the above lines return anything but I'll wait until it dies again and see if the second one gives me something. If that's the case - is there a way to automatically restart DB? – Ralf Apr 22 '16 at 1:44
  • Sorry my bad! I was checking the wrong server! Indeed I got a lot of results on the second command: user@myserver:~# dmesg | grep -o oom oom oom oom ..... What does this mean and how to prevent it? There's 3GB memory on VPS which I presume for one website is enough? – Ralf Apr 22 '16 at 1:48
  • The OOM messages means that the system have run out of free memory and, in order to avoid crashing, it killed some processes - one of them being your MariaDB instance. There are no quick and simple solutions. Instead, you had to check what process is eating memory and evaluate if it really need so much memory. If so, you had to expand your system's RAM. Can you post the output of top -o RES ? – shodanshok Apr 24 '16 at 16:28
0

Thanks to @shodanshok I found the issue. Tracking down /var/log/syslog around the crash I found regularly this before the crash:

Apr 30 22:09:01 servername CRON[3818]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean)
Apr 30 22:09:01 servername CRON[3819]: (root) CMD (  [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)

Turns out that it's a known issue that session cleaning cron is taking a lot of resources and that kills MySQL / MariaDB. More information here: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1356113

  • If my answer was helpful, consider flagging it as the accepted answer ;) – shodanshok Apr 30 '16 at 22:18
  • Sure :) If you could steal the bug link and update your answer so it's easy to find for everyone :) – Ralf May 1 '16 at 23:00
  • Ok, I updated the answer ;) – shodanshok May 2 '16 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.