PT-1707 IPV6 support for recursion method processlist

This commit is contained in:
Carlos Salguero
2019-04-11 17:44:17 -03:00
parent a9eeeb6fb1
commit a97e24be71
22 changed files with 65 additions and 52 deletions

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -3744,7 +3744,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
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.0.13';
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.0.13';
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.0.13';
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.0.13';
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.0.13';
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -112,22 +112,22 @@ use warnings FATAL => 'all';
use English qw(-no_match_vars);
use constant PTDEBUG => $ENV{PTDEBUG} || 0;
sub check_recursion_method {
sub check_recursion_method {
my ($methods) = @_;
if ( @$methods != 1 ) {
if ( grep({ !m/processlist|hosts/i } @$methods)
&& $methods->[0] !~ /^dsn=/i )
{
die "Invalid combination of recursion methods: "
. join(", ", map { defined($_) ? $_ : 'undef' } @$methods) . ". "
. "Only hosts and processlist may be combined.\n"
}
}
else {
if ( @$methods != 1 ) {
if ( grep({ !m/processlist|hosts/i } @$methods)
&& $methods->[0] !~ /^dsn=/i )
{
die "Invalid combination of recursion methods: "
. join(", ", map { defined($_) ? $_ : 'undef' } @$methods) . ". "
. "Only hosts and processlist may be combined.\n"
}
}
else {
my ($method) = @$methods;
die "Invalid recursion method: " . ( $method || 'undef' )
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster$|dsn=)/i;
}
die "Invalid recursion method: " . ( $method || 'undef' )
unless $method && $method =~ m/^(?:processlist$|hosts$|none$|cluster$|dsn=)/i;
}
}
sub new {
@@ -156,7 +156,7 @@ sub get_slaves {
my $methods = $self->_resolve_recursion_methods($args{dsn});
return $slaves unless @$methods;
if ( grep { m/processlist|hosts/i } @$methods ) {
my @required_args = qw(dbh dsn);
foreach my $arg ( @required_args ) {
@@ -201,7 +201,7 @@ sub get_slaves {
else {
die "Unexpected recursion methods: @$methods";
}
return $slaves;
}
@@ -320,7 +320,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
my ( $host ) = $_->{host} =~ m/^(.*):\d+$/;
if ( $host eq 'localhost' ) {
$host = '127.0.0.1'; # Replication never uses sockets.
}
@@ -719,7 +719,7 @@ sub short_host {
}
sub is_replication_thread {
my ( $self, $query, %args ) = @_;
my ( $self, $query, %args ) = @_;
return unless $query;
my $type = lc($args{type} || 'all');
@@ -734,7 +734,7 @@ sub is_replication_thread {
if ( !$match ) {
if ( ($query->{User} || $query->{user} || '') eq "system user" ) {
PTDEBUG && _d("Slave replication thread");
if ( $type ne 'all' ) {
if ( $type ne 'all' ) {
my $state = $query->{State} || $query->{state} || '';
if ( $state =~ m/^init|end$/ ) {
@@ -747,7 +747,7 @@ sub is_replication_thread {
|Reading\sevent\sfrom\sthe\srelay\slog
|Has\sread\sall\srelay\slog;\swaiting
|Making\stemp\sfile
|Waiting\sfor\sslave\smutex\son\sexit)/xi;
|Waiting\sfor\sslave\smutex\son\sexit)/xi;
$match = $type eq 'slave_sql' && $slave_sql ? 1
: $type eq 'slave_io' && !$slave_sql ? 1
@@ -811,7 +811,7 @@ sub get_replication_filters {
replicate_do_db
replicate_ignore_db
replicate_do_table
replicate_ignore_table
replicate_ignore_table
replicate_wild_do_table
replicate_wild_ignore_table
);
@@ -822,7 +822,7 @@ sub get_replication_filters {
$filters{slave_skip_errors} = $row->[1] if $row->[1] && $row->[1] ne 'OFF';
}
return \%filters;
return \%filters;
}

View File

@@ -45,7 +45,7 @@ BEGIN {
{
package Percona::Toolkit;
our $VERSION = '3.0.13';
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -4026,7 +4026,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -4281,8 +4281,7 @@ sub recurse_to_slaves {
PTDEBUG && _d('Connected to', $dp->as_string($slave_dsn));
};
if ( $EVAL_ERROR ) {
#TODO REMOVE DEBUG
print STDERR "1> Cannot connect to ", $dp->as_string($slave_dsn), "\n"
print STDERR "Cannot connect to ", $dp->as_string($slave_dsn), "\n"
or die "Cannot print: $OS_ERROR";
return;
}
@@ -4349,7 +4348,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -10674,7 +10674,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

@@ -2434,7 +2434,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -2845,7 +2845,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -5298,7 +5298,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';
@@ -6843,7 +6843,7 @@ sub _find_slaves_by_processlist {
}
grep { $_ }
map {
my ( $host ) = $_->{host} =~ m/^([^:]+):/;
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.0.13';
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.0.13';
our $VERSION = '3.0.14-dev';
use strict;
use warnings FATAL => 'all';

View File

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

View File

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

View File

@@ -632,6 +632,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.
# #############################################################################