List:Commits« Previous MessageNext Message »
From:Oystein Grovlen Date:September 8 2008 9:27am
Subject:bzr push into mysql-6.0-backup branch (oystein.grovlen:2693 to 2694)
Bug#39152
View as plain text  
 2694 Oystein Grovlen	2008-09-08
      Bug#39152 Intermittent debug_sync time-outs in backup tests
      Timeouts have occurred due to race conditions in debug_sync
      Make sure all accesses to debug_sync_global.ds_signal is protected
      by mutex.
modified:
  sql/debug_sync.cc

 2693 Jorgen Loland	2008-09-08
      Bug#39189 - Backup: backup_backupdir.test fails in pushbuild
                  
      Old behavior: When giving hard path to backup command, a '/' was 
      appended at the end of the path (i.e., after the filename). 
      This was because the whole path was converted to fit the system. 
      In addition, convert_dirname crashed on some but not all 
      platforms when length was not specified.
                  
      New behavior: Only the directory name is converted to system. The
      filename is then appended without conversion. Conversion is 
      done with explicit path length.
modified:
  sql/backup/stream.cc

=== modified file 'sql/debug_sync.cc'

=== modified file 'sql/debug_sync.cc'
--- a/sql/debug_sync.cc	2008-06-30 19:40:33 +0000
+++ b/sql/debug_sync.cc	2008-09-08 09:25:46 +0000
@@ -711,7 +711,9 @@
   ds_control->ds_active= 0;
 
   /* Clear the global signal. */
+  pthread_mutex_lock(&debug_sync_global.ds_mutex);
   debug_sync_global.ds_signal.length(0);
+  pthread_mutex_unlock(&debug_sync_global.ds_mutex);
 
   DBUG_VOID_RETURN;
 }
@@ -1511,7 +1513,11 @@
 
   if (opt_debug_sync_timeout)
   {
-    static char on[]= "ON - current signal: '";
+    static char on[]= "ON - current signal: '"; 
+
+    // Ensure exclusive access to debug_sync_global.ds_signal
+    pthread_mutex_lock(&debug_sync_global.ds_mutex);
+
     size_t lgt= (sizeof(on) /* includes '\0' */ +
                  debug_sync_global.ds_signal.length() + 1 /* for '\'' */);
     char *vend;
@@ -1527,6 +1533,7 @@
         *(vptr++)= '\'';
       *vptr= '\0'; /* We have one byte reserved for the worst case. */
     }
+    pthread_mutex_unlock(&debug_sync_global.ds_mutex);
   }
   else
     value= strmake_root(thd->mem_root, STRING_WITH_LEN("OFF"));
@@ -1582,6 +1589,13 @@
       thd_proc_info(thd, proc_info.c_ptr());
     }
 
+    /*
+      Take mutex to ensure that only one thread access
+      debug_sync_global.ds_signal at a time.  Need to take mutex for
+      read access too, to create a memory barrier in order to avoid that
+      threads just reads an old cached version of the signal.
+    */
+    pthread_mutex_lock(&debug_sync_global.ds_mutex);
     if (action->signal.length())
     {
       /* Copy the signal to the global variable. */
@@ -1606,7 +1620,6 @@
       int             error= 0;
       struct timespec abstime;
 
-      pthread_mutex_lock(&debug_sync_global.ds_mutex);
       /*
         We don't use enter_cond()/exit_cond(). They do not save old
         mutex and cond. This would prohibit the use of DEBUG_SYNC
@@ -1670,6 +1683,11 @@
       pthread_mutex_unlock(&thd->mysys_var->mutex);
 
     } /* end if (action->wait_for.length()) */
+    else
+    {
+      // Make sure to realease mutex also when there is no WAIT_FOR
+      pthread_mutex_unlock(&debug_sync_global.ds_mutex);
+    }
 
   } /* end if (action->execute) */
 

Thread
bzr push into mysql-6.0-backup branch (oystein.grovlen:2693 to 2694)Bug#39152Oystein Grovlen8 Sep