Add server state to routing hint log message

If a server was not chosen as the target of a routing hint, the server
status would not be logged. By logging the server state in the message, it
is easier to figure out why a server wasn't chosen as the routing target.
This commit is contained in:
Markus Mäkelä
2019-01-24 16:30:43 +02:00
parent 2c95119a3b
commit b078eb2cca

View File

@ -834,10 +834,21 @@ SRWBackend RWSplitSession::handle_hinted_target(GWBUF* querybuf, route_target_t
{ {
if (TARGET_IS_NAMED_SERVER(route_target)) if (TARGET_IS_NAMED_SERVER(route_target))
{ {
MXS_INFO("Was supposed to route to named server " char* status = nullptr;
"%s but couldn't find the server in a "
"suitable state.", for (const auto& a : m_backends)
named_server); {
if (strcmp(a->server()->name, named_server) == 0)
{
status = server_status(a->server());
break;
}
}
MXS_INFO("Was supposed to route to named server %s but couldn't find the server in a "
"suitable state. Server state: %s", named_server,
status ? status : "Could not find server");
MXS_FREE(status);
} }
else if (TARGET_IS_RLAG_MAX(route_target)) else if (TARGET_IS_RLAG_MAX(route_target))
{ {