mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 18:20:07 +01:00
multi node shutdown adabtions for restart of management servers
This commit is contained in:
parent
1de7807da9
commit
cfee84be3a
2 changed files with 31 additions and 45 deletions
|
@ -987,41 +987,44 @@ int MgmtSrvr::sendSTOP_REQ(const Vector<NodeId> &node_ids,
|
|||
|
||||
// send the signals
|
||||
NodeBitmask nodes;
|
||||
NodeId nodeId;
|
||||
NodeId nodeId= 0;
|
||||
int use_master_node= 0;
|
||||
int do_send= 0;
|
||||
int do_stop_self= 0;
|
||||
NdbNodeBitmask nodes_to_stop;
|
||||
{
|
||||
for (unsigned i= 0; i < node_ids.size(); i++)
|
||||
nodes_to_stop.set(node_ids[i]);
|
||||
}
|
||||
if (node_ids.size())
|
||||
{
|
||||
do_send= 1;
|
||||
if (node_ids.size() == 1)
|
||||
{
|
||||
nodeId= node_ids[0];
|
||||
if (nodeId == getOwnNodeId())
|
||||
{
|
||||
if (restart)
|
||||
g_RestartServer= true;
|
||||
g_StopServer= true;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
else if (getNodeType(nodeId) == NDB_MGM_NODE_TYPE_MGM)
|
||||
nodeId= node_ids[i];
|
||||
if (getNodeType(nodeId) != NDB_MGM_NODE_TYPE_MGM)
|
||||
nodes_to_stop.set(nodeId);
|
||||
else if (nodeId != getOwnNodeId())
|
||||
{
|
||||
error= sendStopMgmd(nodeId, abort, stop, restart,
|
||||
nostart, initialStart);
|
||||
if (error == 0)
|
||||
stoppedNodes.set(nodeId);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
else
|
||||
do_stop_self= 1;;
|
||||
}
|
||||
else // multi node stop, send to master
|
||||
}
|
||||
int no_of_nodes_to_stop= nodes_to_stop.count();
|
||||
if (node_ids.size())
|
||||
{
|
||||
if (no_of_nodes_to_stop)
|
||||
{
|
||||
use_master_node= 1;
|
||||
nodes_to_stop.copyto(NdbNodeBitmask::Size, stopReq->nodes);
|
||||
StopReq::setStopNodes(stopReq->requestInfo, 1);
|
||||
do_send= 1;
|
||||
if (no_of_nodes_to_stop == 1)
|
||||
{
|
||||
nodeId= nodes_to_stop.find(0);
|
||||
}
|
||||
else // multi node stop, send to master
|
||||
{
|
||||
use_master_node= 1;
|
||||
nodes_to_stop.copyto(NdbNodeBitmask::Size, stopReq->nodes);
|
||||
StopReq::setStopNodes(stopReq->requestInfo, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1105,7 +1108,7 @@ int MgmtSrvr::sendSTOP_REQ(const Vector<NodeId> &node_ids,
|
|||
}
|
||||
else
|
||||
{
|
||||
assert(node_ids.size() > 1);
|
||||
assert(no_of_nodes_to_stop > 1);
|
||||
stoppedNodes.bitOR(nodes_to_stop);
|
||||
}
|
||||
nodes.clear(nodeId);
|
||||
|
@ -1150,6 +1153,12 @@ int MgmtSrvr::sendSTOP_REQ(const Vector<NodeId> &node_ids,
|
|||
DBUG_RETURN(SEND_OR_RECEIVE_FAILED);
|
||||
}
|
||||
}
|
||||
if (!error && do_stop_self)
|
||||
{
|
||||
if (restart)
|
||||
g_RestartServer= true;
|
||||
g_StopServer= true;
|
||||
}
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
|
|
@ -1010,22 +1010,6 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &,
|
|||
nodes.push_back(atoi(p));
|
||||
}
|
||||
|
||||
int stop_self= 0;
|
||||
size_t i;
|
||||
for(i=0; i < nodes.size(); i++) {
|
||||
if (nodes[i] == m_mgmsrv.getOwnNodeId()) {
|
||||
stop_self= 1;
|
||||
if (i != nodes.size()-1) {
|
||||
m_output->println("stop reply");
|
||||
m_output->println("result: server must be stopped last");
|
||||
m_output->println("");
|
||||
return;
|
||||
}
|
||||
nodes.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int stopped= 0;
|
||||
int result= 0;
|
||||
if (nodes.size())
|
||||
|
@ -1035,16 +1019,9 @@ MgmApiSession::stop(Parser<MgmApiSession>::Context &,
|
|||
if(result != 0)
|
||||
m_output->println("result: %s", get_error_text(result));
|
||||
else
|
||||
{
|
||||
m_output->println("result: Ok");
|
||||
if (stop_self)
|
||||
stopped++;
|
||||
}
|
||||
m_output->println("stopped: %d", stopped);
|
||||
m_output->println("");
|
||||
|
||||
if (stop_self)
|
||||
g_StopServer= true;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue