Merge lp:~percona-toolkit-dev/percona-toolkit/fix-887638-ptqa-negative-at-byte into lp:percona-toolkit/2.1

Proposed by Brian Fraser
Status: Merged
Approved by: Daniel Nichter
Approved revision: 460
Merged at revision: 468
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-887638-ptqa-negative-at-byte
Merge into: lp:percona-toolkit/2.1
Diff against target: 83 lines (+36/-3)
3 files modified
bin/pt-query-digest (+1/-1)
lib/QueryReportFormatter.pm (+1/-1)
t/lib/QueryReportFormatter.t (+34/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-887638-ptqa-negative-at-byte
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+134582@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-query-digest'
--- bin/pt-query-digest 2012-11-13 15:22:01 +0000
+++ bin/pt-query-digest 2012-11-16 00:51:23 +0000
@@ -6721,7 +6721,7 @@
6721 }6721 }
67226722
6723 my $line = sprintf(6723 my $line = sprintf(
6724 '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %d ',6724 '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %.f ',
6725 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),6725 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),
6726 $args{rank} || 0,6726 $args{rank} || 0,
6727 shorten($qps || 0, d=>1_000),6727 shorten($qps || 0, d=>1_000),
67286728
=== modified file 'lib/QueryReportFormatter.pm'
--- lib/QueryReportFormatter.pm 2012-08-06 14:37:51 +0000
+++ lib/QueryReportFormatter.pm 2012-11-16 00:51:23 +0000
@@ -524,7 +524,7 @@
524 # First line like:524 # First line like:
525 # Query 1: 9 QPS, 0x concurrency, ID 0x7F7D57ACDD8A346E at byte 5 ________525 # Query 1: 9 QPS, 0x concurrency, ID 0x7F7D57ACDD8A346E at byte 5 ________
526 my $line = sprintf(526 my $line = sprintf(
527 '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %d ',527 '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %.f ',
528 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),528 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),
529 $args{rank} || 0,529 $args{rank} || 0,
530 shorten($qps || 0, d=>1_000),530 shorten($qps || 0, d=>1_000),
531531
=== modified file 't/lib/QueryReportFormatter.t'
--- t/lib/QueryReportFormatter.t 2012-06-12 00:43:05 +0000
+++ t/lib/QueryReportFormatter.t 2012-11-16 00:51:23 +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 => 45;12use Test::More;
1313
14use Data::Dumper;14use Data::Dumper;
15$Data::Dumper::Indent = 1;15$Data::Dumper::Indent = 1;
@@ -187,6 +187,38 @@
187 'Event report'187 'Event report'
188);188);
189189
190{
191 # pt-query-digest prints negative byte offset
192 # https://bugs.launchpad.net/percona-toolkit/+bug/887638
193
194 # printf "%d" can't really handle large values in some systems.
195 # Given a large enough log file, it will start printing
196 # negative values. The workaround is to use %.f instead. I haven't
197 # researched what the recommended solution for this is, but
198 # it's such an uncommon case and that it's not worth the time.
199 # This bug should really only affect 32-bit machines, and even then
200 # only those were the underlaying compiler's printf("%d") coerces the
201 # argument into a signed int.
202 my $item = 'select id from users where name=?';
203 local $ea->results->{samples}->{$item}->{pos_in_log} = 1e+33;
204
205 $result = $qrf->event_report(
206 ea => $ea,
207 # "users" is here to try to cause a failure
208 select => [ qw(Query_time Lock_time Rows_sent Rows_examined ts db user users) ],
209 item => $item,
210 rank => 1,
211 orderby => 'Query_time',
212 reason => 'top',
213 );
214
215 unlike(
216 $result,
217 qr/at byte -/,
218 "Bug 887638: pt-query-digest prints negative byte offset"
219 );
220}
221
190$result = $qrf->chart_distro(222$result = $qrf->chart_distro(
191 ea => $ea,223 ea => $ea,
192 attrib => 'Query_time',224 attrib => 'Query_time',
@@ -1570,4 +1602,5 @@
1570 '_d() works'1602 '_d() works'
1571);1603);
1572ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");1604ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
1605done_testing;
1573exit;1606exit;

Subscribers

People subscribed via source and target branches