Skip to content

Commit c5d904e

Browse files
committed
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. Fixed by enhancing the meaning of basedir in [mysqldN] sections of mysqld_multi. If specified, mysqld_multi will change the current working directory to the basedir directory before starting the server in mysqld_multi ... start ... and then change it back to what it was.
1 parent 728d3c3 commit c5d904e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

scripts/mysqld_multi.sh

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/perl
22

33
use Getopt::Long;
4-
use POSIX qw(strftime);
4+
use POSIX qw(strftime getcwd);
55

66
$|=1;
77
$VER="2.16";
@@ -295,6 +295,7 @@ sub start_mysqlds()
295295
{
296296
@options = defaults_for_group($groups[$i]);
297297

298+
$basedir_found= 0; # The default
298299
$mysqld_found= 1; # The default
299300
$mysqld_found= 0 if (!length($mysqld));
300301
$com= "$mysqld";
@@ -310,6 +311,14 @@ sub start_mysqlds()
310311
$com= $options[$j];
311312
$mysqld_found= 1;
312313
}
314+
elsif ("--basedir=" eq substr($options[$j], 0, 10))
315+
{
316+
$basedir= $options[$j];
317+
$basedir =~ s/^--basedir=//;
318+
$basedir_found= 1;
319+
$options[$j]= quote_shell_word($options[$j]);
320+
$tmp.= " $options[$j]";
321+
}
313322
else
314323
{
315324
$options[$j]= quote_shell_word($options[$j]);
@@ -337,7 +346,16 @@ sub start_mysqlds()
337346
print "group [$groups[$i]] separately.\n";
338347
exit(1);
339348
}
349+
if ($basedir_found)
350+
{
351+
$curdir=getcwd();
352+
chdir($basedir) or die "Can't change to datadir $basedir";
353+
}
340354
system($com);
355+
if ($basedir_found)
356+
{
357+
chdir($curdir) or die "Can't change back to original dir $curdir";
358+
}
341359
}
342360
if (!$i && !$opt_no_log)
343361
{

0 commit comments

Comments
 (0)