Package: mysql-server-5.0
Version: 5.0.32-7etch1
Severity: normal
Tags: patch

*** Please type your report below this line ***

Hi,

Background
----------

I had reason to want to move the location of the binary logs and I
think this may have uncovered a small bug.

I was able to move the datadir, using /etc/mysql/my.cnf; everything
worked fine with that configuration.

Then I went on to move the binary logs.

The relevant defaults in /etc/mysql/my.cnf are
  log_bin          = /var/log/mysql/mysql-bin.log
  expire_logs_days = 10

I stopped mysql with
  # /etc/init.d/mysql stop
and changed the log_bin prefix to
  log_bin                 = /srv/mysql/log/mysql-bin
Then I rsynced the binlogs to that location
  # rsync -a /var/log/mysql/mysql-bin.* /srv/mysql/log/mysql-bin
I added a symbolic link at the locaton of the old binary log directory
  # cd /var/log; mv mysql mysql.d ; ln -s /srv/mysql/log ./msyql
  # /etc/init.d/mysql start
and tried to start mysql
  # /etc/init.d/mysql start
It started fine.

Then I removed the symlink. It should not be needed (right?) since
I've specified the log_bin location in the my.cnf.
  # /etc/init.d/mysql stop
  # rm /var/log/mysql
  # /etc/init.d/mysql start
It would not start.


Analysis
--------

I traced the problem to the call
  /usr/bin/mysqld_safe
in /etc/init.d/mysql, and in particular the parse_arguments() function
in mysqld_safe.

What is happening on my system is that mysqld_safe makes this call:
  parse_arguments `/usr/bin/my_print_defaults $defaults --loose-verbose mysqld 
server`
and then starts using that output to set up the invocation line for mysqld.
It tries to start mysqld, and does a 'mysqladmin ping' to confirm the db is
really going.

In my case, it fails to start the database because the call to mysqld is
lacking the --log_bin argument, and others.

Digging a bit further, I found that the parse_arguments function is dropping
the arguments it does not recognize, instead of passing them through to
mysqld. It is doing this because it tests whether or not to accumulate
unrecognized options with

  test -n "$pick=args"

For some reason, this test is failing and all the arguments that
parse_arguments does not explicitly recognize are being silently dropped.

I've attached a patch to that does the same test in a more robust way.
With this change, mysqld starts up correctly. Please consider applying
this patch.

Also attached are a couple of output files showing the execution trace
before and after the change. You can see before the change that there
are 21 arguments output by my_print_defaults but only 6 are handled.


As an aside, the for loop in the function appears to be a bashist
construct:
  for arg do
    case "$arg" in
    ...
    esac
  done
I'm not sure if it can be changed without losing the ability to process
more than 10 arguments (in my case the arg list is 21 items).

Cheers
Vince


-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-5-686
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)

Versions of packages mysql-server-5.0 depends on:
ii  adduser                3.102             Add and remove users and groups
ii  debconf [debconf-2.0]  1.5.11            Debian configuration management sy
ii  libc6                  2.3.6.ds1-13etch2 GNU C Library: Shared libraries
ii  libdbi-perl            1.53-1            Perl5 database interface by Tim Bu
ii  libgcc1                1:4.1.1-21        GCC support library
ii  libmysqlclient15off    5.0.32-7etch1     mysql database client library
ii  libncurses5            5.5-5             Shared libraries for terminal hand
ii  libreadline5           5.2-2             GNU readline and history libraries
ii  libstdc++6             4.1.1-21          The GNU Standard C++ Library v3
ii  libwrap0               7.6.dbs-13        Wietse Venema's TCP wrappers libra
ii  lsb-base               3.1-23.2etch1     Linux Standard Base 3.1 init scrip
ii  mysql-client-5.0       5.0.32-7etch1     mysql database client binaries
ii mysql-common 5.0.32-7etch1 mysql database common files (e.g. ii passwd 1:4.0.18.1-7 change and administer password and ii perl 5.8.8-7 Larry Wall's Practical Extraction ii psmisc 22.3-1 Utilities that use the proc filesy
ii  zlib1g                 1:1.2.3-13        compression library - runtime

Versions of packages mysql-server-5.0 recommends:
ii  mailx            1:8.1.2-0.20050715cvs-1 A simple mail user agent

-- debconf information:
  mysql-server/root_password: (password omitted)
  mysql-server-5.0/really_downgrade: false
  mysql-server-5.0/need_sarge_compat: false
  mysql-server-5.0/start_on_boot: true
  mysql-server/error_setting_password:
* mysql-server-5.0/nis_warning:
  mysql-server-5.0/postrm_remove_databases: false
  mysql-server-5.0/need_sarge_compat_done: true

Attachment: log.after.gz
Description: Binary data

Attachment: log.before.gz
Description: Binary data

--- /usr/bin/mysqld_safe.orig   2007-09-26 14:37:34.000000000 +1000
+++ /usr/bin/mysqld_safe        2007-09-26 14:38:12.000000000 +1000
@@ -52,7 +52,7 @@
   # We only need to pass arguments through to the server if we don't
   # handle them here.  So, we collect unrecognized options (passed on
   # the command line) into the args variable.
-  pick_args=
+  pick_args=0
   if test "$1" = PICK-ARGS-FROM-ARGV
   then
     pick_args=1
@@ -95,7 +95,7 @@
         usage
         ;;
       *)
-        if test -n "$pick_args"
+        if test "0" = "$pick_args"
         then
           # This sed command makes sure that any special chars are quoted,
           # so the arg gets passed exactly to the server.

Reply via email to