MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:January 28 2008 12:52pm
Subject:bk commit into 5.1 tree (davi:1.2661) BUG#30331
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 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

ChangeSet@stripped, 2008-01-28 10:52:41-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/lock_multi.result@stripped, 2008-01-28 10:52:34-02:00, davi@stripped +12 -0
    Add test case result for Bug#30331

  mysql-test/t/lock_multi.test@stripped, 2008-01-28 10:52:34-02:00, davi@stripped +26 -0
    Add test case for Bug#30331

  mysys/thr_lock.c@stripped, 2008-01-28 10:52:34-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/lock_multi.result b/mysql-test/r/lock_multi.result
--- a/mysql-test/r/lock_multi.result	2007-12-12 19:44:11 -02:00
+++ b/mysql-test/r/lock_multi.result	2008-01-28 10:52:34 -02:00
@@ -143,4 +143,16 @@ connection: default
 flush tables;
 unlock tables;
 drop table t1;
+drop table if exists t1,t2;
+create table t1 (a int);
+flush status;
+lock tables t1 read;
+show status like 'Table_locks_waited';
+Variable_name	Value
+Table_locks_waited	0
+insert into t1 values(1);;
+drop table t1;
+show status like 'Table_locks_waited';
+Variable_name	Value
+Table_locks_waited	1
 End of 5.1 tests
diff -Nrup a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
--- a/mysql-test/t/lock_multi.test	2007-12-12 19:44:11 -02:00
+++ b/mysql-test/t/lock_multi.test	2008-01-28 10:52:34 -02:00
@@ -439,4 +439,30 @@ connection default;
 disconnect flush;
 drop table t1;
+# Bug#30331: Table_locks_waited shows inaccurate values
+drop table if exists t1,t2;
+create table t1 (a int);
+flush status;
+lock tables t1 read;
+show status like 'Table_locks_waited';
+connect (waiter,localhost,root,,);
+connection waiter;
+--send insert into t1 values(1);
+connection default;
+let $wait_condition=
+  select count(*) = 1 from information_schema.processlist
+  where state = "Locked" and info = "insert into t1 values(1)";
+--source include/
+drop table t1;
+disconnect waiter;
+connection default;
+show status like 'Table_locks_waited';
+#show global status like "Table_locks_waited";
 --echo End of 5.1 tests
diff -Nrup a/mysys/thr_lock.c b/mysys/thr_lock.c
--- a/mysys/thr_lock.c	2007-11-15 17:25:40 -02:00
+++ b/mysys/thr_lock.c	2008-01-28 10:52:34 -02:00
@@ -405,6 +405,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;
@@ -469,7 +471,6 @@ wait_for_lock(struct st_lock_list *wait,
     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);
bk commit into 5.1 tree (davi:1.2661) BUG#30331Davi Arnaut28 Jan