Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5713

RFE: Add support for systemd notify feature

Details

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

      Attachments

        Issue Links

          Activity

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

            serg Sergei Golubchik added a comment - hhorak , see also MDEV-5679 . Would that help if mysqld would daemonize itself when it's ready to accept connections?
            hhorak Honza Horak added a comment -

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

            hhorak Honza Horak added a comment - 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).
            grknight Brian Evans added a comment -

            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.

            grknight Brian Evans added a comment - 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.
            danblack Daniel Black added a comment -

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

            danblack Daniel Black added a comment - 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 ).
            danblack Daniel Black added a comment -

            patchwork continuing on MDEV-5536

            danblack Daniel Black added a comment - patchwork continuing on MDEV-5536
            danblack Daniel Black added a comment -

            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?

            danblack Daniel Black added a comment - 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?
            danblack Daniel Black added a comment - https://github.com/MariaDB/server/pull/26

            People

              svoj Sergey Vojtovich
              hhorak Honza Horak
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.