mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-26 15:31:55 +00:00
Fix 1082104: pt-deadlock-logger problem when a username has a dash
This commit is contained in:
@@ -3757,7 +3757,8 @@ my $d = qr/(\d+)/; # Digit
|
|||||||
my $t = qr/((?:\d+ \d+)|(?:[A-Fa-f0-9]+))/; # Transaction ID
|
my $t = qr/((?:\d+ \d+)|(?:[A-Fa-f0-9]+))/; # Transaction ID
|
||||||
my $i = qr/((?:\d{1,3}\.){3}\d+)/; # IP address
|
my $i = qr/((?:\d{1,3}\.){3}\d+)/; # IP address
|
||||||
my $n = qr/([^`\s]+)/; # MySQL object name
|
my $n = qr/([^`\s]+)/; # MySQL object name
|
||||||
my $w = qr/(\w+)/; # Words
|
my $u = qr/((?!\b[0-9]+\b)\S+)/; # Username. This is somewhat wrong, but
|
||||||
|
# usernames with spcaes are rare enough.
|
||||||
my $s = qr/(\d{6} .\d:\d\d:\d\d)/; # InnoDB timestamp
|
my $s = qr/(\d{6} .\d:\d\d:\d\d)/; # InnoDB timestamp
|
||||||
|
|
||||||
# A thread's proc_info can be at least 98 different things I've found in the
|
# A thread's proc_info can be at least 98 different things I've found in the
|
||||||
@@ -4082,7 +4083,7 @@ sub parse_deadlocks {
|
|||||||
# the most useful marker for where I have to start guessing.
|
# the most useful marker for where I have to start guessing.
|
||||||
( $hostname, $ip ) = $thread_line =~ m/query id \d+(?: ([A-Za-z]\S+))? $i/m;
|
( $hostname, $ip ) = $thread_line =~ m/query id \d+(?: ([A-Za-z]\S+))? $i/m;
|
||||||
if ( defined $ip ) {
|
if ( defined $ip ) {
|
||||||
($user, $query_status) = $thread_line =~ m/$ip $w(?: (.*))?$/;
|
($user, $query_status) = $thread_line =~ m/$ip $u(?: (.*))?$/;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# OK, there wasn't an IP address.
|
# OK, there wasn't an IP address.
|
||||||
@@ -4094,7 +4095,7 @@ sub parse_deadlocks {
|
|||||||
# query_status.
|
# query_status.
|
||||||
# It's basically impossible to know which is which.
|
# It's basically impossible to know which is which.
|
||||||
( $hostname, $user, $query_status ) = $thread_line
|
( $hostname, $user, $query_status ) = $thread_line
|
||||||
=~ m/query id \d+(?: ([A-Za-z]\S+))?(?: $w(?: (.*))?)?$/m;
|
=~ m/query id \d+(?: ([A-Za-z]\S+))?(?: $u(?: (.*))?)?$/m;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$user = 'system user';
|
$user = 'system user';
|
||||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings FATAL => 'all';
|
use warnings FATAL => 'all';
|
||||||
use English qw(-no_match_vars);
|
use English qw(-no_match_vars);
|
||||||
use Test::More tests => 1;
|
use Test::More;
|
||||||
|
|
||||||
use PerconaTest;
|
use PerconaTest;
|
||||||
use Sandbox;
|
use Sandbox;
|
||||||
@@ -67,7 +67,60 @@ is_deeply(
|
|||||||
"Bug 903443: pt-deadlock-logger parses the thread id incorrectly for MySQL 5.5",
|
"Bug 903443: pt-deadlock-logger parses the thread id incorrectly for MySQL 5.5",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# #############################################################################
|
||||||
|
# https://bugs.launchpad.net/percona-toolkit/+bug/1082104
|
||||||
|
# pt-deadlock-logger problem when the user have a dash in the name
|
||||||
|
# #############################################################################
|
||||||
|
|
||||||
|
$innodb_status_sample = load_file("t/pt-deadlock-logger/samples/bug_1082104.txt");
|
||||||
|
|
||||||
|
is_deeply(
|
||||||
|
pt_deadlock_logger::parse_deadlocks($innodb_status_sample),
|
||||||
|
{
|
||||||
|
'1' => {
|
||||||
|
db => 'test',
|
||||||
|
hostname => 'localhost',
|
||||||
|
id => 1,
|
||||||
|
idx => 'PRIMARY',
|
||||||
|
ip => '',
|
||||||
|
lock_mode => 'X',
|
||||||
|
lock_type => 'RECORD',
|
||||||
|
query => 'update a set movie_id=96 where id =2',
|
||||||
|
server => '',
|
||||||
|
tbl => 'a',
|
||||||
|
thread => '19',
|
||||||
|
ts => '2011-12-12T22:52:42',
|
||||||
|
txn_id => 0,
|
||||||
|
txn_time => '161',
|
||||||
|
user => 'ro-ot',
|
||||||
|
victim => 0,
|
||||||
|
wait_hold => 'w'
|
||||||
|
},
|
||||||
|
'2' => {
|
||||||
|
db => 'test',
|
||||||
|
hostname => 'localhost',
|
||||||
|
id => 2,
|
||||||
|
idx => 'PRIMARY',
|
||||||
|
ip => '',
|
||||||
|
lock_mode => 'X',
|
||||||
|
lock_type => 'RECORD',
|
||||||
|
query => 'update a set movie_id=98 where id =4',
|
||||||
|
server => '',
|
||||||
|
tbl => 'a',
|
||||||
|
thread => '18',
|
||||||
|
ts => '2011-12-12T22:52:42',
|
||||||
|
txn_id => 0,
|
||||||
|
txn_time => '1026',
|
||||||
|
user => 'ro-ot',
|
||||||
|
victim => 1,
|
||||||
|
wait_hold => 'w'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Bug 1082104: pt-deadlock-logger shows host as user when the username has a dash in the name",
|
||||||
|
);
|
||||||
|
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
# Done.
|
# Done.
|
||||||
# #############################################################################
|
# #############################################################################
|
||||||
|
done_testing;
|
||||||
exit;
|
exit;
|
||||||
|
Reference in New Issue
Block a user