mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
Fix for 1176010: pt-query-digest should know how to group quoted and unquoted database names
This commit is contained in:
@@ -12940,13 +12940,16 @@ sub main {
|
|||||||
|
|
||||||
return [ grep { $_->[0] != $cxn } @{ $sth->fetchall_arrayref(); } ];
|
return [ grep { $_->[0] != $cxn } @{ $sth->fetchall_arrayref(); } ];
|
||||||
};
|
};
|
||||||
|
|
||||||
$pipeline->add(
|
$pipeline->add(
|
||||||
name => ref $pl,
|
name => ref $pl,
|
||||||
process => sub {
|
process => sub {
|
||||||
my ( $args ) = @_;
|
my ( $args ) = @_;
|
||||||
my $event = $pl->parse_event(code => $code);
|
my $event = $pl->parse_event(code => $code);
|
||||||
$args->{event} = $event if $event;
|
if ( $event ) {
|
||||||
|
sanitize_event($event);
|
||||||
|
$args->{event} = $event;
|
||||||
|
}
|
||||||
return $args;
|
return $args;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -13006,6 +13009,7 @@ sub main {
|
|||||||
stats => $args->{stats},
|
stats => $args->{stats},
|
||||||
);
|
);
|
||||||
if ( $event ) {
|
if ( $event ) {
|
||||||
|
sanitize_event($event);
|
||||||
$args->{event} = $event;
|
$args->{event} = $event;
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
@@ -14229,6 +14233,17 @@ sub save_resume_offset {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Quoted and unquoted values should be treated the same
|
||||||
|
# See https://bugs.launchpad.net/percona-toolkit/+bug/1176010
|
||||||
|
sub sanitize_event {
|
||||||
|
my ($event) = @_;
|
||||||
|
foreach my $value ( values %$event ) {
|
||||||
|
if ( $value && $value =~ /\A`(.+)`\z/sm ) {
|
||||||
|
$value = $1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub _d {
|
sub _d {
|
||||||
my ($package, undef, $line) = caller 0;
|
my ($package, undef, $line) = caller 0;
|
||||||
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
@_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; }
|
||||||
|
23
t/lib/samples/slowlogs/slow057.txt
Normal file
23
t/lib/samples/slowlogs/slow057.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# User@Host: meow[meow] @ [1.2.3.8]
|
||||||
|
# Thread_id: 5 Schema: db
|
||||||
|
# Query_time: 0.000002 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
||||||
|
# No InnoDB statistics available for this query
|
||||||
|
# administrator command: Quit;
|
||||||
|
# User@Host: meow[meow] @ [1.2.3.8]
|
||||||
|
# Thread_id: 6 Schema: db2
|
||||||
|
# Query_time: 0.000899 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
||||||
|
# No InnoDB statistics available for this query
|
||||||
|
use db;
|
||||||
|
SET NAMES utf8;
|
||||||
|
# User@Host: meow[meow] @ [1.2.3.8]
|
||||||
|
# Thread_id: 7 Schema: db
|
||||||
|
# Query_time: 0.018799 Lock_time: 0.009453 Rows_sent: 0 Rows_examined: 0
|
||||||
|
# No InnoDB statistics available for this query
|
||||||
|
use `db`;
|
||||||
|
# administrator command: Quit;
|
||||||
|
# User@Host: meow[meow] @ [1.2.3.8]
|
||||||
|
# Thread_id: 9 Schema: db2
|
||||||
|
# Query_time: 0.000899 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
|
||||||
|
# No InnoDB statistics available for this query
|
||||||
|
use db;
|
||||||
|
SET NAMES utf8;
|
52
t/pt-query-digest/samples/slow057.txt
Normal file
52
t/pt-query-digest/samples/slow057.txt
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
# Query 1: 0 QPS, 0x concurrency, ID 0xAA353644DE4C4CB4 at byte 434 ______
|
||||||
|
# This item is included in the report because it matches --limit.
|
||||||
|
# Scores: V/M = 0.02
|
||||||
|
# Attribute pct total min max avg 95% stddev median
|
||||||
|
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||||
|
# Count 50 2
|
||||||
|
# Exec time 91 19ms 2us 19ms 9ms 19ms 13ms 9ms
|
||||||
|
# Lock time 100 9ms 0 9ms 5ms 9ms 7ms 5ms
|
||||||
|
# Rows sent 0 0 0 0 0 0 0 0
|
||||||
|
# Rows examine 0 0 0 0 0 0 0 0
|
||||||
|
# Query size 65 54 27 27 27 27 0 27
|
||||||
|
# String:
|
||||||
|
# Databases db
|
||||||
|
# Hosts
|
||||||
|
# Users meow
|
||||||
|
# Query_time distribution
|
||||||
|
# 1us ################################################################
|
||||||
|
# 10us
|
||||||
|
# 100us
|
||||||
|
# 1ms
|
||||||
|
# 10ms ################################################################
|
||||||
|
# 100ms
|
||||||
|
# 1s
|
||||||
|
# 10s+
|
||||||
|
administrator command: Quit\G
|
||||||
|
|
||||||
|
# Query 2: 0 QPS, 0x concurrency, ID 0xCC47B42511EA22DD at byte 662 ______
|
||||||
|
# This item is included in the report because it matches --limit.
|
||||||
|
# Scores: V/M = 0.00
|
||||||
|
# Attribute pct total min max avg 95% stddev median
|
||||||
|
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||||
|
# Count 50 2
|
||||||
|
# Exec time 8 2ms 899us 899us 899us 899us 0 899us
|
||||||
|
# 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 34 28 14 14 14 14 0 14
|
||||||
|
# String:
|
||||||
|
# Databases db
|
||||||
|
# Hosts
|
||||||
|
# Users meow
|
||||||
|
# Query_time distribution
|
||||||
|
# 1us
|
||||||
|
# 10us
|
||||||
|
# 100us ################################################################
|
||||||
|
# 1ms
|
||||||
|
# 10ms
|
||||||
|
# 100ms
|
||||||
|
# 1s
|
||||||
|
# 10s+
|
||||||
|
SET NAMES utf8\G
|
@@ -393,6 +393,18 @@ ok(
|
|||||||
'Analysis for slow056 (no query bug 1082599)'
|
'Analysis for slow056 (no query bug 1082599)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# Bug 1176010: pt-query-digest should know how to group quoted and unquoted database names
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1176010
|
||||||
|
#############################################################################
|
||||||
|
ok(
|
||||||
|
no_diff(
|
||||||
|
sub { pt_query_digest::main(@args, $sample.'slow057.txt') },
|
||||||
|
"t/pt-query-digest/samples/slow057.txt",
|
||||||
|
),
|
||||||
|
'Analysis for slow057 (no grouping bug 1176010)'
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
Reference in New Issue
Block a user