Keep track of previously observed slave connections

This reduces the ambiguity of server id:s in the slave status contents.
If a slave connection has been seen properly connected at an earlier time,
it can be trusted to report the correct master server id. This also
fixes some wrong status assignment edge cases with the SERVER_WAS_SLAVE-bit.
The bit will be removed in a later commit.

Even this does not solve the situation when MaxScale is started with
some servers down.
This commit is contained in:
Esa Korhonen
2018-08-06 20:19:48 +03:00
parent a05b8c3ab4
commit b7c94abb34
2 changed files with 102 additions and 46 deletions

View File

@ -40,17 +40,20 @@ public:
SLAVE_IO_NO,
};
std::string name; /**< Slave connection name. Must be unique. */
int64_t master_server_id; /**< The master's server_id value. Valid ids are 32bit unsigned. -1 is
* unread/error. */
std::string master_host; /**< Master server host name. */
int master_port; /**< Master server port. */
slave_io_running_t slave_io_running; /**< Slave I/O thread running state: "Yes", "Connecting" or "No" */
bool slave_sql_running; /**< Slave SQL thread running state, true if "Yes" */
GtidList gtid_io_pos; /**< Gtid I/O position of the slave thread. */
std::string last_error; /**< Last IO or SQL error encountered. */
bool seen_connected = false; /* Has this slave connection been seen connected,
* meaning that the master server id is correct? */
std::string name; /* Slave connection name. Must be unique for
* the server.*/
int64_t master_server_id = SERVER_ID_UNKNOWN; /* The master's server_id value. Valid ids are
* 32bit unsigned. -1 is unread/error. */
std::string master_host; /* Master server host name. */
int master_port = PORT_UNKNOWN; /* Master server port. */
slave_io_running_t slave_io_running = SLAVE_IO_NO; /* Slave I/O thread running state: * "Yes",
* "Connecting" or "No" */
bool slave_sql_running = false; /* Slave SQL thread running state, true if "Yes" */
GtidList gtid_io_pos; /* Gtid I/O position of the slave thread. */
std::string last_error; /* Last IO or SQL error encountered. */
SlaveStatus();
std::string to_string() const;
static slave_io_running_t slave_io_from_string(const std::string& str);
static std::string slave_io_to_string(slave_io_running_t slave_io);
@ -448,7 +451,8 @@ public:
private:
bool update_slave_status(std::string* errmsg_out = NULL);
static bool sstatus_arrays_topology_equal(const SlaveStatusArray& lhs, const SlaveStatusArray& rhs);
bool sstatus_array_topology_equal(const SlaveStatusArray& new_slave_status);
void sstatus_array_set_conn_status(SlaveStatusArray* new_slave_status);
};
/**