adds --fingerprint option for pt-kill - 1391240

This commit is contained in:
Frank Cizmich
2014-12-02 16:57:25 -02:00
parent 732a3fa9cc
commit 324a086d6a
2 changed files with 24 additions and 2 deletions
+13 -1
View File
@@ -4007,7 +4007,7 @@ sub get_connected_slaves {
die "You do not have the PROCESS privilege"; die "You do not have the PROCESS privilege";
} }
$sql = 'SHOW PROCESSLIST'; $sql = 'SHOW FULL PROCESSLIST';
PTDEBUG && _d($dbh, $sql); PTDEBUG && _d($dbh, $sql);
grep { $_->{command} =~ m/Binlog Dump/i } grep { $_->{command} =~ m/Binlog Dump/i }
map { # Lowercase the column names map { # Lowercase the column names
@@ -6567,6 +6567,7 @@ use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use POSIX qw(setsid); use POSIX qw(setsid);
use List::Util qw(max); use List::Util qw(max);
use Digest::MD5 qw(md5_hex);
use Data::Dumper; use Data::Dumper;
$Data::Dumper::Indent = 1; $Data::Dumper::Indent = 1;
@@ -7101,6 +7102,11 @@ sub main {
$query->{Id}, ($query->{Command} || 'NULL'), $query->{Time}, $query->{Id}, ($query->{Command} || 'NULL'), $query->{Time},
($query->{Info} || 'NULL'); ($query->{Info} || 'NULL');
} }
if ( $o->get('fingerprint') ) {
my $fp = $qr->fingerprint($query->{'Info'});
my $chksm = uc substr(md5_hex($fp), -16);
print "Fingerprint: 0x$chksm\n";
}
if ( $o->get('execute-command') ) { if ( $o->get('execute-command') ) {
exec_cmd($o->get('execute-command')); exec_cmd($o->get('execute-command'));
msg('Executed ' . $o->get('execute-command')); msg('Executed ' . $o->get('execute-command'));
@@ -7487,6 +7493,12 @@ pt-kill does not provide any safeguards so code carefully!
It is permissible for the code to have side effects (to alter C<$event>). It is permissible for the code to have side effects (to alter C<$event>).
=item --fingerprint
Prints a fingerprint (checksum) of the query that was just killed. This is
equivalent to the fingerprint output of pt-query-digest. This allows
cross-referencing the output of both tools.
=item --group-by =item --group-by
type: string type: string
+11 -1
View File
@@ -9,7 +9,7 @@ BEGIN {
use strict; use strict;
use warnings FATAL => 'all'; use warnings FATAL => 'all';
use English qw(-no_match_vars); use English qw(-no_match_vars);
use Test::More tests => 15; use Test::More tests => 16;
use PerconaTest; use PerconaTest;
use Sandbox; use Sandbox;
@@ -137,6 +137,16 @@ like(
"--match-all" "--match-all"
); );
# --fingerprint option
$output = output(
sub { pt_kill::main(@args, "$trunk/t/lib/samples/pl/recset011.txt", qw(--match-all --print --fingerprint)); }
);
like(
$output,
qr/0x69962191E64980E6/,
'--fingerprint'
);
# ############################################################################# # #############################################################################
# Live tests. # Live tests.
# ############################################################################# # #############################################################################