diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 52309997..650a0526 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -13092,14 +13092,15 @@ sub main { # Create an EventAggregator for this groupby attrib and # add it to callbacks. my $type_for = { - val => 'string', - key_print => 'string', - Status_code => 'string', - Statement_id => 'string', - Error_no => 'string', - Last_errno => 'string', - Thread_id => 'string', - Killed => 'bool', + val => 'string', + key_print => 'string', + Status_code => 'string', + Statement_id => 'string', + Error_no => 'string', + Last_errno => 'string', + Thread_id => 'string', + InnoDB_trx_id => 'string', + Killed => 'bool', }; my $ea = new EventAggregator( diff --git a/t/lib/EventAggregator.t b/t/lib/EventAggregator.t index 5ac7c56c..2e2a2397 100644 --- a/t/lib/EventAggregator.t +++ b/t/lib/EventAggregator.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 80; +use Test::More tests => 81; use QueryRewriter; use EventAggregator; @@ -1906,6 +1906,24 @@ cmp_ok( "Saved no more than 1_000 CRCs" ); +# ############################################################################# +# Bug 821694: pt-query-digest doesn't recognize hex InnoDB txn IDs +# ############################################################################# +$ea = new EventAggregator( + groupby => 'arg', + worst => 'Query_time', + unroll_limit => 5, + type_for => { + 'InnoDB_trx_id' => 'string', + }, +); +parse_file('t/lib/samples/slowlogs/slow054.txt', $p, $ea); +is( + $ea->{result_classes}->{'SELECT * FROM foo WHERE id=1'}->{InnoDB_trx_id}->{cnt}, + 8, + "Parse InnoDB_trx_id as string" +); + # ############################################################################# # Done. # ############################################################################# diff --git a/t/lib/samples/slowlogs/slow054.txt b/t/lib/samples/slowlogs/slow054.txt new file mode 100644 index 00000000..b0dfb194 --- /dev/null +++ b/t/lib/samples/slowlogs/slow054.txt @@ -0,0 +1,32 @@ +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 101 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 102 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 103 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 104 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 105 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: 106 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: A07 +SELECT * FROM foo WHERE id=1; +# Time: 110208 12:00:01 +# Query_time: 0.000012 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 +# InnoDB_trx_id: A08 +SELECT * FROM foo WHERE id=1; diff --git a/t/pt-query-digest/samples/slow054.txt b/t/pt-query-digest/samples/slow054.txt new file mode 100644 index 00000000..777f8908 --- /dev/null +++ b/t/pt-query-digest/samples/slow054.txt @@ -0,0 +1,30 @@ + +# Query 1: 0 QPS, 0x concurrency, ID 0xBB11C6B7F3BAAB30 at byte 1058 _____ +# This item is included in the report because it matches --limit. +# Scores: Apdex = 1.00 [1.0]*, V/M = 0.00 +# Query_time sparkline: | ^ | +# Time range: all events occurred at 2011-02-08 12:00:01 +# Attribute pct total min max avg 95% stddev median +# ============ === ======= ======= ======= ======= ======= ======= ======= +# Count 100 8 +# Exec time 100 96us 12us 12us 12us 12us 0 12us +# Lock time 0 0 0 0 0 0 0 0 +# Rows sent 0 0 0 0 0 0 0 0 +# Rows examine 0 0 0 0 0 0 0 0 +# Query size 100 224 28 28 28 28 0 28 +# String: +# InnoDB trxID 101 (1/12%), 102 (1/12%), 103 (1/12%)... 5 more +# Query_time distribution +# 1us +# 10us ################################################################ +# 100us +# 1ms +# 10ms +# 100ms +# 1s +# 10s+ +# Tables +# SHOW TABLE STATUS LIKE 'foo'\G +# SHOW CREATE TABLE `foo`\G +# EXPLAIN /*!50100 PARTITIONS*/ +SELECT * FROM foo WHERE id=1\G diff --git a/t/pt-query-digest/slowlog_analyses.t b/t/pt-query-digest/slowlog_analyses.t index d0794143..ab6c8c09 100644 --- a/t/pt-query-digest/slowlog_analyses.t +++ b/t/pt-query-digest/slowlog_analyses.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 42; +use Test::More tests => 43; use PerconaTest; @@ -421,6 +421,18 @@ ok( 'Analysis for slow052 (Apdex T = 0.1)', ); +# ############################################################################# +# Bug 821694: pt-query-digest doesn't recognize hex InnoDB txn IDs +# ############################################################################# +ok( + no_diff( + sub { pt_query_digest::main(@args, $sample.'slow054.txt', + qw(--check-attributes-limit 5)) }, + "t/pt-query-digest/samples/slow054.txt", + ), + 'Analysis for slow054 (InnoDB_trx_id bug 821694)' +); + # ############################################################################# # Done. # #############################################################################