BUG#13985: Cluster: ndb_mgm "status" command can return incorrect data node status

- only force HB to data nodes
- flag for if we broadcast condition on receipt of HB
parent 3f5f7b34
...@@ -1941,6 +1941,25 @@ MgmtSrvr::get_connected_nodes(NodeBitmask &connected_nodes) const ...@@ -1941,6 +1941,25 @@ MgmtSrvr::get_connected_nodes(NodeBitmask &connected_nodes) const
} }
} }
void
MgmtSrvr::get_connected_ndb_nodes(NodeBitmask &connected_nodes) const
{
NodeBitmask ndb_nodes;
if (theFacade && theFacade->theClusterMgr)
{
for(Uint32 i = 0; i < MAX_NODES; i++)
{
if (getNodeType(i) == NDB_MGM_NODE_TYPE_NDB)
{
ndb_nodes.set(i);
const ClusterMgr::Node &node= theFacade->theClusterMgr->getNodeInfo(i);
connected_nodes.bitOR(node.m_state.m_connected_nodes);
}
}
}
connected_nodes.bitAND(ndb_nodes);
}
bool bool
MgmtSrvr::alloc_node_id(NodeId * nodeId, MgmtSrvr::alloc_node_id(NodeId * nodeId,
enum ndb_mgm_node_type type, enum ndb_mgm_node_type type,
......
...@@ -485,6 +485,7 @@ public: ...@@ -485,6 +485,7 @@ public:
const char *get_connect_address(Uint32 node_id); const char *get_connect_address(Uint32 node_id);
void get_connected_nodes(NodeBitmask &connected_nodes) const; void get_connected_nodes(NodeBitmask &connected_nodes) const;
void get_connected_ndb_nodes(NodeBitmask &connected_nodes) const;
SocketServer *get_socket_server() { return m_socket_server; } SocketServer *get_socket_server() { return m_socket_server; }
void updateStatus(NodeBitmask nodes); void updateStatus(NodeBitmask nodes);
......
...@@ -952,7 +952,7 @@ printNodeStatus(OutputStream *output, ...@@ -952,7 +952,7 @@ printNodeStatus(OutputStream *output,
enum ndb_mgm_node_type type) { enum ndb_mgm_node_type type) {
NodeId nodeId = 0; NodeId nodeId = 0;
NodeBitmask hbnodes; NodeBitmask hbnodes;
mgmsrv.get_connected_nodes(hbnodes); mgmsrv.get_connected_ndb_nodes(hbnodes);
mgmsrv.updateStatus(hbnodes); mgmsrv.updateStatus(hbnodes);
while(mgmsrv.getNextNodeId(&nodeId, type)) { while(mgmsrv.getNextNodeId(&nodeId, type)) {
enum ndb_mgm_node_status status; enum ndb_mgm_node_status status;
......
...@@ -70,6 +70,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade): ...@@ -70,6 +70,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
ndbSetOwnVersion(); ndbSetOwnVersion();
clusterMgrThreadMutex = NdbMutex_Create(); clusterMgrThreadMutex = NdbMutex_Create();
waitForHBCond= NdbCondition_Create(); waitForHBCond= NdbCondition_Create();
waitingForHB= false;
noOfAliveNodes= 0; noOfAliveNodes= 0;
noOfConnectedNodes= 0; noOfConnectedNodes= 0;
theClusterMgrThread= 0; theClusterMgrThread= 0;
...@@ -172,7 +173,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor) ...@@ -172,7 +173,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
{ {
theFacade.lock_mutex(); theFacade.lock_mutex();
if(!waitForHBFromNodes.isclear()) if(waitingForHB)
{ {
NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000); NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
theFacade.unlock_mutex(); theFacade.unlock_mutex();
...@@ -180,6 +181,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor) ...@@ -180,6 +181,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
} }
global_flag_send_heartbeat_now= 1; global_flag_send_heartbeat_now= 1;
waitingForHB= true;
waitForHBFromNodes= waitFor; waitForHBFromNodes= waitFor;
#ifdef DEBUG_REG #ifdef DEBUG_REG
...@@ -209,10 +211,11 @@ ClusterMgr::forceHB(NodeBitmask waitFor) ...@@ -209,10 +211,11 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
} }
NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000); NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
theFacade.unlock_mutex(); waitingForHB= false;
#ifdef DEBUG_REG #ifdef DEBUG_REG
ndbout << "Still waiting for HB from " << waitForHBFromNodes.getText(buf) << endl; ndbout << "Still waiting for HB from " << waitForHBFromNodes.getText(buf) << endl;
#endif #endif
theFacade.unlock_mutex();
} }
void void
...@@ -404,10 +407,16 @@ ClusterMgr::execAPI_REGCONF(const Uint32 * theData){ ...@@ -404,10 +407,16 @@ ClusterMgr::execAPI_REGCONF(const Uint32 * theData){
node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50; node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50;
} }
if(waitingForHB)
{
waitForHBFromNodes.clear(nodeId); waitForHBFromNodes.clear(nodeId);
if(waitForHBFromNodes.isclear()) if(waitForHBFromNodes.isclear())
{
waitingForHB= false;
NdbCondition_Broadcast(waitForHBCond); NdbCondition_Broadcast(waitForHBCond);
}
}
} }
void void
......
...@@ -90,6 +90,7 @@ private: ...@@ -90,6 +90,7 @@ private:
NodeBitmask waitForHBFromNodes; // used in forcing HBs NodeBitmask waitForHBFromNodes; // used in forcing HBs
NdbCondition* waitForHBCond; NdbCondition* waitForHBCond;
bool waitingForHB;
/** /**
* Used for controlling start/stop of the thread * Used for controlling start/stop of the thread
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment