Commit 0d19df2f authored by unknown's avatar unknown

Replication: give the slave I/O thread a higher priority than the slave SQL thread

so that it has fetched the most from the master's binlog before the master
accidently dies. SCRUM task #756.


sql/slave.cc:
  Replication: give the slave I/O thread a higher priority than the slave SQL thread
  so that it has fetched the most from the master's binlog before the master
  accidently dies.
sql/slave.h:
  Replication: give the slave I/O thread a higher priority than the slave SQL thread
  so that it has fetched the most from the master's binlog before the master
  accidently dies.
parent e376fa61
...@@ -492,7 +492,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, ...@@ -492,7 +492,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
pthread_cond_t *start_cond, pthread_cond_t *start_cond,
volatile bool *slave_running, volatile bool *slave_running,
volatile ulong *slave_run_id, volatile ulong *slave_run_id,
MASTER_INFO* mi) MASTER_INFO* mi,
bool high_priority)
{ {
pthread_t th; pthread_t th;
ulong start_id; ulong start_id;
...@@ -521,6 +522,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, ...@@ -521,6 +522,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock,
} }
start_id= *slave_run_id; start_id= *slave_run_id;
DBUG_PRINT("info",("Creating new slave thread")); DBUG_PRINT("info",("Creating new slave thread"));
if (high_priority)
my_pthread_attr_setprio(&connection_attrib,CONNECT_PRIOR);
if (pthread_create(&th, &connection_attrib, h_func, (void*)mi)) if (pthread_create(&th, &connection_attrib, h_func, (void*)mi))
{ {
if (start_lock) if (start_lock)
...@@ -585,13 +588,13 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, ...@@ -585,13 +588,13 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io, error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io,
cond_io, cond_io,
&mi->slave_running, &mi->slave_run_id, &mi->slave_running, &mi->slave_run_id,
mi); mi, 1); //high priority, to read the most possible
if (!error && (thread_mask & SLAVE_SQL)) if (!error && (thread_mask & SLAVE_SQL))
{ {
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql, error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql,
cond_sql, cond_sql,
&mi->rli.slave_running, &mi->rli.slave_run_id, &mi->rli.slave_running, &mi->rli.slave_run_id,
mi); mi, 0);
if (error) if (error)
terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0); terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
} }
......
...@@ -368,7 +368,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock, ...@@ -368,7 +368,8 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t* start_lock,
pthread_cond_t* start_cond, pthread_cond_t* start_cond,
volatile bool *slave_running, volatile bool *slave_running,
volatile ulong *slave_run_id, volatile ulong *slave_run_id,
MASTER_INFO* mi); MASTER_INFO* mi,
bool high_priority);
/* If fd is -1, dump to NET */ /* If fd is -1, dump to NET */
int mysql_table_dump(THD* thd, const char* db, int mysql_table_dump(THD* thd, const char* db,
......
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