summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-04-15 15:09:22 +0200
committerSergei Golubchik <sergii@pisem.net>2013-04-15 15:09:22 +0200
commita9035be5b7a7b3865ddb4ef34a5d0cfc65dfc254 (patch)
treea9df7341e91623f62fe37cd47fce139d8888fc95 /sql/log.cc
parent3a1c91d87d69ef243b3e78be6089102cafef0a8e (diff)
parentf57ecb7786177e0af3b1e3ec94302720b2e0f967 (diff)
downloadmariadb-git-a9035be5b7a7b3865ddb4ef34a5d0cfc65dfc254.tar.gz
10.0-base merge
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc83
1 files changed, 59 insertions, 24 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 254449da05a..088816d7954 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2290,7 +2290,7 @@ static int find_uniq_filename(char *name)
DBUG_RETURN(1);
}
file_info= dir_info->dir_entry;
- for (i= dir_info->number_off_files ; i-- ; file_info++)
+ for (i= dir_info->number_of_files ; i-- ; file_info++)
{
if (memcmp(file_info->name, start, length) == 0 &&
test_if_number(file_info->name+length, &number,0))
@@ -2301,7 +2301,7 @@ static int find_uniq_filename(char *name)
my_dirend(dir_info);
/* check if reached the maximum possible extension number */
- if ((max_found == MAX_LOG_UNIQUE_FN_EXT))
+ if (max_found == MAX_LOG_UNIQUE_FN_EXT)
{
sql_print_error("Log filename extension number exhausted: %06lu. \
Please fix this by archiving old logs and \
@@ -2965,6 +2965,19 @@ 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;
+ }
+
inited= 0;
close(LOG_CLOSE_INDEX|LOG_CLOSE_STOP_EVENT);
delete description_event_for_queue;
@@ -2981,19 +2994,6 @@ void MYSQL_BIN_LOG::cleanup()
my_free(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;
- }
-
mysql_mutex_destroy(&LOCK_log);
mysql_mutex_destroy(&LOCK_index);
mysql_mutex_destroy(&LOCK_xid_list);
@@ -3715,17 +3715,10 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd, bool create_new_log)
/* Now wait for all checkpoint requests and pending unlog() to complete. */
mysql_mutex_lock(&LOCK_xid_list);
- xid_count_per_binlog *b;
for (;;)
{
- I_List_iterator<xid_count_per_binlog> it(binlog_xid_count_list);
- while ((b= it++))
- {
- if (b->xid_count > 0)
- break;
- }
- if (!b)
- break; /* No more pending XIDs */
+ if (is_xidlist_idle_nolock())
+ break;
/*
Wait until signalled that one more binlog dropped to zero, then check
again.
@@ -4503,6 +4496,32 @@ MYSQL_BIN_LOG::can_purge_log(const char *log_file_name)
#endif /* HAVE_REPLICATION */
+bool
+MYSQL_BIN_LOG::is_xidlist_idle()
+{
+ bool res;
+ mysql_mutex_lock(&LOCK_xid_list);
+ res= is_xidlist_idle_nolock();
+ mysql_mutex_unlock(&LOCK_xid_list);
+ return res;
+}
+
+
+bool
+MYSQL_BIN_LOG::is_xidlist_idle_nolock()
+{
+ xid_count_per_binlog *b;
+
+ I_List_iterator<xid_count_per_binlog> it(binlog_xid_count_list);
+ while ((b= it++))
+ {
+ if (b->xid_count > 0)
+ return false;
+ }
+ return true;
+}
+
+
/**
Create a new log file name.
@@ -8228,6 +8247,13 @@ binlog_background_thread(void *arg __attribute__((unused)))
{
stop= binlog_background_thread_stop;
queue= binlog_background_thread_queue;
+ if (stop && !mysql_bin_log.is_xidlist_idle())
+ {
+ /*
+ Delay stop until all pending binlog checkpoints have been processed.
+ */
+ stop= false;
+ }
if (stop || queue)
break;
mysql_cond_wait(&mysql_bin_log.COND_binlog_background_thread,
@@ -8238,9 +8264,18 @@ binlog_background_thread(void *arg __attribute__((unused)))
mysql_mutex_unlock(&mysql_bin_log.LOCK_binlog_background_thread);
/* Process any incoming commit_checkpoint_notify() calls. */
+ DBUG_EXECUTE_IF("inject_binlog_background_thread_before_mark_xid_done",
+ DBUG_ASSERT(!debug_sync_set_action(
+ thd,
+ STRING_WITH_LEN("binlog_background_thread_before_mark_xid_done "
+ "SIGNAL injected_binlog_background_thread "
+ "WAIT_FOR something_that_will_never_happen "
+ "TIMEOUT 2")));
+ );
while (queue)
{
THD_STAGE_INFO(thd, stage_binlog_processing_checkpoint_notify);
+ DEBUG_SYNC(current_thd, "binlog_background_thread_before_mark_xid_done");
/* Grab next pointer first, as mark_xid_done() may free the element. */
next= queue->next_in_queue;
mysql_bin_log.mark_xid_done(queue->binlog_id, true);