List:Commits« Previous MessageNext Message »
From:Alexander Nozdrin Date:March 13 2008 9:02am
Subject:bk commit into 5.1 tree (anozdrin:1.2562) BUG#35074
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of anozdrin.  When anozdrin 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-13 12:02:12+03:00, anozdrin@quad. +3 -0
  Fix for Bug#35074: max_used_connections is not correct.
  
  The problem was that number of threads was used to calculate
  max_used_connections.
  
  The fix is to use number of active connections.

  mysql-test/r/connect.result@stripped, 2008-03-13 12:02:10+03:00, anozdrin@quad. +34 -0
    Update result file.

  mysql-test/t/connect.test@stripped, 2008-03-13 12:02:10+03:00, anozdrin@quad. +75 -0
    - Add a test case for Bug#35074: max_used_connections is not correct;
    - Make a test case for Bug#33507 more stable.

  sql/mysqld.cc@stripped, 2008-03-13 12:02:11+03:00, anozdrin@quad. +3 -3
    Use number of connections insetad of threads
    to calculate max_used_connections.

diff -Nrup a/mysql-test/r/connect.result b/mysql-test/r/connect.result
--- a/mysql-test/r/connect.result	2008-03-12 17:44:39 +03:00
+++ b/mysql-test/r/connect.result	2008-03-13 12:02:10 +03:00
@@ -162,13 +162,47 @@ root
 
 # -- Resetting variables...
 SET GLOBAL max_connections = 151;
+
+# -- Stopping Event Scheduler...
 SET GLOBAL event_scheduler = OFF;
+# -- Waiting for Event Scheduler to stop...
 
 # -- That's it. Closing connections...
 
 # -- Restoring default connection...
 
+# -- Waiting for connections to close...
+
+DROP USER mysqltest_u1@localhost;
+
 # -- End of Bug#33507.
+
+# -- Bug#35074: max_used_connections is not correct. 
+
+FLUSH STATUS;
+
+SHOW STATUS LIKE 'max_used_connections';
+Variable_name	Value
+Max_used_connections	1
+
+# -- Starting Event Scheduler...
+SET GLOBAL event_scheduler = ON;
+# -- Waiting for Event Scheduler to start...
+
+# -- Opening a new connection to check max_used_connections...
+
+# -- Check that max_used_connections hasn't changed.
+SHOW STATUS LIKE 'max_used_connections';
+Variable_name	Value
+Max_used_connections	2
+
+# -- Closing new connection...
+
+# -- Stopping Event Scheduler...
+SET GLOBAL event_scheduler = OFF;
+# -- Waiting for Event Scheduler to stop...
+
+# -- End of Bug#35074.
 
 # ------------------------------------------------------------------
 # -- End of 5.1 tests
diff -Nrup a/mysql-test/t/connect.test b/mysql-test/t/connect.test
--- a/mysql-test/t/connect.test	2008-03-12 17:44:39 +03:00
+++ b/mysql-test/t/connect.test	2008-03-13 12:02:10 +03:00
@@ -209,12 +209,23 @@ SELECT user FROM information_schema.proc
 --echo # -- Resetting variables...
 
 --eval SET GLOBAL max_connections = $saved_max_connections
+
+--echo
+--echo # -- Stopping Event Scheduler...
 SET GLOBAL event_scheduler = OFF;
 
+--echo # -- Waiting for Event Scheduler to stop...
+let $wait_condition =
+  SELECT COUNT(*) = 0
+  FROM information_schema.processlist
+  WHERE user = 'event_scheduler';
+--source include/wait_condition.inc
+
 --echo
 --echo # -- That's it. Closing connections...
 --disconnect con_1
 --disconnect con_2
+--disconnect con_3
 --disconnect con_super_1
 
 --echo
@@ -222,7 +233,71 @@ SET GLOBAL event_scheduler = OFF;
 --connect (default,localhost,root,,test)
 
 --echo
+--echo # -- Waiting for connections to close...
+let $wait_condition =
+  SELECT COUNT(*) = 1
+  FROM information_schema.processlist
+  WHERE db = 'test';
+--source include/wait_condition.inc
+
+--echo
+DROP USER mysqltest_u1@localhost;
+
+--echo
 --echo # -- End of Bug#33507.
+--echo
+
+###########################################################################
+
+--echo # -- Bug#35074: max_used_connections is not correct. 
+--echo
+
+FLUSH STATUS;
+
+--echo
+SHOW STATUS LIKE 'max_used_connections';
+
+--echo
+--echo # -- Starting Event Scheduler...
+SET GLOBAL event_scheduler = ON;
+
+--echo # -- Waiting for Event Scheduler to start...
+let $wait_condition =
+  SELECT COUNT(*) = 1
+  FROM information_schema.processlist
+  WHERE user = 'event_scheduler';
+--source include/wait_condition.inc
+
+# NOTE: We should use a new connection here instead of reconnect in order to
+# avoid races (we can not for sure when the connection being disconnected is
+# actually disconnected on the server).
+
+--echo
+--echo # -- Opening a new connection to check max_used_connections...
+--connect (con_1,localhost,root)
+
+--echo
+--echo # -- Check that max_used_connections hasn't changed.
+SHOW STATUS LIKE 'max_used_connections';
+
+--echo
+--echo # -- Closing new connection...
+--disconnect con_1
+--connection default
+
+--echo
+--echo # -- Stopping Event Scheduler...
+SET GLOBAL event_scheduler = OFF;
+
+--echo # -- Waiting for Event Scheduler to stop...
+let $wait_condition =
+  SELECT COUNT(*) = 0
+  FROM information_schema.processlist
+  WHERE user = 'event_scheduler';
+--source include/wait_condition.inc
+
+--echo
+--echo # -- End of Bug#35074.
 --echo
 
 --echo # ------------------------------------------------------------------
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc	2008-03-12 17:44:39 +03:00
+++ b/sql/mysqld.cc	2008-03-13 12:02:11 +03:00
@@ -4776,6 +4776,9 @@ static void create_new_thread(THD *thd)
 
   ++connection_count;
 
+  if (connection_count > max_used_connections)
+    max_used_connections= connection_count;
+
   pthread_mutex_unlock(&LOCK_connection_count);
 
   /* Start a new thread to handle connection. */
@@ -4790,9 +4793,6 @@ static void create_new_thread(THD *thd)
   thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
 
   thread_count++;
-
-  if (thread_count - delayed_insert_threads > max_used_connections)
-    max_used_connections= thread_count - delayed_insert_threads;
 
   thread_scheduler.add_connection(thd);
 
Thread
bk commit into 5.1 tree (anozdrin:1.2562) BUG#35074Alexander Nozdrin13 Mar