Commit a610467f authored by unknown's avatar unknown
Browse files

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


ndb/src/mgmsrv/MgmtSrvr.cpp:
  Add get_connected_ndb_nodes to check status for connected data nodes only
ndb/src/mgmsrv/MgmtSrvr.hpp:
  add prototype for get_connected_ndb_nodes
ndb/src/mgmsrv/Services.cpp:
  only force HB to NDBD nodes
ndb/src/ndbapi/ClusterMgr.cpp:
  flag to control if we send the condition
ndb/src/ndbapi/ClusterMgr.hpp:
  flag for if we broadcast condition on receipt of hb
parent 5a8919f2
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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
MgmtSrvr::alloc_node_id(NodeId * nodeId, 
			enum ndb_mgm_node_type type,
+1 −0
Original line number Diff line number Diff line
@@ -485,6 +485,7 @@ public:

  const char *get_connect_address(Uint32 node_id);
  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; }

  void updateStatus(NodeBitmask nodes);
+1 −1
Original line number Diff line number Diff line
@@ -952,7 +952,7 @@ printNodeStatus(OutputStream *output,
		enum ndb_mgm_node_type type) {
  NodeId nodeId = 0;
  NodeBitmask hbnodes;
  mgmsrv.get_connected_nodes(hbnodes);
  mgmsrv.get_connected_ndb_nodes(hbnodes);
  mgmsrv.updateStatus(hbnodes);
  while(mgmsrv.getNextNodeId(&nodeId, type)) {
    enum ndb_mgm_node_status status;
+14 −5
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ ClusterMgr::ClusterMgr(TransporterFacade & _facade):
  ndbSetOwnVersion();
  clusterMgrThreadMutex = NdbMutex_Create();
  waitForHBCond= NdbCondition_Create();
  waitingForHB= false;
  noOfAliveNodes= 0;
  noOfConnectedNodes= 0;
  theClusterMgrThread= 0;
@@ -172,7 +173,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
{
    theFacade.lock_mutex();

    if(!waitForHBFromNodes.isclear())
    if(waitingForHB)
    {
      NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
      theFacade.unlock_mutex();
@@ -180,6 +181,7 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
    }

    global_flag_send_heartbeat_now= 1;
    waitingForHB= true;

    waitForHBFromNodes= waitFor;
#ifdef DEBUG_REG
@@ -209,10 +211,11 @@ ClusterMgr::forceHB(NodeBitmask waitFor)
    }

    NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
    theFacade.unlock_mutex();
    waitingForHB= false;
#ifdef DEBUG_REG
    ndbout << "Still waiting for HB from " << waitForHBFromNodes.getText(buf) << endl;
#endif
    theFacade.unlock_mutex();
}

void
@@ -404,11 +407,17 @@ ClusterMgr::execAPI_REGCONF(const Uint32 * theData){
    node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50;
  }

  if(waitingForHB)
  {
    waitForHBFromNodes.clear(nodeId);

    if(waitForHBFromNodes.isclear())
    {
      waitingForHB= false;
      NdbCondition_Broadcast(waitForHBCond);
    }
  }
}

void
ClusterMgr::execAPI_REGREF(const Uint32 * theData){
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ private:

  NodeBitmask   waitForHBFromNodes; // used in forcing HBs
  NdbCondition* waitForHBCond;
  bool          waitingForHB;

  /**
   * Used for controlling start/stop of the thread