Skip to content

Commit

Permalink
Port v5.1 IS.User_Stats to 5.6
Browse files Browse the repository at this point in the history
Summary:
Port of all of our 5.1 user stats diffs.

Table columns:
    USER_NAME
    // data stats
    BINLOG_BYTES_WRITTEN - number of bytes written to the binlo
    BYTES_RECEIVED, BYTES_SENT - number of network bytes received or sent
    // commands count
    COMMANDS_DDL - number of DDL commands
    COMMANDS_DELETE - number of DELETE and TRUNCATE commands
    COMMANDS_HANDLER - number of HANDLER
    COMMANDS_INSERT - number of INSERT, INSERT SELECT, LOAD and REPLACE commands
    COMMANDS_OTHER - number of other commands
    COMMANDS_SELECT - number of SELECT commands
    COMMANDS_TRANSACTION - number of BEGIN, COMMIT, ROLLBACK commands
    COMMANDS_UPDATE - number of UPDATE commands
    // connections
    CONNECTIONS_CONCURRENT - concurrent connections for this user
    CONNECTIONS_DENIED_MAX_GLOBAL - number of connections denied because
        the global connection limit was reached
    CONNECTIONS_DENIED_MAX_USER -number of connections denied because
        the per user limit was reached
    CONNECTIONS_LOST - number of connections lost rather than properly closed
    CONNECTIONS_TOTAL - total number of connections
    // io perf
    DISK_READ_BYTES
    DISK_READ_REQUESTS
    DISK_READ_SVC_USECS
    DISK_READ_WAIT_USECS
    DISK_READ_BYTES_BLOB
    DISK_READ_REQUESTS_BLOB
    DISK_READ_SVC_USECS_BLOB
    DISK_READ_WAIT_USECS_BLOB
    // error counts
    ERRORS_ACCESS_DENIED - number of access denied errors
    ERRORS_TOTAL
    // timers
    MICROSECONDS_WALL - number of wallclock seconds running commands
    MICROSECONDS_DDL
    MICROSECONDS_DELETE
    MICROSECONDS_HANDLER
    MICROSECONDS_INSERT
    MICROSECONDS_OTHER
    MICROSECONDS_SELECT
    MICROSECONDS_TRANSACTION
    MICROSECONDS_UPDATE
    // empty query
    QUERIES_EMPTY - number of queries that return 0 rows
    // row stats
    ROWS_DELETED - number of rows deleted
    ROWS_FETCHED - number of rows sent back to a user
    ROWS_INSERTED - number of rows inserted
    ROWS_READ - number of rows read from a table
    ROWS_UPDATED - number of rows updated
    ROWS_INDEX_FIRST
    ROWS_INDEX_NEXT
    // transaction stats
    TRANSACTIONS_COMMIT - number of commits, this includes auto-commit
    TRANSACTIONS_ROLLBACK number of rollbacks

Tests added:
    user_stats_bytes
    user_stats_max_conns
    user_stats_rows_primary
    user_stats_rows
    user_stats_commands
    user_stats_disk
    user_stats_errors
    user_stats_more
    user_stats_rows_fetched
    user_stats_rows_secondary
    user_stats_transactions
    rpl.rpl_user_stats_rows
    rpl.rpl_user_stats_bytes
Tests modified:
    information_schema
    sys_vars.max_user_connections_func
Test results changed:
    information_schema_db
    mysqlshow
    funcs_1.is_columns_is
    funcs_1.is_tables_is

Test Plan: mtr

Reviewers: steaphan

Reviewed By: steaphan
  • Loading branch information
Rongrong Zhong authored and Herman Lee committed Jan 24, 2017
1 parent f6ddb53 commit 4554e16
Show file tree
Hide file tree
Showing 60 changed files with 4,021 additions and 76 deletions.
2 changes: 2 additions & 0 deletions mysql-test/r/information_schema-big.result
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ TABLE_PRIVILEGES TABLE_SCHEMA
TABLE_STATISTICS TABLE_SCHEMA
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
USER_STATISTICS USER_NAME
VIEWS TABLE_SCHEMA
SELECT t.table_name, c1.column_name
FROM information_schema.tables t
Expand Down Expand Up @@ -100,4 +101,5 @@ TABLE_PRIVILEGES TABLE_SCHEMA
TABLE_STATISTICS TABLE_SCHEMA
TRIGGERS TRIGGER_SCHEMA
USER_PRIVILEGES GRANTEE
USER_STATISTICS USER_NAME
VIEWS TABLE_SCHEMA
91 changes: 90 additions & 1 deletion mysql-test/r/information_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ TABLE_PRIVILEGES
TABLE_STATISTICS
TRIGGERS
USER_PRIVILEGES
USER_STATISTICS
VIEWS
columns_priv
db
Expand Down Expand Up @@ -903,7 +904,7 @@ table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest')
AND table_name not like 'ndb%' AND table_name not like 'innodb_%'
GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 32
information_schema 33
mysql 25
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
Expand Down Expand Up @@ -1374,6 +1375,7 @@ TABLE_PRIVILEGES information_schema.TABLE_PRIVILEGES 1
TABLE_STATISTICS information_schema.TABLE_STATISTICS 1
TRIGGERS information_schema.TRIGGERS 1
USER_PRIVILEGES information_schema.USER_PRIVILEGES 1
USER_STATISTICS information_schema.USER_STATISTICS 1
VIEWS information_schema.VIEWS 1
create table t1(f1 int);
create view v1 as select f1+1 as a from t1;
Expand Down Expand Up @@ -2088,6 +2090,93 @@ t6 e timestamp 6
# Clean-up.
drop database mysqltest;
use test;
describe information_schema.table_statistics;
Field Type Null Key Default Extra
TABLE_SCHEMA varchar(192) NO
TABLE_NAME varchar(192) NO
TABLE_ENGINE varchar(192) NO
ROWS_INSERTED bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_REQUESTED bigint(21) NO 0
ROWS_INDEX_FIRST bigint(21) NO 0
ROWS_INDEX_NEXT bigint(21) NO 0
IO_READ_BYTES bigint(21) NO 0
IO_READ_REQUESTS bigint(21) NO 0
IO_READ_SVC_USECS bigint(21) NO 0
IO_READ_SVC_USECS_MAX bigint(21) NO 0
IO_READ_WAIT_USECS bigint(21) NO 0
IO_READ_WAIT_USECS_MAX bigint(21) NO 0
IO_READ_OLD_IOS bigint(21) NO 0
IO_WRITE_BYTES bigint(21) NO 0
IO_WRITE_REQUESTS bigint(21) NO 0
IO_WRITE_SVC_USECS bigint(21) NO 0
IO_WRITE_SVC_USECS_MAX bigint(21) NO 0
IO_WRITE_WAIT_USECS bigint(21) NO 0
IO_WRITE_WAIT_USECS_MAX bigint(21) NO 0
IO_WRITE_OLD_IOS bigint(21) NO 0
IO_READ_BYTES_BLOB bigint(21) NO 0
IO_READ_REQUESTS_BLOB bigint(21) NO 0
IO_READ_SVC_USECS_BLOB bigint(21) NO 0
IO_READ_SVC_USECS_MAX_BLOB bigint(21) NO 0
IO_READ_WAIT_USECS_BLOB bigint(21) NO 0
IO_READ_WAIT_USECS_MAX_BLOB bigint(21) NO 0
IO_READ_OLD_IOS_BLOB bigint(21) NO 0
IO_INDEX_INSERTS bigint(21) NO 0
QUERIES_USED bigint(21) NO 0
select * from information_schema.table_statistics where TABLE_NAME = "does not exist";
TABLE_SCHEMA TABLE_NAME TABLE_ENGINE ROWS_INSERTED ROWS_UPDATED ROWS_DELETED ROWS_READ ROWS_REQUESTED ROWS_INDEX_FIRST ROWS_INDEX_NEXT IO_READ_BYTES IO_READ_REQUESTS IO_READ_SVC_USECS IO_READ_SVC_USECS_MAX IO_READ_WAIT_USECS IO_READ_WAIT_USECS_MAX IO_READ_OLD_IOS IO_WRITE_BYTES IO_WRITE_REQUESTS IO_WRITE_SVC_USECS IO_WRITE_SVC_USECS_MAX IO_WRITE_WAIT_USECS IO_WRITE_WAIT_USECS_MAX IO_WRITE_OLD_IOS IO_READ_BYTES_BLOB IO_READ_REQUESTS_BLOB IO_READ_SVC_USECS_BLOB IO_READ_SVC_USECS_MAX_BLOB IO_READ_WAIT_USECS_BLOB IO_READ_WAIT_USECS_MAX_BLOB IO_READ_OLD_IOS_BLOB IO_INDEX_INSERTS QUERIES_USED
describe information_schema.user_statistics;
Field Type Null Key Default Extra
USER_NAME varchar(192) NO
BINLOG_BYTES_WRITTEN bigint(21) NO 0
BYTES_RECEIVED bigint(21) NO 0
BYTES_SENT bigint(21) NO 0
COMMANDS_DDL bigint(21) NO 0
COMMANDS_DELETE bigint(21) NO 0
COMMANDS_HANDLER bigint(21) NO 0
COMMANDS_INSERT bigint(21) NO 0
COMMANDS_OTHER bigint(21) NO 0
COMMANDS_SELECT bigint(21) NO 0
COMMANDS_TRANSACTION bigint(21) NO 0
COMMANDS_UPDATE bigint(21) NO 0
CONNECTIONS_CONCURRENT int(11) NO 0
CONNECTIONS_DENIED_MAX_GLOBAL bigint(21) NO 0
CONNECTIONS_DENIED_MAX_USER bigint(21) NO 0
CONNECTIONS_LOST bigint(21) NO 0
CONNECTIONS_TOTAL bigint(21) NO 0
DISK_READ_BYTES bigint(21) NO 0
DISK_READ_REQUESTS bigint(21) NO 0
DISK_READ_SVC_USECS bigint(21) NO 0
DISK_READ_WAIT_USECS bigint(21) NO 0
DISK_READ_BYTES_BLOB bigint(21) NO 0
DISK_READ_REQUESTS_BLOB bigint(21) NO 0
DISK_READ_SVC_USECS_BLOB bigint(21) NO 0
DISK_READ_WAIT_USECS_BLOB bigint(21) NO 0
ERRORS_ACCESS_DENIED bigint(21) NO 0
ERRORS_TOTAL bigint(21) NO 0
MICROSECONDS_WALL bigint(21) NO 0
MICROSECONDS_DDL bigint(21) NO 0
MICROSECONDS_DELETE bigint(21) NO 0
MICROSECONDS_HANDLER bigint(21) NO 0
MICROSECONDS_INSERT bigint(21) NO 0
MICROSECONDS_OTHER bigint(21) NO 0
MICROSECONDS_SELECT bigint(21) NO 0
MICROSECONDS_TRANSACTION bigint(21) NO 0
MICROSECONDS_UPDATE bigint(21) NO 0
QUERIES_EMPTY bigint(21) NO 0
ROWS_DELETED bigint(21) NO 0
ROWS_FETCHED bigint(21) NO 0
ROWS_INSERTED bigint(21) NO 0
ROWS_READ bigint(21) NO 0
ROWS_UPDATED bigint(21) NO 0
ROWS_INDEX_FIRST bigint(21) NO 0
ROWS_INDEX_NEXT bigint(21) NO 0
TRANSACTIONS_COMMIT bigint(21) NO 0
TRANSACTIONS_ROLLBACK bigint(21) NO 0
select * from information_schema.user_statistics where USER_NAME = "does not exist";
USER_NAME BINLOG_BYTES_WRITTEN BYTES_RECEIVED BYTES_SENT COMMANDS_DDL COMMANDS_DELETE COMMANDS_HANDLER COMMANDS_INSERT COMMANDS_OTHER COMMANDS_SELECT COMMANDS_TRANSACTION COMMANDS_UPDATE CONNECTIONS_CONCURRENT CONNECTIONS_DENIED_MAX_GLOBAL CONNECTIONS_DENIED_MAX_USER CONNECTIONS_LOST CONNECTIONS_TOTAL DISK_READ_BYTES DISK_READ_REQUESTS DISK_READ_SVC_USECS DISK_READ_WAIT_USECS DISK_READ_BYTES_BLOB DISK_READ_REQUESTS_BLOB DISK_READ_SVC_USECS_BLOB DISK_READ_WAIT_USECS_BLOB ERRORS_ACCESS_DENIED ERRORS_TOTAL MICROSECONDS_WALL MICROSECONDS_DDL MICROSECONDS_DELETE MICROSECONDS_HANDLER MICROSECONDS_INSERT MICROSECONDS_OTHER MICROSECONDS_SELECT MICROSECONDS_TRANSACTION MICROSECONDS_UPDATE QUERIES_EMPTY ROWS_DELETED ROWS_FETCHED ROWS_INSERTED ROWS_READ ROWS_UPDATED ROWS_INDEX_FIRST ROWS_INDEX_NEXT TRANSACTIONS_COMMIT TRANSACTIONS_ROLLBACK
#
# Test for bug #16869534 - "QUERYING SUBSET OF COLUMNS DOESN'T USE TABLE
# CACHE; OPENED_TABLES INCREASES"
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/information_schema_db.result
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ TABLE_PRIVILEGES
TABLE_STATISTICS
TRIGGERS
USER_PRIVILEGES
USER_STATISTICS
VIEWS
show tables from INFORMATION_SCHEMA like 'T%';
Tables_in_information_schema (T%)
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/mysqlshow.result
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Database: information_schema
| TABLE_STATISTICS |
| TRIGGERS |
| USER_PRIVILEGES |
| USER_STATISTICS |
| VIEWS |
| INNODB_LOCKS |
| INNODB_TRX |
Expand Down Expand Up @@ -176,6 +177,7 @@ Database: INFORMATION_SCHEMA
| TABLE_STATISTICS |
| TRIGGERS |
| USER_PRIVILEGES |
| USER_STATISTICS |
| VIEWS |
| INNODB_LOCKS |
| INNODB_TRX |
Expand Down
26 changes: 26 additions & 0 deletions mysql-test/r/user_stats_bytes.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
drop table if exists userstats;
create table userstats (i int primary key, j int);
flush statistics;

At start

select bytes_sent, bytes_received from information_schema.user_statistics where user_name = 'root';;
bytes_sent 11
bytes_received 104
insert into userstats values (1,1);

after insert

select bytes_sent, bytes_received from information_schema.user_statistics where user_name = 'root';;
bytes_sent 252
bytes_received 247
select * from userstats;
i j
1 1

after select

select bytes_sent, bytes_received from information_schema.user_statistics where user_name = 'root';;
bytes_sent 614
bytes_received 379
drop table userstats;
Loading

0 comments on commit 4554e16

Please sign in to comment.