List:Commits« Previous MessageNext Message »
From:Rohit Kalhans Date:August 26 2011 10:01am
Subject:bzr push into mysql-5.1 branch (rohit.kalhans:3590 to 3591) Bug#11878104
View as plain text  
 3591 Rohit Kalhans	2011-08-26
      BUG#11878104: FIXES OF BUG 11752963 - 44312 TO BACKPORT TO MYSQL-5.1
      Background: Backporting fix for BUG 11752963 to Mysql5.1 branch.
      Problem: Fix of bug 11752963 was only available for trunk and 5.5 branch.
      Partial fix has been pushed to 5.1 branch as well. 
      Fix: backporting the fixes of bug 11752963 to 5.1 branch. 
      1. Made all major changes to make 5.1 branch in line with 5.5 and the trunk.
      2. skipped the partial patch that was already applied to the 5.1 branch. 
     @ sql/rpl_rli.h
        Made inited Volatile (find inline comments)
     @ sql/slave.cc
        backported all changes from the fix of BUG#11752963.

    modified:
      sql/rpl_rli.h
      sql/slave.cc
 3590 Sergey Vojtovich	2011-08-24 [merge]
      Merge.

    modified:
      mysql-test/r/merge.result
      mysql-test/t/merge.test
      sql/sql_base.cc
=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h	2011-06-30 15:37:13 +0000
+++ b/sql/rpl_rli.h	2011-08-26 09:57:29 +0000
@@ -221,7 +221,13 @@ public:
 #endif  
 
   /* if not set, the value of other members of the structure are undefined */
-  bool inited;
+  /*
+    inited changes its value within LOCK_active_mi-guarded critical
+    sections  at times of start_slave_threads() (0->1) and end_slave() (1->0).
+    Readers may not acquire the mutex while they realize potential concurrency
+    issue.
+  */
+  volatile bool inited;
   volatile bool abort_slave;
   volatile uint slave_running;
 

=== modified file 'sql/slave.cc'
--- a/sql/slave.cc	2011-07-03 15:47:37 +0000
+++ b/sql/slave.cc	2011-08-26 09:57:29 +0000
@@ -598,11 +598,15 @@ int start_slave_thread(pthread_handler h
       DBUG_PRINT("sleep",("Waiting for slave thread to start"));
       const char* old_msg = thd->enter_cond(start_cond,cond_lock,
                                             "Waiting for slave thread to start");
-      pthread_cond_wait(start_cond,cond_lock);
+      pthread_cond_wait(start_cond, cond_lock);
       thd->exit_cond(old_msg);
       pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
       if (thd->killed)
+      {
+        if (start_lock)
+          pthread_mutex_unlock(start_lock);
         DBUG_RETURN(thd->killed_errno());
+      }
     }
   }
   if (start_lock)
@@ -2531,6 +2535,7 @@ pthread_handler_t handle_slave_io(void *
 
   thd= new THD; // note that contructor of THD uses DBUG_ !
   THD_CHECK_SENTRY(thd);
+  DBUG_ASSERT(mi->io_thd == 0);
   mi->io_thd = thd;
 
   pthread_detach_this_thread();
@@ -4489,9 +4494,6 @@ int rotate_relay_log(Master_info* mi)
   Relay_log_info* rli= &mi->rli;
   int error= 0;
 
-  /* We don't lock rli->run_lock. This would lead to deadlocks. */
-  pthread_mutex_lock(&mi->run_lock);
-
   /*
      We need to test inited because otherwise, new_file() will attempt to lock
      LOCK_log, which may not be inited (if we're not a slave).
@@ -4521,7 +4523,6 @@ int rotate_relay_log(Master_info* mi)
   */
   rli->relay_log.harvest_bytes_written(&rli->log_space_total);
 end:
-  pthread_mutex_unlock(&mi->run_lock);
   DBUG_RETURN(error);
 }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1 branch (rohit.kalhans:3590 to 3591) Bug#11878104Rohit Kalhans26 Aug