MXS-1503: Enable master reconnection
The `master_reconnection` parameter now controls both the reconnection of the master server as well as the migration of the master server to another server. Although these two cases appear to be different, the end result from readwritesplit's point of view is the same and are thus controlled with the same parameter. The RWBackend class now resets its internal state when it is closed. This allows readwritesplit to handle the case when a result was expected from the master but the master died before the result was returned. The same code should also handle slave connection failures mid-result, allowing Backend reuse. Added a test case that verifies the new functionality when combined with `master_failure_mode=error_on_write`.
This commit is contained in:
@ -1376,17 +1376,32 @@ static void handleError(MXS_ROUTER *instance,
|
||||
can_continue = true;
|
||||
}
|
||||
}
|
||||
else if (!SERVER_IS_MASTER(srv) && !srv->master_err_is_logged)
|
||||
else
|
||||
{
|
||||
ss_dassert(backend);
|
||||
MXS_ERROR("Server %s (%s) lost the master status while waiting"
|
||||
" for a result. Client sessions will be closed.",
|
||||
backend->name(), backend->uri());
|
||||
backend->server()->master_err_is_logged = true;
|
||||
// We were expecting a response but we aren't going to get one
|
||||
rses->expected_responses--;
|
||||
|
||||
if (rses->rses_config.master_failure_mode == RW_ERROR_ON_WRITE)
|
||||
{
|
||||
/** In error_on_write mode, the session can continue even
|
||||
* if the master is lost. Send a read-only error to
|
||||
* the client to let it know that the query failed. */
|
||||
can_continue = true;
|
||||
send_readonly_error(rses->client_dcb);
|
||||
}
|
||||
|
||||
if (!SERVER_IS_MASTER(srv) && !srv->master_err_is_logged)
|
||||
{
|
||||
ss_dassert(backend);
|
||||
MXS_ERROR("Server %s (%s) lost the master status while waiting"
|
||||
" for a result. Client sessions will be closed.",
|
||||
backend->name(), backend->uri());
|
||||
backend->server()->master_err_is_logged = true;
|
||||
}
|
||||
}
|
||||
|
||||
*succp = can_continue;
|
||||
backend->close(mxs::Backend::CLOSE_FATAL);
|
||||
backend->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user