Skip to content

Commit 69b75cb

Browse files
committed
MDEV-26440 Missing connection id value in I_S.thread_pool_queues
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.
1 parent 4009e9b commit 69b75cb

File tree

4 files changed

+91
-15
lines changed

4 files changed

+91
-15
lines changed

mysql-test/main/thread_pool_info.opt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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
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-pool-size=1 --thread-pool-max-threads=2 --thread-pool-dedicated-listener

mysql-test/main/thread_pool_info.result

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ SUM(QUEUE_LENGTH)
2626
SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
2727
SUM(IS_STALLED)
2828
0
29-
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
30-
Field Type Null Key Default Extra
31-
GROUP_ID int(6) NO 0
32-
POSITION int(6) NO 0
33-
PRIORITY int(1) NO 0
34-
CONNECTION_ID bigint(19) unsigned YES NULL
35-
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
3629
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
3730
Field Type Null Key Default Extra
3831
GROUP_ID int(6) NO 0
@@ -56,9 +49,12 @@ FLUSH THREAD_POOL_STATS;
5649
SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
5750
SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER)
5851
1
59-
SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
60-
SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3
61-
1
52+
SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
53+
SUM(POLLS_BY_LISTENER)
54+
2
55+
SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
56+
SUM(POLLS_BY_WORKER)
57+
0
6258
DESC INFORMATION_SCHEMA.THREAD_POOL_WAITS;
6359
Field Type Null Key Default Extra
6460
REASON varchar(16) NO
@@ -87,3 +83,29 @@ SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
8783
COUNT
8884
1
8985
FLUSH THREAD_POOL_WAITS;
86+
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
87+
Field Type Null Key Default Extra
88+
GROUP_ID int(6) NO 0
89+
POSITION int(6) NO 0
90+
PRIORITY int(1) NO 0
91+
CONNECTION_ID bigint(19) unsigned YES NULL
92+
QUEUEING_TIME_MICROSECONDS bigint(19) NO 0
93+
# restart: with restart_parameters
94+
connect con1, localhost, root,,test;
95+
connection con1;
96+
connect con2, localhost, root,,test;
97+
connection con2;
98+
connect extra_con,127.0.0.1,root,,test,$extra_port,;
99+
connection con1;
100+
SELECT SLEEP(1000);
101+
connection extra_con;
102+
connection con2;
103+
DO 1;
104+
connection extra_con;
105+
KILL QUERY con1_id;
106+
disconnect extra_con;
107+
connection con1;
108+
disconnect con1;
109+
connection con2;
110+
disconnect con2;
111+
connection default;

mysql-test/main/thread_pool_info.test

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ SELECT SUM(ACTIVE_THREADS) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
1515
SELECT SUM(QUEUE_LENGTH) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
1616
SELECT SUM(IS_STALLED) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS;
1717

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

2219
# I_S.THREAD_POOL_STATS
2320
DESC INFORMATION_SCHEMA.THREAD_POOL_STATS;
@@ -29,7 +26,8 @@ SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) > 0 FROM INFORMATION_SCHEMA.THREAD
2926
--disable_ps_protocol
3027
FLUSH THREAD_POOL_STATS;
3128
SELECT SUM(DEQUEUES_BY_LISTENER+DEQUEUES_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
32-
SELECT SUM(POLLS_BY_LISTENER+POLLS_BY_WORKER) BETWEEN 2 AND 3 FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
29+
SELECT SUM(POLLS_BY_LISTENER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
30+
SELECT SUM(POLLS_BY_WORKER) FROM INFORMATION_SCHEMA.THREAD_POOL_STATS;
3331
--enable_ps_protocol
3432

3533
#I_S.THREAD_POOL_WAITS
@@ -39,3 +37,56 @@ SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
3937
SELECT SLEEP(0.01);
4038
SELECT COUNT FROM INFORMATION_SCHEMA.THREAD_POOL_WAITS WHERE REASON='Sleep';
4139
FLUSH THREAD_POOL_WAITS;
40+
41+
42+
# I_S.THREAD_POOL_QUEUES
43+
DESC INFORMATION_SCHEMA.THREAD_POOL_QUEUES;
44+
let $extra_port=`select @@port+1`;
45+
46+
let $restart_parameters=--extra-port=$extra_port;
47+
let $restart_noprint=1;
48+
source include/restart_mysqld.inc;
49+
50+
connect (con1, localhost, root,,test);
51+
connection con1;
52+
let $con1_id=`SELECT CONNECTION_ID()`;
53+
54+
connect (con2, localhost, root,,test);
55+
connection con2;
56+
let $con2_id=`SELECT CONNECTION_ID()`;
57+
58+
connect(extra_con,127.0.0.1,root,,test,$extra_port,);
59+
60+
connection con1;
61+
send SELECT SLEEP(1000);
62+
63+
connection extra_con;
64+
let $wait_condition=
65+
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.PROCESSLIST
66+
WHERE STATE='User sleep' AND ID=$con1_id;
67+
--source include/wait_condition.inc
68+
69+
connection con2;
70+
send DO 1;
71+
72+
73+
connection extra_con;
74+
let $wait_condition=
75+
SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.THREAD_POOL_QUEUES
76+
WHERE CONNECTION_ID IS NOT NULL;
77+
--source include/wait_condition.inc
78+
79+
--replace_result $con1_id con1_id
80+
eval KILL QUERY $con1_id;
81+
disconnect extra_con;
82+
83+
connection con1;
84+
error 0,ER_QUERY_INTERRUPTED;
85+
reap;
86+
disconnect con1;
87+
88+
connection con2;
89+
reap;
90+
disconnect con2;
91+
92+
connection default;

sql/thread_pool_info.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ static int queues_fill_table(THD* thd, TABLE_LIST* tables, COND*)
131131
table->field[2]->store(prio, true);
132132
/* CONNECTION_ID */
133133
if (c->thd)
134+
{
135+
table->field[3]->set_notnull();
134136
table->field[3]->store(c->thd->thread_id, true);
137+
}
135138
/* QUEUEING_TIME */
136139
table->field[4]->store(now - c->enqueue_time, true);
137140

0 commit comments

Comments
 (0)