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

MariaDB holds stdin open after startup as mysqld

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 5.5.35, 10.0.8
    • 10.0.16
    • OTHER
    • None
    • Gentoo Linux

    Description

      In reference to Gentoo Bug 461226,

      MariaDB holds open stdin after being started like this example:

      start-stop-daemon --background --exec /usr/sbin/mysqld -- --defaults-file=/etc/mysql/my.cnf

      Posting the issue here as suggested by serg on IRC

      Attachments

        Issue Links

          Activity

            grknight Brian Evans created issue -
            grknight Brian Evans made changes -
            Field Original Value New Value
            serg Sergei Golubchik made changes -
            Description In reference to Gentoo Bug 461226,

            MariaDB holds open stdin after being started like this example:

            start-stop-daemon --background --exec /usr/sbin/mysqld -- --defaults-file=/etc/mysql/my.cnf

            Posting the issue here as suggested by serg on IRC
            In reference to Gentoo Bug 461226,

            MariaDB holds open stdin after being started like this example:
            {noformat}
            start-stop-daemon --background --exec /usr/sbin/mysqld -- --defaults-file=/etc/mysql/my.cnf
            {noformat}
            Posting the issue here as suggested by serg on IRC

            My suggestion was to implement a very old and popular request and let mysqld to daemonize itself. Additionally, if it'll do that only after it is ready to accept new connections it will also remove the need for hacks like Fedora's mysql-wait-ready script that runs mysqladmin ping in a loop to detect when a server is finally ready to serve (meaning, systemd can start services that depend on mysqld).

            serg Sergei Golubchik added a comment - My suggestion was to implement a very old and popular request and let mysqld to daemonize itself. Additionally, if it'll do that only after it is ready to accept new connections it will also remove the need for hacks like Fedora's mysql-wait-ready script that runs mysqladmin ping in a loop to detect when a server is finally ready to serve (meaning, systemd can start services that depend on mysqld).
            serg Sergei Golubchik made changes -
            Fix Version/s 5.5.37 [ 15000 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.10 [ 14500 ]
            serg Sergei Golubchik made changes -
            Assignee Sergei Golubchik [ serg ]
            serg Sergei Golubchik made changes -
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.11 [ 15200 ]
            Fix Version/s 10.0.10 [ 14500 ]

            There's one difficulty with daemonizing — if mysqld will simply fork and exit when it's ready to accept connections, it will change the pid of the mysqld daemon process. And by that time the pid is already written into the pidfile. Creating the pidfile later is not a good idea, currently it's created as soon as the signal handler is installed, that is, as soon as mysqld can process signals sent to this pid. Rewriting pidfile to put a new pid in it could work, but I don't know what it might possibly break. A safe solution might be to fork early but make the parent process wait until the child is ready to accept connections.

            serg Sergei Golubchik added a comment - There's one difficulty with daemonizing — if mysqld will simply fork and exit when it's ready to accept connections, it will change the pid of the mysqld daemon process. And by that time the pid is already written into the pidfile. Creating the pidfile later is not a good idea, currently it's created as soon as the signal handler is installed, that is, as soon as mysqld can process signals sent to this pid. Rewriting pidfile to put a new pid in it could work, but I don't know what it might possibly break. A safe solution might be to fork early but make the parent process wait until the child is ready to accept connections.
            serg Sergei Golubchik made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 5.5.38 [ 15400 ]
            Fix Version/s 5.5.37 [ 15000 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.12 [ 15201 ]
            Fix Version/s 5.5.39 [ 15800 ]
            Fix Version/s 10.0.11 [ 15200 ]
            Fix Version/s 5.5.38 [ 15400 ]
            serg Sergei Golubchik made changes -
            Workflow defaullt [ 34723 ] MariaDB v2 [ 42765 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.13 [ 16000 ]
            Fix Version/s 10.0.12 [ 15201 ]
            serg Sergei Golubchik made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Status In Progress [ 3 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1 [ 16100 ]
            Fix Version/s 5.5 [ 15800 ]
            Fix Version/s 10.0 [ 16000 ]

            postponed, looks like nobody needs this feature.
            working patch is attached.

            serg Sergei Golubchik added a comment - postponed, looks like nobody needs this feature. working patch is attached.
            serg Sergei Golubchik made changes -
            Attachment daemonize.diff [ 34601 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.1 [ 16100 ]
            danblack Daniel Black added a comment -

            With systemd coming along and it generally works better without daemonizing as it relying on sigchild is heaps more repliable than fiddling with pid files, this bug can be fixed by doing the minimal approach and just close the stdin after the checking we aren't doing a bootstrap.

            danblack Daniel Black added a comment - With systemd coming along and it generally works better without daemonizing as it relying on sigchild is heaps more repliable than fiddling with pid files, this bug can be fixed by doing the minimal approach and just close the stdin after the checking we aren't doing a bootstrap.
            danblack Daniel Black made changes -
            Attachment close-stdin.patch [ 36620 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0 [ 16000 ]
            serg Sergei Golubchik made changes -
            Status Stalled [ 10000 ] In Progress [ 3 ]
            serg Sergei Golubchik made changes -
            Fix Version/s 10.0.16 [ 17900 ]
            Fix Version/s 10.0 [ 16000 ]
            serg Sergei Golubchik made changes -
            Component/s OTHER [ 10125 ]
            Resolution Fixed [ 1 ]
            Status In Progress [ 3 ] Closed [ 6 ]
            ratzpo Rasmus Johansson (Inactive) made changes -
            Workflow MariaDB v2 [ 42765 ] MariaDB v3 [ 65153 ]

            I just got a query from ALTLinux maintainers. They're interested in "daemonize" option, the reasons are:

            • compatibility with MySQL 5.7 (it has this option too)
            • most server binaries (e.g. sshd) have ability to daemonize
            • simplified SysV scripts
            • no need for extra overcomplicated wrappers (like mysqld_safe)
            svoj Sergey Vojtovich added a comment - I just got a query from ALTLinux maintainers. They're interested in "daemonize" option, the reasons are: compatibility with MySQL 5.7 (it has this option too) most server binaries (e.g. sshd) have ability to daemonize simplified SysV scripts no need for extra overcomplicated wrappers (like mysqld_safe)
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 65153 ] MariaDB v4 [ 147510 ]

            People

              serg Sergei Golubchik
              grknight Brian Evans
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.