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

MariaDB holds stdin open after startup as mysqld

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.5.35, 10.0.8
    • Fix Version/s: 10.0.16
    • Component/s: OTHER
    • Labels:
      None
    • Environment:
      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

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

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

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

              Show
              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.
              Hide
              serg Sergei Golubchik added a comment -

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

              Show
              serg Sergei Golubchik added a comment - postponed, looks like nobody needs this feature. working patch is attached.
              Hide
              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.

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

                People

                • Assignee:
                  serg Sergei Golubchik
                  Reporter:
                  grknight Brian Evans
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Time Tracking

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Remaining Estimate - 0 minutes
                    0m
                    Logged:
                    Time Spent - 1 hour, 20 minutes
                    1h 20m