diff --git a/mysql-test/suite/thread_pool/r/threadpool_connection_balance.result b/mysql-test/suite/thread_pool/r/threadpool_connection_balance.result new file mode 100644 index 0000000000000000000000000000000000000000..18726afca571ddd47ec8e20758281500b8d05108 --- /dev/null +++ b/mysql-test/suite/thread_pool/r/threadpool_connection_balance.result @@ -0,0 +1,42 @@ +# restart: --plugin-load-add=thread_pool.so --thread_pool_size=9 --thread_pool_connection_balance=ON --admin-address=127.0.0.1 --admin-port=ADMIN_PORT --innodb_lock_wait_timeout=3600 --loose-debug-sync-timeout=300 +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT CONNECTIONS FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +CONNECTIONS +1 +1 +1 +1 +1 +1 +1 +1 +2 +SET GLOBAL thread_pool_size=3; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT CONNECTIONS FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +CONNECTIONS +3 +3 +3 +0 +0 +0 +0 +0 +1 diff --git a/mysql-test/suite/thread_pool/t/threadpool_admin_port.test b/mysql-test/suite/thread_pool/t/threadpool_admin_port.test index 99eb0d62f1bad5a81b073e41ea4c4d702ccb3bec..90a0917718edcdc5a850c3e45e1d16daeb6647b3 100644 --- a/mysql-test/suite/thread_pool/t/threadpool_admin_port.test +++ b/mysql-test/suite/thread_pool/t/threadpool_admin_port.test @@ -64,7 +64,9 @@ connect(admin_local_con,localhost,root,,,$ADMIN_PORT,,TCP); connection admin_local_con; SELECT CURRENT_USER(); +--disable_warnings ER_WARN_DEPRECATED_SYNTAX select user, command, state, info from information_schema.processlist where user = "root" order by id asc; +--enable_warnings ER_WARN_DEPRECATED_SYNTAX --disable_query_log eval KILL QUERY $conn0_id; diff --git a/mysql-test/suite/thread_pool/t/threadpool_connection_balance.test b/mysql-test/suite/thread_pool/t/threadpool_connection_balance.test new file mode 100644 index 0000000000000000000000000000000000000000..9691620f7d8fa0d52aabb8edf0c68f36bef3d055 --- /dev/null +++ b/mysql-test/suite/thread_pool/t/threadpool_connection_balance.test @@ -0,0 +1,68 @@ +# Restart with plugin-load-add=thread_pool.so + +--disable_query_log +CALL mtr.add_suppression("Failed to initialize TLS for channel: mysql_admin"); +CALL mtr.add_suppression("Failed to set up SSL because of the following SSL library error"); +--enable_query_log + +# Calculate value for admin port +--let $PORT_OFFSET = 1 +--expr $ADMIN_PORT = $MASTER_MYPORT + $PORT_OFFSET + +--let $restart_parameters=restart: --plugin-load-add=thread_pool.so --thread_pool_size=9 --thread_pool_connection_balance=ON --admin-address=127.0.0.1 --admin-port=$ADMIN_PORT --innodb_lock_wait_timeout=3600 --loose-debug-sync-timeout=300 +--replace_result $ADMIN_PORT ADMIN_PORT +--source include/restart_mysqld.inc + +connect(conn0,127.0.0.1,root,,,); +connect(conn1,127.0.0.1,root,,,); +connect(conn2,127.0.0.1,root,,,); +connect(conn3,127.0.0.1,root,,,); +connect(conn4,127.0.0.1,root,,,); +connect(conn5,127.0.0.1,root,,,); +connect(conn6,127.0.0.1,root,,,); +connect(conn7,127.0.0.1,root,,,); +connect(conn8,127.0.0.1,root,,,); +connect(extracon,127.0.0.1,root,,,$ADMIN_PORT); + +--let $counter=0 +while ($counter<9) +{ + connection conn$counter; + --disable_result_log + SELECT 1; + --enable_result_log + + --inc $counter +} + +connection extracon; +SELECT CONNECTIONS FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; +SET GLOBAL thread_pool_size=3; + +--let $counter=0 +while ($counter<9) +{ + connection conn$counter; + --disable_result_log + SELECT 1; + --enable_result_log + --sleep 1 + + --inc $counter +} + +connection extracon; +# Test that under this circumstance, information offered by information schema is as expected +# I_S.THREAD_POOL_GROUPS +SELECT CONNECTIONS FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; + +disconnect conn0; +disconnect conn1; +disconnect conn2; +disconnect conn3; +disconnect conn4; +disconnect conn5; +disconnect conn6; +disconnect conn7; +disconnect conn8; +disconnect extracon; \ No newline at end of file diff --git a/mysql-test/suite/thread_pool/t/threadpool_pool_size.test b/mysql-test/suite/thread_pool/t/threadpool_pool_size.test index 30aff1b3879563c2bb6322ac50af4cb9e917a508..3646ba877214bd94a8f2f9a959b55508ac2fba65 100644 --- a/mysql-test/suite/thread_pool/t/threadpool_pool_size.test +++ b/mysql-test/suite/thread_pool/t/threadpool_pool_size.test @@ -34,7 +34,9 @@ SEND SELECT benchmark(9999999999, md5('very long command 2')); # Test that only one command is being executed connection extracon; +--disable_warnings ER_WARN_DEPRECATED_SYNTAX SELECT COUNT(Id) FROM INFORMATION_SCHEMA.processlist where Info like 'SELECT benchmark(9999999999, md5(\'very long command%'; +--enable_warnings ER_WARN_DEPRECATED_SYNTAX # Test that under this circumstance, information offered by information schema is as expected # I_S.THREAD_POOL_GROUPS SELECT SUM(CONNECTIONS) FROM INFORMATION_SCHEMA.THREAD_POOL_GROUPS; diff --git a/mysql-test/suite/thread_pool/t/threadpool_too_busy_active.test b/mysql-test/suite/thread_pool/t/threadpool_too_busy_active.test index 44fa0296964f5cda2402925b5daebf2a3760cbcd..cd4bb941c92fdbfd38fdcc2ecb300e246f8e3c62 100644 --- a/mysql-test/suite/thread_pool/t/threadpool_too_busy_active.test +++ b/mysql-test/suite/thread_pool/t/threadpool_too_busy_active.test @@ -26,6 +26,8 @@ connection conn2; --let $conn2_id = `SELECT connection_id()` SEND SELECT benchmark(9999999999, md5('very long command 2')); +--sleep 1 + # Test that new connection cannot be established --disable_abort_on_error --echo You should see a Lost connection message diff --git a/mysql-test/suite/thread_pool/t/threadpool_too_busy_wait-debug.test b/mysql-test/suite/thread_pool/t/threadpool_too_busy_wait-debug.test index e1371b5e731e18f872f686f5363d03471b53455b..2d626cc641115479906e3ce46d4bd9105050a58e 100644 --- a/mysql-test/suite/thread_pool/t/threadpool_too_busy_wait-debug.test +++ b/mysql-test/suite/thread_pool/t/threadpool_too_busy_wait-debug.test @@ -41,6 +41,7 @@ SELECT * FROM db1.t1 WHERE c1=2 FOR UPDATE; connection conn1; START TRANSACTION; SEND SELECT * FROM db1.t1 WHERE c1=2 LOCK IN SHARE MODE; +--sleep 1 connection conn2; START TRANSACTION;