#1108553 mariadb-server: Upgrading 1:11.8.1-4 to 1:11.8.2-1 generates warning and error, but appears to work

Package:
mariadb-server
Source:
mariadb-server
Description:
MariaDB database server binaries
Submitter:
Daniel Lewart
Date:
2025-11-27 05:01:03 UTC
Severity:
normal
Tags:
#1108553#5
Date:
2025-07-01 03:00:00 UTC
From:
To:
Dear Otto, et al,

Upgrading mariadb-server from version 1:11.8.1-4 to 1:11.8.2-1
generates a warning and an error, but appears to work:

$ sudo apt-get install mariadb-server
...
Setting up mariadb-server (1:11.8.2-1) ...
Warning: The unit file, source configuration file or drop-ins of mariadb.service changed on disk. Run 'systemctl daemon-reload' to reload units.

$ journalctl -p3 -t mariadb-server.postinst
... debian mariadb-server.postinst[nnnnn]: mysql.user table already exists!
... debian mariadb-server.postinst[nnnnn]: Run mariadb-upgrade, not mariadb-install-db

$ sudo mariadb-upgrade
This installation of MariaDB is already upgraded to 11.8.1-MariaDB.
There is no need to run mariadb-upgrade again for 11.8.2-MariaDB, because they're both 11.8.
You can use --force if you still want to run mariadb-upgrade

Relevant excerpt from mariadb-server.postinst:
   185	    # initiate databases. Output is not allowed by debconf :-(
   186	    # This will fail if we are upgrading an existing database; in this case
   187	    # mariadb-upgrade, called from the /etc/mysql/debian-start script, will
   188	    # handle things.
   189	    # Debian: beware of the bashisms...
   190	    # Debian: can safely run on upgrades with existing databases
   191	    # Workaround for Debian Bug #1022994: failure to create database when
   192	    # working with libpam-tmpdir (by setting TMPDIR to empty value).
   193	    set +e
   194	    TMPDIR='' bash /usr/bin/mariadb-install-db \
   195	      --rpm --cross-bootstrap \
   196	      --user=mysql --disable-log-bin \
   197	      --skip-test-db 2>&1 |
   198	      $ERR_LOGGER
   199	    set -e

Perhaps the journal errors could be addressed by the following?:
	if [ ! -f "$mysql_datadir/mysql/user.frm" ]; then
		<excerpt>
	fi

Also, why is "--rpm --cross-bootstrap" used?

Thank you!
Daniel Lewart
Urbana, Illinois

#1108553#10
Date:
2025-07-01 06:33:41 UTC
From:
To:
Hi!

Thanks for a detailed report!

The mariadb.service file for systemd/systemctl is inherited as-is from
upstream and it has a change in the most recent upstream release:
https://salsa.debian.org/mariadb-team/mariadb-server/-/blob/debian/latest/support-files/mariadb.service.in

Off the top of my head I don't know how systemd is designed to handle
service file updates, and if this warning is supposed to trigger every
single time any service file updates, and if packages are supposed to
do anything more than just trigger service reloads (like done via
https://salsa.debian.org/mariadb-team/mariadb-server/-/blob/debian/latest/debian/mariadb-server.triggers)
or if maintainer scripts are supposed to run systemctl reloads on
their own.

What comes to the 'mysql.user table already exists!' warning, there
are at least no changes in the maintainer script
https://salsa.debian.org/mariadb-team/mariadb-server/-/blob/debian/latest/debian/mariadb-server.postinst
in latest 1:11.8.2-1, nor for a long time before it either. The `--rpm
--cross-bootstrap` has existed for 10+ years since
https://salsa.debian.org/mariadb-team/mariadb-server/-/commit/8823defebeb9bd5c75e4398541a8cf295d5014db
and are correct, albeit confusingly named upstream parameters to tell
the script it is being called from a Linux packaging script.

The most recent functional change to this section is
https://salsa.debian.org/mariadb-team/mariadb-server/-/commit/cde8b8613e08ecb8d5f4a5de09d34418576d3040
by Sunil, but I don't see how it would cause the warnings you are
seeing.

Thus, I think that the mariadb-install-db section has probably emitted
that warning all the time. But you are correct to point out that it is
bad design to have warnings emitted to users about something users
should not worry about. The `mariadb-install-db` should run only if
the data directory is empty and no database exists, and otherwise
`mariadb-upgrade` should run to upgrade the existing database.

#1108553#15
Date:
2025-07-05 06:11:00 UTC
From:
To:
Dear Otto, et al,

Thank you for your comments!

Untested patch for the "mysql.user table already exists!" error is attached.

Regarding the "mariadb.service changed on disk" warning,
I think it should be handled by dh_installsystemd.
This part of the rules file seems correct, but I am no expert:
   212    # Define name used for service, and install mariadb.service
on Linux only
   213    override_dh_installsystemd:
   214    ifneq (,$(filter linux,$(DEB_HOST_ARCH_OS)))
   215        dh_installsystemd -pmariadb-server mariadb.service
   216    endif

Thank you!
Daniel Lewart
Urbana, Illinois

#1108553#26
Date:
2025-08-28 22:47:05 UTC
From:
To:
Hi Daniel!

You filed this https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1108553
and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1105029, both
with with detailed investigations and a patch for upstream code. Did
you open PR(s) upstream, did they accept your fix?

- Otto

#1108553#31
Date:
2025-11-27 04:59:34 UTC
From:
To:
Just checking how it went with these?

It would be great if you could contribute this fix directly to
upstream systemd files (see
https://github.com/MariaDB/server/tree/main/support-files).