Skip to content

Commit

Permalink
MDEV-26440 Missing connection id value in I_S.thread_pool_queues
Browse files Browse the repository at this point in the history
It turns out, Field::set_notnull is required for a nullable I_S field.
Rework thread_pool_info.test to test request queueing in threadpool.
  • Loading branch information
vaintroub committed Aug 19, 2021
1 parent 4009e9b commit 69b75cb
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mysql-test/main/thread_pool_info.opt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--thread-handling=pool-of-threads --loose-thread-pool-mode=generic --loose-thread-pool-groups=ON --loose-thread-pool-queues=ON --thread-pool-stats=ON --thread-pool-waits=ON
--thread-handling=pool-of-threads --loose-thread-pool-mode=generic --loose-thread-pool-groups=ON --loose-thread-pool-queues=ON --thread-pool-stats=ON --thread-pool-waits=ON --thread-pool-size=1 --thread-pool-max-threads=2 --thread-pool-dedicated-listener
42 changes: 32 additions & 10 deletions mysql-test/main/thread_pool_info.result
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ SUM(QUEUE_LENGTH)
SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
SUM(IS_STALLED)
0
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
Field Type Null Key Default Extra
GROUP_ID int(6) NO 0
POSITION int(6) NO 0
PRIORITY int(1) NO 0
CONNECTION_ID bigint(19) unsigned YES NULL
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
Field Type Null Key Default Extra
GROUP_ID int(6) NO 0
Expand All @@ -56,9 +49,12 @@ FLUSH THREAD_POOL_STATS;
SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER)
1
SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3
1
SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SUM(POLLS_BY_LISTENER)
2
SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SUM(POLLS_BY_WORKER)
0
DESC INFORMATION_SCHEMA.THREAD_POOL_WAITS;
Field Type Null Key Default Extra
REASON varchar(16) NO
Expand Down Expand Up @@ -87,3 +83,29 @@ SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
COUNT
1
FLUSH THREAD_POOL_WAITS;
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
Field Type Null Key Default Extra
GROUP_ID int(6) NO 0
POSITION int(6) NO 0
PRIORITY int(1) NO 0
CONNECTION_ID bigint(19) unsigned YES NULL
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
# restart: with restart_parameters
connect con1, localhost, root,,test;
connection con1;
connect con2, localhost, root,,test;
connection con2;
connect extra_con,127.0.0.1,root,,test,$extra_port,;
connection con1;
SELECT SLEEP(1000);
connection extra_con;
connection con2;
DO 1;
connection extra_con;
KILL QUERY con1_id;
disconnect extra_con;
connection con1;
disconnect con1;
connection con2;
disconnect con2;
connection default;
59 changes: 55 additions & 4 deletions mysql-test/main/thread_pool_info.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ SELECT SUM(ACTIVE_THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
SELECT SUM(QUEUE_LENGTH) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;

# I_S.THREAD_POOL_QUEUES
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
#Todo - figure out how to populate queue with debug test

# I_S.THREAD_POOL_STATS
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
Expand All @@ -29,7 +26,8 @@ SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD
--disable_ps_protocol
FLUSH THREAD_POOL_STATS;
SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
--enable_ps_protocol

#I_S.THREAD_POOL_WAITS
Expand All @@ -39,3 +37,56 @@ SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
SELECT SLEEP(0.01);
SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
FLUSH THREAD_POOL_WAITS;


# I_S.THREAD_POOL_QUEUES
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
let $extra_port=`select @@port+1`;

let $restart_parameters=--extra-port=$extra_port;
let $restart_noprint=1;
source include/restart_mysqld.inc;

connect (con1, localhost, root,,test);
connection con1;
let $con1_id=`SELECT CONNECTION_ID()`;

connect (con2, localhost, root,,test);
connection con2;
let $con2_id=`SELECT CONNECTION_ID()`;

connect(extra_con,127.0.0.1,root,,test,$extra_port,);

connection con1;
send SELECT SLEEP(1000);

connection extra_con;
let $wait_condition=
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE STATE='User sleep' AND ID=$con1_id;
--source include/wait_condition.inc

connection con2;
send DO 1;


connection extra_con;
let $wait_condition=
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_QUEUES
WHERE CONNECTION_ID IS NOT NULL;
--source include/wait_condition.inc

--replace_result $con1_id con1_id
eval KILL QUERY $con1_id;
disconnect extra_con;

connection con1;
error 0,ER_QUERY_INTERRUPTED;
reap;
disconnect con1;

connection con2;
reap;
disconnect con2;

connection default;
3 changes: 3 additions & 0 deletions sql/thread_pool_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ static int queues_fill_table(THD* thd, TABLE_LIST* tables, COND*)
table->field[2]->store(prio, true);
/* CONNECTION_ID */
if (c->thd)
{
table->field[3]->set_notnull();
table->field[3]->store(c->thd->thread_id, true);
}
/* QUEUEING_TIME */
table->field[4]->store(now - c->enqueue_time, true);

Expand Down

0 comments on commit 69b75cb

Please sign in to comment.