MXS-2325 Only enable events that were enabled on the master
The monitor now continuously updates a list of enabled server events. When promoting a new master in failover/switchover, only events that were enabled on the previous master are enabled on the new. This avoids enabling events that may have been disabled on the master yet stayed in the SLAVESIDE_DISABLED- state on the slave. In the case of reset-replication command, events on the new master are only enabled if the monitor had a master when the command was launched. Otherwise all events remain disabled.
This commit is contained in:
@ -72,6 +72,17 @@ struct NodeData
|
||||
class MariaDBServer
|
||||
{
|
||||
public:
|
||||
MariaDBServer(MXS_MONITORED_SERVER* monitored_server, int config_index,
|
||||
bool assume_unique_hostnames, bool query_events);
|
||||
|
||||
class EventInfo
|
||||
{
|
||||
public:
|
||||
std::string name; /**< Event name in <database.name> form */
|
||||
std::string definer; /**< Definer of the event */
|
||||
std::string status; /**< Status of the event */
|
||||
};
|
||||
|
||||
enum class server_type
|
||||
{
|
||||
UNKNOWN, /* Totally unknown. Server has not been connected to yet. */
|
||||
@ -135,10 +146,10 @@ public:
|
||||
* 'update_replication_settings' before use. */
|
||||
ReplicationSettings m_rpl_settings;
|
||||
|
||||
bool m_print_update_errormsg = true; /* Should an update error be printed? */
|
||||
bool m_query_events; /* Copy of monitor->m_handle_event_scheduler. TODO: move elsewhere */
|
||||
EventNameSet m_enabled_events; /* Enabled scheduled events */
|
||||
|
||||
MariaDBServer(MXS_MONITORED_SERVER* monitored_server, int config_index,
|
||||
bool assume_unique_hostnames = true);
|
||||
bool m_print_update_errormsg = true; /* Should an update error be printed? */
|
||||
|
||||
/**
|
||||
* Print server information to a json object.
|
||||
@ -329,12 +340,14 @@ public:
|
||||
bool run_sql_from_file(const std::string& path, json_t** error_out);
|
||||
|
||||
/**
|
||||
* Enable any "SLAVESIDE_DISABLED" events. Event scheduler is not touched.
|
||||
* Enable any "SLAVESIDE_DISABLED" or "DISABLED events. Event scheduler is not touched. Only events
|
||||
* with names matching an element in the event_names set are enabled.
|
||||
*
|
||||
* @param event_names Names of events that should be enabled
|
||||
* @param error_out Error output
|
||||
* @return True if all SLAVESIDE_DISABLED events were enabled
|
||||
*/
|
||||
bool enable_events(json_t** error_out);
|
||||
bool enable_events(const EventNameSet& event_names, json_t** error_out);
|
||||
|
||||
/**
|
||||
* Disable any "ENABLED" events. Event scheduler is not touched.
|
||||
@ -516,7 +529,6 @@ public:
|
||||
void set_status(uint64_t bits);
|
||||
|
||||
private:
|
||||
class EventInfo;
|
||||
typedef std::function<void (const EventInfo&, json_t** error_out)> ManipulatorFunc;
|
||||
|
||||
enum class StopMode
|
||||
@ -558,4 +570,6 @@ private:
|
||||
bool set_read_only(ReadOnlySetting value, maxbase::Duration time_limit, json_t** error_out);
|
||||
bool merge_slave_conns(GeneralOpData& op, const SlaveStatusArray& conns_to_merge);
|
||||
std::string generate_change_master_cmd(GeneralOpData& op, const SlaveStatus& slave_conn);
|
||||
|
||||
bool update_enabled_events();
|
||||
};
|
||||
|
Reference in New Issue
Block a user