Warn if no slaves are found.

This commit is contained in:
Daniel Nichter
2013-01-03 08:58:58 -07:00
parent d4d081d1e6
commit baded38d2c
2 changed files with 68 additions and 2 deletions

View File

@@ -8741,6 +8741,15 @@ sub main {
} @$slaves;
}
PTDEBUG && _d(scalar @$slaves, 'slaves found');
if ( !@$slaves && $o->get('recursion-method')->[0] ne 'none' ) {
$exit_status |= 1;
if ( $o->get('quiet') < 2 ) {
warn "Diffs cannot be detected because no slaves were found. "
. "Please read the --recursion-method documentation for "
. "information.\n";
}
}
# https://bugs.launchpad.net/percona-toolkit/+bug/938068
if ( $o->get('check-binlog-format') ) {
@@ -11490,6 +11499,13 @@ type: array; default: processlist,hosts
Preferred recursion method for discovering replicas. pt-table-checksum
performs several L<"REPLICA CHECKS"> before and while running.
Although replicas are not required to run pt-table-checksum, the tool
cannot detect diffs on slaves that it cannot discover. Therefore,
a warning is printed and the L<"EXIT STATUS"> is non-zero if no replicas
are found and the method is not C<none>. If this happens, try a different
recursion method, or use the C<dsn> method to specify the replicas to check.
Possible methods are:
METHOD USES

View File

@@ -361,10 +361,11 @@ $output = output(
stderr => 1,
);
# Before 2.2 the exit status was 0, but bug 1087804 changed this to 1.
is(
$exit_status,
0,
"No host in DSN, zero exit status"
1,
"No host in DSN, non-zero exit status"
);
is(
@@ -490,6 +491,55 @@ is(
"Bug 821675 (dot): 0 errors"
);
# #############################################################################
# Bug 1087804: pt-table-checksum doesn't warn if no slaves are found
# #############################################################################
$sb->load_file('master', "$sample/dsn-table.sql");
$master_dbh->do('TRUNCATE TABLE dsns.dsns');
$sb->wait_for_slaves;
my $slave1_dsn = $sb->dsn_for('slave1');
$output = output(
sub { $exit_status = pt_table_checksum::main(@args,
qw(-t sakila.country),
"--recursion-method", "dsn=$slave1_dsn,t=dsns.dsns")
},
stderr => 1,
);
like(
$output,
qr/no slaves were found/,
"Warns if no slaves are found"
);
is(
$exit_status,
1,
'...exit status 1'
);
$output = output(
sub { $exit_status = pt_table_checksum::main(@args,
qw(-t sakila.country),
"--recursion-method", "none")
},
stderr => 1,
);
unlike(
$output,
qr/no slaves were found/,
"No warning if no slaves and --recursion-method=none"
);
is(
$exit_status,
0,
'...exit status 0'
);
# #############################################################################
# Done.
# #############################################################################