mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-10-18 00:14:12 +00:00
Fix and test parser_error_packet() for non-SQL errors.
This commit is contained in:
@@ -3348,7 +3348,8 @@ sub _packet_from_server {
|
||||
}
|
||||
my $event;
|
||||
|
||||
if ( $session->{state} eq 'client_auth' ) {
|
||||
if ( $session->{state} eq 'client_auth'
|
||||
|| $session->{state} eq 'server_handshake' ) {
|
||||
PTDEBUG && _d('Connection failed');
|
||||
$event = {
|
||||
cmd => 'Admin',
|
||||
@@ -3727,9 +3728,17 @@ sub parse_error_packet {
|
||||
}
|
||||
my $errno = to_num(substr($data, 0, 4));
|
||||
my $marker = to_string(substr($data, 4, 2));
|
||||
return unless $marker eq '#';
|
||||
my $sqlstate = to_string(substr($data, 6, 10));
|
||||
my $message = to_string(substr($data, 16));
|
||||
my $sqlstate = '';
|
||||
my $message = '';
|
||||
if ( $marker eq '#' ) {
|
||||
$sqlstate = to_string(substr($data, 6, 10));
|
||||
$message = to_string(substr($data, 16));
|
||||
}
|
||||
else {
|
||||
$marker = '';
|
||||
$message = to_string(substr($data, 4));
|
||||
}
|
||||
return unless $message;
|
||||
my $pkt = {
|
||||
errno => $errno,
|
||||
sqlstate => $marker . $sqlstate,
|
||||
|
@@ -612,7 +612,8 @@ sub _packet_from_server {
|
||||
}
|
||||
my $event;
|
||||
|
||||
if ( $session->{state} eq 'client_auth' ) {
|
||||
if ( $session->{state} eq 'client_auth'
|
||||
|| $session->{state} eq 'server_handshake' ) {
|
||||
PTDEBUG && _d('Connection failed');
|
||||
$event = {
|
||||
cmd => 'Admin',
|
||||
@@ -1070,9 +1071,17 @@ sub parse_error_packet {
|
||||
}
|
||||
my $errno = to_num(substr($data, 0, 4));
|
||||
my $marker = to_string(substr($data, 4, 2));
|
||||
return unless $marker eq '#';
|
||||
my $sqlstate = to_string(substr($data, 6, 10));
|
||||
my $message = to_string(substr($data, 16));
|
||||
my $sqlstate = '';
|
||||
my $message = '';
|
||||
if ( $marker eq '#' ) {
|
||||
$sqlstate = to_string(substr($data, 6, 10));
|
||||
$message = to_string(substr($data, 16));
|
||||
}
|
||||
else {
|
||||
$marker = '';
|
||||
$message = to_string(substr($data, 4));
|
||||
}
|
||||
return unless $message;
|
||||
my $pkt = {
|
||||
errno => $errno,
|
||||
sqlstate => $marker . $sqlstate,
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 72;
|
||||
use Test::More;
|
||||
|
||||
use MySQLProtocolParser;
|
||||
use TcpdumpParser;
|
||||
@@ -1700,7 +1700,54 @@ test_protocol_parser(
|
||||
],
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Bug 1103045: pt-query-digest fails to parse non-SQL errors
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1103045
|
||||
# #############################################################################
|
||||
|
||||
$protocol = new MySQLProtocolParser(
|
||||
server => '127.0.0.1',
|
||||
port => '12345',
|
||||
);
|
||||
test_protocol_parser(
|
||||
parser => $tcpdump,
|
||||
protocol => $protocol,
|
||||
file => "$sample/tcpdump043.txt",
|
||||
desc => 'Bad connection',
|
||||
result =>
|
||||
[
|
||||
{
|
||||
Error_msg => 'Got packets out of order',
|
||||
Error_no => 1156,
|
||||
No_good_index_used => 'No',
|
||||
No_index_used => 'No',
|
||||
Query_time => '3.536306',
|
||||
Rows_affected => 0,
|
||||
Thread_id => 27,
|
||||
Warning_count => 0,
|
||||
arg => 'administrator command: Connect',
|
||||
bytes => 30,
|
||||
cmd => 'Admin',
|
||||
db => undef,
|
||||
host => '127.0.0.1',
|
||||
ip => '127.0.0.1',
|
||||
port => '62160',
|
||||
pos_in_log => undef,
|
||||
ts => '130124 13:03:28.672987',
|
||||
user => undef,
|
||||
}
|
||||
],
|
||||
);
|
||||
|
||||
test_protocol_parser(
|
||||
parser => $tcpdump,
|
||||
protocol => $protocol,
|
||||
file => "$sample/tcpdump042.txt",
|
||||
desc => 'Client went away during handshake',
|
||||
result => [],
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
||||
done_testing;
|
||||
|
59
t/lib/samples/tcpdump/tcpdump042.txt
Normal file
59
t/lib/samples/tcpdump/tcpdump042.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
2013-01-24 12:55:38.276006 IP 127.0.0.1.62133 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0040 b290 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2b5 3039 58cf 8e7c 0000 0000
|
||||
0x0020: b002 ffff fe34 0000 0204 3fd8 0103 0303
|
||||
0x0030: 0101 080a 0580 fe1f 0000 0000 0402 0000
|
||||
2013-01-24 12:55:38.276053 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 0
|
||||
0x0000: 4500 0040 65de 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 dad0 58cf 8e7d
|
||||
0x0020: b012 ffff fe34 0000 0204 3fd8 0103 0303
|
||||
0x0030: 0101 080a 0580 fe1f 0580 fe1f 0402 0000
|
||||
2013-01-24 12:55:38.276062 IP 127.0.0.1.62133 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 2fb2 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2b5 3039 58cf 8e7d 1c49 dad1
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0580 fe1f
|
||||
0x0030: 0580 fe1f
|
||||
2013-01-24 12:55:38.276071 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 0
|
||||
0x0000: 4500 0034 4cba 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 dad1 58cf 8e7d
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0580 fe1f
|
||||
0x0030: 0580 fe1f
|
||||
2013-01-24 12:55:38.278813 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 60
|
||||
0x0000: 4508 0070 e5f9 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 dad1 58cf 8e7d
|
||||
0x0020: 8018 ffff fe64 0000 0101 080a 0580 fe1f
|
||||
0x0030: 0580 fe1f 3800 0000 0a35 2e31 2e35 332d
|
||||
0x0040: 6c6f 6700 1800 0000 6553 5179 332d 2925
|
||||
0x0050: 00ff f708 0200 0000 0000 0000 0000 0000
|
||||
0x0060: 0000 007b 6154 5f62 4d3d 274a 2269 6900
|
||||
2013-01-24 12:55:38.278831 IP 127.0.0.1.62133 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 0cb3 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2b5 3039 58cf 8e7d 1c49 db0d
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0580 fe1f
|
||||
0x0030: 0580 fe1f
|
||||
2013-01-24 12:55:48.274417 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 0
|
||||
0x0000: 4508 0034 5ba9 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 db0d 58cf 8e7d
|
||||
0x0020: 8011 ffff fe28 0000 0101 080a 0580 fe83
|
||||
0x0030: 0580 fe1f
|
||||
2013-01-24 12:55:48.274515 IP 127.0.0.1.62133 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 4493 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2b5 3039 58cf 8e7d 1c49 db0e
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0580 fe83
|
||||
0x0030: 0580 fe83
|
||||
2013-01-24 12:55:48.274541 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 0
|
||||
0x0000: 4508 0034 cfea 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 db0e 58cf 8e7d
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0580 fe83
|
||||
0x0030: 0580 fe83
|
||||
2013-01-24 12:55:48.274741 IP 127.0.0.1.62133 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 6e98 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2b5 3039 58cf 8e7d 1c49 db0e
|
||||
0x0020: 8011 ffff fe28 0000 0101 080a 0580 fe83
|
||||
0x0030: 0580 fe83
|
||||
2013-01-24 12:55:48.274836 IP 127.0.0.1.12345 > 127.0.0.1.62133: tcp 0
|
||||
0x0000: 4508 0034 bcc4 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2b5 1c49 db0e 58cf 8e7e
|
||||
0x0020: 8010 fffe fe28 0000 0101 080a 0580 fe83
|
||||
0x0030: 0580 fe83
|
||||
|
82
t/lib/samples/tcpdump/tcpdump043.txt
Normal file
82
t/lib/samples/tcpdump/tcpdump043.txt
Normal file
@@ -0,0 +1,82 @@
|
||||
2013-01-24 13:03:25.136681 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0040 ea0e 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d49 0000 0000
|
||||
0x0020: b002 ffff fe34 0000 0204 3fd8 0103 0303
|
||||
0x0030: 0101 080a 0581 1055 0000 0000 0402 0000
|
||||
2013-01-24 13:03:25.136728 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4500 0040 dc6f 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 6881 ad71 3d4a
|
||||
0x0020: b012 ffff fe34 0000 0204 3fd8 0103 0303
|
||||
0x0030: 0101 080a 0581 1055 0581 1055 0402 0000
|
||||
2013-01-24 13:03:25.136737 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 0e53 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d4a 7d01 6882
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1055
|
||||
0x0030: 0581 1055
|
||||
2013-01-24 13:03:25.136746 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4500 0034 f54e 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 6882 ad71 3d4a
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1055
|
||||
0x0030: 0581 1055
|
||||
2013-01-24 13:03:25.146062 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 60
|
||||
0x0000: 4508 0070 6334 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 6882 ad71 3d4a
|
||||
0x0020: 8018 ffff fe64 0000 0101 080a 0581 1055
|
||||
0x0030: 0581 1055 3800 0000 0a35 2e31 2e35 332d
|
||||
0x0040: 6c6f 6700 1b00 0000 4d34 5946 3267 3260
|
||||
0x0050: 00ff f708 0200 0000 0000 0000 0000 0000
|
||||
0x0060: 0000 006c 225e 3633 3a6c 3048 5863 6800
|
||||
2013-01-24 13:03:25.146080 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 3e79 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d4a 7d01 68be
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1055
|
||||
0x0030: 0581 1055
|
||||
2013-01-24 13:03:28.672802 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 15
|
||||
0x0000: 4510 0043 145a 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d4a 7d01 68be
|
||||
0x0020: 8018 ffff fe37 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1055 6865 6c6c 6f2c 2077 6f72 6c64
|
||||
0x0040: 210d 0a
|
||||
2013-01-24 13:03:28.672856 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4508 0034 b07b 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 68be ad71 3d59
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.672987 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 31
|
||||
0x0000: 4508 0053 6336 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 68be ad71 3d59
|
||||
0x0020: 8018 ffff fe47 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079 1b00 0001 ff84 0447 6f74 2070
|
||||
0x0040: 6163 6b65 7473 206f 7574 206f 6620 6f72
|
||||
0x0050: 6465 72
|
||||
2013-01-24 13:03:28.673017 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 fb76 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d59 7d01 68dd
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.673103 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4508 0034 ae21 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 68dd ad71 3d59
|
||||
0x0020: 8011 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.673139 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 d821 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d59 7d01 68de
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.673156 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4508 0034 ab2e 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 68de ad71 3d59
|
||||
0x0020: 8010 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.673444 IP 127.0.0.1.62160 > 127.0.0.1.12345: tcp 0
|
||||
0x0000: 4510 0034 e03d 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 f2d0 3039 ad71 3d59 7d01 68de
|
||||
0x0020: 8011 ffff fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
2013-01-24 13:03:28.673464 IP 127.0.0.1.12345 > 127.0.0.1.62160: tcp 0
|
||||
0x0000: 4508 0034 b22d 4000 4006 0000 7f00 0001
|
||||
0x0010: 7f00 0001 3039 f2d0 7d01 68de ad71 3d5a
|
||||
0x0020: 8010 fffe fe28 0000 0101 080a 0581 1079
|
||||
0x0030: 0581 1079
|
||||
|
@@ -9,7 +9,7 @@ BEGIN {
|
||||
use strict;
|
||||
use warnings FATAL => 'all';
|
||||
use English qw(-no_match_vars);
|
||||
use Test::More tests => 6;
|
||||
use Test::More;
|
||||
|
||||
use PerconaTest;
|
||||
|
||||
@@ -76,7 +76,21 @@ ok(
|
||||
'Analysis for tcpdump017 with microsecond timestamps (issue 398)'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Bug 1103045: pt-query-digest fails to parse non-SQL errors
|
||||
# https://bugs.launchpad.net/percona-toolkit/+bug/1103045
|
||||
# #############################################################################
|
||||
ok(
|
||||
no_diff(
|
||||
sub { pt_query_digest::main(@args, $sample.'tcpdump043.txt',
|
||||
'--report-format', 'header,query_report,profile',
|
||||
qw(--watch-server 127.0.0.1:12345)) },
|
||||
"t/pt-query-digest/samples/tcpdump043_report.txt"
|
||||
),
|
||||
'Analysis for tcpdump043 with connection error (bug 1103045)'
|
||||
);
|
||||
|
||||
# #############################################################################
|
||||
# Done.
|
||||
# #############################################################################
|
||||
exit;
|
||||
done_testing;
|
||||
|
41
t/pt-query-digest/samples/tcpdump043_report.txt
Normal file
41
t/pt-query-digest/samples/tcpdump043_report.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
# Overall: 1 total, 1 unique, 0 QPS, 0x concurrency ______________________
|
||||
# Time range: all events occurred at 2013-01-24 13:03:28.672987
|
||||
# Attribute total min max avg 95% stddev median
|
||||
# ============ ======= ======= ======= ======= ======= ======= =======
|
||||
# Exec time 4s 4s 4s 4s 4s 0 4s
|
||||
# Rows affecte 0 0 0 0 0 0 0
|
||||
# Query size 30 30 30 30 30 0 30
|
||||
# Warning coun 0 0 0 0 0 0 0
|
||||
|
||||
# Query 1: 0 QPS, 0x concurrency, ID 0x5D51E5F01B88B79E at byte 0 ________
|
||||
# This item is included in the report because it matches --limit.
|
||||
# Scores: Apdex = 0.50 [1.0]*, V/M = 0.00
|
||||
# Query_time sparkline: | ^ |
|
||||
# Time range: all events occurred at 2013-01-24 13:03:28.672987
|
||||
# Attribute pct total min max avg 95% stddev median
|
||||
# ============ === ======= ======= ======= ======= ======= ======= =======
|
||||
# Count 100 1
|
||||
# Exec time 100 4s 4s 4s 4s 4s 0 4s
|
||||
# Rows affecte 0 0 0 0 0 0 0 0
|
||||
# Query size 100 30 30 30 30 30 0 30
|
||||
# Warning coun 0 0 0 0 0 0 0 0
|
||||
# String:
|
||||
# Error msg Got packets out of order
|
||||
# Errors 1156
|
||||
# Hosts 127.0.0.1
|
||||
# Query_time distribution
|
||||
# 1us
|
||||
# 10us
|
||||
# 100us
|
||||
# 1ms
|
||||
# 10ms
|
||||
# 100ms
|
||||
# 1s ################################################################
|
||||
# 10s+
|
||||
administrator command: Connect\G
|
||||
|
||||
# Profile
|
||||
# Rank Query ID Response time Calls R/Call Apdx V/M Item
|
||||
# ==== ================== ============= ===== ====== ==== ===== ==========
|
||||
# 1 0x5D51E5F01B88B79E 3.5363 100.0% 1 3.5363 0.50 0.00 ADMIN CONNECT
|
Reference in New Issue
Block a user