MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:December 21 2007 12:49pm
Subject:bk commit into 5.0 tree (davi:1.2583) BUG#30331
View as plain text  
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, 2007-12-21 10:49:21-02:00, davi@stripped +3 -0
  Bug#30331 Table_locks_waited shows inaccurate values
  
  The problem is that the Table_locks_waited was incremented only
  when the lock request succeed. If a thread waiting for the lock
  gets killed or the lock request is aborted, the variable would
  not be incremented, leading to inaccurate values in the variable.
  
  The solution is to increment the Table_locks_waited whenever the
  lock request is queued. This reflects better the intended behavior
  of the variable -- show how many times a lock was waited.

  mysql-test/r/variables.result@stripped, 2007-12-21 10:49:19-02:00, davi@stripped +14 -0
    Add test case result for Bug#30331

  mysql-test/t/variables.test@stripped, 2007-12-21 10:49:19-02:00, davi@stripped +24 -0
    Add test case for Bug#30331

  mysys/thr_lock.c@stripped, 2007-12-21 10:49:20-02:00, davi@stripped +2 -1
    Increment locks_waited whenever the thread is supposed
    to wait for the lock.

diff -Nrup a/mysql-test/r/variables.result b/mysql-test/r/variables.result
--- a/mysql-test/r/variables.result	2007-11-30 03:32:02 -02:00
+++ b/mysql-test/r/variables.result	2007-12-21 10:49:19 -02:00
@@ -838,6 +838,20 @@ SELECT @@log_slow_queries;
 1
 SET GLOBAL log_slow_queries=0;
 ERROR HY000: Variable 'log_slow_queries' is a read only variable
+drop table if exists t1,t2;
+create table t1 (a int);
+flush status;
+lock tables t1 read;
+show global status like "Table_locks%";
+Variable_name	Value
+Table_locks_immediate	1
+Table_locks_waited	0
+insert into t1 values(1);;
+drop table t1;
+show global status like "Table_locks%";
+Variable_name	Value
+Table_locks_immediate	1
+Table_locks_waited	1
 End of 5.0 tests
 set global binlog_cache_size         =@my_binlog_cache_size;
 set global connect_timeout           =@my_connect_timeout;
diff -Nrup a/mysql-test/t/variables.test b/mysql-test/t/variables.test
--- a/mysql-test/t/variables.test	2007-12-13 08:49:11 -02:00
+++ b/mysql-test/t/variables.test	2007-12-21 10:49:19 -02:00
@@ -696,6 +696,30 @@ SELECT @@log_slow_queries;
 --error 1238
 SET GLOBAL log_slow_queries=0;
 
+#
+# Bug #30331: Table_locks_waited shows inaccurate values
+#
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (a int);
+flush status;
+lock tables t1 read;
+show global status like "Table_locks%";
+connect (waiter,localhost,root,,);
+connection waiter;
+--send insert into t1 values(1);
+connection default;
+let $show_type= open tables where in_use=2;
+let $show_pattern= '%t1%2%0';
+--source include/wait_show_pattern.inc
+drop table t1;
+disconnect waiter;
+connection default;
+show global status like "Table_locks%";
+
 --echo End of 5.0 tests
 
 # This is at the very after the versioned tests, since it involves doing
diff -Nrup a/mysys/thr_lock.c b/mysys/thr_lock.c
--- a/mysys/thr_lock.c	2007-08-05 06:16:59 -03:00
+++ b/mysys/thr_lock.c	2007-12-21 10:49:20 -02:00
@@ -403,6 +403,8 @@ wait_for_lock(struct st_lock_list *wait,
     wait->last= &data->next;
   }
 
+  statistic_increment(locks_waited, &THR_LOCK_lock);
+
   /* Set up control struct to allow others to abort locks */
   thread_var->current_mutex= &data->lock->mutex;
   thread_var->current_cond=  cond;
@@ -458,7 +460,6 @@ wait_for_lock(struct st_lock_list *wait,
   else
   {
     result= THR_LOCK_SUCCESS;
-    statistic_increment(locks_waited, &THR_LOCK_lock);
     if (data->lock->get_status)
       (*data->lock->get_status)(data->status_param, 0);
     check_locks(data->lock,"got wait_for_lock",0);
Thread
bk commit into 5.0 tree (davi:1.2583) BUG#30331Davi Arnaut21 Dec
  • Re: bk commit into 5.0 tree (davi:1.2583) BUG#30331Dmitri Lenev24 Jan