Hello Georgi,
Please see my comments below.
Thank you,
Gleb.
Georgi Kodinov wrote:
> #At file:///Users/kgeorge/mysql/work/B36654-5.0-bugteam/ based on
> revid:alexey.kopytov@stripped
>
> 2778 Georgi Kodinov 2009-06-18
> Bug #36654: mysqld_multi cannot start instances with different versions
> occasionally.
>
> mysql_multi can call mysqld_safe. In doing this it's not changing the current
> working
> directory. This may cause confusion in the case where mysqld_multi is handling
> instances
> of servers of different versions and the current working directory is the
> installation
> directory of one of these servers.
>
> Added a new option : --changedir to change the current working directory to the
>
> data directory (if specified in the relevant mysqldNN section) before doing
> mysqld_multi ... start ... and then change it back to what it was.
> @ scripts/mysqld_multi.sh
> Bug #36654: optionally preserve, change and restore the cwd when starting
> server
> instances
>
> modified:
> scripts/mysqld_multi.sh
> === modified file 'scripts/mysqld_multi.sh'
> --- a/scripts/mysqld_multi.sh 2009-04-02 15:29:28 +0000
> +++ b/scripts/mysqld_multi.sh 2009-06-18 15:44:11 +0000
> @@ -1,7 +1,7 @@
> #!/usr/bin/perl
>
> use Getopt::Long;
> -use POSIX qw(strftime);
> +use POSIX qw(strftime getcwd);
>
> $|=1;
> $VER="2.16";
> @@ -20,6 +20,7 @@ $opt_user = "root";
> $opt_version = 0;
> $opt_silent = 0;
> $opt_verbose = 0;
> +$opt_changedir = 0;
>
> my $my_print_defaults_exists= 1;
> my $logdir= undef();
> @@ -87,7 +88,7 @@ sub main
> # We've already handled --no-defaults, --defaults-file, etc.
> if (!GetOptions("help", "example", "version", "mysqld=s", "mysqladmin=s",
> "user=s", "password=s", "log=s", "no-log",
> - "tcp-ip", "silent", "verbose"))
> + "tcp-ip", "silent", "verbose", "changedir"))
> {
> $flag_exit= 1;
> }
> @@ -298,6 +299,7 @@ sub start_mysqlds()
> $mysqld_found= 1; # The default
> $mysqld_found= 0 if (!length($mysqld));
> $com= "$mysqld";
> + $datadir_found= 1; # The default
^^^
AFAIU, your $datadir_found is always 1.
Please replace this with:
+ $datadir_found= 0; # The default
^^^
> for ($j = 0, $tmp= ""; defined($options[$j]); $j++)
> {
> if ("--mysqladmin=" eq substr($options[$j], 0, 13))
> @@ -310,6 +312,12 @@ sub start_mysqlds()
> $com= $options[$j];
> $mysqld_found= 1;
> }
> + elsif ("--datadir=" eq substr($options[$j], 0, 9))
> + {
> + $options[$j]=~ s/\-\-datadir\=//;
> + $datadir= $options[$j];
> + $datadir_found= 1;
> + }
Escapings of '-' and '=' are unnecessary.
I suggest a bit shorter code:
elsif ($options[$j] =~ s/^--datadir=//)
{
$datadir= $options[$j];
$datadir_found= 1;
}
> else
> {
> $options[$j]= quote_shell_word($options[$j]);
> @@ -337,7 +345,16 @@ sub start_mysqlds()
> print "group [$groups[$i]] separately.\n";
> exit(1);
> }
> + if ($opt_changedir && $datadir_found)
> + {
> + $curdir=getcwd();
> + chdir($datadir) or die "Can't change to datadir $datadir";
> + }
> system($com);
> + if ($opt_changedir && $datadir_found)
> + {
> + chdir($curdir) or die "Can't change back to original dir $curdir";
> + }
> }
> if (!$i && !$opt_no_log)
> {
> @@ -749,6 +766,8 @@ These options must be given before any o
> standard system-wide and user-specific files
> Using: @{[join ' ', @defaults_options]}
>
> +--changedir Change the working directory to datadir (if specified)
> + before starting the individual servers.
> --config-file=... Deprecated, please use --defaults-extra-file instead
> --example Give an example of a config file with extra information.
> --help Print this help and exit.
>
>
>
> ------------------------------------------------------------------------
>
>