Merge lp:~percona-toolkit-dev/percona-toolkit/pt-kill-should-print-query-fingerprint-hash-after-killing-a-query-1391240 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 613
Merged at revision: 614
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-kill-should-print-query-fingerprint-hash-after-killing-a-query-1391240
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13
Diff against target: 91 lines (+33/-2)
2 files modified
bin/pt-kill (+22/-1)
t/pt-kill/match.t (+11/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-kill-should-print-query-fingerprint-hash-after-killing-a-query-1391240
Reviewer Review Type Date Requested Status
Daniel Nichter Needs Fixing
Review via email: mp+245160@code.launchpad.net

Description of the change

Adds a --fingerprint option to pt-kill
This prints the hash fingerprint after every query kill (or print), equivalent to the one in pt-query-digest.
This is useful for cross-referencing.

Note:
A tiny modification was made in the MasterSlave module fatpacked in pt-kill.
Since most tools are out of sync with that module, I left the delicate task of synching them for later, since the risks outweigh the benefits at this point.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

This mixes terms: fingerprint is "select c from t where id=?", checksum is 0xA4F90EC8, so --fingerprint is misleading: users will expect the former. Look in pqd docs and see if we call it "query ID" or "query checksum" and then either --query-id or --query-checksum.

Also the line

   my $chksm = uc substr(md5_hex($fp), -16);

duplicates Transformers::make_checksum(). Granted it's just one line though.

review: Needs Fixing
613. By Frank Cizmich

used Transformers::make_checksum. Changed option to --query-id

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-kill'
--- bin/pt-kill 2014-11-11 13:28:27 +0000
+++ bin/pt-kill 2015-01-12 17:24:08 +0000
@@ -4007,7 +4007,7 @@
4007 die "You do not have the PROCESS privilege";4007 die "You do not have the PROCESS privilege";
4008 }4008 }
40094009
4010 $sql = 'SHOW PROCESSLIST';4010 $sql = 'SHOW FULL PROCESSLIST';
4011 PTDEBUG && _d($dbh, $sql);4011 PTDEBUG && _d($dbh, $sql);
4012 grep { $_->{command} =~ m/Binlog Dump/i }4012 grep { $_->{command} =~ m/Binlog Dump/i }
4013 map { # Lowercase the column names4013 map { # Lowercase the column names
@@ -6567,6 +6567,7 @@
6567use English qw(-no_match_vars);6567use English qw(-no_match_vars);
6568use POSIX qw(setsid);6568use POSIX qw(setsid);
6569use List::Util qw(max);6569use List::Util qw(max);
6570use Digest::MD5 qw(md5_hex);
65706571
6571use Data::Dumper;6572use Data::Dumper;
6572$Data::Dumper::Indent = 1;6573$Data::Dumper::Indent = 1;
@@ -7101,6 +7102,11 @@
7101 $query->{Id}, ($query->{Command} || 'NULL'), $query->{Time},7102 $query->{Id}, ($query->{Command} || 'NULL'), $query->{Time},
7102 ($query->{Info} || 'NULL');7103 ($query->{Info} || 'NULL');
7103 }7104 }
7105 if ( $o->get('query-id') ) {
7106 my $fp = $qr->fingerprint($query->{'Info'});
7107 my $chksm = Transformers::make_checksum($fp);
7108 print "Query ID: 0x$chksm\n";
7109 }
7104 if ( $o->get('execute-command') ) {7110 if ( $o->get('execute-command') ) {
7105 exec_cmd($o->get('execute-command'));7111 exec_cmd($o->get('execute-command'));
7106 msg('Executed ' . $o->get('execute-command'));7112 msg('Executed ' . $o->get('execute-command'));
@@ -7487,6 +7493,7 @@
74877493
7488It is permissible for the code to have side effects (to alter C<$event>).7494It is permissible for the code to have side effects (to alter C<$event>).
74897495
7496
7490=item --group-by7497=item --group-by
74917498
7492type: string7499type: string
@@ -7590,6 +7597,20 @@
75907597
7591Port number to use for connection.7598Port number to use for connection.
75927599
7600=item --query-id
7601
7602Prints an ID of the query that was just killed. This is
7603equivalent to the "ID" output of pt-query-digest. This allows
7604cross-referencing the output of both tools.
7605
7606Example:
7607
7608 Query ID 0xE9800998ECF8427E
7609
7610Note that this is a digest (or hash) of the query's "fingerprint",
7611so queries of the same form but with different values will have the same ID.
7612See pt-query-digest for more information.
7613
7593=item --run-time7614=item --run-time
75947615
7595type: time7616type: time
75967617
=== modified file 't/pt-kill/match.t'
--- t/pt-kill/match.t 2012-06-03 19:14:30 +0000
+++ t/pt-kill/match.t 2015-01-12 17:24:08 +0000
@@ -9,7 +9,7 @@
9use strict;9use strict;
10use warnings FATAL => 'all';10use warnings FATAL => 'all';
11use English qw(-no_match_vars);11use English qw(-no_match_vars);
12use Test::More tests => 15;12use Test::More tests => 16;
1313
14use PerconaTest;14use PerconaTest;
15use Sandbox;15use Sandbox;
@@ -137,6 +137,16 @@
137 "--match-all"137 "--match-all"
138);138);
139139
140# --query-id option
141$output = output(
142 sub { pt_kill::main(@args, "$trunk/t/lib/samples/pl/recset011.txt", qw(--match-all --print --query-id)); }
143);
144like(
145 $output,
146 qr/0x69962191E64980E6/,
147 '--query-id'
148);
149
140# #############################################################################150# #############################################################################
141# Live tests.151# Live tests.
142# #############################################################################152# #############################################################################

Subscribers

People subscribed via source and target branches

to all changes: