SlowLogParser leaved host empty when --skip-name-resolve was on. Now uses IP if empty - 1262456

This commit is contained in:
Frank Cizmich
2014-09-08 19:00:40 -03:00
parent f0a0a8f737
commit 5e3eaa6c73
19 changed files with 56 additions and 46 deletions

View File

@@ -2845,6 +2845,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
@@ -2857,6 +2858,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;

View File

@@ -5039,6 +5039,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
@@ -5051,6 +5052,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;

View File

@@ -1629,6 +1629,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
@@ -1641,6 +1642,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;

View File

@@ -6610,6 +6610,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;
@@ -6622,6 +6623,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
if ( $thread_id ) {
push @properties, 'Thread_id', $thread_id;

View File

@@ -541,7 +541,7 @@ sub no_diff {
`cat $expected_output | sed $sed_args > /tmp/pt-test-outfile-trf`;
$expected_output = "/tmp/pt-test-outfile-trf";
}
die("entre");
# Determine cmd type and run it.
if ( ref $cmd eq 'CODE' ) {
output($cmd, file => $tmp_file);

View File

@@ -162,6 +162,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
# 5.6 has the thread id on the User@Host line
if ( $thread_id ) {
@@ -177,6 +178,7 @@ sub parse_event {
&& ( my ( $user, $host, $ip, $thread_id ) = $line =~ m/$slow_log_uh_line/o )
) {
PTDEBUG && _d("Got user, host, ip", $user, $host, $ip);
$host ||= $ip; # sometimes host is missing when using skip-name-resolve (LP #issue 1262456)
push @properties, 'user', $user, 'host', $host, 'ip', $ip;
# 5.6 has the thread id on the User@Host line
if ( $thread_id ) {

View File

@@ -587,7 +587,7 @@ test_log_parser(
'ip' => '1.2.3.8',
'arg' => 'administrator command: Quit',
'Thread_id' => '5',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.000002',
@@ -602,7 +602,7 @@ test_log_parser(
'ip' => '1.2.3.8',
arg => 'SET NAMES utf8',
'Thread_id' => '6',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.000899',
@@ -616,7 +616,7 @@ test_log_parser(
'arg' => 'SELECT MIN(id),MAX(id) FROM tbl',
'ip' => '1.2.3.8',
'Thread_id' => '6',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.018799',
@@ -664,7 +664,7 @@ test_log_parser(
'arg' => 'administrator command: Quit',
'ip' => '1.2.3.8',
'Thread_id' => '5',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.000002',
@@ -679,7 +679,7 @@ test_log_parser(
'ip' => '1.2.3.8',
arg => 'SET NAMES utf8',
'Thread_id' => '6',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.000899',
@@ -694,7 +694,7 @@ test_log_parser(
'arg' => 'administrator command: Quit',
'ip' => '1.2.3.8',
'Thread_id' => '7',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.018799',
@@ -709,7 +709,7 @@ test_log_parser(
'ip' => '1.2.3.8',
arg => 'SET NAMES utf8',
'Thread_id' => '9',
'host' => '',
'host' => '1.2.3.8',
'Rows_examined' => '0',
'user' => 'meow',
'Query_time' => '0.000899',
@@ -731,7 +731,7 @@ test_log_parser(
'arg' => 'SET autocommit=1',
'ip' => '10.1.250.19',
'Thread_id' => '39387',
'host' => '',
'host' => '10.1.250.19',
'Rows_examined' => '0',
'user' => 'sabapp',
'Query_time' => '0.000018',
@@ -745,7 +745,7 @@ test_log_parser(
'arg' => 'SET autocommit=1',
'ip' => '10.1.250.19',
'Thread_id' => '39387',
'host' => '',
'host' => '10.1.250.19',
'Rows_examined' => '0',
'user' => 'sabapp',
'Query_time' => '0.000018',
@@ -769,7 +769,7 @@ test_log_parser(
'arg' => 'SET autocommit=1',
'ip' => '10.1.250.19',
'Thread_id' => '39796',
'host' => '',
'host' => '10.1.250.19',
'pos_in_log' => '0',
'Rows_examined' => '0',
'user' => 'foo_app',
@@ -785,7 +785,7 @@ test_log_parser(
'ip' => '10.1.12.201',
'ts' => '081127 8:51:20',
'Thread_id' => '39947',
'host' => '',
'host' => '10.1.12.201',
'pos_in_log' => '174',
'Rows_examined' => '226',
'Query_time' => '0.149435',
@@ -800,7 +800,7 @@ test_log_parser(
'ip' => '10.1.12.201',
'ts' => '081127 8:51:21',
'Thread_id' => '39947',
'host' => '',
'host' => '10.1.12.201',
'pos_in_log' => '385',
'Rows_examined' => '0',
'Query_time' => '0.000005',
@@ -815,7 +815,7 @@ test_log_parser(
'arg' => 'SET autocommit=0',
'ip' => '10.1.250.19',
'Thread_id' => '39796',
'host' => '',
'host' => '10.1.250.19',
'pos_in_log' => '600',
'Rows_examined' => '0',
'user' => 'foo_app',
@@ -829,7 +829,7 @@ test_log_parser(
'arg' => 'commit',
'ip' => '10.1.250.19',
'Thread_id' => '39796',
'host' => '',
'host' => '10.1.250.19',
'pos_in_log' => '782',
'Rows_examined' => '0',
'user' => 'foo_app',
@@ -965,7 +965,7 @@ test_log_parser(
Thread_id => '5',
arg => 'administrator command: Quit',
cmd => 'Admin',
host => '',
host => '1.2.3.8',
ip => '1.2.3.8',
pos_in_log => '0',
user => 'meow',
@@ -980,7 +980,7 @@ test_log_parser(
arg => 'SET NAMES utf8',
cmd => 'Query',
db => 'db',
host => '',
host => '1.2.3.8',
ip => '1.2.3.8',
pos_in_log => '221',
user => 'meow',
@@ -995,7 +995,7 @@ test_log_parser(
arg => 'administrator command: Quit',
cmd => 'Admin',
db => 'db2',
host => '',
host => '1.2.3.8',
ip => '1.2.3.8',
pos_in_log => '435',
user => 'meow',
@@ -1184,7 +1184,7 @@ test_log_parser(
arg => 'SELECT missing_a_schema_above from crash_me',
bytes => 43,
cmd => 'Query',
host => '',
host => '10.1.12.30',
ip => '10.1.12.30',
pos_in_log => '0',
ts => '081126 13:08:25',
@@ -1319,7 +1319,7 @@ test_log_parser(
Last_errno => 0,
Killed => 0,
db => 'test_db',
host => '',
host => '127.0.0.1',
Schema => 'test_db',
ip => '127.0.0.1',
timestamp => '1111111111',
@@ -1340,7 +1340,7 @@ test_log_parser(
arg => 'update t set b = b + 30 where user_id=1',
bytes => 39,
cmd => 'Query',
host => '',
host => '127.0.0.1',
ip => '127.0.0.1',
pos_in_log => 596,
timestamp => '2222222222',

View File

@@ -12,7 +12,7 @@
# Query size 43 31 31 31 31 31 0 31
# String:
# Databases db2
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us
@@ -42,7 +42,7 @@ SELECT MIN(id),MAX(id) FROM tbl\G
# Query size 19 14 14 14 14 14 0 14
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us
@@ -68,7 +68,7 @@ SET NAMES utf8\G
# Query size 37 27 27 27 27 27 0 27
# String:
# Databases db1
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################################################

View File

@@ -12,7 +12,7 @@
# Query size 65 54 27 27 27 27 0 27
# String:
# Databases db1 (1/50%), db2 (1/50%)
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################################################
@@ -38,7 +38,7 @@ administrator command: Quit\G
# Query size 34 28 14 14 14 14 0 14
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us

View File

@@ -13,7 +13,7 @@
# Query size 14 11 11 11 11 11 0 11
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Users mytopuser
# Query_time distribution
# 1us
@@ -40,7 +40,7 @@ SHOW STATUS\G
# Query size 42 32 16 16 16 16 0 16
# String:
# Databases abc
# Hosts
# Hosts 10.1.250.19
# Users foo_app
# Query_time distribution
# 1us
@@ -67,7 +67,7 @@ SET autocommit=0\G
# Query size 7 6 6 6 6 6 0 6
# String:
# Databases abc
# Hosts
# Hosts 10.1.250.19
# Users foo_app
# Query_time distribution
# 1us
@@ -94,7 +94,7 @@ commit\G
# Query size 35 27 27 27 27 27 0 27
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Users mytopuser
# Query_time distribution
# 1us ################################################################

View File

@@ -27,7 +27,7 @@
# Query size 14 11 11 11 11 11 0 11
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Users mytopuser
# Query_time distribution
# 1us
@@ -58,7 +58,7 @@ SHOW STATUS\G
# Query size 50 38 11 27 19 27 11.31 19
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Query_time distribution
# 1us ################################################################
# 10us

View File

@@ -13,7 +13,7 @@
# Query size 14 11 11 11 11 11 0 11
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Users mytopuser
# Query_time distribution
# 1us

View File

@@ -17,7 +17,7 @@
# Query size 50 38 11 27 19 27 11.31 19
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Query_time distribution
# 1us ################################################################
# 10us
@@ -43,7 +43,7 @@ mytopuser
# Query size 50 38 6 16 12.67 15.25 4.48 15.25
# String:
# Databases abc
# Hosts
# Hosts 10.1.250.19
# Query_time distribution
# 1us
# 10us ################################################################

View File

@@ -17,7 +17,7 @@
# Query size 50 38 11 27 19 27 11.31 19
# String:
# Databases test
# Hosts
# Hosts 10.1.12.201
# Query_time distribution
# 1us ################################################################
# 10us
@@ -43,7 +43,7 @@ mytopuser
# Query size 50 38 6 16 12.67 15.25 4.48 15.25
# String:
# Databases abc
# Hosts
# Hosts 10.1.250.19
# Query_time distribution
# 1us
# 10us ################################################################

View File

@@ -12,7 +12,7 @@
# Query size 79 54 27 27 27 27 0 27
# String:
# Databases db1 (1/50%), db2 (1/50%)
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################################################
@@ -38,7 +38,7 @@ administrator command: Quit\G
# Query size 20 14 14 14 14 14 0 14
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us

View File

@@ -15,7 +15,7 @@
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 72 14 31 24 30.19 6.95 26.08
# String:
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################################################

View File

@@ -15,7 +15,7 @@
# Query size 100 39 39 39 39 39 0 39
# String:
# Databases test_db
# Hosts
# Hosts 127.0.0.1
# Last errno 0
# Users root
# Query_time distribution
@@ -51,7 +51,7 @@ select b = b + 30 from t where user_id=1\G
# Query size 0 0 0 0 0 0 0 0
# String:
# Databases test_db
# Hosts
# Hosts 127.0.0.1
# Last errno 0
# Users root
# Query_time distribution

View File

@@ -15,7 +15,7 @@
# Rows examine 0 0 0 0 0 0 0 0
# Query size 100 82 14 27 20.50 26.08 6.12 26.08
# String:
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################

View File

@@ -12,7 +12,7 @@
# Query size 24 52 26 26 26 26 0 26
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us
@@ -41,7 +41,7 @@ insert `foo` values("bar")\G
# Query size 25 54 27 27 27 27 0 27
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us
@@ -70,7 +70,7 @@ replace `foo` values("bar")\G
# Query size 50 108 54 54 54 54 0 54
# String:
# Databases db
# Hosts
# Hosts 1.2.3.8
# Users meow
# Query_time distribution
# 1us ################################################################