MariaDb going down every night because of package updates

SYSTEM INFORMATION
OS type and version Debian 11
Webmin version 2.202

Last 2 nights MariaDB has shut down and hasn’t come back up during the nightly /etc/webmin/package-updates/update.pl and I see these entries in the log, as if its trying to install mariadb but its already installed.

Sep 18 03:43:15 yourrentl mariadb-server-10.5.postinst[882136]: mysql.user table already exists!
Sep 18 03:43:15 yourrentl mariadb-server-10.5.postinst[882136]: Run mysql_upgrade, not mysql_install_db

Sounds like your running out of ram so the oom killer is dropping mariadb. The general concensus is to work out why your memory is being used rather than just restarting mariadb as it appearscafter 2 restarts of mariadb after an oom failure can corrupt you database. Using wordpress by any chance ?

I held off upgrading but pulled the trigger because it was a security update. I’ll know tomorrow.

Not sure where you’re getting that its a memory issue? There are no memory issues. Nor can I see how a memory issue would cause the /etc/webmin/package-updates/update.pl cron job to run mysql_install_db instead of mysql_upgrade (if that’s needed - the package list says its all up to date)
The cron job starts, it tells mariadb to shut down, which it does as instructed, then its running mysql_install_db which can’t run because its already installed and that’s it.

I set it to inform rather than install security updates and it didn’t turn it off last night

Mission critical = notify security only and then manually install updates.

I tend to do updates in batches i.e. all the php ones and make sure there are no issues before doing another batch.

If there is a mariadb or mysql update I would backup everything before I did those.

Looks like my upgrade didn’t run into this problem. I’m on Debian 11.

root@main:~# service mariadb status
● mariadb.service - MariaDB 10.5.26 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2024-09-19 08:55:01 EDT; 23h ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 3211237 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 11 (limit: 125608)
     Memory: 119.0M
        CPU: 1min 2.183s
     CGroup: /system.slice/mariadb.service
             └─3211237 /usr/sbin/mariadbd

Further down I see:

Sep 19 08:55:01 main.cisnetadmin.com /etc/mysql/debian-start[3211270]: Upgrading MySQL tables if necessary.

I wonder if your upgrade failed somehow. The whole thing about it not seeing the db as already existent is disturbing. Dump a current backup and force a reinstall?

My history. Provider only had a Debian 10 image. I installed that and immediately updated to 11 so my system doesn’t have much of a history. Maybe some little wrinkle across time?

EDIT: Doesn’t apt have some sort of mechanism for fixing the installed package database?