# At a local mysql-6.0 repository of davi
2857 Davi Arnaut 2008-10-07
Bug#39916: pool-of-threads fails to increment the number of created threads
The problem is that threads created under the pool-of-threads mode
weren't being properly accounted for in the Threads_created variable.
The solution is to increase the number of Threads_created every time
a thread is created and added to the pool. This means that the number
of threads created is equal to the size of the thread pool.
modified:
mysql-test/r/status.result
mysql-test/t/status.test
sql/mysql_priv.h
sql/mysqld.cc
sql/scheduler.cc
per-file messages:
mysql-test/r/status.result
Add test case result for Bug#39916
mysql-test/t/status.test
Add test case for Bug#39916
sql/mysql_priv.h
Export thread_created
sql/mysqld.cc
thread_created is now exported.
sql/scheduler.cc
Incrase thread_created every time a thread is created.
=== modified file 'mysql-test/r/status.result'
--- a/mysql-test/r/status.result 2008-10-03 12:44:52 +0000
+++ b/mysql-test/r/status.result 2008-10-07 20:09:02 +0000
@@ -221,4 +221,9 @@ NAME VALUE
SELECT * FROM v1 WHERE NAME = 'Threads_running' AND VALUE < @tr;
NAME VALUE
DROP VIEW v1;
+SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME = 'Threads_created' AND
+CONVERT(VARIABLE_VALUE, UNSIGNED) > 0;
+VARIABLE_NAME
+THREADS_CREATED
set @@global.concurrent_insert= @old_concurrent_insert;
=== modified file 'mysql-test/t/status.test'
--- a/mysql-test/t/status.test 2008-10-03 12:44:52 +0000
+++ b/mysql-test/t/status.test 2008-10-07 20:09:02 +0000
@@ -314,6 +314,15 @@ SELECT * FROM v1 WHERE NAME = 'Threads_r
DROP VIEW v1;
+#
+# Bug#39916: pool-of-threads fails to increment the number of created threads
+#
+
+SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+ WHERE VARIABLE_NAME = 'Threads_created' AND
+ CONVERT(VARIABLE_VALUE, UNSIGNED) > 0;
+
+
# Restore global concurrent_insert value. Keep in the end of the test file.
--connection default
set @@global.concurrent_insert= @old_concurrent_insert;
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2008-10-07 17:04:28 +0000
+++ b/sql/mysql_priv.h 2008-10-07 20:09:02 +0000
@@ -2038,6 +2038,7 @@ extern bool opt_disable_networking, opt_
extern my_bool opt_character_set_client_handshake;
extern bool volatile abort_loop, shutdown_in_progress;
extern uint volatile thread_count, thread_running, global_read_lock;
+extern ulong thread_created;
extern uint connection_count;
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2008-10-07 17:04:28 +0000
+++ b/sql/mysqld.cc 2008-10-07 20:09:02 +0000
@@ -408,7 +408,7 @@ static bool volatile ready_to_exit;
static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
static my_bool opt_short_log_format= 0;
static uint kill_cached_threads, wake_thread;
-static ulong killed_threads, thread_created;
+static ulong killed_threads;
static ulong max_used_connections;
static volatile ulong cached_thread_count= 0;
static const char *sql_mode_str= "OFF";
@@ -533,6 +533,7 @@ uint delay_key_write_options, protocol_v
uint lower_case_table_names;
uint tc_heuristic_recover= 0;
uint volatile thread_count, thread_running;
+ulong thread_created;
ulonglong thd_startup_options;
ulong back_log, connect_timeout, concurrency, server_id;
ulong table_cache_size, table_def_size;
=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc 2008-06-27 19:07:13 +0000
+++ b/sql/scheduler.cc 2008-10-07 20:09:02 +0000
@@ -548,6 +548,7 @@ pthread_handler_t libevent_thread_proc(v
*/
(void) pthread_mutex_lock(&LOCK_thread_count);
created_threads++;
+ thread_created++;
if (created_threads == thread_pool_size)
(void) pthread_cond_signal(&COND_thread_count);
(void) pthread_mutex_unlock(&LOCK_thread_count);
| Thread |
|---|
| • bzr commit into mysql-6.0 branch (davi:2857) Bug#39916 | Davi Arnaut | 7 Oct |