WIP: MDEV-26850: Never delete my.cnf, always use update-alternatives instead
In Debian the file /etc/my.cnf is supposed to point to mariadb.cnf. This symlink is created and maintained by update-alternatives as run from mysql-common (the real Debian package) or a tweaked version of mariadb-common from mariadb.org repositories.
Do not just bluntly replace it with a link during upgrades.
This fixes a regression introduced in 07d1c8567cbfe which lacks a commit message explaining why this file was added in the first place.
@ottok Thanks for working on this!
I know this is a WIP so I'm adding comments to make sure we don't forget. I believe this sort of use case requires an Upgrade test in buildbot, correct? There is a plan to have upgrade tests present in the Server repo instead of having them present in buildbot config.
When you are done with this PR, can you also briefly describe how to test this so I can make sure it gets put created as an upgrade test?
@ottok this looks good.
Tested with:
podman run -it -v /tmp/build/:/build debian:10 bash -c "apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y software-properties-common dirmngr apt-transport-https \
&& apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' \
&& add-apt-repository 'deb https://mirror.mva-n.net/mariadb/repo/10.3/debian buster main' \
&& apt-get update && apt-get install -y mariadb-server \
&& echo '#user modification' >> /etc/mysql/my.cnf \
&& apt-get -y install apt-utils \
&& cd /build && apt-ftparchive packages .>Packages \
&& echo 'deb [trusted=yes] file:/build ./' >>/etc/apt/sources.list \
&& apt-get update && apt-get upgrade -y \
&& cat /etc/mysql/my.cnf \
&& ls -l /etc/mysql/"
Where /tmp/build contains deb packages build from your branch (on a Debian Buster container).
As expected the user gets a warning when upgrading:
Preparing to unpack .../mysql-common_10.5.13+maria~buster_all.deb ...
Unpacking mysql-common (1:10.5.13+maria~buster) over (1:10.3.31+maria~buster) ...
Preparing to unpack .../mariadb-common_10.5.13+maria~buster_all.deb ...
Unpacking mariadb-common (1:10.5.13+maria~buster) over (1:10.3.31+maria~buster) ...
Preparing to unpack .../libmariadb3_10.5.13+maria~buster_amd64.deb ...
Unpacking libmariadb3:amd64 (1:10.5.13+maria~buster) over (1:10.3.31+maria~buster) ...
Setting up mysql-common (1:10.5.13+maria~buster) ...
Setting up mariadb-common (1:10.5.13+maria~buster) ...
Installing new version of config file /etc/mysql/mariadb.cnf ...
Notice: configure-symlinks trigger could not be called.
Please manually create symlinks by running:
mv -f /etc/mysql/my.cnf /etc/mysql/my.cnf.old
ln -sf mariadb.cnf /etc/mysql/my.cnf
update-alternatives: error: no alternatives for my.cnf
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
And /etc/mysql/my.cnf is not touched:
cat /etc/mysql/my.cnf
...
!includedir /etc/mysql/conf.d/
#user modification
...
ls -l /etc/mysql/
total 28
drwxr-xr-x 2 root root 4096 Nov 5 16:23 conf.d
-rwxr-xr-x 1 root root 1525 Aug 2 10:58 debian-start
-rw------- 1 root root 333 Nov 5 16:23 debian.cnf
-rw-r--r-- 1 root root 1126 Nov 5 11:31 mariadb.cnf
drwxr-xr-x 2 root root 4096 Aug 2 12:33 mariadb.conf.d
-rw-r--r-- 1 root root 5184 Nov 5 16:23 my.cnf
When you are done with this PR, can you also briefly describe how to test this so I can make sure it gets put created as an upgrade test?
I believe that this could be a good source of inspiration for BB upgrade tests: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L19-21
and corresponding stage: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L231-330
"/etc/my.cnf" meaning "/etc/mariadb/my.cnf"? So what happens when there is no user modification to /etc/mysql/my.cnf"?
Sorry, I didn't have time to finalize this yet. It is not the final form yet, as the installation of the initial symlink fails with:
update-alternatives --install /etc/mysql/my.cnf my.cnf "/etc/mysql/mariadb.cnf" 500
update-alternatives: warning: forcing reinstallation of alternative /etc/mysql/mariadb.cnf because link group my.cnf is broken
update-alternatives: warning: not replacing /etc/mysql/my.cnf with a link
I need to fix this so that it mysql-common+mariadb-common in mariadb.org repos work in the same way and as reliable as those packages in official Debian and Ubuntu repos (source: https://salsa.debian.org/mariadb-team/mysql/-/tree/mysql-defaults/debian/master/debian).
ready?
Unfortunately, no, I have not had time to finalize this. We might have to drop the mysql-common pacakge form upstream repositories to align it with Debian and make the upgrade testing etc more manageable.
@ottok is this PR still relevant, are you expecting anything from MariaDB developers?
Unfortunately I have not had time to test this, nor to contribute upstream better upgrade testing. Issue is still unresolved and bug and PR should stay open.
When you are done with this PR, can you also briefly describe how to test this so I can make sure it gets put created as an upgrade test?
I believe that this could be a good source of inspiration for BB upgrade tests: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L19-21
and corresponding stage: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L231-330
Where exactly in https://github.com/MariaDB/buildbot is the source code of the BB upgrade tests? How does one start out with a job/test name and locate the relevant file in that repository? Where should I check if upstream BB does this or similar testing now 3 years later since suggestion surfaced?
@cvicentiu ^
When you are done with this PR, can you also briefly describe how to test this so I can make sure it gets put created as an upgrade test?
I believe that this could be a good source of inspiration for BB upgrade tests: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L19-21 and corresponding stage: https://salsa.debian.org/mariadb-team/mariadb-10.5/-/blob/master/debian/salsa-ci.yml#L231-330
Where exactly in https://github.com/MariaDB/buildbot is the source code of the BB upgrade tests?
https://github.com/MariaDB/buildbot/blob/dev/scripts/deb-upgrade.sh
How does one start out with a job/test name and locate the relevant file in that repository?
Probably just search in github in the repo for distinct names of things used in the steps of the build.
https://github.com/MariaDB/buildbot/blob/42cca764c55353870ed59f1e246cf4bfc412931c/master-libvirt/master.cfg#L88
Where should I check if upstream BB does this or similar testing now
MariaDB/buildbot is just configuration.
3 years later since suggestion surfaced?
since we're past the 3 year mark :-)