mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
Don't ask mgm server for port to connect transporter to if we already have one; only ask if connect fails.
Reconnect to mgm server in connect_clients thread if m_mgm_handle is disconnected.
This commit is contained in:
parent
1dcbc45b43
commit
6d12f23047
3 changed files with 44 additions and 11 deletions
|
@ -519,6 +519,13 @@ extern "C" {
|
|||
*/
|
||||
int ndb_mgm_connect(NdbMgmHandle handle, int no_retries,
|
||||
int retry_delay_in_seconds, int verbose);
|
||||
/**
|
||||
* Return true if connected.
|
||||
*
|
||||
* @param handle Management handle
|
||||
* @return 0 if not connected, non-zero if connected.
|
||||
*/
|
||||
int ndb_mgm_is_connected(NdbMgmHandle handle);
|
||||
|
||||
/**
|
||||
* Disconnects from a management server
|
||||
|
|
|
@ -1211,11 +1211,37 @@ TransporterRegistry::start_clients_thread()
|
|||
switch(performStates[nodeId]){
|
||||
case CONNECTING:
|
||||
if(!t->isConnected() && !t->isServer) {
|
||||
int result= 0;
|
||||
/**
|
||||
* First, we try to connect (if we have a port number).
|
||||
*/
|
||||
if (theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|
||||
|| t->get_s_port() > 0)
|
||||
result= t->connect_client();
|
||||
|
||||
|
||||
if (result<0 && t->get_s_port()!=0)
|
||||
{
|
||||
ndbout_c("Error while trying to make connection (Node %u to"
|
||||
" %u via port %u) error: %d. Retrying...",
|
||||
t->getRemoteNodeId(),
|
||||
t->getLocalNodeId(),
|
||||
t->get_s_port());
|
||||
NdbSleep_MilliSleep(400); // wait before retrying
|
||||
}
|
||||
|
||||
/**
|
||||
* If dynamic, get the port for connecting from the management server
|
||||
*/
|
||||
if(t->get_s_port() <= 0) { // Port is dynamic
|
||||
int server_port= 0;
|
||||
struct ndb_mgm_reply mgm_reply;
|
||||
int res;
|
||||
|
||||
if(!ndb_mgm_is_connected(m_mgm_handle))
|
||||
if(ndb_mgm_connect(m_mgm_handle, 0, 0, 0)<0)
|
||||
ndbout_c("Failed to reconnect to management server");
|
||||
|
||||
res= ndb_mgm_get_connection_int_parameter(m_mgm_handle,
|
||||
t->getRemoteNodeId(),
|
||||
t->getLocalNodeId(),
|
||||
|
@ -1231,17 +1257,6 @@ TransporterRegistry::start_clients_thread()
|
|||
else
|
||||
ndbout_c("Failed to get dynamic port to connect to: %d", res);
|
||||
}
|
||||
if (theTransporterTypes[nodeId] != tt_TCP_TRANSPORTER
|
||||
|| t->get_s_port() > 0) {
|
||||
int result = t->connect_client();
|
||||
if (result<0)
|
||||
ndbout_c("Error while trying to make connection (Node %u to"
|
||||
" %u via port %u) error: %d. Retrying...",
|
||||
t->getRemoteNodeId(),
|
||||
t->getLocalNodeId(),
|
||||
t->get_s_port());
|
||||
} else
|
||||
NdbSleep_MilliSleep(400); // wait before retrying
|
||||
}
|
||||
break;
|
||||
case DISCONNECTING:
|
||||
|
|
|
@ -334,6 +334,17 @@ ndb_mgm_call(NdbMgmHandle handle, const ParserRow<ParserDummy> *command_reply,
|
|||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if connected
|
||||
*/
|
||||
extern "C"
|
||||
int ndb_mgm_is_connected(NdbMgmHandle handle)
|
||||
{
|
||||
if(!handle)
|
||||
return 0;
|
||||
return handle->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a management server
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue