MXS-2424 Stop passing redundant information around
mysql_get_host_info(MYSQL*) returns enough information to identify the connection.
This commit is contained in:
parent
c422aafe1d
commit
164ca7b5f1
@ -98,13 +98,10 @@ Clustrix::SubState Clustrix::substate_from_string(const std::string& substate)
|
||||
}
|
||||
}
|
||||
|
||||
bool Clustrix::is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon)
|
||||
bool Clustrix::is_part_of_the_quorum(const char* zName, MYSQL* pCon)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
const char* zAddress = server.address;
|
||||
int port = server.port;
|
||||
|
||||
const char ZQUERY[] = "SELECT status FROM system.membership WHERE nid = gtmnid()";
|
||||
|
||||
if (mysql_query(pCon, ZQUERY) == 0)
|
||||
@ -127,51 +124,50 @@ bool Clustrix::is_part_of_the_quorum(const char* zName, const SERVER& server, MY
|
||||
break;
|
||||
|
||||
case Clustrix::Status::STATIC:
|
||||
MXS_NOTICE("%s: Node %s:%d is not part of the quorum (static), switching to "
|
||||
MXS_NOTICE("%s: Node %s is not part of the quorum (static), switching to "
|
||||
"other node for monitoring.",
|
||||
zName, zAddress, port);
|
||||
zName, mysql_get_host_info(pCon));
|
||||
break;
|
||||
|
||||
case Clustrix::Status::DYNAMIC:
|
||||
MXS_NOTICE("%s: Node %s:%d is not part of the quorum (dynamic), switching to "
|
||||
MXS_NOTICE("%s: Node %s is not part of the quorum (dynamic), switching to "
|
||||
"other node for monitoring.",
|
||||
zName, zAddress, port);
|
||||
zName, mysql_get_host_info(pCon));
|
||||
break;
|
||||
|
||||
case Clustrix::Status::UNKNOWN:
|
||||
MXS_WARNING("%s: Do not know how to interpret '%s'. Assuming node %s:%d "
|
||||
MXS_WARNING("%s: Do not know how to interpret '%s'. Assuming node %s "
|
||||
"is not part of the quorum.",
|
||||
zName, row[0], zAddress, port);
|
||||
zName, row[0], mysql_get_host_info(pCon));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No status returned for '%s' on %s:%d.", zName, ZQUERY, zAddress, port);
|
||||
MXS_WARNING("%s: No status returned for '%s' on %s.",
|
||||
zName, ZQUERY, mysql_get_host_info(pCon));
|
||||
}
|
||||
|
||||
mysql_free_result(pResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No result returned for '%s' on %s:%d.", zName, ZQUERY, zAddress, port);
|
||||
MXS_WARNING("%s: No result returned for '%s' on %s.",
|
||||
zName, ZQUERY, mysql_get_host_info(pCon));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s:%d: %s",
|
||||
zName, ZQUERY, zAddress, port, mysql_error(pCon));
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s: %s",
|
||||
zName, ZQUERY, mysql_get_host_info(pCon), mysql_error(pCon));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool Clustrix::is_being_softfailed(const char* zName, const SERVER& server, MYSQL* pCon)
|
||||
bool Clustrix::is_being_softfailed(const char* zName, MYSQL* pCon)
|
||||
{
|
||||
bool rv = false;
|
||||
|
||||
const char* zAddress = server.address;
|
||||
int port = server.port;
|
||||
|
||||
const char ZQUERY[] = "SELECT nodeid FROM system.softfailed_nodes WHERE nodeid = gtmnid()";
|
||||
|
||||
if (mysql_query(pCon, ZQUERY) == 0)
|
||||
@ -193,13 +189,14 @@ bool Clustrix::is_being_softfailed(const char* zName, const SERVER& server, MYSQ
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_WARNING("%s: No result returned for '%s' on %s:%d.", zName, ZQUERY, zAddress, port);
|
||||
MXS_WARNING("%s: No result returned for '%s' on %s.",
|
||||
zName, ZQUERY, mysql_get_host_info(pCon));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s:%d: %s",
|
||||
zName, ZQUERY, zAddress, port, mysql_error(pCon));
|
||||
MXS_ERROR("%s: Could not execute '%s' on %s: %s",
|
||||
zName, ZQUERY, mysql_get_host_info(pCon), mysql_error(pCon));
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -216,9 +213,9 @@ bool Clustrix::ping_or_connect_to_hub(const char* zName,
|
||||
|
||||
if (Monitor::connection_is_ok(rv))
|
||||
{
|
||||
if (Clustrix::is_part_of_the_quorum(zName, server, *ppCon))
|
||||
if (Clustrix::is_part_of_the_quorum(zName, *ppCon))
|
||||
{
|
||||
if ((softfailed == Softfailed::REJECT) && Clustrix::is_being_softfailed(zName, server, *ppCon))
|
||||
if ((softfailed == Softfailed::REJECT) && Clustrix::is_being_softfailed(zName, *ppCon))
|
||||
{
|
||||
MXS_NOTICE("%s: The Clustrix node %s used as hub is part of the quorum, "
|
||||
"but it is being softfailed. Switching to another node.",
|
||||
|
@ -50,12 +50,11 @@ enum class Softfailed
|
||||
* Is a particular Clustrix node part of the quorum.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param server The server object of a Clustrix node.
|
||||
* @param pCon Valid MYSQL handle to the server.
|
||||
*
|
||||
* @return True, if the node is part of the quorum, false otherwise.
|
||||
*/
|
||||
bool is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon);
|
||||
bool is_part_of_the_quorum(const char* zName, MYSQL* pCon);
|
||||
|
||||
/**
|
||||
* Is a particular Clustrix node part of the quorum.
|
||||
@ -67,22 +66,20 @@ bool is_part_of_the_quorum(const char* zName, const SERVER& server, MYSQL* pCon)
|
||||
*/
|
||||
inline bool is_part_of_the_quorum(const char* zName, mxs::MonitorServer& ms)
|
||||
{
|
||||
mxb_assert(ms.server);
|
||||
mxb_assert(ms.con);
|
||||
|
||||
return is_part_of_the_quorum(zName, *ms.server, ms.con);
|
||||
return is_part_of_the_quorum(zName, ms.con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is a particular Clustrix node being softfailed.
|
||||
*
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param server The server object of a Clustrix node.
|
||||
* @param pCon Valid MYSQL handle to the server.
|
||||
* @param zName The name of the Clustrix monitor instance.
|
||||
* @param pCon Valid MYSQL handle to the server.
|
||||
*
|
||||
* @return True, if the node is being softfailed, false otherwise.
|
||||
*/
|
||||
bool is_being_softfailed(const char* zName, const SERVER& server, MYSQL* pCon);
|
||||
bool is_being_softfailed(const char* zName, MYSQL* pCon);
|
||||
|
||||
/**
|
||||
* Ping or create connection to server and check whether it can be used
|
||||
|
Loading…
x
Reference in New Issue
Block a user