Merge pull request #395 from percona/PT-1707

PT-1707 IPV6 support for recursion method processlist
This commit is contained in:
Carlos Salguero
2019-10-29 09:15:53 -03:00
committed by GitHub
23 changed files with 80 additions and 45 deletions

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -3775,8 +3775,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -43,7 +43,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -42,7 +42,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -38,7 +38,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -39,7 +39,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -35,7 +35,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -37,7 +37,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -44,7 +44,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -320,8 +320,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -47,7 +47,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -4052,8 +4052,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -56,7 +56,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -4378,8 +4378,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -64,7 +64,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -10700,8 +10700,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -40,7 +40,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -2460,8 +2460,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -41,7 +41,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -2871,8 +2871,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -58,7 +58,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -5328,8 +5328,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -55,7 +55,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -2137,10 +2137,6 @@ sub parse {
}
}
if ($final_props{F}) {
%final_props = ( 'F' => $final_props{F} );
}
return \%final_props;
}
@@ -6858,8 +6854,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}

View File

@@ -61,7 +61,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -44,7 +44,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -263,7 +263,13 @@ sub find_slave_hosts {
sub _find_slaves_by_processlist {
my ( $self, $dsn_parser, $dbh, $dsn ) = @_;
my @connected_slaves = $self->get_connected_slaves($dbh);
my @slaves = $self->_process_slaves_list($dsn_parser, $dsn, \@connected_slaves);
return @slaves;
}
sub _process_slaves_list {
my ($self, $dsn_parser, $dsn, $connected_slaves) = @_;
my @slaves = map {
my $slave = $dsn_parser->parse("h=$_", $dsn);
$slave->{source} = 'processlist';
@@ -271,13 +277,15 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
$host ||= $_->{host};
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}
if ($host =~ m/::/) {
$host = '['.$host.']';
}
$host;
} $self->get_connected_slaves($dbh);
} @$connected_slaves;
return @slaves;
}

View File

@@ -18,7 +18,7 @@
# ###########################################################################
package Percona::Toolkit;
our $VERSION = '3.1.0';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -640,6 +640,20 @@ SKIP: {
$dbh->disconnect();
}
is_deeply(
$dp->parse('h=f000::1,P=12345,u=msandbox,p=msandbox'),
{ u => 'msandbox',
p => 'msandbox',
S => undef,
h => 'f000::1',
P => '12345',
F => undef,
D => undef,
A => undef,
},
'IPV6 support'
);
# #############################################################################
# Done.
# #############################################################################

View File

@@ -335,7 +335,6 @@ $res = $ms->wait_for_master(
slave_dbh => $slaves[0],
timeout => 10,
);
warn "res->{result}: $res->{result}";
ok($res->{result} >= 0, 'Wait was successful');
@@ -868,6 +867,33 @@ SKIP: {
$sb->stop_sandbox(qw(chan_master1 chan_master2 chan_slave1));
}
my $connected_slaves = [
{
command => 'Binlog Dump',
db => undef,
host => '2001:db8:1::242:ac11:3:53902',
id => 7,
info => undef,
rows_examined => 0,
rows_sent => 0,
state => 'Master has sent all binlog to slave; waiting for more updates',
time => 80,
user => 'root'
},
];
my @g = $ms->_process_slaves_list ($dp, $dsn, $connected_slaves);
is (
scalar @g,
1,
"1 slave (IPv6) detected",
);
is (
$g[0]->{h},
"[2001:db8:1::242:ac11:3]",
"Brackets were added to IPv6 detected slave host",
);
# #############################################################################
# Done.
# #############################################################################