diff --git a/sql/binlog.cc b/sql/binlog.cc index e7ad65d82e1..e9403430948 100644 --- a/sql/binlog.cc +++ b/sql/binlog.cc @@ -6133,8 +6133,7 @@ err: shall be acquired, false if the called is already the owner of the lock_index. @param need_update_threads If we want to update the log coordinates of all threads. False for relay logs, true otherwise. - @param decrease_log_space If not null, decrement this variable of - the amount of log space freed + @param decrease_log_space If not null, return the amount of log space freed @param auto_purge True if this is an automatic purge. @note @@ -6461,7 +6460,7 @@ int MYSQL_BIN_LOG::purge_index_entry(THD *thd, ulonglong *decrease_log_space, DBUG_SET("-d,wait_in_purge_index_entry"); };); - if (decrease_log_space) *decrease_log_space -= s.st_size; + if (decrease_log_space) *decrease_log_space += s.st_size; } else { if (my_errno() == ENOENT) { if (thd) { diff --git a/sql/rpl_applier_reader.cc b/sql/rpl_applier_reader.cc index 18de4c84eea..a79515dc940 100644 --- a/sql/rpl_applier_reader.cc +++ b/sql/rpl_applier_reader.cc @@ -533,14 +533,16 @@ bool Rpl_applier_reader::purge_applied_logs() { DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE();); - mysql_mutex_lock(&m_rli->log_space_lock); + ulonglong log_space_purged = 0; if (m_rli->relay_log.purge_logs( m_rli->get_group_relay_log_name(), false /* include */, false /*need_lock_index*/, false /*need_update_threads*/, - &m_rli->log_space_total, true) != 0) + &log_space_purged, true) != 0) m_errmsg = "Error purging processed logs"; + mysql_mutex_lock(&m_rli->log_space_lock); + m_rli->log_space_total -= log_space_purged; // Tell the I/O thread to take the relay_log_space_limit into account m_rli->ignore_log_space_limit = false; mysql_cond_broadcast(&m_rli->log_space_cond);