diff options
| author | Sachin Setiya <sachin.setiya@mariadb.com> | 2017-06-05 12:24:53 +0530 |
|---|---|---|
| committer | Sachin Setiya <sachin.setiya@mariadb.com> | 2017-06-05 12:25:24 +0530 |
| commit | 2a847875e0084c7e5322646e298f9842e40c3613 (patch) | |
| tree | 84090965e8e7bcbee5abf68ff83501f395269c96 /sql | |
| parent | e4d10e09cf318aad237143254c45458d16009f70 (diff) | |
| download | mariadb-git-bb-mdev-9544.tar.gz | |
MDEV-9544 FLUSH [RELAY] LOGS does not rotate logs for a named slavebb-mdev-9544
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')
| -rw-r--r-- | sql/rpl_mi.cc | 51 | ||||
| -rw-r--r-- | sql/rpl_mi.h | 2 | ||||
| -rw-r--r-- | sql/sql_reload.cc | 8 |
3 files changed, 58 insertions, 3 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index c9dcf7b8fd7..99c9b5e1961 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; + } + + 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; + } + mi->in_flush_all_relay_logs= 1; + /* Restart from first element as master_info_hash may have changed */ + i= 0; + continue; + } + //DBUG_ASSERT(0); + mysql_mutex_unlock(&LOCK_active_mi); + DBUG_RETURN(result); +} + #endif /* HAVE_REPLICATION */ diff --git a/sql/rpl_mi.h b/sql/rpl_mi.h index 31c0f280ac1..d0f6171815c 100644 --- a/sql/rpl_mi.h +++ b/sql/rpl_mi.h @@ -302,6 +302,7 @@ class Master_info : public Slave_reporting_capability /* gtid_event_seen is false until we receive first GTID event from master. */ bool gtid_event_seen; bool in_start_all_slaves, in_stop_all_slaves; + bool in_flush_all_relay_logs; uint users; /* Active user for object */ uint killed; @@ -354,6 +355,7 @@ public: bool start_all_slaves(THD *thd); bool stop_all_slaves(THD *thd); void free_connections(); + bool flush_all_relay_logs(); }; diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 995c4c0a838..376dfeb1542 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -181,8 +181,12 @@ bool reload_acl_and_cache(THD *thd, unsigned long long options, slave is not likely to have the same connection names. */ tmp_write_to_binlog= 0; - - if (!(mi= (get_master_info(&connection_name, + if (connection_name.length == 0) + { + if (master_info_index->flush_all_relay_logs()) + *write_to_binlog= -1; + } + else if (!(mi= (get_master_info(&connection_name, Sql_condition::WARN_LEVEL_ERROR)))) { result= 1; |
