From 0e62abd9980218a3c7f3e16d12757a31784540ae Mon Sep 17 00:00:00 2001 From: krad Date: Thu, 5 Mar 2015 14:53:11 -0800 Subject: [PATCH] Group user network errors by error code. Summary: Currently the code, reports network errors across all clients by error code but reports the total network error experienced by each client. It will be beneficial to group network errors per user as well by the error code. Test Plan: Run newly added unit test Reviewers: ebergen, pengt Reviewed By: pengt --- .../connection_net_errors_stats_test.inc | 55 ++++++++ .../include/get_user_net_error_stats.inc | 54 ++++++++ .../r/connection_net_errors_stats.result | 130 +++++++++++++++++- mysql-test/r/information_schema.result | 9 +- mysql-test/r/user_stats_commands.result | 18 ++- .../suite/funcs_1/r/is_columns_is.result | 70 ++++++---- mysql-test/t/connection_net_errors_stats.test | 83 +++++------ sql/sql_connect.cc | 29 +++- sql/structs.h | 12 +- sql/table_stats.cc | 9 +- 10 files changed, 385 insertions(+), 84 deletions(-) create mode 100644 mysql-test/include/connection_net_errors_stats_test.inc create mode 100644 mysql-test/include/get_user_net_error_stats.inc diff --git a/mysql-test/include/connection_net_errors_stats_test.inc b/mysql-test/include/connection_net_errors_stats_test.inc new file mode 100644 index 000000000000..e371183481d7 --- /dev/null +++ b/mysql-test/include/connection_net_errors_stats_test.inc @@ -0,0 +1,55 @@ +--echo connection_net_errors_stats_test (user= $user, ER_NET_READ_ERROR= $ER_NET_READ_ERROR, ER_NET_READ_INTERRUPTED= $ER_NET_READ_INTERRUPTED) + +connect (conn_stat,127.0.0.1,root); + +--let $mode=baseline +--source include/get_user_net_error_stats.inc + +flush status; + +# Test ER_NET_READ_ERROR +if ($ER_NET_READ_ERROR == 1) +{ + connect (conn1,127.0.0.1,$user); + select "disconnect the connection"; + dirty_close conn1; + + --source include/wait_until_disconnected.inc +} + +# Test ER_NET_READ_INTERRUPTED +if ($ER_NET_READ_INTERRUPTED == 1) +{ + connect (conn2,127.0.0.1,$user); + set session wait_timeout = 1; + --real_sleep 2 + --error 2006, 2013 + # Why do we check for two error codes ? + # The client fails with very related error codes in different builds. The + # intention of this test is to test that the server stats reflect correctly. + # This is a known client side behavior and other tests like kill.test + # and wait_until_connected already does the same. + select "connection should have been closed by server"; + disconnect conn2; +} + +# We don't have a mechanism to trigger the following errors +# ER_NET_WRITE_INTERRUPTED +# ER_NET_ERROR_ON_WRITE +# ER_NET_PACKET_TOO_LARGE +# ER_NET_UNCOMPRESS_ERROR +# ER_NET_PACKETS_OUT_OF_ORDER + +--connection conn_stat + +# Verify the counters +show status like "Connection_errors_net_%"; + +--let $mode=compute +--source include/get_user_net_error_stats.inc + +# Run flush status +flush status; +show status like "Connection_errors_net_%"; + +disconnect conn_stat; diff --git a/mysql-test/include/get_user_net_error_stats.inc b/mysql-test/include/get_user_net_error_stats.inc new file mode 100644 index 000000000000..ccce662c93b7 --- /dev/null +++ b/mysql-test/include/get_user_net_error_stats.inc @@ -0,0 +1,54 @@ +let $select_errors_net_total = select errors_net_total from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_ERROR_ON_WRITE = select +errors_net_ER_NET_ERROR_ON_WRITE from information_schema.user_statistics where +user_name="$user"; +let $select_errors_net_ER_NET_PACKETS_OUT_OF_ORDER = select errors_net_ER_NET_PACKETS_OUT_OF_ORDER from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_PACKET_TOO_LARGE = select errors_net_ER_NET_PACKET_TOO_LARGE from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_READ_ERROR = select errors_net_ER_NET_READ_ERROR from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_READ_INTERRUPTED = select errors_net_ER_NET_READ_INTERRUPTED from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_UNCOMPRESS_ERROR = select errors_net_ER_NET_UNCOMPRESS_ERROR from information_schema.user_statistics where user_name="$user"; +let $select_errors_net_ER_NET_WRITE_INTERRUPTED = select errors_net_ER_NET_WRITE_INTERRUPTED from information_schema.user_statistics where user_name="$user"; + +if ($mode == 'baseline') +{ + --let $base_errors_net_total = query_get_value($select_errors_net_total, errors_net_total, 1) + --let $base_errors_net_ER_NET_ERROR_ON_WRITE = query_get_value($select_errors_net_ER_NET_ERROR_ON_WRITE, errors_net_ER_NET_ERROR_ON_WRITE, 1) + --let $base_errors_net_ER_NET_PACKETS_OUT_OF_ORDER = query_get_value($select_errors_net_ER_NET_PACKETS_OUT_OF_ORDER, errors_net_ER_NET_PACKETS_OUT_OF_ORDER, 1) + --let $base_errors_net_ER_NET_PACKET_TOO_LARGE = query_get_value($select_errors_net_ER_NET_PACKET_TOO_LARGE, errors_net_ER_NET_PACKET_TOO_LARGE, 1) + --let $base_errors_net_ER_NET_READ_ERROR = query_get_value($select_errors_net_ER_NET_READ_ERROR, errors_net_ER_NET_READ_ERROR, 1) + --let $base_errors_net_ER_NET_READ_INTERRUPTED = query_get_value($select_errors_net_ER_NET_READ_INTERRUPTED, errors_net_ER_NET_READ_INTERRUPTED, 1) + --let $base_errors_net_ER_NET_UNCOMPRESS_ERROR = query_get_value($select_errors_net_ER_NET_UNCOMPRESS_ERROR, errors_net_ER_NET_UNCOMPRESS_ERROR, 1) + --let $base_errors_net_ER_NET_WRITE_INTERRUPTED = query_get_value($select_errors_net_ER_NET_WRITE_INTERRUPTED, errors_net_ER_NET_WRITE_INTERRUPTED, 1) +} + +if ($mode == 'compute') +{ + --let $errors_net_total = query_get_value($select_errors_net_total, errors_net_total, 1) + --let $errors_net_ER_NET_ERROR_ON_WRITE = query_get_value($select_errors_net_ER_NET_ERROR_ON_WRITE, errors_net_ER_NET_ERROR_ON_WRITE, 1) + --let $errors_net_ER_NET_PACKETS_OUT_OF_ORDER = query_get_value($select_errors_net_ER_NET_PACKETS_OUT_OF_ORDER, errors_net_ER_NET_PACKETS_OUT_OF_ORDER, 1) + --let $errors_net_ER_NET_PACKET_TOO_LARGE = query_get_value($select_errors_net_ER_NET_PACKET_TOO_LARGE, errors_net_ER_NET_PACKET_TOO_LARGE, 1) + --let $errors_net_ER_NET_READ_ERROR = query_get_value($select_errors_net_ER_NET_READ_ERROR, errors_net_ER_NET_READ_ERROR, 1) + --let $errors_net_ER_NET_READ_INTERRUPTED = query_get_value($select_errors_net_ER_NET_READ_INTERRUPTED, errors_net_ER_NET_READ_INTERRUPTED, 1) + --let $errors_net_ER_NET_UNCOMPRESS_ERROR = query_get_value($select_errors_net_ER_NET_UNCOMPRESS_ERROR, errors_net_ER_NET_UNCOMPRESS_ERROR, 1) + --let $errors_net_ER_NET_WRITE_INTERRUPTED = query_get_value($select_errors_net_ER_NET_WRITE_INTERRUPTED, errors_net_ER_NET_WRITE_INTERRUPTED, 1) + + --disable_query_log + eval select $errors_net_total - $base_errors_net_total into @errors_net_total; + eval select $errors_net_ER_NET_ERROR_ON_WRITE - $base_errors_net_ER_NET_ERROR_ON_WRITE into @errors_net_ER_NET_ERROR_ON_WRITE; + eval select $errors_net_ER_NET_PACKETS_OUT_OF_ORDER - $base_errors_net_ER_NET_PACKETS_OUT_OF_ORDER into @errors_net_ER_NET_PACKETS_OUT_OF_ORDER; + eval select $errors_net_ER_NET_PACKET_TOO_LARGE - $base_errors_net_ER_NET_PACKET_TOO_LARGE into @errors_net_ER_NET_PACKET_TOO_LARGE; + eval select $errors_net_ER_NET_READ_ERROR - $base_errors_net_ER_NET_READ_ERROR into @errors_net_ER_NET_READ_ERROR; + eval select $errors_net_ER_NET_READ_INTERRUPTED - $base_errors_net_ER_NET_READ_INTERRUPTED into @errors_net_ER_NET_READ_INTERRUPTED; + eval select $errors_net_ER_NET_UNCOMPRESS_ERROR - $base_errors_net_ER_NET_UNCOMPRESS_ERROR into @errors_net_ER_NET_UNCOMPRESS_ERROR; + eval select $errors_net_ER_NET_WRITE_INTERRUPTED - $base_errors_net_ER_NET_WRITE_INTERRUPTED into @errors_net_ER_NET_WRITE_INTERRUPTED; + + --enable_query_log + select @errors_net_total; + select @errors_net_ER_NET_ERROR_ON_WRITE; + select @errors_net_ER_NET_PACKETS_OUT_OF_ORDER; + select @errors_net_ER_NET_PACKET_TOO_LARGE; + select @errors_net_ER_NET_READ_ERROR; + select @errors_net_ER_NET_READ_INTERRUPTED; + select @errors_net_ER_NET_UNCOMPRESS_ERROR; + select @errors_net_ER_NET_WRITE_INTERRUPTED; +} diff --git a/mysql-test/r/connection_net_errors_stats.result b/mysql-test/r/connection_net_errors_stats.result index 0503e9d80e77..3f3637795fb1 100644 --- a/mysql-test/r/connection_net_errors_stats.result +++ b/mysql-test/r/connection_net_errors_stats.result @@ -1,3 +1,8 @@ +create user mysqltest_1@localhost; +select "Init stats for user mysqltest_1"; +Init stats for user mysqltest_1 +Init stats for user mysqltest_1 +connection_net_errors_stats_test (user= root, ER_NET_READ_ERROR= 1, ER_NET_READ_INTERRUPTED= 1) flush status; select "disconnect the connection"; disconnect the connection @@ -14,9 +19,30 @@ Connection_errors_net_ER_NET_READ_ERROR 1 Connection_errors_net_ER_NET_READ_INTERRUPTED 1 Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 -select @errors_networking; -@errors_networking +select @errors_net_total; +@errors_net_total 2 +select @errors_net_ER_NET_ERROR_ON_WRITE; +@errors_net_ER_NET_ERROR_ON_WRITE +0 +select @errors_net_ER_NET_PACKETS_OUT_OF_ORDER; +@errors_net_ER_NET_PACKETS_OUT_OF_ORDER +0 +select @errors_net_ER_NET_PACKET_TOO_LARGE; +@errors_net_ER_NET_PACKET_TOO_LARGE +0 +select @errors_net_ER_NET_READ_ERROR; +@errors_net_ER_NET_READ_ERROR +1 +select @errors_net_ER_NET_READ_INTERRUPTED; +@errors_net_ER_NET_READ_INTERRUPTED +1 +select @errors_net_ER_NET_UNCOMPRESS_ERROR; +@errors_net_ER_NET_UNCOMPRESS_ERROR +0 +select @errors_net_ER_NET_WRITE_INTERRUPTED; +@errors_net_ER_NET_WRITE_INTERRUPTED +0 flush status; show status like "Connection_errors_net_%"; Variable_name Value @@ -27,3 +53,103 @@ Connection_errors_net_ER_NET_READ_ERROR 0 Connection_errors_net_ER_NET_READ_INTERRUPTED 0 Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 +connection_net_errors_stats_test (user= mysqltest_1, ER_NET_READ_ERROR= 1, ER_NET_READ_INTERRUPTED= 1) +flush status; +select "disconnect the connection"; +disconnect the connection +disconnect the connection +set session wait_timeout = 1; +select "connection should have been closed by server"; +Got one of the listed errors +show status like "Connection_errors_net_%"; +Variable_name Value +Connection_errors_net_ER_NET_ERROR_ON_WRITE 0 +Connection_errors_net_ER_NET_PACKETS_OUT_OF_ORDER 0 +Connection_errors_net_ER_NET_PACKET_TOO_LARGE 0 +Connection_errors_net_ER_NET_READ_ERROR 1 +Connection_errors_net_ER_NET_READ_INTERRUPTED 1 +Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 +Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 +select @errors_net_total; +@errors_net_total +2 +select @errors_net_ER_NET_ERROR_ON_WRITE; +@errors_net_ER_NET_ERROR_ON_WRITE +0 +select @errors_net_ER_NET_PACKETS_OUT_OF_ORDER; +@errors_net_ER_NET_PACKETS_OUT_OF_ORDER +0 +select @errors_net_ER_NET_PACKET_TOO_LARGE; +@errors_net_ER_NET_PACKET_TOO_LARGE +0 +select @errors_net_ER_NET_READ_ERROR; +@errors_net_ER_NET_READ_ERROR +1 +select @errors_net_ER_NET_READ_INTERRUPTED; +@errors_net_ER_NET_READ_INTERRUPTED +1 +select @errors_net_ER_NET_UNCOMPRESS_ERROR; +@errors_net_ER_NET_UNCOMPRESS_ERROR +0 +select @errors_net_ER_NET_WRITE_INTERRUPTED; +@errors_net_ER_NET_WRITE_INTERRUPTED +0 +flush status; +show status like "Connection_errors_net_%"; +Variable_name Value +Connection_errors_net_ER_NET_ERROR_ON_WRITE 0 +Connection_errors_net_ER_NET_PACKETS_OUT_OF_ORDER 0 +Connection_errors_net_ER_NET_PACKET_TOO_LARGE 0 +Connection_errors_net_ER_NET_READ_ERROR 0 +Connection_errors_net_ER_NET_READ_INTERRUPTED 0 +Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 +Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 +connection_net_errors_stats_test (user= mysqltest_1, ER_NET_READ_ERROR= 1, ER_NET_READ_INTERRUPTED= 0) +flush status; +select "disconnect the connection"; +disconnect the connection +disconnect the connection +show status like "Connection_errors_net_%"; +Variable_name Value +Connection_errors_net_ER_NET_ERROR_ON_WRITE 0 +Connection_errors_net_ER_NET_PACKETS_OUT_OF_ORDER 0 +Connection_errors_net_ER_NET_PACKET_TOO_LARGE 0 +Connection_errors_net_ER_NET_READ_ERROR 1 +Connection_errors_net_ER_NET_READ_INTERRUPTED 0 +Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 +Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 +select @errors_net_total; +@errors_net_total +1 +select @errors_net_ER_NET_ERROR_ON_WRITE; +@errors_net_ER_NET_ERROR_ON_WRITE +0 +select @errors_net_ER_NET_PACKETS_OUT_OF_ORDER; +@errors_net_ER_NET_PACKETS_OUT_OF_ORDER +0 +select @errors_net_ER_NET_PACKET_TOO_LARGE; +@errors_net_ER_NET_PACKET_TOO_LARGE +0 +select @errors_net_ER_NET_READ_ERROR; +@errors_net_ER_NET_READ_ERROR +1 +select @errors_net_ER_NET_READ_INTERRUPTED; +@errors_net_ER_NET_READ_INTERRUPTED +0 +select @errors_net_ER_NET_UNCOMPRESS_ERROR; +@errors_net_ER_NET_UNCOMPRESS_ERROR +0 +select @errors_net_ER_NET_WRITE_INTERRUPTED; +@errors_net_ER_NET_WRITE_INTERRUPTED +0 +flush status; +show status like "Connection_errors_net_%"; +Variable_name Value +Connection_errors_net_ER_NET_ERROR_ON_WRITE 0 +Connection_errors_net_ER_NET_PACKETS_OUT_OF_ORDER 0 +Connection_errors_net_ER_NET_PACKET_TOO_LARGE 0 +Connection_errors_net_ER_NET_READ_ERROR 0 +Connection_errors_net_ER_NET_READ_INTERRUPTED 0 +Connection_errors_net_ER_NET_UNCOMPRESS_ERROR 0 +Connection_errors_net_ER_NET_WRITE_INTERRUPTED 0 +drop user mysqltest_1@localhost; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index e6d08be17e48..0ee8df782f2e 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -2209,7 +2209,14 @@ DISK_READ_REQUESTS_SECONDARY bigint(21) NO 0 DISK_READ_SVC_USECS_SECONDARY bigint(21) NO 0 DISK_READ_WAIT_USECS_SECONDARY bigint(21) NO 0 ERRORS_ACCESS_DENIED bigint(21) NO 0 -ERRORS_NETWORKING bigint(21) NO 0 +ERRORS_NET_TOTAL bigint(21) NO 0 +ERRORS_NET_ER_NET_ERROR_ON_WRITE bigint(21) NO 0 +ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER bigint(21) NO 0 +ERRORS_NET_ER_NET_PACKET_TOO_LARGE bigint(21) NO 0 +ERRORS_net_ER_NET_READ_ERROR bigint(21) NO 0 +ERRORS_net_ER_NET_READ_INTERRUPTED bigint(21) NO 0 +ERRORS_net_ER_NET_UNCOMPRESS_ERROR bigint(21) NO 0 +ERRORS_net_ER_NET_WRITE_INTERRUPTED bigint(21) NO 0 ERRORS_TOTAL bigint(21) NO 0 MICROSECONDS_WALL bigint(21) NO 0 MICROSECONDS_DDL bigint(21) NO 0 diff --git a/mysql-test/r/user_stats_commands.result b/mysql-test/r/user_stats_commands.result index 017bab607359..4291b90643d5 100644 --- a/mysql-test/r/user_stats_commands.result +++ b/mysql-test/r/user_stats_commands.result @@ -160,7 +160,14 @@ DISK_READ_REQUESTS_SECONDARY bigint(21) NO 0 DISK_READ_SVC_USECS_SECONDARY bigint(21) NO 0 DISK_READ_WAIT_USECS_SECONDARY bigint(21) NO 0 ERRORS_ACCESS_DENIED bigint(21) NO 0 -ERRORS_NETWORKING bigint(21) NO 0 +ERRORS_NET_TOTAL bigint(21) NO 0 +ERRORS_NET_ER_NET_ERROR_ON_WRITE bigint(21) NO 0 +ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER bigint(21) NO 0 +ERRORS_NET_ER_NET_PACKET_TOO_LARGE bigint(21) NO 0 +ERRORS_net_ER_NET_READ_ERROR bigint(21) NO 0 +ERRORS_net_ER_NET_READ_INTERRUPTED bigint(21) NO 0 +ERRORS_net_ER_NET_UNCOMPRESS_ERROR bigint(21) NO 0 +ERRORS_net_ER_NET_WRITE_INTERRUPTED bigint(21) NO 0 ERRORS_TOTAL bigint(21) NO 0 MICROSECONDS_WALL bigint(21) NO 0 MICROSECONDS_DDL bigint(21) NO 0 @@ -225,7 +232,14 @@ USER_STATISTICS CREATE TEMPORARY TABLE `USER_STATISTICS` ( `DISK_READ_SVC_USECS_SECONDARY` bigint(21) NOT NULL DEFAULT '0', `DISK_READ_WAIT_USECS_SECONDARY` bigint(21) NOT NULL DEFAULT '0', `ERRORS_ACCESS_DENIED` bigint(21) NOT NULL DEFAULT '0', - `ERRORS_NETWORKING` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_NET_TOTAL` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_NET_ER_NET_ERROR_ON_WRITE` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_NET_ER_NET_PACKET_TOO_LARGE` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_net_ER_NET_READ_ERROR` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_net_ER_NET_READ_INTERRUPTED` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_net_ER_NET_UNCOMPRESS_ERROR` bigint(21) NOT NULL DEFAULT '0', + `ERRORS_net_ER_NET_WRITE_INTERRUPTED` bigint(21) NOT NULL DEFAULT '0', `ERRORS_TOTAL` bigint(21) NOT NULL DEFAULT '0', `MICROSECONDS_WALL` bigint(21) NOT NULL DEFAULT '0', `MICROSECONDS_DDL` bigint(21) NOT NULL DEFAULT '0', diff --git a/mysql-test/suite/funcs_1/r/is_columns_is.result b/mysql-test/suite/funcs_1/r/is_columns_is.result index 39ca68598f95..853e073e24b8 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is.result @@ -457,7 +457,7 @@ def information_schema USER_STATISTICS CONNECTIONS_CONCURRENT 14 0 NO int NULL N def information_schema USER_STATISTICS CONNECTIONS_DENIED_MAX_GLOBAL 15 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS CONNECTIONS_DENIED_MAX_USER 16 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS CONNECTIONS_LOST 17 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS CONNECTIONS_SSL_TOTAL 62 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS CONNECTIONS_SSL_TOTAL 69 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS CONNECTIONS_TOTAL 18 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS DISK_READ_BYTES 19 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS DISK_READ_BYTES_BLOB 23 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select @@ -476,32 +476,39 @@ def information_schema USER_STATISTICS DISK_READ_WAIT_USECS_BLOB 26 0 NO bigint def information_schema USER_STATISTICS DISK_READ_WAIT_USECS_PRIMARY 30 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS DISK_READ_WAIT_USECS_SECONDARY 34 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS ERRORS_ACCESS_DENIED 35 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ERRORS_NETWORKING 36 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ERRORS_TOTAL 37 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS GTID_UNSAFE_CREATE_DROP_TEMPORARY_TABLE_IN_TRANSACTION 60 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select -def information_schema USER_STATISTICS GTID_UNSAFE_CREATE_SELECT 59 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select -def information_schema USER_STATISTICS GTID_UNSAFE_NON_TRANSACTIONAL_TABLE 61 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select -def information_schema USER_STATISTICS MICROSECONDS_DDL 39 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_DELETE 40 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_HANDLER 41 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_INSERT 42 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_OTHER 43 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_SELECT 44 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_TRANSACTION 45 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_UPDATE 46 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS MICROSECONDS_WALL 38 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS QUERIES_EMPTY 47 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS QUERY_COMMENT_BYTES 48 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS RELAY_LOG_BYTES_WRITTEN 49 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_DELETED 50 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_FETCHED 51 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_INDEX_FIRST 55 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_INDEX_NEXT 56 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_INSERTED 52 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_READ 53 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS ROWS_UPDATED 54 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS TRANSACTIONS_COMMIT 57 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select -def information_schema USER_STATISTICS TRANSACTIONS_ROLLBACK 58 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_NET_ER_NET_ERROR_ON_WRITE 37 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER 38 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_NET_ER_NET_PACKET_TOO_LARGE 39 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_net_ER_NET_READ_ERROR 40 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_net_ER_NET_READ_INTERRUPTED 41 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_net_ER_NET_UNCOMPRESS_ERROR 42 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_net_ER_NET_WRITE_INTERRUPTED 43 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_NET_TOTAL 36 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ERRORS_TOTAL 44 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS GTID_UNSAFE_CREATE_DROP_TEMPORARY_TABLE_IN_TRANSACTION 67 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select +def information_schema USER_STATISTICS GTID_UNSAFE_CREATE_SELECT 66 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select +def information_schema USER_STATISTICS GTID_UNSAFE_NON_TRANSACTIONAL_TABLE 68 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(11) select +def information_schema USER_STATISTICS MICROSECONDS_DDL 46 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_DELETE 47 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_HANDLER 48 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_INSERT 49 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_OTHER 50 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_SELECT 51 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_TRANSACTION 52 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_UPDATE 53 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS MICROSECONDS_WALL 45 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS QUERIES_EMPTY 54 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS QUERY_COMMENT_BYTES 55 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS RELAY_LOG_BYTES_WRITTEN 56 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_DELETED 57 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_FETCHED 58 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_INDEX_FIRST 62 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_INDEX_NEXT 63 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_INSERTED 59 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_READ 60 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS ROWS_UPDATED 61 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS TRANSACTIONS_COMMIT 64 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select +def information_schema USER_STATISTICS TRANSACTIONS_ROLLBACK 65 0 NO bigint NULL NULL 19 0 NULL NULL NULL bigint(21) select def information_schema USER_STATISTICS USER_NAME 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select def information_schema VIEWS CHARACTER_SET_CLIENT 9 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) select def information_schema VIEWS CHECK_OPTION 5 NO varchar 8 24 NULL NULL NULL utf8 utf8_general_ci varchar(8) select @@ -1045,7 +1052,14 @@ NULL information_schema USER_STATISTICS DISK_READ_REQUESTS_SECONDARY bigint NULL NULL information_schema USER_STATISTICS DISK_READ_SVC_USECS_SECONDARY bigint NULL NULL NULL NULL bigint(21) NULL information_schema USER_STATISTICS DISK_READ_WAIT_USECS_SECONDARY bigint NULL NULL NULL NULL bigint(21) NULL information_schema USER_STATISTICS ERRORS_ACCESS_DENIED bigint NULL NULL NULL NULL bigint(21) -NULL information_schema USER_STATISTICS ERRORS_NETWORKING bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_NET_TOTAL bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_NET_ER_NET_ERROR_ON_WRITE bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_NET_ER_NET_PACKET_TOO_LARGE bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_net_ER_NET_READ_ERROR bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_net_ER_NET_READ_INTERRUPTED bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_net_ER_NET_UNCOMPRESS_ERROR bigint NULL NULL NULL NULL bigint(21) +NULL information_schema USER_STATISTICS ERRORS_net_ER_NET_WRITE_INTERRUPTED bigint NULL NULL NULL NULL bigint(21) NULL information_schema USER_STATISTICS ERRORS_TOTAL bigint NULL NULL NULL NULL bigint(21) NULL information_schema USER_STATISTICS MICROSECONDS_WALL bigint NULL NULL NULL NULL bigint(21) NULL information_schema USER_STATISTICS MICROSECONDS_DDL bigint NULL NULL NULL NULL bigint(21) diff --git a/mysql-test/t/connection_net_errors_stats.test b/mysql-test/t/connection_net_errors_stats.test index 86c0740ec659..97f098f59336 100644 --- a/mysql-test/t/connection_net_errors_stats.test +++ b/mysql-test/t/connection_net_errors_stats.test @@ -1,46 +1,37 @@ -# prep the environment for testing -let $select_errors_networking = select errors_networking from information_schema.user_statistics where user_name="root"; ---let $base_errors_networking_count = query_get_value($select_errors_networking, errors_networking, 1) -flush status; - -# Test ER_NET_READ_ERROR -connect (conn1,127.0.0.1,root); -select "disconnect the connection"; -dirty_close conn1; - ---source include/wait_until_disconnected.inc - -# Test ER_NET_READ_INTERRUPTED -connect (conn2,127.0.0.1,root); -set session wait_timeout = 1; ---real_sleep 2 ---error 2006, 2013 -# Why do we check for two error codes ? -# The client fails with very related error codes in different builds. The -# intention of this test is to test that the server stats reflect correctly. -# This is a known client side behavior and other tests like kill.test -# and wait_until_connected already does the same. -select "connection should have been closed by server"; - -# We don't have a mechanism to trigger the following errors -# ER_NET_WRITE_INTERRUPTED -# ER_NET_ERROR_ON_WRITE -# ER_NET_PACKET_TOO_LARGE -# ER_NET_UNCOMPRESS_ERROR -# ER_NET_PACKETS_OUT_OF_ORDER - -# Verify the counters -connect (conn3,127.0.0.1,root); -show status like "Connection_errors_net_%"; - ---disable_query_log ---let $errors_networking_count = query_get_value($select_errors_networking, errors_networking, 1) -eval select $errors_networking_count - $base_errors_networking_count into @errors_networking; ---enable_query_log -select @errors_networking; - -# Run flush status -flush status; -show status like "Connection_errors_net_%"; - -disconnect conn3; +create user mysqltest_1@localhost; + +# Hack: Create a connection so user statistics will be initialized +connect(conn_mysqltest_1, 127.0.0.1, mysqltest_1); +select "Init stats for user mysqltest_1"; +disconnect conn_mysqltest_1; + +# +# Run the test to simulate all network errors with root user +# +--let $ER_NET_READ_ERROR= 1 +--let $ER_NET_READ_INTERRUPTED= 1 +--let $user= root +--source include/connection_net_errors_stats_test.inc + +# +# Run the test to simulate all network errors for mysqltest_1 user +# +--let $ER_NET_READ_ERROR= 1 +--let $ER_NET_READ_INTERRUPTED= 1 +--let $user=mysqltest_1 +--source include/connection_net_errors_stats_test.inc + +# +# Run the test to simulate only subset of network errors on mysqltest_1 +# user +# +--let $ER_NET_READ_ERROR= 1 +--let $ER_NET_READ_INTERRUPTED= 0 +--let $user=mysqltest_1 +--source include/connection_net_errors_stats_test.inc + +# +# Cleanup +# +--connection default +drop user mysqltest_1@localhost; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 302d915b269b..4590054a26cd 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -939,36 +939,43 @@ void thd_update_net_stats(THD *thd) } USER_STATS *us= thd_get_user_stats(thd); - us->errors_networking.inc(); + us->errors_net_total.inc(); switch (net->last_errno) { case ER_NET_ERROR_ON_WRITE: statistic_increment(connection_errors_net_ER_NET_ERROR_ON_WRITE, &LOCK_status); + us->errors_net_ER_NET_ERROR_ON_WRITE.inc(); break; case ER_NET_PACKETS_OUT_OF_ORDER: statistic_increment(connection_errors_net_ER_NET_PACKETS_OUT_OF_ORDER, &LOCK_status); + us->errors_net_ER_NET_PACKETS_OUT_OF_ORDER.inc(); break; case ER_NET_PACKET_TOO_LARGE: statistic_increment(connection_errors_net_ER_NET_PACKET_TOO_LARGE, &LOCK_status); + us->errors_net_ER_NET_PACKET_TOO_LARGE.inc(); break; case ER_NET_READ_ERROR: statistic_increment(connection_errors_net_ER_NET_READ_ERROR, &LOCK_status); + us->errors_net_ER_NET_READ_ERROR.inc(); break; case ER_NET_READ_INTERRUPTED: statistic_increment(connection_errors_net_ER_NET_READ_INTERRUPTED, &LOCK_status); + us->errors_net_ER_NET_READ_INTERRUPTED.inc(); break; case ER_NET_UNCOMPRESS_ERROR: statistic_increment(connection_errors_net_ER_NET_UNCOMPRESS_ERROR, &LOCK_status); + us->errors_net_ER_NET_UNCOMPRESS_ERROR.inc(); break; case ER_NET_WRITE_INTERRUPTED: statistic_increment(connection_errors_net_ER_NET_WRITE_INTERRUPTED, &LOCK_status); + us->errors_net_ER_NET_WRITE_INTERRUPTED.inc(); break; } } @@ -1163,7 +1170,14 @@ void init_user_stats(USER_STATS *user_stats) user_stats->connections_total.clear(); user_stats->connections_ssl_total.clear(); user_stats->errors_access_denied.clear(); - user_stats->errors_networking.clear(); + user_stats->errors_net_total.clear(); + user_stats->errors_net_ER_NET_ERROR_ON_WRITE.clear(); + user_stats->errors_net_ER_NET_PACKETS_OUT_OF_ORDER.clear(); + user_stats->errors_net_ER_NET_PACKET_TOO_LARGE.clear(); + user_stats->errors_net_ER_NET_READ_ERROR.clear(); + user_stats->errors_net_ER_NET_READ_INTERRUPTED.clear(); + user_stats->errors_net_ER_NET_UNCOMPRESS_ERROR.clear(); + user_stats->errors_net_ER_NET_WRITE_INTERRUPTED.clear(); user_stats->errors_total.clear(); user_stats->microseconds_wall.clear(); user_stats->microseconds_ddl.clear(); @@ -1458,7 +1472,16 @@ fill_one_user_stats(TABLE *table, USER_CONN *uc, USER_STATS* us, us->io_perf_read_secondary.wait_time.load()), TRUE); table->field[f++]->store(us->errors_access_denied.load(), TRUE); - table->field[f++]->store(us->errors_networking.load(), TRUE); + table->field[f++]->store(us->errors_net_total.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_ERROR_ON_WRITE.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_PACKETS_OUT_OF_ORDER.load(), + TRUE); + table->field[f++]->store(us->errors_net_ER_NET_PACKET_TOO_LARGE.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_READ_ERROR.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_READ_INTERRUPTED.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_UNCOMPRESS_ERROR.load(), TRUE); + table->field[f++]->store(us->errors_net_ER_NET_WRITE_INTERRUPTED.load(), + TRUE); table->field[f++]->store(us->errors_total.load(), TRUE); table->field[f++]->store(us->microseconds_wall.load(), TRUE); table->field[f++]->store(us->microseconds_ddl.load(), TRUE); diff --git a/sql/structs.h b/sql/structs.h index 8bfcda54b739..ade3c2f93ec1 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -253,7 +253,17 @@ typedef struct st_user_stats { atomic_stat connections_total; // total conns created atomic_stat connections_ssl_total; // total ssl conns created atomic_stat errors_access_denied; // ..to table or db - atomic_stat errors_networking; // client networking errors + + /* networking errors */ + atomic_stat errors_net_total; + atomic_stat errors_net_ER_NET_ERROR_ON_WRITE; + atomic_stat errors_net_ER_NET_PACKETS_OUT_OF_ORDER; + atomic_stat errors_net_ER_NET_PACKET_TOO_LARGE; + atomic_stat errors_net_ER_NET_READ_ERROR; + atomic_stat errors_net_ER_NET_READ_INTERRUPTED; + atomic_stat errors_net_ER_NET_UNCOMPRESS_ERROR; + atomic_stat errors_net_ER_NET_WRITE_INTERRUPTED; + atomic_stat errors_total; atomic_stat microseconds_wall; atomic_stat microseconds_ddl; diff --git a/sql/table_stats.cc b/sql/table_stats.cc index 6560409e98e5..96346c1a15cd 100644 --- a/sql/table_stats.cc +++ b/sql/table_stats.cc @@ -813,7 +813,14 @@ ST_FIELD_INFO user_stats_fields_info[]= {"DISK_READ_SVC_USECS_SECONDARY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"DISK_READ_WAIT_USECS_SECONDARY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"ERRORS_ACCESS_DENIED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, - {"ERRORS_NETWORKING", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_NET_TOTAL", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_NET_ER_NET_ERROR_ON_WRITE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_NET_ER_NET_PACKETS_OUT_OF_ORDER", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_NET_ER_NET_PACKET_TOO_LARGE", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_net_ER_NET_READ_ERROR", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_net_ER_NET_READ_INTERRUPTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_net_ER_NET_UNCOMPRESS_ERROR", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, + {"ERRORS_net_ER_NET_WRITE_INTERRUPTED", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"ERRORS_TOTAL", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"MICROSECONDS_WALL", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE}, {"MICROSECONDS_DDL", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 0, 0, SKIP_OPEN_TABLE},