MXS-1503: Fix master failure logging logic
The code that logs the master failure error was not working correctly after the changes done for MXS-359 and MXS-1503. Updated the logic and converted impossible cases into debug assertions.
This commit is contained in:
@ -702,8 +702,10 @@ SRWBackend handle_slave_is_target(RWSplit *inst, RWSplitSession *rses,
|
||||
static void log_master_routing_failure(RWSplitSession *rses, bool found,
|
||||
SRWBackend& old_master, SRWBackend& curr_master)
|
||||
{
|
||||
/** Both backends should either be empty, not connected or the DCB should
|
||||
* be a backend (the last check is slightly redundant). */
|
||||
ss_dassert(!old_master || !old_master->in_use() || old_master->dcb()->dcb_role == DCB_ROLE_BACKEND_HANDLER);
|
||||
ss_dassert(!curr_master || curr_master->dcb()->dcb_role == DCB_ROLE_BACKEND_HANDLER);
|
||||
ss_dassert(!curr_master || !curr_master->in_use()|| curr_master->dcb()->dcb_role == DCB_ROLE_BACKEND_HANDLER);
|
||||
char errmsg[MAX_SERVER_ADDRESS_LEN * 2 + 100]; // Extra space for error message
|
||||
|
||||
if (!found)
|
||||
@ -713,24 +715,16 @@ static void log_master_routing_failure(RWSplitSession *rses, bool found,
|
||||
else if (old_master && curr_master && old_master->in_use())
|
||||
{
|
||||
/** We found a master but it's not the same connection */
|
||||
ss_dassert(!rses->rses_config.master_reconnection);
|
||||
ss_dassert(!curr_master->in_use());
|
||||
ss_dassert(old_master != curr_master);
|
||||
ss_dassert(old_master->dcb()->server && curr_master->dcb()->server);
|
||||
|
||||
if (old_master != curr_master)
|
||||
{
|
||||
sprintf(errmsg, "Master server changed from '%s' to '%s'",
|
||||
old_master->name(),
|
||||
curr_master->name());
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dassert(false); // Currently we don't reconnect to the master
|
||||
sprintf(errmsg, "Connection to master '%s' was recreated",
|
||||
curr_master->name());
|
||||
}
|
||||
sprintf(errmsg, "Master server changed from '%s' to '%s'",
|
||||
old_master->name(), curr_master->name());
|
||||
}
|
||||
else if (old_master && old_master->in_use())
|
||||
{
|
||||
// TODO: Figure out if this is an impossible situation
|
||||
ss_dassert(!curr_master);
|
||||
/** We have an original master connection but we couldn't find it */
|
||||
sprintf(errmsg, "The connection to master server '%s' is not available",
|
||||
old_master->name());
|
||||
@ -743,18 +737,13 @@ static void log_master_routing_failure(RWSplitSession *rses, bool found,
|
||||
sprintf(errmsg, "Session is in read-only mode because it was created "
|
||||
"when no master was available");
|
||||
}
|
||||
else if (old_master && !old_master->in_use())
|
||||
else
|
||||
{
|
||||
ss_dassert(old_master && !old_master->in_use());
|
||||
sprintf(errmsg, "Was supposed to route to master but the master connection is %s",
|
||||
old_master->is_closed() ? "closed" : "not in a suitable state");
|
||||
ss_dassert(old_master->is_closed());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(errmsg, "Was supposed to route to master but couldn't "
|
||||
"find original master connection");
|
||||
ss_dassert(!true);
|
||||
}
|
||||
}
|
||||
|
||||
MXS_WARNING("[%s] Write query received from %s@%s. %s. Closing client connection.",
|
||||
|
Reference in New Issue
Block a user