1# Start with thread_handling=pool-of-threads
2# and run a number of tests
3
4-- source include/have_pool_of_threads.inc
5-- source include/default_optimizer_switch.inc
6
7SET optimizer_switch='outer_join_with_cache=off';
8# Slow test, don't run during staging part
9-- source include/not_staging.inc
10-- source include/long_test.inc
11-- source include/common-tests.inc
12SET optimizer_switch=default;
13
14# Test that we cannot have more simultaneous connections than
15# --thread-pool-size on the standard port, but _can_ have additional
16# connections on the extra port.
17
18# First set two connections running, and check that extra connection
19# on normal port fails due to --thread-pool-max-threads=2.
20# We can afford using a really long sleep, because we won't wait
21# till it ends, we'll interrupt it as soon as we don't need it anymore
22
23connection default;
24--let $con1_id= `SELECT CONNECTION_ID()`
25
26send SELECT sleep(50);
27--sleep  1
28
29connect(con2,localhost,root,,);
30--let $con2_id= `SELECT CONNECTION_ID()`
31
32send SELECT sleep(50);
33--sleep  0.5
34
35--disable_abort_on_error
36--disable_result_log
37--disable_query_log
38connect(con3,localhost,root,,,,,connect_timeout=2);
39--enable_query_log
40--enable_result_log
41--enable_abort_on_error
42let $error = $mysql_errno;
43if (!$error)
44{
45  --echo # -- Error: managed to establish more than --thread_pool_max_threads connections
46}
47if ($error)
48{
49  --echo # -- Success: more than --thread_pool_max_threads normal connections not possible
50}
51
52connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
53connection extracon;
54SELECT 'Connection on extra port ok';
55
56# Here, sleep just for slightly longer than 5 sec to trigger MDEV-4566
57# (abort in interruptible wait connection check).
58send SELECT sleep(5.5);
59
60
61connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
62connection extracon2;
63SELECT 'Connection on extra port 2 ok';
64
65--disable_abort_on_error
66--disable_result_log
67--disable_query_log
68connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,,connect_timeout=2);
69--enable_query_log
70--enable_result_log
71--enable_abort_on_error
72let $error = $mysql_errno;
73if (!$error)
74{
75  --echo # -- Error: managed to establish more than --extra-max-connections + 1 connections
76}
77if ($error)
78{
79  --echo # -- Success: more than --extra-max-connections + 1 normal connections not possible
80}
81
82connection extracon2;
83--replace_result $con1_id <default_connection_ID>
84eval KILL QUERY $con1_id;
85--replace_result $con2_id <con2_connection_ID>
86eval KILL QUERY $con2_id;
87
88connection default;
89--error ER_QUERY_INTERRUPTED
90--reap
91connection con2;
92--error ER_QUERY_INTERRUPTED
93--reap
94
95connection extracon;
96--reap
97
98# Check if compression works OK
99connect (comp_con,localhost,root,,,,,COMPRESS);
100SELECT 1;
101disconnect comp_con;
102
103