[MDEV-5713] RFE: Add support for systemd notify feature Created: 2014-02-21  Updated: 2015-10-15  Resolved: 2015-10-15

Status: Closed
Project: MariaDB Server
Component/s: Packaging
Fix Version/s: 10.1.8

Type: Task Priority: Major
Reporter: Honza Horak Assignee: Sergey Vojtovich
Resolution: Fixed Votes: 2
Labels: systemd

Attachments: File mysql-notify.patch    
Issue Links:
Relates
relates to MDEV-427 Provide a systemd script for MariaDB Closed
relates to MDEV-4606 cmake build to be able to choose sysv... Closed
relates to MDEV-5679 MariaDB holds stdin open after startu... Closed
relates to MDEV-5536 Support systemd socket activation Closed
relates to MDEV-6347 Build RHEL7 packages Closed
Sprint: 10.1.7-1, 10.1.7-2, 10.1.8-1, 10.1.8-3, 10.1.8-4

 Description   

Originally reported as http://bugs.mysql.com/bug.php?id=65809

Since systemd tries to start services parallel, it's not easy to ensure that mysql daemon is started before another service, which requires it. Currently, we have to use an arbitrary script, that checks if the daemon is ready.

However, systemd has a feature to notify daemon about a service status, which would help in this scenario a lot and packagers wouldn't need any additional scripts to test daemon status. MySQL daemon can simple send a message to systemd daemon, that startup actions have been done successfully and we are ready to accept connections.

Using this feature is really straightforward and doesn't make any issues if a user uses alternative init system. To be concrete, only one function call and some configuration checking is needed.

Please, consider adopting the following patch attached.



 Comments   
Comment by Sergei Golubchik [ 2014-02-21 ]

hhorak, see also MDEV-5679. Would that help if mysqld would daemonize itself when it's ready to accept connections?

Comment by Honza Horak [ 2014-02-21 ]

Well, simply said from my POV, it would mean a lot of work more needed to be done.

IIUIC, it might help if we either:

1) stopped using mysqld_safe and ran mysqld directly in the systemd unit file (then using "type=forking" systemd would wait until the first process exists, which would be at a time the forked process would be already prepared; however, we'd lose some functionality in mysqld_safe)

2) added the notification mechanism into mysqld_safe, so mysqld_safe would send message as soon as the mysqld's first process finishes. Then we'd have to add a logic for monitoring the forked process, which is actually what systemd does, so we would basically duplicate the effort.

3) changed "eval" call to "exec" call in mysqld_safe, so we could use the parameter parsing done by mysqld_safe, but monitoring itself would be done by systemd.

Getting rid of mysqld_safe monitoring (options 1 and 3) would mean that we'd have to use restarting mechanism from systemd to recover after daemon failure, which is not so easy now – we simply cannot distinguish easily between daemon failure and desired stop (systemd decides based on exit codes, which would mean changing the exit codes and use them properly on many places).

Comment by Brian Evans [ 2014-10-13 ]

Suggest a cmake option be added (default on if you want), so that this can be decided at build time.
This helps Gentoo Linux keep the server going if a user decides to switch between init systems.

Comment by Daniel Black [ 2014-12-27 ]

As requested by grknight added a WITH_SYSTEMD option here.

Added packages deps to the debian/ubuntu.

Added bits to the support-files/mysql.spec for systemd however its not packaged until openSUSE_13 and RHEL7 (MDEV-6347).

Comment by Daniel Black [ 2015-01-02 ]

patchwork continuing on MDEV-5536

Comment by Daniel Black [ 2015-01-02 ]

needed:

locations in the code for global server status and presenting notification to users
http://0pointer.de/public/systemd-man/sd_notify.html
e.g.
galera could us RELOADING=1 when it goes to donor/accept and back to READY=1 when finished

some STATUS= messages when in innodb recovery.

Any other cases?

Comment by Daniel Black [ 2015-03-11 ]

https://github.com/MariaDB/server/pull/26

Generated at Thu Feb 08 07:06:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.