1
package GenTest::Reporter::ReplicationConnectionKiller;
4
@ISA = qw(GenTest::Reporter);
9
use GenTest::Constants;
13
use constant KILL_DURATION => 5;
16
local $SIG{INT} = sub {
17
kill(15, $tcpkill_pid) if defined $tcpkill_pid;
23
my $dsn = $reporter->dsn();
25
my $dbh = DBI->connect($dsn);
27
my $slave_host = $reporter->serverInfo('slave_host');
28
my $master_port = $reporter->serverVariable('port');
30
# If interface is not specified, tcpkill will auto-pick the first available
32
my $interface = $slave_host eq '127.0.0.1' ? 'lo' : '';
34
my $slave_local = $dbh->selectrow_array("
36
FROM INFORMATION_SCHEMA.PROCESSLIST
37
WHERE COMMAND = 'Binlog Dump'
40
my ($slave_local_host, $slave_local_port) = split (':', $slave_local);
42
$tcpkill_pid = fork();
44
if ($tcpkill_pid) { # parent
46
say("Killing tcpkill with pid $tcpkill_pid");
47
kill (15, $tcpkill_pid);
51
my $command = "/usr/sbin/tcpkill -i $interface src host $slave_local_host and src port $slave_local_port and dst port $master_port";
52
say("Executing $command");
59
return REPORTER_TYPE_PERIODIC;