mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-07 21:09:14 +00:00
bail out when pt-slave-restart has gtid enabled and multiple replication threads are enabled
This commit is contained in:
@@ -5003,6 +5003,18 @@ sub watch_server {
|
||||
? 'enabled'
|
||||
: 'disabled'));
|
||||
|
||||
# If GTID is enabled, slave_parallel_workers should be == 0.
|
||||
# it's currently not possible to know what GTID event the failed trx is
|
||||
if ( $gtid_mode eq 'ON') {
|
||||
my $threads = $dbh->selectrow_hashref('SELECT
|
||||
@@GLOBAL.slave_parallel_workers AS threads');
|
||||
if ( $threads->{threads} > 0 ) {
|
||||
die("Error: GTID is enabled, and slave_parallel_workers="
|
||||
. $threads->{threads}
|
||||
. ". It is impossible to skip transactions properly.\n");
|
||||
}
|
||||
}
|
||||
|
||||
# ########################################################################
|
||||
# Lookup tables of things to do when a problem is detected.
|
||||
# ########################################################################
|
||||
|
@@ -118,7 +118,7 @@ make_sandbox() {
|
||||
echo "enforce_gtid_consistency" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
if [ -n "$REPLICATION_THREADS" ]; then
|
||||
echo "slave-parallel-workers=$REPLICATION_THREADS" >> /tmp/$port/my.sandbox.cnf
|
||||
echo "slave_parallel_workers=$REPLICATION_THREADS" >> /tmp/$port/my.sandbox.cnf
|
||||
fi
|
||||
|
||||
if [ -n "$EXTRA_DEFAULTS_FILE" ]; then
|
||||
|
@@ -115,7 +115,6 @@ $output = `ps -eaf | grep pt-slave-restart | grep -v grep`;
|
||||
unlike($output, qr/pt-slave-restart --max/, 'slaveofslave: stopped pt-slave-restart successfully');
|
||||
diag(`rm -f /tmp/pt-slave-re*`);
|
||||
|
||||
|
||||
# #############################################################################
|
||||
# test skipping 2 events in a row.
|
||||
# #############################################################################
|
||||
@@ -160,8 +159,8 @@ diag(`rm -f /tmp/pt-slave-re*`);
|
||||
# Done.
|
||||
# #############################################################################
|
||||
diag(`rm -f /tmp/pt-slave-re*`);
|
||||
# diag(`$trunk/sandbox/test-env stop >/dev/null`);
|
||||
# diag(`$trunk/sandbox/test-env start >/dev/null`);
|
||||
diag(`$trunk/sandbox/test-env stop >/dev/null`);
|
||||
diag(`$trunk/sandbox/test-env start >/dev/null`);
|
||||
|
||||
#ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
||||
|
64
t/pt-slave-restart/gtid_parallelreplication.t
Normal file
64
t/pt-slave-restart/gtid_parallelreplication.t
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
BEGIN {
|
||||
die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
|
||||
unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
|
||||
unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
|
||||
};
|
||||
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
use Sandbox;
|
||||
require "$trunk/bin/pt-slave-restart";
|
||||
|
||||
if ( $sandbox_version lt '5.6' ) {
|
||||
plan skip_all => 'MySQL Version ' . $sandbox_version
|
||||
. ' < 5.6, GTID is not available, skipping tests';
|
||||
}
|
||||
|
||||
diag("Stopping/reconfiguring/restarting sandboxes 12345, 12346 and 12347");
|
||||
|
||||
diag(`$trunk/sandbox/test-env stop >/dev/null`);
|
||||
diag(`REPLICATION_THREADS=2 GTID=1 $trunk/sandbox/test-env start >/dev/null`);
|
||||
|
||||
my $dp = new DSNParser(opts=>$dsn_opts);
|
||||
my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
|
||||
my $master_dbh = $sb->get_dbh_for('master');
|
||||
my $slave_dbh = $sb->get_dbh_for('slave1');
|
||||
my $slave2_dbh = $sb->get_dbh_for('slave2');
|
||||
|
||||
if ( !$master_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox master';
|
||||
}
|
||||
elsif ( !$slave_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave1';
|
||||
}
|
||||
elsif ( !$slave2_dbh ) {
|
||||
plan skip_all => 'Cannot connect to sandbox slave2';
|
||||
}
|
||||
|
||||
# #############################################################################
|
||||
# pt-slave-restart should exit!
|
||||
# #############################################################################
|
||||
# Start an instance
|
||||
my $output=`$trunk/bin/pt-slave-restart --run-time=1s -h 127.0.0.1 -P 12346 -u msandbox -p msandbox 2>&1`;
|
||||
|
||||
like(
|
||||
$output,
|
||||
qr/It is impossible to skip transactions properly./,
|
||||
"pt-slave-restart exits with multiple replication threads"
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
diag(`rm -f /tmp/pt-slave-re*`);
|
||||
diag(`$trunk/sandbox/test-env stop >/dev/null`);
|
||||
diag(`$trunk/sandbox/test-env start >/dev/null`);
|
||||
|
||||
ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
|
||||
done_testing;
|
Reference in New Issue
Block a user