[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 Created: 2014-03-26  Updated: 2016-11-25  Resolved: 2016-11-25

Status: Closed
Project: MariaDB Server
Component/s: Platform Debian
Affects Version/s: 5.5.36
Fix Version/s: 10.2.3

Type: Bug Priority: Major
Reporter: Jean Weisbuch Assignee: Otto Kekäläinen
Resolution: Fixed Votes: 1
Labels: debian, init, mysqld_safe
Environment:

Debian Wheezy


Issue Links:
PartOf
is part of MDEV-6284 Merge downstream Debian/Ubuntu packag... Closed
Relates
relates to MDEV-6762 Init script is too silent in case of ... Closed

 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'



 Comments   
Comment by Otto Kekäläinen [ 2014-03-28 ]

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/

Comment by Mikhael Anisimov [ 2015-05-19 ]

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.

Comment by Andrii Nikitin (Inactive) [ 2016-11-03 ]

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'

Comment by Otto Kekäläinen [ 2016-11-25 ]

This was fixed for 10.2 in https://github.com/MariaDB/server/commit/73f1c655

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