mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-12 06:00:14 +00:00
added --skip-check-slave-lag
This commit is contained in:
@@ -8508,9 +8508,31 @@ sub main {
|
|||||||
$slave_lag_cxns = $slaves;
|
$slave_lag_cxns = $slaves;
|
||||||
}
|
}
|
||||||
if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) {
|
if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) {
|
||||||
print "Will check slave lag on:\n";
|
if ($o->get('skip-check-slave-lag')) {
|
||||||
foreach my $cxn ( @$slave_lag_cxns ) {
|
my $slaves_to_skip = $o->get('skip-check-slave-lag');
|
||||||
print " " . $cxn->name() . "\n";
|
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 ) {
|
||||||
|
printf("%s -> %s:%s\n", $cxn->name(), $cxn->{dsn}->{h}, $cxn->{dsn}->{P});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -9681,11 +9681,40 @@ sub main {
|
|||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PTDEBUG && _d('Will check slave lag on', $slave_cxn->name());
|
PTDEBUG && _d('May check slave lag on', $slave_cxn->name());
|
||||||
$slave_cxn;
|
$slave_cxn;
|
||||||
}
|
}
|
||||||
} @$slave_lag_cxns;
|
} @$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.
|
# 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 separator character used for CONCAT_WS(). This character is used to join
|
||||||
the values of columns when checksumming.
|
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
|
=item --slave-user
|
||||||
|
|
||||||
type: string
|
type: string
|
||||||
|
@@ -483,6 +483,7 @@ sub start_sandbox {
|
|||||||
|
|
||||||
if ( $type eq 'master') {
|
if ( $type eq 'master') {
|
||||||
my $out = `$env $trunk/sandbox/start-sandbox $type $port`;
|
my $out = `$env $trunk/sandbox/start-sandbox $type $port`;
|
||||||
|
warn "$env";
|
||||||
die $out if $CHILD_ERROR;
|
die $out if $CHILD_ERROR;
|
||||||
}
|
}
|
||||||
elsif ( $type eq 'slave' ) {
|
elsif ( $type eq 'slave' ) {
|
||||||
|
@@ -39,7 +39,9 @@ make_sandbox() {
|
|||||||
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
rm -rf /tmp/$port || die "Failed to rm /tmp/$port"
|
||||||
mkdir /tmp/$port || die "Failed to mkdir /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
|
cp $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/my.sandbox.cnf /tmp/$port
|
||||||
tar xzf $PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version/data.tar.gz -C /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
|
for script in "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/"*; do
|
||||||
if [ -f $script ]; then
|
if [ -f $script ]; then
|
||||||
@@ -244,6 +246,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
APP="${FORK:-"mysql"}"
|
APP="${FORK:-"mysql"}"
|
||||||
|
echo "APP $APP" > /home/karl/k
|
||||||
|
|
||||||
if [ $type = "cluster" -o $APP = "pxc" ]; then
|
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
|
# 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
|
else
|
||||||
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
|
||||||
fi
|
fi
|
||||||
|
echo "version $version" >> /home/karl/k
|
||||||
|
|
||||||
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
|
if [ ! -d "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version" ]; then
|
||||||
die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist."
|
die "$PERCONA_TOOLKIT_BRANCH/sandbox/servers/${APP#mysql}/$version does not exist."
|
||||||
|
@@ -22,6 +22,10 @@ require "$trunk/bin/pt-online-schema-change";
|
|||||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
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(
|
my ($master_dbh, $master_dsn) = $sb->start_sandbox(
|
||||||
server => 'cmaster',
|
server => 'cmaster',
|
||||||
type => 'master',
|
type => 'master',
|
||||||
|
@@ -184,9 +184,9 @@ $output = output(
|
|||||||
|
|
||||||
chomp($output);
|
chomp($output);
|
||||||
|
|
||||||
is(
|
like(
|
||||||
$output,
|
$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"
|
"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"
|
"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
|
# Illegal division by zero at pt-table-checksum line 7950
|
||||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1075638
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1075638
|
||||||
@@ -319,6 +335,7 @@ diag(`/tmp/12346/stop >/dev/null`);
|
|||||||
diag(`/tmp/12346/start >/dev/null`);
|
diag(`/tmp/12346/start >/dev/null`);
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
Reference in New Issue
Block a user