summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2021-08-19 17:54:13 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2021-08-19 21:16:22 +0200
commit69b75cb3dba9dfacf17f93dfddb66d1bfb4fec99 (patch)
treef9329a60c817e9e1832cd4128e3a425f92b6f565
parent4009e9b25333fb1819f2696760946679f7e20674 (diff)
downloadmariadb-git-69b75cb3dba9dfacf17f93dfddb66d1bfb4fec99.tar.gz
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.
-rw-r--r--mysql-test/main/thread_pool_info.opt2
-rw-r--r--mysql-test/main/thread_pool_info.result42
-rw-r--r--mysql-test/main/thread_pool_info.test59
-rw-r--r--sql/thread_pool_info.cc3
4 files changed, 91 insertions, 15 deletions
diff --git a/mysql-test/main/thread_pool_info.opt b/mysql-test/main/thread_pool_info.opt
index 4094287a9bf..61bfc80d237 100644
--- a/mysql-test/main/thread_pool_info.opt
+++ b/mysql-test/main/thread_pool_info.opt
@@ -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 \ No newline at end of file
+--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
diff --git a/mysql-test/main/thread_pool_info.result b/mysql-test/main/thread_pool_info.result
index 27717aa298a..53fa1d1255d 100644
--- a/mysql-test/main/thread_pool_info.result
+++ b/mysql-test/main/thread_pool_info.result
@@ -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
@@ -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
@@ -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;
diff --git a/mysql-test/main/thread_pool_info.test b/mysql-test/main/thread_pool_info.test
index 914720af862..cd906454d8c 100644
--- a/mysql-test/main/thread_pool_info.test
+++ b/mysql-test/main/thread_pool_info.test
@@ -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;
@@ -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
@@ -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;
diff --git a/sql/thread_pool_info.cc b/sql/thread_pool_info.cc
index f003581a5b0..90ac6871784 100644
--- a/sql/thread_pool_info.cc
+++ b/sql/thread_pool_info.cc
@@ -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);