Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: MDEV-26850: Never delete my.cnf, always use update-alternatives instead #1944

Draft
wants to merge 1 commit into
base: 10.5
Choose a base branch
from

Conversation

ottok
Copy link
Contributor

@ottok ottok commented Nov 5, 2021

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 07d1c85 which lacks a commit
message explaining why this file was added in the first place.

@an3l an3l added this to the 10.5 milestone Nov 5, 2021
@an3l an3l requested a review from fauust November 5, 2021 05:21
@cvicentiu
Copy link
Member

cvicentiu commented Nov 5, 2021

@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?

@cvicentiu cvicentiu self-requested a review November 5, 2021 07:43
@fauust
Copy link
Contributor

fauust commented Nov 5, 2021

@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

@fauust
Copy link
Contributor

fauust commented Nov 5, 2021

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

@grooverdan grooverdan self-requested a review November 5, 2021 23:51
@grooverdan
Copy link
Member

"/etc/my.cnf" meaning "/etc/mariadb/my.cnf"? So what happens when there is no user modification to /etc/mysql/my.cnf"?

@ottok
Copy link
Contributor Author

ottok commented Nov 8, 2021

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).

@grooverdan grooverdan marked this pull request as draft November 25, 2021 21:36
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 07d1c85 which lacks a commit
message explaining why this file was added in the first place.
@grooverdan
Copy link
Member

ready?

@ottok
Copy link
Contributor Author

ottok commented Feb 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants