MySQL crashing regularly - Insights needed

Hi,

I been having an issue with mysql server going down regularly (once a week). In my Webmin, I’ve been seeing virtual fluctuate memory 85%-100%. I am still new virtualmin, but I did search the forum to find some answers, but not quite there for a solution.

free -m
              total        used        free      shared  buff/cache   available
Mem:           1993         493         392         164        1108        1187
Swap:           270         231          39

Also, I got an OOM, but for clamscan? Could this affect MySQL server?

dmesg | tail -10
[115152.924211] [22609]  1012 22609   197659   154849  1511424     1494             0 clamscan
[115152.924212] [22623]  1011 22623     4255      105    77824        0             0 clam-wrapper.pl
[115152.924213] [22624]  1011 22624     1157       17    57344        0             0 sh
[115152.924214] [22625]  1011 22625   197723   154405  1507328     2021             0 clamscan
[115152.924215] [22664]  1000 22664   125630     6618   610304        0             0 php-cgi7.2
[115152.924216] [22675]  1000 22675   106059     5874   565248        0             0 php-cgi7.2
[115152.924217] [22691]     0 22691     4630       44    77824       41             0 dovecot
[115152.924218] Out of memory: Kill process 22625 (clamscan) score 270 or sacrifice child
[115152.927690] Killed process 22625 (clamscan) total-vm:790892kB, anon-rss:617468kB, file-rss:152kB, shmem-rss:0kB
[115153.009805] oom_reaper: reaped process 22625 (clamscan), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

I had a good look at this: https://www.virtualmin.com/documentation/system/low-memory, my server is mostly configured for low memory. The only changes I made was:

  1. set max_allowed_packet = 1M (mine was 16M) for mysqd.cnf

  2. disable ProFTPD FTP Server since I dont’ use it.

  3. What could be causing my mysql outages?

  4. I am not sure how to set up more virtual memory here via virtualmin, i did browse here, but probably need a noobs guide!

  5. What else should I be checking that could be related to mysql server issues?

  6. Are there any optimisations for mysql that can be run that may help?

Thank you. Love virtualmin, its a great system.
stay safe

I noticed that when I installed updates this error message appears:

The mysql.session needs SELECT privileges in the performance_schema database and the mysql.db table and also SUPER privileges.mysql_upgrade failed with exit status 5

I am not sure if this is the issue (I had to reboot mysqlserver this morning). The potential solution is here:https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1726656.

UPDATE mysql.user SET Super_priv ='Y' WHERE USER= 'mysql.session';
GRANT SELECT on performance_schema.* to 'mysql.session'@'localhost';
flush privileges;

I ran some additional virtualmin updates and they seemed to go without a hitch. This doesn’t mean that this is the solution, but it looks like its something that needed to be fixed.