summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
authorSachin Setiya <sachin.setiya@mariadb.com>2017-06-05 13:10:24 +0530
committerSachin Setiya <sachin.setiya@mariadb.com>2017-06-05 13:11:10 +0530
commitda61107fc8481b03ae858188dd03b3114e7aa084 (patch)
tree5964b2c334614bfdf12cfd24a5d627bb1c451aa9 /sql/rpl_mi.cc
parent112b21da37dad0fbb28bc65f9ab5a3ba6c0c2186 (diff)
downloadmariadb-git-da61107fc8481b03ae858188dd03b3114e7aa084.tar.gz
MDEV-9544 FLUSH [RELAY] LOGS does not rotate logs for a named slave
Problem:- In the case of multisource replication/named slave when we run "FLUSH LOGS" , it does not flush logs. Solution:- A new function Master_info_index->flush_all_relay_logs() is created which will rotate relay logs for all named slave. This will be called in reload_acl_and_cache function when connection_name.length == 0
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc51
1 files changed, 50 insertions, 1 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index c9dcf7b8fd7..ed756a996ca 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -41,7 +41,7 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
master_id(0), prev_master_id(0),
using_gtid(USE_GTID_NO), events_queued_since_last_gtid(0),
gtid_reconnect_event_skip_count(0), gtid_event_seen(false),
- in_start_all_slaves(0), in_stop_all_slaves(0),
+ in_start_all_slaves(0), in_stop_all_slaves(0), in_flush_all_relay_logs(0),
users(0), killed(0)
{
host[0] = 0; user[0] = 0; password[0] = 0;
@@ -1980,4 +1980,53 @@ void prot_store_ids(THD *thd, DYNAMIC_ARRAY *ids)
return;
}
+bool Master_info_index::flush_all_relay_logs()
+{
+ DBUG_ENTER("flush_all_relay_logs");
+ bool result= false;
+ int error= 0;
+ mysql_mutex_lock(&LOCK_active_mi);
+ for (uint i= 0; i< master_info_hash.records; i++)
+ {
+ Master_info *mi;
+ mi= (Master_info *) my_hash_element(&master_info_hash, i);
+ mi->in_flush_all_relay_logs= 0;
+ }
+ for (uint i=0; i < master_info_hash.records;)
+ {
+ Master_info *mi;
+ mi= (Master_info *)my_hash_element(&master_info_hash, i);
+ DBUG_ASSERT(mi);
+
+ if (mi->in_flush_all_relay_logs)
+ {
+ i++;
+ continue;
+ }
+ mi->in_flush_all_relay_logs= 1;
+
+ mysql_mutex_lock(&mi->sleep_lock);
+ mi->users++; // Mark used
+ mysql_mutex_unlock(&mi->sleep_lock);
+ mysql_mutex_unlock(&LOCK_active_mi);
+
+ mysql_mutex_lock(&mi->data_lock);
+ error= rotate_relay_log(mi);
+ mysql_mutex_unlock(&mi->data_lock);
+ mi->release();
+ mysql_mutex_lock(&LOCK_active_mi);
+
+ if (error)
+ {
+ result= true;
+ break;
+ }
+ /* Restart from first element as master_info_hash may have changed */
+ i= 0;
+ continue;
+ }
+ mysql_mutex_unlock(&LOCK_active_mi);
+ DBUG_RETURN(result);
+}
+
#endif /* HAVE_REPLICATION */