added --skip-check-slave-lag

This commit is contained in:
Carlos Salguero
2017-04-12 12:34:39 -03:00
parent 4ff8e664ae
commit 2fe4afc9cf
6 changed files with 91 additions and 7 deletions

View File

@@ -8508,9 +8508,31 @@ sub main {
$slave_lag_cxns = $slaves;
}
if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) {
if ($o->get('skip-check-slave-lag')) {
my $slaves_to_skip = $o->get('skip-check-slave-lag');
my $filtered_slaves = [];
for my $slave (@$slave_lag_cxns) {
my $found=0;
for my $slave_to_skip (@$slaves_to_skip) {
if ($slave->{dsn}->{h} eq $slave_to_skip->{h} && $slave->{dsn}->{P} eq $slave_to_skip->{P}) {
$found=1;
}
}
if ($found) {
printf("Skipping slave %s -> %s:%s\n", $slave->name(), $slave->{dsn}->{h}, $slave->{dsn}->{P});
} else {
push @$filtered_slaves, $slave;
}
}
$slave_lag_cxns = $filtered_slaves;
}
if (!scalar @$slave_lag_cxns) {
print "Not checking slave lag because all slaves were skipped\n";
} else{
print "Will check slave lag on:\n";
foreach my $cxn ( @$slave_lag_cxns ) {
print " " . $cxn->name() . "\n";
printf("%s -> %s:%s\n", $cxn->name(), $cxn->{dsn}->{h}, $cxn->{dsn}->{P});
}
}
}
else {

View File

@@ -9681,11 +9681,40 @@ sub main {
0;
}
else {
PTDEBUG && _d('Will check slave lag on', $slave_cxn->name());
PTDEBUG && _d('May check slave lag on', $slave_cxn->name());
$slave_cxn;
}
} @$slave_lag_cxns;
if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) {
if ($o->get('skip-check-slave-lag')) {
my $slaves_to_skip = $o->get('skip-check-slave-lag');
my $filtered_slaves = [];
for my $slave (@$slave_lag_cxns) {
my $found=0;
for my $slave_to_skip (@$slaves_to_skip) {
if ($slave->{dsn}->{h} eq $slave_to_skip->{h} && $slave->{dsn}->{P} eq $slave_to_skip->{P}) {
$found=1;
}
}
if ($found) {
printf("Skipping slave %s -> %s:%s\n", $slave->name(), $slave->{dsn}->{h}, $slave->{dsn}->{P});
} else {
push @$filtered_slaves, $slave;
}
}
$slave_lag_cxns = $filtered_slaves;
}
}
if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) {
for my $slave (@$slave_lag_cxns) {
printf("Checking lag on %s -> %s:%s\n", $slave->name(), $slave->{dsn}->{h}, $slave->{dsn}->{P});
}
} else {
print "Not checking slave lag because no slaves were found or they were set to be skipped\n";
}
# #####################################################################
# Possibly check replication slaves and exit.
# #####################################################################
@@ -12701,6 +12730,13 @@ type: string; default: #
The separator character used for CONCAT_WS(). This character is used to join
the values of columns when checksumming.
=item --skip-check-slave-lag
type: DSN; repeatable: yes
DSN to skip when checking slave lag. It can be used multiple times.
Example: --skip-check-slave-lag h=127.1,P=12345 --skip-check-slave-lag h=127.1,P=12346
=item --slave-user
type: string

View File

@@ -483,6 +483,7 @@ sub start_sandbox {
if ( $type eq 'master') {
my $out = `$env $trunk/sandbox/start-sandbox $type $port`;
warn "$env";
die $out if $CHILD_ERROR;
}
elsif ( $type eq 'slave' ) {

View File

@@ -39,7 +39,9 @@ make_sandbox() {
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
mkdir /tmp/$port || die "Failed to mkdir /tmp/$port"
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf /tmp/$port
if [ -e $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz ]; then
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /tmp/$port
fi
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
if [ -f $script ]; then
@@ -244,6 +246,7 @@ else
fi
APP="${FORK:-"mysql"}"
echo "APP $APP" > /home/karl/k
if [ $type = "cluster" -o $APP = "pxc" ]; then
# disabled for now because used perl module is not available everywhere and in some distros it returns ipv6 address
@@ -253,6 +256,7 @@ if [ $type = "cluster" -o $APP = "pxc" ]; then
else
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
fi
echo "version $version" >> /home/karl/k
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist."

View File

@@ -22,6 +22,10 @@ require "$trunk/bin/pt-online-schema-change";
my $dp = new DSNParser(opts=>$dsn_opts);
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
if ( !$sb->is_cluster_mode ) {
plan skip_all => 'Only for PXC',
}
my ($master_dbh, $master_dsn) = $sb->start_sandbox(
server => 'cmaster',
type => 'master',

View File

@@ -184,9 +184,9 @@ $output = output(
chomp($output);
is(
like(
$output,
'',
qr/Checking lag on h=127.0.0.1,P=12346 -> 127.0.0.1:12346/,
"Bug 1074179: ignore-tables-regex works with --replicate-check-only"
);
# #############################################################################
@@ -206,6 +206,22 @@ like(
"Bug 1016131: ptc should skip tables where all columns are excluded"
);
# Test #12
{
$output = output(
sub { pt_table_checksum::main(@args,
'--skip-check-slave-lag', "h=127.0.0.1,P=".$sb->port_for('slave1'),
),
},
);
my $skipping_str = "Skipping.*".$sb->port_for('slave1');
like(
$output,
qr/$skipping_str/s,
"--skip-check-slave-lag",
);
}
# #############################################################################
# Illegal division by zero at pt-table-checksum line 7950
# https://bugs.launchpad.net/percona-toolkit/+bug/1075638
@@ -319,6 +335,7 @@ diag(`/tmp/12346/stop >/dev/null`);
diag(`/tmp/12346/start >/dev/null`);
#
# #############################################################################
# Done.
# #############################################################################