The Memory of Maria

A problem on one of my VPS haunted me for weeks: occasionally, almost once a day, the database (MariaDB, default drop-in for MySQL on Debian) stopped to accept connections and the only way to fix was to manually kill and restart it.

A bit more of investigation resulted in a "Out of Memory" error by MariaDB. So I concluded that sometime too much requests (a spam bot? A bruteforce on one of the many Wordpress hosted instances?) blocked all the resources on the server, causing a RAM saturation, but was not the case.

At the end of the day, I found that MariaDB 10.3 (installed automatically by an unattended upgrade in Debian from version 10.1) has some known issue with memory allocation, and someone managed to fix it changing the allocator library.

Most of the documentation and suggestions found online was about CentOS, so I digged a bit more and this is what I did on Debian:

apt-get install libtcmalloc-minimal4
systemctl edit mysql

Added line


And finally

service mysql restart

Now memory allocation from MariaDB seems stable, or at least doesn't growns as before.