List:Commits« Previous MessageNext Message »
From:rsomla Date:November 28 2006 8:26am
Subject:bk commit into 5.0 tree (rafal:1.2310) BUG#24507
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of rafal. When rafal 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, 2006-11-28 09:26:26+01:00, rafal@quant.(none) +1 -0
  BUG#24507 (rpl_log.test crash slave):
  
  This patch introduces pthread_join() call when terminating slave I/O 
  and SQL threads. This will make the main thread to wait until these 
  threads are really finished avoiding possible race conditions in 
  thread termination code.
  
  Using pthread_join() means that the threads should not be deteached.
  
  This change could also help with BUG#24387.

  sql/slave.cc@stripped, 2006-11-28 09:26:23+01:00, rafal@quant.(none) +14 -6
    - Added pthread_join() call in terminate_slave_thread.
    - Removed pthread_deteatch... calls from slave thread handlers.
    - Added more messages informing about what is going on at slave 
      thread termination (to help locating bugs in the future).
    - Added more asserts. 

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	rafal
# Host:	quant.(none)
# Root:	/ext/mysql/bk/mysql-5.0-bug24507

--- 1.284/sql/slave.cc	2006-11-28 09:26:31 +01:00
+++ 1.285/sql/slave.cc	2006-11-28 09:26:31 +01:00
@@ -705,6 +705,9 @@
     set_timespec(abstime,2);
     pthread_cond_timedwait(term_cond, cond_lock, &abstime);
   }
+  
+  pthread_join(thd->real_id,NULL);  // wait until thread really terminates.
+  
   if (term_lock)
     pthread_mutex_unlock(term_lock);
   DBUG_RETURN(0);
@@ -1107,6 +1110,7 @@
 
 static bool io_slave_killed(THD* thd, MASTER_INFO* mi)
 {
+  DBUG_ASSERT(mi && thd);
   DBUG_ASSERT(mi->io_thd == thd);
   DBUG_ASSERT(mi->slave_running); // tracking buffer overrun
   return mi->abort_slave || abort_loop || thd->killed;
@@ -1115,6 +1119,7 @@
 
 static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli)
 {
+  DBUG_ASSERT(rli && thd);
   DBUG_ASSERT(rli->sql_thd == thd);
   DBUG_ASSERT(rli->slave_running == 1);// tracking buffer overrun
   return rli->abort_slave || abort_loop || thd->killed;
@@ -3459,7 +3464,7 @@
   thd= new THD; // note that contructor of THD uses DBUG_ !
   THD_CHECK_SENTRY(thd);
 
-  pthread_detach_this_thread();
+  // pthread_detach_this_thread(); // do not deteach as we want to join later 
   thd->thread_stack= (char*) &thd; // remember where our stack is
   if (init_slave_thread(thd, SLAVE_THD_IO))
   {
@@ -3760,14 +3765,17 @@
   mi->slave_running= 0;
   mi->io_thd= 0;
   pthread_mutex_unlock(&mi->run_lock);
+  sql_print_information("Slave I/O thread: broadcasting stop_cond");
   pthread_cond_broadcast(&mi->stop_cond);       // tell the world we are done
+  
 #ifndef DBUG_OFF
   if (abort_slave_event_count && !events_till_abort)
     goto slave_begin;
 #endif
-  my_thread_end();
-  pthread_exit(0);
-  DBUG_RETURN(0);				// Can't return anything here
+  sql_print_information("Slave I/O thread: exit.");
+  my_thread_end(); 
+  pthread_exit(0);	
+  return 0;				// Can't return anything here
 }
 
 
@@ -3802,7 +3810,7 @@
   /* Inform waiting threads that slave has started */
   rli->slave_run_id++;
 
-  pthread_detach_this_thread();
+  // pthread_detach_this_thread();  // do not deteach since we are going to join with this thread
   if (init_slave_thread(thd, SLAVE_THD_SQL))
   {
     /*
@@ -3996,7 +4004,7 @@
 #endif  
   my_thread_end();
   pthread_exit(0);
-  DBUG_RETURN(0);				// Can't return anything here
+  return 0;				// Can't return anything here
 }
 
 
Thread
bk commit into 5.0 tree (rafal:1.2310) BUG#24507rsomla28 Nov