List:Commits« Previous MessageNext Message »
From:msvensson Date:August 15 2007 7:11am
Subject:bk commit into 5.0 tree (msvensson:1.2513)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-08-15 09:11:17+02:00, msvensson@pilot.(none) +3 -0
  Decrease time to run 'ndb_waiter --no-contact' from 8 seconds to less
  than 1 second by:
   1. Only call getStatus once per loop in ndb_waiter
   2. Only wait for reply to forced API_REGREQ if any signals
      has been sent
   3. Only call 'updateStatus'(and forcing HB) once before printing
      node status 
  This will actually decrease time for any "get status" command in ndb_mgmd
  but "no_contact" was the worst case.

  ndb/src/mgmsrv/Services.cpp@stripped, 2007-08-15 09:11:16+02:00, msvensson@pilot.(none) +1 -1
    Update status of connected nodes in cluster only once, move
    call to 'updateStatus' out of 'printNodeStatus'

  ndb/src/ndbapi/ClusterMgr.cpp@stripped, 2007-08-15 09:11:16+02:00, msvensson@pilot.(none) +4 -1
    Only wait for nodes to reply if API_REGREQ has been sent to any nodes

  ndb/tools/waiter.cpp@stripped, 2007-08-15 09:11:16+02:00, msvensson@pilot.(none) +15 -45
    Only call 'getStatus' once per loop
    Only sleep if not done(all nodes has entered requested state)
    Remove _timeout as argument to 'waitNodeStatus', it hides the outer
    variable _timeout
    Remove the _nodes array and the _num_nodes counter, read directly
    from the ndbNodes vector
    Remove unused mgmNodes and apiNodes vector

diff -Nrup a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp
--- a/ndb/src/mgmsrv/Services.cpp	2007-02-22 19:33:58 +01:00
+++ b/ndb/src/mgmsrv/Services.cpp	2007-08-15 09:11:16 +02:00
@@ -923,7 +923,6 @@ printNodeStatus(OutputStream *output,
 		MgmtSrvr &mgmsrv,
 		enum ndb_mgm_node_type type) {
   NodeId nodeId = 0;
-  mgmsrv.updateStatus();
   while(mgmsrv.getNextNodeId(&nodeId, type)) {
     enum ndb_mgm_node_status status;
     Uint32 startPhase = 0, 
@@ -972,6 +971,7 @@ MgmApiSession::getStatus(Parser<MgmApiSe
   
   m_output->println("node status");
   m_output->println("nodes: %d", noOfNodes);
+  m_mgmsrv.updateStatus();
   printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_NDB);
   printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_MGM);
   printNodeStatus(m_output, m_mgmsrv, NDB_MGM_NODE_TYPE_API);
diff -Nrup a/ndb/src/ndbapi/ClusterMgr.cpp b/ndb/src/ndbapi/ClusterMgr.cpp
--- a/ndb/src/ndbapi/ClusterMgr.cpp	2007-05-09 15:02:59 +02:00
+++ b/ndb/src/ndbapi/ClusterMgr.cpp	2007-08-15 09:11:16 +02:00
@@ -222,7 +222,10 @@ ClusterMgr::forceHB()
       theFacade.sendSignalUnCond(&signal, nodeId);
     }
 
-    NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
+    /* Wait for nodes to reply - if any was sent */
+    if (!waitForHBFromNodes.isclear())
+      NdbCondition_WaitTimeout(waitForHBCond, theFacade.theMutexPtr, 1000);
+
     waitingForHB= false;
 #ifdef DEBUG_REG
     ndbout << "Still waiting for HB from " << waitForHBFromNodes.getText(buf) << endl;
diff -Nrup a/ndb/tools/waiter.cpp b/ndb/tools/waiter.cpp
--- a/ndb/tools/waiter.cpp	2007-03-09 09:37:03 +01:00
+++ b/ndb/tools/waiter.cpp	2007-08-15 09:11:16 +02:00
@@ -26,8 +26,7 @@
 #include <NDBT.hpp>
 
 int 
-waitClusterStatus(const char* _addr, ndb_mgm_node_status _status,
-		  unsigned int _timeout);
+waitClusterStatus(const char* _addr, ndb_mgm_node_status _status);
 
 enum ndb_waiter_options {
   OPT_WAIT_STATUS_NOT_STARTED = NDB_STD_OPTIONS_LAST,
@@ -38,7 +37,7 @@ NDB_STD_OPTS_VARS;
 static int _no_contact = 0;
 static int _not_started = 0;
 static int _single_user = 0;
-static int _timeout = 120;
+static unsigned int _timeout = 120;
 
 const char *load_default_groups[]= { "mysql_cluster",0 };
 
@@ -105,7 +104,7 @@ int main(int argc, char** argv){
     wait_status= NDB_MGM_NODE_STATUS_STARTED;
   }
 
-  if (waitClusterStatus(_hostName, wait_status, _timeout) != 0)
+  if (waitClusterStatus(_hostName, wait_status) != 0)
     return NDBT_ProgramExit(NDBT_FAILED);
   return NDBT_ProgramExit(NDBT_OK);
 }
@@ -118,8 +117,6 @@ int main(int argc, char** argv){
 NdbMgmHandle handle= NULL;
 
 Vector<ndb_mgm_node_state> ndbNodes;
-Vector<ndb_mgm_node_state> mgmNodes;
-Vector<ndb_mgm_node_state> apiNodes;
 
 int 
 getStatus(){
@@ -128,8 +125,6 @@ getStatus(){
   struct ndb_mgm_node_state * node;
   
   ndbNodes.clear();
-  mgmNodes.clear();
-  apiNodes.clear();
 
   while(retries < 10){
     status = ndb_mgm_get_status(handle);
@@ -153,18 +148,16 @@ getStatus(){
 	ndbNodes.push_back(*node);
 	break;
       case NDB_MGM_NODE_TYPE_MGM:
-	mgmNodes.push_back(*node);
+        /* Don't care about MGM nodes */
 	break;
       case NDB_MGM_NODE_TYPE_API:
-	apiNodes.push_back(*node);
+        /* Don't care about API nodes */
 	break;
       default:
 	if(node->node_status == NDB_MGM_NODE_STATUS_UNKNOWN ||
 	   node->node_status == NDB_MGM_NODE_STATUS_NO_CONTACT){
 	  retries++;
 	  ndbNodes.clear();
-	  mgmNodes.clear();
-	  apiNodes.clear();
 	  free(status); 
 	  status = NULL;
           count = 0;
@@ -190,14 +183,10 @@ getStatus(){
 
 int 
 waitClusterStatus(const char* _addr,
-		  ndb_mgm_node_status _status,
-		  unsigned int _timeout)
+		  ndb_mgm_node_status _status)
 {
   int _startphase = -1;
 
-  int _nodes[MAX_NDB_NODES];
-  int _num_nodes = 0;
-
   handle = ndb_mgm_create_handle();
   if (handle == NULL){
     g_err << "handle == NULL" << endl;
@@ -216,15 +205,6 @@ waitClusterStatus(const char* _addr,
     return -1;
   }
 
-  if (getStatus() != 0)
-    return -1;
-  
-  // Collect all nodes into nodes
-  for (size_t i = 0; i < ndbNodes.size(); i++){
-    _nodes[i] = ndbNodes[i].node_id;
-    _num_nodes++;
-  }
-
   unsigned int attempts = 0;
   unsigned int resetAttempts = 0;
   const unsigned int MAX_RESET_ATTEMPTS = 10;
@@ -278,27 +258,14 @@ waitClusterStatus(const char* _addr,
       return -1;
     }
 
-    // ndbout << "waitNodeState; _num_nodes = " << _num_nodes << endl;
-    // for (int i = 0; i < _num_nodes; i++)
-    //   ndbout << " node["<<i<<"] =" <<_nodes[i] << endl;
-
-    for (int i = 0; i < _num_nodes; i++){
-      ndb_mgm_node_state* ndbNode = NULL;
-      for (size_t n = 0; n < ndbNodes.size(); n++){
-	if (ndbNodes[n].node_id == _nodes[i])
-	  ndbNode = &ndbNodes[n];
-      }
+    for (size_t n = 0; n < ndbNodes.size(); n++){
+      ndb_mgm_node_state* ndbNode = &ndbNodes[n];
 
-      if(ndbNode == NULL){
-	allInState = false;
-	continue;
-      }
+      assert(ndbNode != NULL);
 
       g_info << "State node " << ndbNode->node_id << " "
 	     << ndb_mgm_get_node_status_string(ndbNode->node_status)<< endl;
 
-      assert(ndbNode != NULL);
-
       if(_status == NDB_MGM_NODE_STATUS_STARTING && 
 	 ((ndbNode->node_status == NDB_MGM_NODE_STATUS_STARTING && 
 	   ndbNode->start_phase >= _startphase) ||
@@ -322,9 +289,12 @@ waitClusterStatus(const char* _addr,
 	  allInState = false;
       }
     }
-    g_info << "Waiting for cluster enter state " 
-	    << ndb_mgm_get_node_status_string(_status)<< endl;
-    NdbSleep_SecSleep(1);
+
+    if (!allInState) {
+      g_info << "Waiting for cluster enter state " 
+             << ndb_mgm_get_node_status_string(_status)<< endl;
+      NdbSleep_SecSleep(1);
+    }
     attempts++;
   }
   return 0;
Thread
bk commit into 5.0 tree (msvensson:1.2513)msvensson15 Aug