mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-19 00:43:58 +00:00
PT-1869: Enable slave list reloading (#456)
* PT-1869: Enable slave list reloading * PT-1869: Fix pt-osc/slave_lag sample sizes for more consistent testing results * PT-1869: Move slaves_to_skip to get_slaves_cb
This commit is contained in:

committed by
GitHub

parent
f9b510e22f
commit
d6ada6a7bf
@@ -29,22 +29,22 @@ use constant PTDEBUG => $ENV{PTDEBUG} || 0;
|
||||
|
||||
# Sub: check_recursion_method
|
||||
# Check that the arrayref of recursion methods passed in is valid
|
||||
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 {
|
||||
@@ -73,7 +73,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 ) {
|
||||
@@ -86,7 +86,7 @@ sub get_slaves {
|
||||
{ dbh => $dbh,
|
||||
dsn => $dsn,
|
||||
slave_user => $o->got('slave-user') ? $o->get('slave-user') : '',
|
||||
slave_password => $o->got('slave-password') ? $o->get('slave-password') : '',
|
||||
slave_password => $o->got('slave-password') ? $o->get('slave-password') : '',
|
||||
callback => sub {
|
||||
my ( $dsn, $dbh, $level, $parent ) = @_;
|
||||
return unless $level;
|
||||
@@ -118,7 +118,7 @@ sub get_slaves {
|
||||
else {
|
||||
die "Unexpected recursion methods: @$methods";
|
||||
}
|
||||
|
||||
|
||||
return $slaves;
|
||||
}
|
||||
|
||||
@@ -798,7 +798,7 @@ sub short_host {
|
||||
# Returns:
|
||||
# True if the proclist item is the given type of replication thread.
|
||||
sub is_replication_thread {
|
||||
my ( $self, $query, %args ) = @_;
|
||||
my ( $self, $query, %args ) = @_;
|
||||
return unless $query;
|
||||
|
||||
my $type = lc($args{type} || 'all');
|
||||
@@ -814,7 +814,7 @@ sub is_replication_thread {
|
||||
# On a slave, there are two threads. Both have user="system user".
|
||||
if ( ($query->{User} || $query->{user} || '') eq "system user" ) {
|
||||
PTDEBUG && _d("Slave replication thread");
|
||||
if ( $type ne 'all' ) {
|
||||
if ( $type ne 'all' ) {
|
||||
# Match a particular slave thread.
|
||||
my $state = $query->{State} || $query->{state} || '';
|
||||
|
||||
@@ -831,7 +831,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;
|
||||
|
||||
# Type is either "slave_sql" or "slave_io". The second line
|
||||
# implies that if this isn't the sql thread then it must be
|
||||
@@ -919,7 +919,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
|
||||
);
|
||||
@@ -931,7 +931,7 @@ sub get_replication_filters {
|
||||
$filters{slave_skip_errors} = $row->[1] if $row->[1] && $row->[1] ne 'OFF';
|
||||
}
|
||||
|
||||
return \%filters;
|
||||
return \%filters;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user