List:Commits« Previous MessageNext Message »
From:Davi Arnaut Date:February 10 2009 12:30pm
Subject:bzr commit into mysql-6.0-bugteam branch (davi:3039) Bug#39897
View as plain text  
# At a local mysql-6.0-bugteam repository of davi

 3039 Davi Arnaut	2009-01-15
      Bug#39897: lock_multi fails in pushbuild: timeout waiting for processlist
      
      The problem is that relying on the "Table lock" thread state in
      its current position to detect that a thread is waiting on a lock
      is race prone. The "Table lock" state change happens before the
      thread actually tries to grab a lock on a table.
      
      The solution is to move the "Table lock" state so that its set
      only when a thread is actually going to wait for a lock. The state
      change happens after the thread fails to grab the lock (because it
      is owned by other thread) and proceeds to wait on a condition.
      modified:
        mysys/thr_lock.c
        sql/lock.cc

per-file messages:
  mysys/thr_lock.c
    Update thread state while waiting for a table lock.
  sql/lock.cc
    Remove state change.
=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c	2009-02-04 11:52:20 +0000
+++ b/mysys/thr_lock.c	2009-01-15 14:17:57 +0000
@@ -426,6 +426,7 @@ wait_for_lock(struct st_lock_list *wait,
   struct timespec wait_timeout;
   enum enum_thr_lock_result result= THR_LOCK_ABORTED;
   my_bool can_deadlock= test(data->owner->info->n_cursors);
+  const char *old_proc_info;
   DBUG_ENTER("wait_for_lock");
 
 #if defined(ENABLED_DEBUG_SYNC)
@@ -451,6 +452,9 @@ wait_for_lock(struct st_lock_list *wait,
   thread_var->current_cond=  cond;
   data->cond= cond;
 
+  old_proc_info= proc_info_hook(NULL, "Table lock",
+                                __func__, __FILE__, __LINE__);
+
   if (can_deadlock)
     set_timespec(wait_timeout, table_lock_wait_timeout);
   while (!thread_var->abort || in_wait_list)
@@ -521,6 +525,9 @@ wait_for_lock(struct st_lock_list *wait,
   thread_var->current_mutex= 0;
   thread_var->current_cond=  0;
   pthread_mutex_unlock(&thread_var->mutex);
+
+  proc_info_hook(NULL, old_proc_info, __func__, __FILE__, __LINE__);
+
   DBUG_RETURN(result);
 }
 

=== modified file 'sql/lock.cc'
--- a/sql/lock.cc	2009-01-18 23:21:43 +0000
+++ b/sql/lock.cc	2009-01-15 14:17:57 +0000
@@ -310,7 +310,6 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, 
       reset_lock_data_and_free(&sql_lock);
       break;
     }
-    thd_proc_info(thd, "Table lock");
     DBUG_PRINT("info", ("thd->proc_info %s", thd->proc_info));
     /* Copy the lock data array. thr_multi_lock() reorders its contens. */
     memcpy(sql_lock->locks + sql_lock->lock_count, sql_lock->locks,

Thread
bzr commit into mysql-6.0-bugteam branch (davi:3039) Bug#39897Davi Arnaut10 Feb 2009