Commit e46b3453 authored by Rohit Kalhans's avatar Rohit Kalhans

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.
parent 9fb4a47e
...@@ -221,7 +221,13 @@ class Relay_log_info : public Slave_reporting_capability ...@@ -221,7 +221,13 @@ class Relay_log_info : public Slave_reporting_capability
#endif #endif
/* if not set, the value of other members of the structure are undefined */ /* 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 bool abort_slave;
volatile uint slave_running; volatile uint slave_running;
......
...@@ -598,11 +598,15 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, ...@@ -598,11 +598,15 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
DBUG_PRINT("sleep",("Waiting for slave thread to start")); DBUG_PRINT("sleep",("Waiting for slave thread to start"));
const char* old_msg = thd->enter_cond(start_cond,cond_lock, const char* old_msg = thd->enter_cond(start_cond,cond_lock,
"Waiting for slave thread to start"); "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); thd->exit_cond(old_msg);
pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released pthread_mutex_lock(cond_lock); // re-acquire it as exit_cond() released
if (thd->killed) if (thd->killed)
{
if (start_lock)
pthread_mutex_unlock(start_lock);
DBUG_RETURN(thd->killed_errno()); DBUG_RETURN(thd->killed_errno());
}
} }
} }
if (start_lock) if (start_lock)
...@@ -2531,6 +2535,7 @@ pthread_handler_t handle_slave_io(void *arg) ...@@ -2531,6 +2535,7 @@ pthread_handler_t handle_slave_io(void *arg)
thd= new THD; // note that contructor of THD uses DBUG_ ! thd= new THD; // note that contructor of THD uses DBUG_ !
THD_CHECK_SENTRY(thd); THD_CHECK_SENTRY(thd);
DBUG_ASSERT(mi->io_thd == 0);
mi->io_thd = thd; mi->io_thd = thd;
pthread_detach_this_thread(); pthread_detach_this_thread();
...@@ -4489,9 +4494,6 @@ int rotate_relay_log(Master_info* mi) ...@@ -4489,9 +4494,6 @@ int rotate_relay_log(Master_info* mi)
Relay_log_info* rli= &mi->rli; Relay_log_info* rli= &mi->rli;
int error= 0; 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 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). LOCK_log, which may not be inited (if we're not a slave).
...@@ -4521,7 +4523,6 @@ int rotate_relay_log(Master_info* mi) ...@@ -4521,7 +4523,6 @@ int rotate_relay_log(Master_info* mi)
*/ */
rli->relay_log.harvest_bytes_written(&rli->log_space_total); rli->relay_log.harvest_bytes_written(&rli->log_space_total);
end: end:
pthread_mutex_unlock(&mi->run_lock);
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment