diff options
author | Rohit Kalhans <rohit.kalhans@oracle.com> | 2011-08-26 15:27:29 +0530 |
---|---|---|
committer | Rohit Kalhans <rohit.kalhans@oracle.com> | 2011-08-26 15:27:29 +0530 |
commit | 2529effa80aec846ee8b496012d8c54774f54aeb (patch) | |
tree | 008d6ca214f476b5346153ccebd4b6028d7e874e /sql | |
parent | 4a0238b36af733fb30c4578e32345b11c51e5e99 (diff) | |
download | mariadb-git-2529effa80aec846ee8b496012d8c54774f54aeb.tar.gz |
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.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/rpl_rli.h | 8 | ||||
-rw-r--r-- | sql/slave.cc | 11 |
2 files changed, 13 insertions, 6 deletions
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h index 811ad8eb864..ae8639c69ac 100644 --- a/sql/rpl_rli.h +++ b/sql/rpl_rli.h @@ -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; diff --git a/sql/slave.cc b/sql/slave.cc index 6c375238ce4..02d8cc2c199 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -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")); 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 *arg) 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); } |