Below is the list of changes that have just been committed into a local
6.0 repository of davi. When davi does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-03-18 15:08:06-03:00, davi@stripped +4 -0
Bug#17954 Threads_connected > Threads_created
The problem is that insert delayed threads are counted as connected
but not as created, leading to a Threads_connected value greater then
the Threads_created value.
The solution is to enforce documented behavior that the
Threads_connected value shall be the number of currently
open connections and that Threads_created shall be the
number of threads created to handle connections.
Also there is a incompatible change that Thread_connected
and Thread_created are not reset to 0 anymore by the FLUSH
STATUS statement.
mysql-test/r/status.result@stripped, 2008-03-18 15:08:01-03:00, davi@stripped +9 -0
Add test case result for Bug#17954
mysql-test/t/status.test@stripped, 2008-03-18 15:08:01-03:00, davi@stripped +11 -0
Add test case for Bug#17954
sql/mysql_priv.h@stripped, 2008-03-18 15:08:01-03:00, davi@stripped +3 -2
thread_running and connection_count as long
sql/mysqld.cc@stripped, 2008-03-18 15:08:01-03:00, davi@stripped +6 -5
Change connection_count and thread_running types to unsigned
long and don't allow flushing it's values because their values
reflect the number of connections or threads running in the
server at a given moment, also it's not thread-safe to change
this variables without acquiring the appropriate locks.
diff -Nrup a/mysql-test/r/status.result b/mysql-test/r/status.result
--- a/mysql-test/r/status.result 2007-12-18 22:27:12 -02:00
+++ b/mysql-test/r/status.result 2008-03-18 15:08:01 -03:00
@@ -183,3 +183,12 @@ Com_create_function 1
Com_drop_function 1
Com_show_function_code 0
Com_show_function_status 0
+SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
+SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
+VARIABLE_NAME
+SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
+FLUSH STATUS;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
+VARIABLE_NAME VARIABLE_VALUE
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;
+VARIABLE_NAME VARIABLE_VALUE
diff -Nrup a/mysql-test/t/status.test b/mysql-test/t/status.test
--- a/mysql-test/t/status.test 2007-12-21 17:27:42 -02:00
+++ b/mysql-test/t/status.test 2008-03-18 15:08:01 -03:00
@@ -262,3 +262,14 @@ show global status like 'Com%function%';
# End of 5.1 tests
+
+#
+# Bug #17954: Threads_connected > Threads_created
+#
+
+SELECT VARIABLE_VALUE INTO @tc FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected';
+SELECT VARIABLE_NAME FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_created' AND VARIABLE_VALUE < @tc;
+SELECT VARIABLE_VALUE INTO @tr FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running';
+FLUSH STATUS;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_connected' AND VARIABLE_VALUE < @tc;
+SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Threads_running' AND VARIABLE_VALUE < @tr;
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h 2008-03-12 11:49:46 -03:00
+++ b/sql/mysql_priv.h 2008-03-18 15:08:01 -03:00
@@ -1981,8 +1981,9 @@ extern my_bool opt_log_queries_not_using
extern bool opt_disable_networking, opt_skip_show_db;
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 uint connection_count;
+extern uint volatile thread_count, global_read_lock;
+extern ulong volatile thread_running;
+extern ulong 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;
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2008-03-14 10:42:59 -03:00
+++ b/sql/mysqld.cc 2008-03-18 15:08:01 -03:00
@@ -503,7 +503,8 @@ uint mysqld_port_timeout;
uint delay_key_write_options, protocol_version;
uint lower_case_table_names;
uint tc_heuristic_recover= 0;
-uint volatile thread_count, thread_running;
+uint volatile thread_count;
+ulong volatile thread_running;
ulonglong thd_startup_options;
ulong back_log, connect_timeout, concurrency, server_id;
ulong table_cache_size, table_def_size;
@@ -799,7 +800,7 @@ struct st_VioSSLFd *ssl_acceptor_fd;
Number of currently active user connections. The variable is protected by
LOCK_connection_count.
*/
-uint connection_count= 0;
+ulong connection_count= 0;
/* Function declarations */
@@ -2504,7 +2505,7 @@ and this may fail.\n\n");
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads);
- fprintf(stderr, "threads_connected=%u\n", thread_count);
+ fprintf(stderr, "thread_count=%u\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
@@ -7438,9 +7439,9 @@ SHOW_VAR status_vars[]= {
{"Tc_log_page_waits", (char*) &tc_log_page_waits, SHOW_LONG},
#endif
{"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH},
- {"Threads_connected", (char*) &thread_count, SHOW_INT},
+ {"Threads_connected", (char*) &connection_count, SHOW_LONG_NOFLUSH},
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
- {"Threads_running", (char*) &thread_running, SHOW_INT},
+ {"Threads_running", (char*) &thread_running, SHOW_LONG_NOFLUSH},
{"Uptime", (char*) &show_starttime, SHOW_FUNC},
#ifdef COMMUNITY_SERVER
{"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_FUNC},