Below is the list of changes that have just been committed into a local
5.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-01-14 09:28:42-02:00, davi@stripped +5 -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 increment the Threads_created variable when insert
delayed threads are created. Nevertheless, the Threads_connected may
still be greater then Threads_created because in reality it reflects
the number of open connections (or open thread states) that also might
not be associated with created threads.
mysql-test/r/status.result@stripped, 2008-01-14 09:28:39-02:00, davi@stripped +12 -0
Add test case result for Bug#17954
mysql-test/t/status.test@stripped, 2008-01-14 09:28:39-02:00, davi@stripped +27 -0
Add test case for Bug#17954
sql/mysql_priv.h@stripped, 2008-01-14 09:28:40-02:00, davi@stripped +1 -0
Export the thread_created variable.
sql/mysqld.cc@stripped, 2008-01-14 09:28:40-02:00, davi@stripped +2 -1
thread_create is now used outside this compilation unit.
sql/sql_insert.cc@stripped, 2008-01-14 09:28:40-02:00, davi@stripped +2 -3
Increment the thread_count value after the thread has been
created. Also, increment the thread_created value since
the thread has been successfully created.
diff -Nrup a/mysql-test/r/status.result b/mysql-test/r/status.result
--- a/mysql-test/r/status.result 2007-08-28 12:51:02 -03:00
+++ b/mysql-test/r/status.result 2008-01-14 09:28:39 -02:00
@@ -91,3 +91,15 @@ SHOW SESSION STATUS LIKE 'Last_query_cos
Variable_name Value
Last_query_cost 4.805836
DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int);
+FLUSH STATUS;
+SELECT @dit < @tcr;
+@dit < @tcr
+1
+SET GLOBAL delayed_insert_limit= 10;
+INSERT DELAYED INTO t1 VALUES (0);
+DROP TABLE t1;
+SELECT @dit < @ditp, @tcr < @tcrp, @ditp < @tcrp;
+@dit < @ditp @tcr < @tcrp @ditp < @tcrp
+1 1 1
diff -Nrup a/mysql-test/t/status.test b/mysql-test/t/status.test
--- a/mysql-test/t/status.test 2007-08-28 12:51:02 -03:00
+++ b/mysql-test/t/status.test 2008-01-14 09:28:39 -02:00
@@ -170,5 +170,32 @@ SHOW SESSION STATUS LIKE 'Last_query_cos
DROP TABLE t1;
+#
+# Bug #17954: Threads_connected > Threads_created
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a int);
+FLUSH STATUS;
+let $dit= `SHOW STATUS LIKE 'delayed_insert_threads'`;
+let $tcr= `SHOW STATUS LIKE 'threads_created'`;
+--disable_query_log
+eval SET @dit= SUBSTRING_INDEX('$dit', ' ', -1);
+eval SET @tcr= SUBSTRING_INDEX('$tcr', ' ', -1);
+--enable_query_log
+SELECT @dit < @tcr;
+SET GLOBAL delayed_insert_limit= 10;
+INSERT DELAYED INTO t1 VALUES (0);
+let $dit= `SHOW STATUS LIKE 'delayed_insert_threads'`;
+let $tcr= `SHOW STATUS LIKE 'threads_created'`;
+DROP TABLE t1;
+--disable_query_log
+eval SET @ditp= SUBSTRING_INDEX('$dit', ' ', -1);
+eval SET @tcrp= SUBSTRING_INDEX('$tcr', ' ', -1);
+--enable_query_log
+SELECT @dit < @ditp, @tcr < @tcrp, @ditp < @tcrp;
# End of 5.0 tests
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h 2007-12-13 08:49:12 -02:00
+++ b/sql/mysql_priv.h 2008-01-14 09:28:40 -02:00
@@ -1291,6 +1291,7 @@ extern ulong table_cache_size;
extern ulong max_connections,max_connect_errors, connect_timeout;
extern ulong slave_net_timeout, slave_trans_retries;
extern uint max_user_connections;
+extern ulong thread_created;
extern ulong what_to_log,flush_time;
extern ulong query_buff_size, thread_stack;
extern ulong max_prepared_stmt_count, prepared_stmt_count;
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-12-14 03:53:52 -02:00
+++ b/sql/mysqld.cc 2008-01-14 09:28:40 -02:00
@@ -323,7 +323,7 @@ static my_bool opt_debugging= 0, opt_ext
static my_bool opt_bdb, opt_isam, opt_ndbcluster, opt_merge;
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 ulong my_bind_addr; /* the address we bind to */
static volatile ulong cached_thread_count= 0;
@@ -438,6 +438,7 @@ ulong specialflag=0;
ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections, max_connect_errors;
uint max_user_connections= 0;
+ulong thread_created;
/*
Limit of the total number of prepared statements in the server.
Is necessary to protect the server against out-of-memory attacks.
diff -Nrup a/sql/sql_insert.cc b/sql/sql_insert.cc
--- a/sql/sql_insert.cc 2007-12-13 08:52:47 -02:00
+++ b/sql/sql_insert.cc 2008-01-14 09:28:40 -02:00
@@ -1804,9 +1804,6 @@ bool delayed_get_table(THD *thd, TABLE_L
thd->fatal_error();
goto end_create;
}
- pthread_mutex_lock(&LOCK_thread_count);
- thread_count++;
- pthread_mutex_unlock(&LOCK_thread_count);
di->thd.set_db(table_list->db, strlen(table_list->db));
di->thd.query= my_strdup(table_list->table_name, MYF(MY_WME));
if (di->thd.db == NULL || di->thd.query == NULL)
@@ -2149,6 +2146,8 @@ pthread_handler_t handle_delayed_insert(
pthread_detach_this_thread();
/* Add thread to THD list so that's it's visible in 'show processlist' */
pthread_mutex_lock(&LOCK_thread_count);
+ thread_created++;
+ thread_count++;
thd->thread_id=thread_id++;
thd->end_time();
threads.append(thd);
| Thread |
|---|
| • bk commit into 5.0 tree (davi:1.2583) BUG#17954 | Davi Arnaut | 14 Jan |