Readwritesplit: Graceful maintenance mode
By allowing transactions to the master to end even if the server is in maintenance mode makes it possible to terminate connections at a known point. This helps prevent interrupted transactions which can help reduce errors that are visible to the clients.
This commit is contained in:
@ -386,6 +386,25 @@ static inline const char* failure_mode_to_str(enum failure_mode type)
|
||||
void closed_session_reply(GWBUF* querybuf);
|
||||
bool send_readonly_error(DCB* dcb);
|
||||
|
||||
/**
|
||||
* See if the current master is still a valid TARGET_MASTER candidate
|
||||
*
|
||||
* The master is valid if it's in `Master, Running` state or if it is still in but in maintenance mode while a
|
||||
* transaction is open. If a transaction is open to a master in maintenance mode, the connection is closed on
|
||||
* the next COMMIT or ROLLBACK.
|
||||
*
|
||||
* @see RWSplitSession::close_stale_connections()
|
||||
*/
|
||||
inline bool can_continue_using_master(const mxs::RWBackend* current_master)
|
||||
{
|
||||
constexpr uint64_t bits = SERVER_MASTER | SERVER_RUNNING | SERVER_MAINT;
|
||||
auto server = current_master->server();
|
||||
|
||||
return server->is_master() || (current_master->in_use()
|
||||
&& (server->status & bits) == bits
|
||||
&& session_trx_is_active(current_master->dcb()->session));
|
||||
}
|
||||
|
||||
mxs::RWBackend* get_root_master(const mxs::PRWBackends& backends, mxs::RWBackend* current_master,
|
||||
const BackendSelectFunction& func);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user