Skip to content

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

Draft
ottok wants to merge 1 commit into
MariaDB:10.5from
ottok:ok-10.5-MDEV-26850
Draft

WIP: MDEV-26850: Never delete my.cnf, always use update-alternatives instead#1944
ottok wants to merge 1 commit into
MariaDB:10.5from
ottok:ok-10.5-MDEV-26850

Conversation

@ottok

@ottok ottok commented Nov 5, 2021

Copy link
Copy Markdown
Contributor

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

cvicentiu commented Nov 5, 2021

Copy link
Copy Markdown
Contributor

@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

fauust commented Nov 5, 2021

Copy link
Copy Markdown
Contributor

@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

fauust commented Nov 5, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@ottok

ottok commented Nov 8, 2021

Copy link
Copy Markdown
Contributor Author

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.
@ottok
ottok force-pushed the ok-10.5-MDEV-26850 branch from 499d3de to ad47353 Compare May 5, 2022 05:17
@grooverdan

Copy link
Copy Markdown
Member

ready?

@ottok

ottok commented Feb 8, 2024

Copy link
Copy Markdown
Contributor Author

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.

@cvicentiu cvicentiu added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Nov 26, 2024
@svoj

svoj commented Apr 21, 2025

Copy link
Copy Markdown
Contributor

@ottok is this PR still relevant, are you expecting anything from MariaDB developers?

@ottok

ottok commented Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

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.

@ottok

ottok commented Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

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?

@svoj

svoj commented Apr 21, 2025

Copy link
Copy Markdown
Contributor

@cvicentiu ^

@grooverdan

Copy link
Copy Markdown
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

6 participants