From 04dc9191c6ea61bfe0d659c1b10373cf88f70fde Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Mon, 8 May 2017 18:21:42 -0300 Subject: [PATCH] PT-131 Added --disable-qrt-plugin option to pt-table-checksum --- bin/pt-table-checksum | 57 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 338c1bee..058e1fc9 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -9112,6 +9112,7 @@ use sigtrap 'handler', \&sig_int, 'normal-signals'; my $oktorun = 1; my $print_header = 1; my $exit_status = 0; +my $original_qrt_plugin_master_status = undef; # "exit codes 1 - 2, 126 - 165, and 255 [1] have special meanings, # and should therefore be avoided for user-specified exit parameters" @@ -9357,6 +9358,7 @@ sub main { . "level to REPEATABLE-READ.\n"; } + return; }; @@ -9385,6 +9387,21 @@ sub main { my $master_dbh = $master_cxn->dbh(); # just for brevity my $master_dsn = $master_cxn->dsn(); # just for brevity + if ($o->get('disable-qrt-plugin')) { + eval { + $master_dbh->selectrow_arrayref('SELECT @@QUERY_RESPONSE_TIME_SESSION_STATS' ); + warn Data::Dumper::Dumper($original_qrt_plugin_master_status); + }; + if ($EVAL_ERROR) { + $original_qrt_plugin_master_status = undef; + PTDEBUG && _d('QRT plugin is not installed: '.$EVAL_ERROR); + } else { + ($original_qrt_plugin_master_status) = $master_dbh->selectrow_arrayref('SELECT @@query_response_time_stats' ); + PTDEBUG && _d("Disabling qrt plugin on master server"); + $master_dbh->do('SET GLOBAL query_response_time_stats = off'); + } + } + # ######################################################################## # Set up the run time, if any. Anything that waits should check this # between waits, else this will happen: @@ -9656,6 +9673,23 @@ sub main { } } + for my $slave (@$slaves) { + my $qrt_plugin_status; + eval { + ($qrt_plugin_status) = $slave->{dbh}->selectrow_arrayref('SELECT @@QUERY_RESPONSE_TIME_SESSION_STATS' ); + }; + if ($EVAL_ERROR) { + PTDEBUG && _d('QRT plugin is not installed on slave '.$slave->{dsn_name}); + $slave->{qrt_plugin_status} = undef; + next; + } + $slave->{qrt_plugin_status} = $qrt_plugin_status->[0]; + if ($slave->{qrt_plugin_status}) { + PTDEBUG && _d("Disabling qrt plugin state on slave ".$slave->{dsn_name}); + $slave->{dbh}->do('SET GLOBAL query_response_time_stats = off'); + } + } + if ( $o->get('check-slave-lag') ) { PTDEBUG && _d('Will use --check-slave-lag to check for slave lag'); my $cxn = $make_cxn->( @@ -10650,6 +10684,25 @@ sub main { } } + # Restore origin QRT pligin state + if ($o->get('disable-qrt-plugin')) { + eval { + if ($original_qrt_plugin_master_status) { + PTDEBUG && _d("Restoring qrt plugin state on master server"); + $master_dbh->do("SET GLOBAL query_response_time_stats = $original_qrt_plugin_master_status->[0]"); + } + for my $slave (@$slaves) { + if ($slave->{qrt_plugin_status}) { + PTDEBUG && _d("Restoring qrt plugin state on slave ".$slave->{dsn_name}); + $slave->{dbh}->do("SET GLOBAL query_response_time_stats = $slave->{qrt_plugin_status}"); + } + } + }; + if ($EVAL_ERROR) { + warn "Cannot restore qrt_plugin status: $EVAL_ERROR"; + } + } + PTDEBUG && _d('Exit status', $exit_status, 'oktorun', $oktorun, 'have time', $have_time->()); @@ -12308,6 +12361,10 @@ short form: -F; type: string; group: Connection Only read mysql options from the given file. You must give an absolute pathname. +=item --disable-qrt-plugin + +Disable the QRT (Query Response Time) plugin if it is enabled. + =item --[no]empty-replicate-table default: yes