codership / mysql-wsrep

wsrep API patch for MySQL server
Other
65 stars 34 forks source link

mysqld_safe is broken #349

Open ayurchen opened 6 years ago

ayurchen commented 6 years ago

A user (Hancz, Steven steven.hancz@citi.com) reports:

Hi I noticed two bugs in the fie /usr/bin/mysqld_safe script.

This is from the latest version available for RHEL6

Starting up a node produces the following error message:

mysqld_safe --defaults-file=$CONFIG_FILE >/dev/null &
sed: -e expression #1, char 29: number option to `s' command may not be zero

From the mysqld_safe script the following lines produce the error:

305     optname=`echo "$arg" | sed -e 's/^\(--[^=]*\)=.*$/\1/'`
306     # replace "_" by "-" ; mysqld_safe must accept "_" like mysqld does.
307     optname_subst=`echo "$optname" | sed 's/_/-/g'`

Here is from debug mode:

+ optname_subst=gmcast.listen-addr=tcp://0.0.0.0:4567
++ echo gmcast.listen_addr=tcp://0.0.0.0:4567
++ sed
's/^gmcast.listen_addr=tcp://0.0.0.0:4567/gmcast.listen-addr=tcp://0.0.0.0:4567/'
sed: -e expression #1, char 29: number option to `s' command may not be zero

The problem is with the sed statement to replace _ with -. A better command would be to use tr like this in line 307

optname_subst=`echo "$optname" |  tr '_' '-'

The problem is the // in the string sed uses the / char as a separator. Also in the same file there is missing parameter in the comparison.

1084   if [ -n "$wsrep_restart" ]
1085   then
1086     if [ $wsrep_restart -le $max_wsrep_restarts ]
1087     then
+ '[' -n 1 ']'
+ '[' 1 -le ']'
/usr/bin/mysqld_safe: line 1086: [: 1: unary operator expected

The problem here is that the variable max_wsrep_restarts is not defined anywhere in the code.