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

mysqld_safe errors are lost when executed from the init script and additional arguments are not passed in case of a "restart" on Debian

Details

    Description

      When mysqld_safe is exeuted by the init script and fails with an error message sent on stderr, the message will neither be displayed nor logged :

      # mysqld_safe --malloc-lib=test1234
      140326 16:13:38 mysqld_safe --malloc-lib must be an absolute path or 'tcmalloc';  ignoring value 'test1234'

      # /etc/init.d/mysql start --malloc-lib=test1234                                                                                     
      Starting MariaDB database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

      There is no mention of the error throwed by mysqld_safe on the mysql error log or on the syslog, it fails and the only way to know why it failed is to manually launch mysqld_safe on foreground.

      Another issue, is that calling the init script with "restart" wont pass the additional arguments as it does when calling it with "start" (this issue exists on the Debian/Ubuntu packages init script but not on support-files/mysql.server) :

      # /etc/init.d/mysql restart --malloc-lib=test1234                                                                                   
      Stopping MariaDB database server: mysqld.
      Starting MariaDB database server: mysqld . ..
      Checking for corrupt, not cleanly closed and upgrade needing tables..

      (while it should fail)

      Here is a simple patch for both issues for the Debian/Ubuntu init script that will send the mysqld_safe stderr to syslog (but it will keep a logger process running, solving that on mysqld_safe itself if possible should be better) and keep the additional arguments when using the "restart" command (which is already working on the non-packaged init that pass the $other_args variable) :

      --- /etc/init.d/mysql	2014-03-26 16:30:29.786052516 +0100
      +++ /etc/init.d/mysql	2014-03-26 16:19:55.316198723 +0100
      @@ -106,7 +106,7 @@
       	    test -e /var/run/mysqld || install -m 755 -o mysql -g root -d /var/run/mysqld
       
       	    # Start MariaDB!
      -  	    /usr/bin/mysqld_safe "${@:2}" > /dev/null 2>&1 &
      +  	    /usr/bin/mysqld_safe "${@:2}" 2>&1 >/dev/null | $ERR_LOGGER &
       
       	    # 6s was reported in #352070 to be too few when using ndbcluster
       	    for i in $(seq 1 "${MYSQLD_STARTUP_TIMEOUT:-30}"); do
      @@ -161,7 +161,8 @@
       
         'restart')
       	set +e; $SELF stop; set -e
      -	$SELF start 
      +	shift
      +	$SELF start "${@}"
       	;;
       
         'reload'|'force-reload')

      After having applied the patch :

      # /etc/init.d/mysql restart --malloc-lib=test1234
      [ ok ] Stopping MariaDB database server: mysqld.
      [FAIL] Starting MariaDB database server: mysqld . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!

      And we can find this line on the syslog :

      Mar 26 17:18:48 server /etc/init.d/mysql[22154]: 145326 17:18:48 mysqld_safe --malloc-lib must be an absolute path or 'tcmalloc';  ignoring value 'test1234'

      Attachments

        Issue Links

          Activity

            Patch added to 5.5 branch of my packaging in https://github.com/ottok/mariadb-5.5/commit/2f78ab8bc31cbc10de22bea21fdf162076ddd14c

            Once builds are done (http://labs.seravo.fi/~otto/mariadb-repo/build.log) you can test the resulting binaries by installing from these repos:

            deb http://labs.seravo.fi/~otto/mariadb-repo/ wheezy-amd64/
            deb http://labs.seravo.fi/~otto/mariadb-repo/ wheezy-i386/

            otto Otto Kekäläinen added a comment - Patch added to 5.5 branch of my packaging in https://github.com/ottok/mariadb-5.5/commit/2f78ab8bc31cbc10de22bea21fdf162076ddd14c Once builds are done ( http://labs.seravo.fi/~otto/mariadb-repo/build.log ) you can test the resulting binaries by installing from these repos: deb http://labs.seravo.fi/~otto/mariadb-repo/ wheezy-amd64/ deb http://labs.seravo.fi/~otto/mariadb-repo/ wheezy-i386/
            Mikhael Mikhael Anisimov added a comment - - edited

            There is a problem running mysqld_safe together with logger. I am trying to run /etc/init.d/mysql from script, that also collects the output of init-script invocation. My script never finishes, probably, due to the non-closed pipe, left by logger.

            Steps to reproduce:

            1. create test.sh with the following content:

              #!/bin/bash
              ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i"
              /usr/bin/mysqld_safe 2>&1 >/dev/null | $ERR_LOGGER &
              echo OK

            1. stop mysql
            2. run the script, collecting the output using tee utility:

            # bash -x ./test.sh 2>&1 | tee test2.log
            + ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mysql -i'
            + echo OK
            OK
            + logger -p daemon.err -t /etc/init.d/mysql -i
            + /usr/bin/mysqld_safe
            .... (permanently waiting) .....

            Originally, without logger, collection of the output worked normally.

            Mikhael Mikhael Anisimov added a comment - - edited There is a problem running mysqld_safe together with logger . I am trying to run /etc/init.d/mysql from script, that also collects the output of init-script invocation. My script never finishes, probably, due to the non-closed pipe, left by logger. Steps to reproduce: create test.sh with the following content: #!/bin/bash ERR_LOGGER="logger -p daemon.err -t /etc/init.d/mysql -i" /usr/bin/mysqld_safe 2>&1 >/dev/null | $ERR_LOGGER & echo OK stop mysql run the script, collecting the output using tee utility: # bash -x ./test.sh 2>&1 | tee test2.log + ERR_LOGGER='logger -p daemon.err -t /etc/init.d/mysql -i' + echo OK OK + logger -p daemon.err -t /etc/init.d/mysql -i + /usr/bin/mysqld_safe .... (permanently waiting) ..... Originally, without logger, collection of the output worked normally.

            Fix confirmed in recent build of 10.2.3 http://buildbot.askmonty.org/buildbot/builders/kvm-deb-trusty-amd64/builds/3854
            revision c6713f651f5a50709273d14ce5732f7ef3409737 :

            (both 'start' and 'restart' now fail with corresponding message in syslog):

            $ tail /var/log/syslog | grep malloc
            Nov 3 13:16:16 u1 /etc/init.d/mysql[9369]: 161103 13:16:16 mysqld_safe --malloc-lib must be an absolute path or 'tcmalloc'; ignoring value 'test1234'

            anikitin Andrii Nikitin (Inactive) added a comment - Fix confirmed in recent build of 10.2.3 http://buildbot.askmonty.org/buildbot/builders/kvm-deb-trusty-amd64/builds/3854 revision c6713f651f5a50709273d14ce5732f7ef3409737 : (both 'start' and 'restart' now fail with corresponding message in syslog): $ tail /var/log/syslog | grep malloc Nov 3 13:16:16 u1 /etc/init.d/mysql [9369] : 161103 13:16:16 mysqld_safe --malloc-lib must be an absolute path or 'tcmalloc'; ignoring value 'test1234'
            otto Otto Kekäläinen added a comment - This was fixed for 10.2 in https://github.com/MariaDB/server/commit/73f1c655

            People

              otto Otto Kekäläinen
              jb-boin Jean Weisbuch
              Votes:
              1 Vote for this issue
              Watchers:
              6 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.