[MDEV-19432] Systemd service does not get re-enabled after upgrade Created: 2019-05-09  Updated: 2020-03-07  Resolved: 2019-10-30

Status: Closed
Project: MariaDB Server
Component/s: Platform RedHat
Affects Version/s: 10.2.24, 10.1.39
Fix Version/s: 10.2.28, 10.1.42, 10.3.19, 10.4.9

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Sergei Golubchik
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
causes MDEV-21793 The mariadb.service unit not enabled ... Confirmed

 Description   

Starting from 10.1.39, pre-uninstall scriplet disables mariadb service. But if later the server is reinstalled/upgraded, the post-install service doesn't always enable the service, so it stays disabled.

As a side-effect, mysql alias of the service doesn't work after upgrade, and mysqld alias is not even recognized:

[buildbot@centos73-amd64 ~]$ systemctl status mysql --no-pager
● mysql.service - LSB: start and stop MariaDB
   Loaded: loaded (/etc/rc.d/init.d/mysql; bad; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)
[buildbot@centos73-amd64 ~]$ systemctl status mysqld --no-pager
Unit mysqld.service could not be found.
 
[buildbot@centos73-amd64 ~]$ sudo systemctl enable mariadb 
Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[buildbot@centos73-amd64 ~]$ systemctl status mysqld --no-pager
● mariadb.service - MariaDB 10.3.15 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf, tokudb.conf
   Active: active (running) since Thu 2019-05-09 21:59:30 UTC; 1h 27min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 3027 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─3027 /usr/sbin/mysqld
 
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] mysqld: Server GSSAPI error (major 85...mpty.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] Plugin 'gssapi' init function returned error.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Server socket created on IP: '::'.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] Incorrect definition of table mysql.e...'POST
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] mysqld: Event Scheduler: An error occ...uler.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Reading of all Master_info entries succeded
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Added new Master_info '' to hash table
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] /usr/sbin/mysqld: ready for connections.
May 09 21:59:30 centos73-amd64 mysqld[3027]: Version: '10.3.15-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  po...erver
May 09 21:59:30 centos73-amd64 systemd[1]: Started MariaDB 10.3.15 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[buildbot@centos73-amd64 ~]$ 
[buildbot@centos73-amd64 ~]$ systemctl status mysql --no-pager
● mariadb.service - MariaDB 10.3.15 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf, tokudb.conf
   Active: active (running) since Thu 2019-05-09 21:59:30 UTC; 1h 29min ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 3027 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─3027 /usr/sbin/mysqld
 
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] mysqld: Server GSSAPI error (major 85...mpty.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] Plugin 'gssapi' init function returned error.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Server socket created on IP: '::'.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] Incorrect definition of table mysql.e...'POST
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [ERROR] mysqld: Event Scheduler: An error occ...uler.
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Reading of all Master_info entries succeded
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] Added new Master_info '' to hash table
May 09 21:59:30 centos73-amd64 mysqld[3027]: 2019-05-09 21:59:30 0 [Note] /usr/sbin/mysqld: ready for connections.
May 09 21:59:30 centos73-amd64 mysqld[3027]: Version: '10.3.15-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  po...erver
May 09 21:59:30 centos73-amd64 systemd[1]: Started MariaDB 10.3.15 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Important note: In order to avoid failures with mysql alias, we will explicitly re-enable the service before using the alias in RPM upgrade tests. It needs to be re-visited after the problem is fixed one or another way.



 Comments   
Comment by Sergei Golubchik [ 2019-05-10 ]

Fedora recommends to use special macros to deal with systemd: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/

I doubt we can use them, as we build not only on Fedora. But that's what these macros do on FC29:

/usr/lib/rpm/macros.d/macros.systemd

%systemd_post() \
if [ $1 -eq 1 ] ; then \
        # Initial installation \
        systemctl --no-reload preset %{?*} &>/dev/null || : \
fi \
%{nil}
 
%systemd_preun() \
if [ $1 -eq 0 ] ; then \
        # Package removal, not upgrade \
        systemctl --no-reload disable --now %{?*} &>/dev/null || : \
fi \
%{nil}
 
%systemd_postun() %{nil}
 
%systemd_postun_with_restart() \
if [ $1 -ge 1 ] ; then \
        # Package upgrade, not uninstall \
        systemctl try-restart %{?*} &>/dev/null || : \
fi \
%{nil}

Note that pre-uninstall indeed disables the service. But post-install does preset which enables it again.
I'm leaning towards doing the same, trusting Fedora on this.

Any thoughts? axel? danblack?

Generated at Thu Feb 08 08:51:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.