mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
3871477c40
The patch fixes two test failures: - on slow builders, sometimes a connection attempt which should fail due to the exceeded number of thread_pool_max_threads actually succeeds; - on even slow builders, MTR sometimes cannot establish the initial connection, and check-testcase fails prior to the test start The problem with check-testcase was caused by connect-timeout=2 which was set for all clients in the test config file. On slow builders it might be not enough. There is no way to override it for the pre-test check, so it needed to be substantially increased or removed. The other problem was caused by a race condition between sleeps that the test performs in existing connections and the connect timeout for the connection attempt which was expected to fail. If sleeps finished before the connect-timeout was exceeded, it would allow the connection to succeed. To solve each problem without making the other one worse, connect-timeout should be configured dynamically during the test. Due to the nature of the test (all connections must be busy at the moment when we need to change the timeout, and cannot execute SET GLOBAL ...), it needs to be done independently from the server. The solution: - recognize 'connect_timeout' as a connection option in mysqltest's "connect" command; - remove connect-timeout from the test configuration file; - use the new connect_timeout option for those connections which are expected to fail; - re-arrange the test flow to allow running a huge SLEEP without affecting the test execution time (because it would be interrupted after the main test flow is finished). The test is still subject to false negatives, e.g. if the connection fails due to timeout rather than due to the exceeded number of allowed threads, or if the connection on extra port succeeds due to a race condition and not because the special logic for the extra port. But those false negatives have always been possible there on slow builders, they should not be critical because faster builders should catch such failures if they appear.
93 lines
2.5 KiB
Text
93 lines
2.5 KiB
Text
# Start with thread_handling=pool-of-threads
|
|
# and run a number of tests
|
|
|
|
-- source include/have_pool_of_threads.inc
|
|
SET @save_optimizer_switch=@@optimizer_switch;
|
|
SET optimizer_switch='outer_join_with_cache=off';
|
|
# Slow test, don't run during staging part
|
|
-- source include/not_staging.inc
|
|
-- source include/long_test.inc
|
|
-- source include/common-tests.inc
|
|
SET optimizer_switch=@save_optimizer_switch;
|
|
|
|
# Test that we cannot have more simultaneous connections than
|
|
# --thread-pool-size on the standard port, but _can_ have additional
|
|
# connections on the extra port.
|
|
|
|
# First set two connections running, and check that extra connection
|
|
# on normal port fails due to --thread-pool-max-threads=2.
|
|
# We can afford using a really long sleep, because we won't wait
|
|
# till it ends, we'll interrupt it as soon as we don't need it anymore
|
|
|
|
connection default;
|
|
--let $con1_id= `SELECT CONNECTION_ID()`
|
|
|
|
send SELECT sleep(50);
|
|
--sleep 1
|
|
|
|
connect(con2,localhost,root,,);
|
|
--let $con2_id= `SELECT CONNECTION_ID()`
|
|
|
|
send SELECT sleep(50);
|
|
--sleep 0.5
|
|
|
|
--disable_abort_on_error
|
|
--disable_result_log
|
|
--disable_query_log
|
|
connect(con3,localhost,root,,,,,connect_timeout=2);
|
|
--enable_query_log
|
|
--enable_result_log
|
|
--enable_abort_on_error
|
|
let $error = $mysql_errno;
|
|
if (!$error)
|
|
{
|
|
--echo # -- Error: managed to establish more than --thread_pool_max_threads connections
|
|
}
|
|
if ($error)
|
|
{
|
|
--echo # -- Success: more than --thread_pool_max_threads normal connections not possible
|
|
}
|
|
|
|
connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
|
|
connection extracon;
|
|
SELECT 'Connection on extra port ok';
|
|
|
|
# Here, sleep just for slightly longer than 5 sec to trigger MDEV-4566
|
|
# (abort in interruptible wait connection check).
|
|
send SELECT sleep(5.5);
|
|
|
|
|
|
connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
|
|
connection extracon2;
|
|
SELECT 'Connection on extra port 2 ok';
|
|
|
|
--disable_abort_on_error
|
|
--disable_result_log
|
|
--disable_query_log
|
|
connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,,connect_timeout=2);
|
|
--enable_query_log
|
|
--enable_result_log
|
|
--enable_abort_on_error
|
|
let $error = $mysql_errno;
|
|
if (!$error)
|
|
{
|
|
--echo # -- Error: managed to establish more than --extra-max-connections + 1 connections
|
|
}
|
|
if ($error)
|
|
{
|
|
--echo # -- Success: more than --extra-max-connections + 1 normal connections not possible
|
|
}
|
|
|
|
connection extracon2;
|
|
--replace_result $con1_id <default_connection_ID>
|
|
eval KILL QUERY $con1_id;
|
|
--replace_result $con2_id <con2_connection_ID>
|
|
eval KILL QUERY $con2_id;
|
|
|
|
connection default;
|
|
--reap
|
|
connection con2;
|
|
--reap
|
|
|
|
connection extracon;
|
|
--reap
|