Commit 2e4bde4c authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Fix pool_of_threads test case

parent a5a22e9f
...@@ -2084,10 +2084,10 @@ fld6 char(4) latin1_swedish_ci NO # ...@@ -2084,10 +2084,10 @@ fld6 char(4) latin1_swedish_ci NO #
show full columns from t2 from test like 's%'; show full columns from t2 from test like 's%';
Field Type Collation Null Key Default Extra Privileges Comment Field Type Collation Null Key Default Extra Privileges Comment
show keys from t2; show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
t2 1 fld3 1 fld3 A NULL NULL NULL BTREE t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
drop table t4, t3, t2, t1; drop table t4, t3, t2, t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
cont_nr int(11) NOT NULL auto_increment, cont_nr int(11) NOT NULL auto_increment,
...@@ -2153,7 +2153,7 @@ Warning 1052 Column 'kundentyp' in group statement is ambiguous ...@@ -2153,7 +2153,7 @@ Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1; drop table t1;
SELECT sleep(5); SELECT sleep(5);
SELECT sleep(5); SELECT sleep(5);
# -- Success: more than --thread-pool-size normal connections not possible # -- Success: more than --thread_pool_max_threads normal connections not possible
sleep(5) sleep(5)
0 0
sleep(5) sleep(5)
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
[mysqld.1] [mysqld.1]
loose-thread-handling= pool-of-threads loose-thread-handling= pool-of-threads
loose-thread_pool_size= 2 loose-thread_pool_size= 1
loose-thread_pool_max_threads= 2
extra-port= @ENV.MASTER_EXTRA_PORT extra-port= @ENV.MASTER_EXTRA_PORT
extra-max-connections=1 extra-max-connections=1
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
# connections on the extra port. # connections on the extra port.
# First set two connections running, and check that extra connection # First set two connections running, and check that extra connection
# on normal port fails due to--thread-pool-size=2 # on normal port fails due to--thread-pool-max_threads=2
connection default; connection default;
send SELECT sleep(5); send SELECT sleep(5);
...@@ -32,11 +32,11 @@ connect(con3,localhost,root,,); ...@@ -32,11 +32,11 @@ connect(con3,localhost,root,,);
let $error = $mysql_errno; let $error = $mysql_errno;
if (!$error) if (!$error)
{ {
--echo # -- Error: managed to establish more than --thread-pool-size connections --echo # -- Error: managed to establish more than --thread_pool_max_threads connections
} }
if ($error) if ($error)
{ {
--echo # -- Success: more than --thread-pool-size normal connections not possible --echo # -- Success: more than --thread_pool_max_threads normal connections not possible
} }
connection default; connection default;
......
...@@ -624,14 +624,22 @@ static pool_event_t * listener(worker_thread_t *current_thread, ...@@ -624,14 +624,22 @@ static pool_event_t * listener(worker_thread_t *current_thread,
/* Creates a new worker thread. thread_mutex must be held when calling this function */ /*
Creates a new worker thread.
thread_mutex must be held when calling this function
NOTE: in rare cases, the number of threads can exceed
threadpool_max_threads, because we need at least 2 threads
per group to prevent deadlocks (one listener + one worker)
*/
static int create_worker(thread_group_t *thread_group) static int create_worker(thread_group_t *thread_group)
{ {
pthread_t thread_id; pthread_t thread_id;
int err; int err;
DBUG_ENTER("create_worker"); DBUG_ENTER("create_worker");
if (tp_stats.num_worker_threads >= (int)threadpool_max_threads) if (tp_stats.num_worker_threads >= (int)threadpool_max_threads
&& thread_group->thread_count >= 2)
{ {
DBUG_PRINT("info", DBUG_PRINT("info",
("Cannot create new thread (maximum allowed threads reached)")); ("Cannot create new thread (maximum allowed threads reached)"));
...@@ -667,6 +675,9 @@ static int wake_or_create_thread(thread_group_t *thread_group) ...@@ -667,6 +675,9 @@ static int wake_or_create_thread(thread_group_t *thread_group)
if (thread_group->pending_thread_start_count > 0) if (thread_group->pending_thread_start_count > 0)
DBUG_RETURN(-1); DBUG_RETURN(-1);
if (thread_group->thread_count > thread_group->connection_count)
DBUG_RETURN(-1);
if (thread_group->thread_count < 4) if (thread_group->thread_count < 4)
{ {
DBUG_RETURN(create_worker(thread_group)); DBUG_RETURN(create_worker(thread_group));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment