Skip to content

Commit

Permalink
stop binlog background thread together with others
Browse files Browse the repository at this point in the history
that fixes many rpl tests failures
  • Loading branch information
vuvova committed Jun 4, 2016
1 parent 562c1df commit 4a0612e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
28 changes: 17 additions & 11 deletions sql/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3171,6 +3171,21 @@ MYSQL_BIN_LOG::MYSQL_BIN_LOG(uint *sync_period)
bzero((char*) &purge_index_file, sizeof(purge_index_file));
}

void MYSQL_BIN_LOG::stop_background_thread()
{
if (binlog_background_thread_started)
{
mysql_mutex_lock(&LOCK_binlog_background_thread);
binlog_background_thread_stop= true;
mysql_cond_signal(&COND_binlog_background_thread);
while (binlog_background_thread_stop)
mysql_cond_wait(&COND_binlog_background_thread_end,
&LOCK_binlog_background_thread);
mysql_mutex_unlock(&LOCK_binlog_background_thread);
binlog_background_thread_started= false;
}
}

/* this is called only once */

void MYSQL_BIN_LOG::cleanup()
Expand All @@ -3181,17 +3196,8 @@ void MYSQL_BIN_LOG::cleanup()
xid_count_per_binlog *b;

/* Wait for the binlog background thread to stop. */
if (!is_relay_log && binlog_background_thread_started)
{
mysql_mutex_lock(&LOCK_binlog_background_thread);
binlog_background_thread_stop= true;
mysql_cond_signal(&COND_binlog_background_thread);
while (binlog_background_thread_stop)
mysql_cond_wait(&COND_binlog_background_thread_end,
&LOCK_binlog_background_thread);
mysql_mutex_unlock(&LOCK_binlog_background_thread);
binlog_background_thread_started= false;
}
if (!is_relay_log)
stop_background_thread();

inited= 0;
close(LOG_CLOSE_INDEX|LOG_CLOSE_STOP_EVENT);
Expand Down
2 changes: 2 additions & 0 deletions sql/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,8 @@ class MYSQL_BIN_LOG: public TC_LOG, private MYSQL_LOG
mysql_cond_t COND_binlog_background_thread;
mysql_cond_t COND_binlog_background_thread_end;

void stop_background_thread();

using MYSQL_LOG::generate_name;
using MYSQL_LOG::is_open;

Expand Down
1 change: 1 addition & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ static void close_connections(void)

Events::deinit();
end_slave();
mysql_bin_log.stop_background_thread();

/*
Give threads time to die.
Expand Down

0 comments on commit 4a0612e

Please sign in to comment.