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

Proposed by Brian Fraser on 2012-11-16
Status: Merged
Approved by: Daniel Nichter on 2012-11-28
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 2012-11-16 Approve on 2012-11-28
Review via email: mp+134582@code.launchpad.net
To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-query-digest'
2--- bin/pt-query-digest 2012-11-13 15:22:01 +0000
3+++ bin/pt-query-digest 2012-11-16 00:51:23 +0000
4@@ -6721,7 +6721,7 @@
5 }
6
7 my $line = sprintf(
8- '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %d ',
9+ '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %.f ',
10 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),
11 $args{rank} || 0,
12 shorten($qps || 0, d=>1_000),
13
14=== modified file 'lib/QueryReportFormatter.pm'
15--- lib/QueryReportFormatter.pm 2012-08-06 14:37:51 +0000
16+++ lib/QueryReportFormatter.pm 2012-11-16 00:51:23 +0000
17@@ -524,7 +524,7 @@
18 # First line like:
19 # Query 1: 9 QPS, 0x concurrency, ID 0x7F7D57ACDD8A346E at byte 5 ________
20 my $line = sprintf(
21- '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %d ',
22+ '# %s %d: %s QPS, %sx concurrency, ID 0x%s at byte %.f ',
23 ($ea->{groupby} eq 'fingerprint' ? 'Query' : 'Item'),
24 $args{rank} || 0,
25 shorten($qps || 0, d=>1_000),
26
27=== modified file 't/lib/QueryReportFormatter.t'
28--- t/lib/QueryReportFormatter.t 2012-06-12 00:43:05 +0000
29+++ t/lib/QueryReportFormatter.t 2012-11-16 00:51:23 +0000
30@@ -9,7 +9,7 @@
31 use strict;
32 use warnings FATAL => 'all';
33 use English qw(-no_match_vars);
34-use Test::More tests => 45;
35+use Test::More;
36
37 use Data::Dumper;
38 $Data::Dumper::Indent = 1;
39@@ -187,6 +187,38 @@
40 'Event report'
41 );
42
43+{
44+ # pt-query-digest prints negative byte offset
45+ # https://bugs.launchpad.net/percona-toolkit/+bug/887638
46+
47+ # printf "%d" can't really handle large values in some systems.
48+ # Given a large enough log file, it will start printing
49+ # negative values. The workaround is to use %.f instead. I haven't
50+ # researched what the recommended solution for this is, but
51+ # it's such an uncommon case and that it's not worth the time.
52+ # This bug should really only affect 32-bit machines, and even then
53+ # only those were the underlaying compiler's printf("%d") coerces the
54+ # argument into a signed int.
55+ my $item = 'select id from users where name=?';
56+ local $ea->results->{samples}->{$item}->{pos_in_log} = 1e+33;
57+
58+ $result = $qrf->event_report(
59+ ea => $ea,
60+ # "users" is here to try to cause a failure
61+ select => [ qw(Query_time Lock_time Rows_sent Rows_examined ts db user users) ],
62+ item => $item,
63+ rank => 1,
64+ orderby => 'Query_time',
65+ reason => 'top',
66+ );
67+
68+ unlike(
69+ $result,
70+ qr/at byte -/,
71+ "Bug 887638: pt-query-digest prints negative byte offset"
72+ );
73+}
74+
75 $result = $qrf->chart_distro(
76 ea => $ea,
77 attrib => 'Query_time',
78@@ -1570,4 +1602,5 @@
79 '_d() works'
80 );
81 ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox");
82+done_testing;
83 exit;

Subscribers

People subscribed via source and target branches