Skip to content

Commit

Permalink
Add I_S.admission_control_entities table
Browse files Browse the repository at this point in the history
Summary: Add `INFORMATION_SCHEMA.admission_control_entities` table to show aggregate entity information. In the future this will also show information unrelated to query concurrency queues.

Reviewed By: sagar0

Differential Revision: D24151364

fbshipit-source-id: 3680c424b77
  • Loading branch information
george-reynya authored and facebook-github-bot committed Oct 11, 2020
1 parent 92a454e commit 2d50f4c
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 14 deletions.
15 changes: 15 additions & 0 deletions mysql-test/r/admission_control.result
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Check status variables
aborted_queries = 3
running_queries = 10
waiting_queries = 5
select * from information_schema.admission_control_entities;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test 0 0 0 0
test_db 5 10 3 0
Filled up queues on one db doesn't affect queries on other db.
use test;
set @@global.max_waiting_queries=6;
Expand Down Expand Up @@ -92,6 +96,10 @@ both running_queries and waiting_queries resources should be 0 (released)
aborted_queries = 5
running_queries = 0
waiting_queries = 0;
select * from information_schema.admission_control_entities;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test 0 0 0 0
test_db 0 0 5 0
set @@global.admission_control_by_trx = @save_admission_control_by_trx;
select @@global.admission_control_by_trx;
@@global.admission_control_by_trx
Expand Down Expand Up @@ -125,6 +133,10 @@ timeout_queries should be 1
timeout_queries = 1
waiting_queries should be 0
waiting_queries = 0
select * from information_schema.admission_control_entities;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test 0 0 0 0
test_db 0 0 5 1
reset global.max_running_queries and global.max_waiting_queries
set @@global.max_running_queries=10;
set @@global.max_waiting_queries=5;
Expand All @@ -135,6 +147,9 @@ Verify there are no waiting threads.
select count(*) from information_schema.processlist where state='waiting for admission';
count(*)
0
select * from information_schema.admission_control_entities;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test 0 0 0 0
set @@global.max_running_queries=@start_max_running_queries;
set @@global.max_waiting_queries=@start_max_waiting_queries;
drop user test_user@localhost;
33 changes: 33 additions & 0 deletions mysql-test/r/admission_control_queue.result
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ select GET_LOCK('lock1', -1);
GET_LOCK('lock1', -1)
1
select GET_LOCK('lock1', -1);
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 1 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 0 1 0 0
select RELEASE_LOCK('lock1');
RELEASE_LOCK('lock1')
1
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
GET_LOCK('lock1', -1)
Expand All @@ -33,12 +40,19 @@ GET_LOCK('lock1', -1)
1
use test_db;
select GET_LOCK('lock1', -1);
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 1 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 1 0 1 0 0
select RELEASE_LOCK('lock1');
RELEASE_LOCK('lock1')
1
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
GET_LOCK('lock1', -1)
Expand All @@ -51,12 +65,19 @@ GET_LOCK('lock1', -1)
1
use test_db;
select GET_LOCK('lock1', -1);
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 1 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 2 0 1 0 0
select RELEASE_LOCK('lock1');
RELEASE_LOCK('lock1')
1
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
GET_LOCK('lock1', -1)
Expand All @@ -77,6 +98,10 @@ select GET_LOCK('lock1', -1);
select GET_LOCK('lock1', -1);
select GET_LOCK('lock1', -1);
select GET_LOCK('lock1', -1);
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 5 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 0 5 0 0
Expand All @@ -92,6 +117,10 @@ select GET_LOCK('lock2', -1);
select GET_LOCK('lock2', -1);
select GET_LOCK('lock2', -1);
# Check that 10 queries are waiting
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 10 5 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 0 0 5 0 0
Expand All @@ -101,6 +130,10 @@ select RELEASE_LOCK('lock1');
RELEASE_LOCK('lock1')
1
# Check that 5 of the 10 queries are now scheduled with 2-3 ratio.
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;
SCHEMA_NAME WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 5 5 0 0
select * from information_schema.admission_control_queue;
SCHEMA_NAME QUEUE_ID WAITING_QUERIES RUNNING_QUERIES ABORTED_QUERIES TIMEOUT_QUERIES
test_db 1 3 2 0 0
Expand Down
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 @@ -80,6 +80,7 @@ CLIENT_ATTRIBUTES CLIENT_ID
SQL_PLANS PLAN_ID
COLUMN_STATISTICS TABLE_SCHEMA
DATABASE_APPLIED_HLC DATABASE_NAME
ADMISSION_CONTROL_ENTITIES SCHEMA_NAME
ADMISSION_CONTROL_QUEUE SCHEMA_NAME
SQL_FINDINGS SQL_ID
THREAD_PRIORITIES ID
Expand Down Expand Up @@ -162,6 +163,7 @@ CLIENT_ATTRIBUTES CLIENT_ID
SQL_PLANS PLAN_ID
COLUMN_STATISTICS TABLE_SCHEMA
DATABASE_APPLIED_HLC DATABASE_NAME
ADMISSION_CONTROL_ENTITIES SCHEMA_NAME
ADMISSION_CONTROL_QUEUE SCHEMA_NAME
SQL_FINDINGS SQL_ID
THREAD_PRIORITIES ID
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/r/information_schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ CLIENT_ATTRIBUTES
SQL_PLANS
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ADMISSION_CONTROL_ENTITIES
ADMISSION_CONTROL_QUEUE
SQL_FINDINGS
THREAD_PRIORITIES
Expand Down Expand Up @@ -978,7 +979,7 @@ table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest')
AND table_name not like 'ndb%' AND table_name not like 'innodb_%' AND table_name not like 'rocksdb_%'
GROUP BY TABLE_SCHEMA;
table_schema count(*)
information_schema 64
information_schema 65
mysql 27
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
Expand Down Expand Up @@ -1418,6 +1419,7 @@ and t.table_name not like 'innodb_%'
and t.table_name not like 'rocksdb_%'
group by t.table_name order by num1, t.table_name;
table_name group_concat(t.table_schema, '.', t.table_name) num1
ADMISSION_CONTROL_ENTITIES information_schema.ADMISSION_CONTROL_ENTITIES 1
ADMISSION_CONTROL_QUEUE information_schema.ADMISSION_CONTROL_QUEUE 1
AUTHINFO information_schema.AUTHINFO 1
CHARACTER_SETS information_schema.CHARACTER_SETS 1
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 @@ -64,6 +64,7 @@ CLIENT_ATTRIBUTES
SQL_PLANS
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ADMISSION_CONTROL_ENTITIES
ADMISSION_CONTROL_QUEUE
SQL_FINDINGS
THREAD_PRIORITIES
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 @@ -75,6 +75,7 @@ Database: test
2 rows in set.

DROP TABLE t1, t2;
| ADMISSION_CONTROL_ENTITIES |
| ADMISSION_CONTROL_QUEUE |
| AUTHINFO |
| CHARACTER_SETS |
Expand Down Expand Up @@ -182,6 +183,7 @@ DROP TABLE t1, t2;
| WRITE_STATISTICS_HISTOGRAM |
| WRITE_THROTTLING_LOG |
| WRITE_THROTTLING_RULES |
| ADMISSION_CONTROL_ENTITIES |
| ADMISSION_CONTROL_QUEUE |
| AUTHINFO |
| CHARACTER_SETS |
Expand Down
10 changes: 10 additions & 0 deletions mysql-test/suite/funcs_1/r/is_columns_is.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%' AND table_name not like 'rocksdb_%'
ORDER BY table_schema, table_name, column_name;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT
def information_schema ADMISSION_CONTROL_ENTITIES ABORTED_QUERIES 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_ENTITIES RUNNING_QUERIES 3 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_ENTITIES SCHEMA_NAME 1 NO varchar 192 576 NULL NULL NULL utf8 utf8_general_ci varchar(192) select
def information_schema ADMISSION_CONTROL_ENTITIES TIMEOUT_QUERIES 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_ENTITIES WAITING_QUERIES 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_QUEUE ABORTED_QUERIES 5 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_QUEUE QUEUE_ID 2 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
def information_schema ADMISSION_CONTROL_QUEUE RUNNING_QUERIES 4 0 NO bigint NULL NULL 20 0 NULL NULL NULL bigint(21) unsigned select
Expand Down Expand Up @@ -765,6 +770,11 @@ WHERE table_schema = 'information_schema'
AND table_name <> 'profiling' AND table_name not like 'innodb_%' AND table_name not like 'rocksdb_%'
ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION;
COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE
3.0000 information_schema ADMISSION_CONTROL_ENTITIES SCHEMA_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema ADMISSION_CONTROL_ENTITIES WAITING_QUERIES bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema ADMISSION_CONTROL_ENTITIES RUNNING_QUERIES bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema ADMISSION_CONTROL_ENTITIES ABORTED_QUERIES bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema ADMISSION_CONTROL_ENTITIES TIMEOUT_QUERIES bigint NULL NULL NULL NULL bigint(21) unsigned
3.0000 information_schema ADMISSION_CONTROL_QUEUE SCHEMA_NAME varchar 192 576 utf8 utf8_general_ci varchar(192)
NULL information_schema ADMISSION_CONTROL_QUEUE QUEUE_ID bigint NULL NULL NULL NULL bigint(21) unsigned
NULL information_schema ADMISSION_CONTROL_QUEUE WAITING_QUERIES bigint NULL NULL NULL NULL bigint(21) unsigned
Expand Down
46 changes: 46 additions & 0 deletions mysql-test/suite/funcs_1/r/is_tables_is.result
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ AND table_name <> 'profiling' AND table_name not like 'innodb_%' AND table_name
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ADMISSION_CONTROL_ENTITIES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
VERSION 10
ROW_FORMAT Fixed
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_general_ci
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ADMISSION_CONTROL_QUEUE
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
Expand Down Expand Up @@ -1481,6 +1504,29 @@ AND table_name <> 'profiling' AND table_name not like 'innodb_%' AND table_name
ORDER BY table_schema,table_name;
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ADMISSION_CONTROL_ENTITIES
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
VERSION 10
ROW_FORMAT Fixed
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT NULL
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION utf8_general_ci
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ADMISSION_CONTROL_QUEUE
TABLE_TYPE SYSTEM VIEW
ENGINE MEMORY
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/t/admission_control.test
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ let $waiting_queries = `select $waiting_queries - $start_waiting_queries`;
--echo aborted_queries = $aborted_queries
--echo running_queries = $running_queries
--echo waiting_queries = $waiting_queries
select * from information_schema.admission_control_entities;

--echo Filled up queues on one db doesn't affect queries on other db.
connect (con_test, localhost, test_user,,test);
Expand Down Expand Up @@ -300,6 +301,7 @@ let $waiting_queries = `select $waiting_queries - $start_waiting_queries`;
--echo aborted_queries = $aborted_queries
--echo running_queries = $running_queries
--echo waiting_queries = $waiting_queries;
select * from information_schema.admission_control_entities;

# restore admission_control_by_trx
connection default;
Expand Down Expand Up @@ -367,6 +369,7 @@ let $timeout_queries = `select $timeout_queries - $start_timeout_queries`;
let $waiting_queries = query_get_value(show global status like "Database_admission_control_waiting_queries", Value, 1);
--echo waiting_queries should be 0
--echo waiting_queries = $waiting_queries
select * from information_schema.admission_control_entities;

connection default;
--echo reset global.max_running_queries and global.max_waiting_queries
Expand Down Expand Up @@ -405,6 +408,7 @@ enable_result_log;
connection default;
--echo Verify there are no waiting threads.
select count(*) from information_schema.processlist where state='waiting for admission';
select * from information_schema.admission_control_entities;
set @@global.max_running_queries=@start_max_running_queries;
set @@global.max_waiting_queries=@start_max_waiting_queries;
drop user test_user@localhost;
Expand Down
13 changes: 13 additions & 0 deletions mysql-test/t/admission_control_queue.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ set @save_admission_control_weights = @@admission_control_weights;
set global max_running_queries = 5;
set global max_waiting_queries = 2000;

let $ac_entities_query =
select * from information_schema.admission_control_entities
where waiting_queries + running_queries + aborted_queries + timeout_queries != 0;

--source include/count_sessions.inc

--echo #
Expand All @@ -27,13 +31,15 @@ let $wait_condition =
select count(*) = 1 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id = 0 and waiting_queries = 0 and running_queries = 1;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

select RELEASE_LOCK('lock1');

let $wait_condition =
select count(*) = 0 from information_schema.admission_control_queue;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--connection con1
Expand Down Expand Up @@ -61,13 +67,15 @@ let $wait_condition =
select count(*) = 1 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id = 1 and waiting_queries = 0 and running_queries = 1;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

select RELEASE_LOCK('lock1');

let $wait_condition =
select count(*) = 0 from information_schema.admission_control_queue;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--connection con1
Expand Down Expand Up @@ -96,13 +104,15 @@ let $wait_condition =
select count(*) = 1 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id = 2 and waiting_queries = 0 and running_queries = 1;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

select RELEASE_LOCK('lock1');

let $wait_condition =
select count(*) = 0 from information_schema.admission_control_queue;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--connection con1
Expand Down Expand Up @@ -137,6 +147,7 @@ let $wait_condition =
select count(*) = 1 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id = 0 and waiting_queries = 0 and running_queries = 5;
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--echo # Set up 5 waiting queries each for queue 1 and 2
Expand All @@ -162,6 +173,7 @@ let $wait_condition =
select sum(waiting_queries) = 10 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id in (1, 2);
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--connection default
Expand All @@ -178,6 +190,7 @@ let $wait_condition =
select sum(running_queries) = 5 from information_schema.admission_control_queue
where schema_name = "test_db" and queue_id in (1, 2);
--source include/wait_condition.inc
--eval $ac_entities_query
select * from information_schema.admission_control_queue;

--echo # Cleanup
Expand Down
Loading

0 comments on commit 2d50f4c

Please sign in to comment.