Skip to content

Commit

Permalink
* Bug fix: MHA Manager looks for relay-log.info in wrong location
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshinorim committed Sep 27, 2011
1 parent 4cee0be commit e798039
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ t/perlcriticrc
tests/intro.txt
tests/run_suites.sh
tests/t/bulk_tran_insert.pl
tests/t/change_relay_log_info.sh
tests/t/check
tests/t/env.sh
tests/t/init.sh
Expand Down
6 changes: 6 additions & 0 deletions lib/MHA/DBHelper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ use constant Stop_Slave_SQL => "STOP SLAVE";
use constant Start_SQL_Thread_SQL => "START SLAVE SQL_THREAD";
use constant Stop_SQL_Thread_SQL => "STOP SLAVE SQL_THREAD";
use constant Get_Basedir_SQL => "SELECT \@\@global.basedir AS Value";
use constant Get_Datadir_SQL => "SELECT \@\@global.datadir AS Value";
use constant Get_MaxAllowedPacket_SQL =>
"SELECT \@\@global.max_allowed_packet AS Value";
use constant Set_MaxAllowedPacket1G_SQL =>
Expand Down Expand Up @@ -231,6 +232,11 @@ sub get_basedir($) {
return $self->get_variable(Get_Basedir_SQL);
}

sub get_datadir($) {
my $self = shift;
return $self->get_variable(Get_Datadir_SQL);
}

sub get_version($) {
my $self = shift;
return MHA::SlaveUtil::get_version( $self->{dbh} );
Expand Down
3 changes: 3 additions & 0 deletions lib/MHA/MasterFailover.pm
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ sub find_slave_with_all_relay_logs {
}
else {
$command .= " --relay_log_info=$latest_slave->{relay_log_info} ";
$command .= " --relay_dir=$latest_slave->{datadir} ";
}
if ( $latest_slave->{log_level} eq "debug" ) {
$command .= " --debug ";
Expand Down Expand Up @@ -816,6 +817,7 @@ sub generate_diff_from_readpos {
}
else {
$command .= " --relay_log_info=$latest_slave->{relay_log_info} ";
$command .= " --relay_dir=$latest_slave->{datadir} ";
}
unless ( $target->{handle_raw_binlog} ) {
$command .= " --target_version=$target->{mysql_version} ";
Expand Down Expand Up @@ -1003,6 +1005,7 @@ sub gen_diff_from_exec_to_read {
}
else {
$command .= " --relay_log_info=$target->{relay_log_info} ";
$command .= " --binlog_dir=$target->{datadir} ";
}
unless ( $target->{handle_raw_binlog} ) {
$command .= " --oldest_version=$target->{mysql_version} ";
Expand Down
1 change: 1 addition & 0 deletions lib/MHA/MasterMonitor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ sub check_slave_env() {
}
else {
$command .= " --relay_log_info=$s->{relay_log_info} ";
$command .= " --relay_dir=$s->{datadir} ";
}
if ( $s->{log_level} eq "debug" ) {
$command .= " --debug ";
Expand Down
1 change: 1 addition & 0 deletions lib/MHA/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ sub connect_and_get_status {
);
croak;
}
$self->{datadir} = $dbhelper->get_datadir();
}

my %status = $dbhelper->check_slave_status();
Expand Down
6 changes: 6 additions & 0 deletions tests/run_suites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ echo "5.5.16 row"
./run_tests --mysql_version=5.5.16 --use_row_format
echo "5.5.16 stmt"
./run_tests --mysql_version=5.5.16
echo "5.5.16 stmt relay log info"
./run_tests --mysql_version=5.5.16 --init_script=change_relay_log_info.sh --tests=need*
./run_tests --mysql_version=5.5.16 --init_script=change_relay_log_info.sh --tests=large*
echo "5.5.15 stmt"
./run_tests --mysql_version=5.5.15
echo "5.1.58 row"
./run_tests --mysql_version=5.1.58 --use_row_format
echo "5.1.58 stmt"
./run_tests --mysql_version=5.1.58
echo "5.1.58 stmt relay log info"
./run_tests --mysql_version=5.1.58 --init_script=change_relay_log_info.sh --tests=need*
./run_tests --mysql_version=5.1.58 --init_script=change_relay_log_info.sh --tests=large*
echo "5.0.91"
./run_tests --mysql_version=5.0.91
echo "5.0.45"
Expand Down
10 changes: 10 additions & 0 deletions tests/t/change_relay_log_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

./stop_s1.sh
./stop_s2.sh
rm -rf /var/tmp/mha_relay_test_dir
mkdir -p /var/tmp/mha_relay_test_dir
./start_s1.sh --relay_log_info=/var/tmp/mha_relay_test_dir/relay_log.info
./start_s2.sh --relay_log_info=/var/tmp/mha_relay_test_dir/relay_log2.info


5 changes: 4 additions & 1 deletion tests/t/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ $SANDBOX_HOME/send_kill_all > bootstrap.log 2>&1
$SANDBOX_HOME/clear_all > bootstrap.log 2>&1
make_replication_sandbox --how_many_slaves=4 --upper_directory=$SANDBOX_HOME --sandbox_base_port=$MP $VERSION >> bootstrap.log 2>&1

mysql $M test -e "create table t1 (id int primary key, value int, value2 text) engine=innodb; insert into t1 values(1, 100, 'abc');"
if [ "A$INIT_SCRIPT" != "A" ]; then
eval $INIT_SCRIPT
fi

mysql $M test -e "create table t1 (id int primary key, value int, value2 text) engine=innodb; insert into t1 values(1, 100, 'abc');"
15 changes: 14 additions & 1 deletion tests/t/run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ use File::Copy;

my $mysql_version;
my $use_row_format;
my $init_script;
my $tests;
GetOptions(
'mysql_version=s' => \$mysql_version,
'use_row_format' => \$use_row_format,
'init_script=s' => \$init_script,
'tests=s' => \$tests,
);

if ($mysql_version) {
Expand All @@ -26,7 +30,16 @@ else {
$ENV{'USE_ROW_FORMAT'} = "";
}

my @test_files = `ls t_*.sh`;
if ($init_script) {
$ENV{'INIT_SCRIPT'} = $init_script;
}else {
$ENV{'INIT_SCRIPT'} = "";
}
unless ($tests) {
$tests= "*";
}

my @test_files = `ls t_$tests.sh`;
foreach my $test_file (@test_files) {
chomp($test_file);
my $rc = system("sh $test_file");
Expand Down

0 comments on commit e798039

Please sign in to comment.