List:Commits« Previous MessageNext Message »
From:tomas Date:January 23 2007 4:46am
Subject:bk commit into 5.1 tree (tomas:1.2399)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of tomas. When tomas 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
  1.2399 07/01/23 11:46:13 tomas@stripped +4 -0
  Merge poseidon.mysql.com:/home/tomas/mysql-5.0-ndb
  into  poseidon.mysql.com:/home/tomas/mysql-5.1-new-ndb

  storage/ndb/src/ndbapi/SignalSender.cpp
    1.10 07/01/23 11:46:03 tomas@stripped +0 -0
    Auto merged

  storage/ndb/src/ndbapi/ClusterMgr.hpp
    1.14 07/01/23 11:46:03 tomas@stripped +0 -0
    Auto merged

  storage/ndb/src/ndbapi/ClusterMgr.cpp
    1.33 07/01/23 11:46:03 tomas@stripped +0 -0
    Auto merged

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp
    1.116 07/01/23 11:46:03 tomas@stripped +0 -0
    Auto merged

  storage/ndb/src/ndbapi/SignalSender.cpp
    1.3.5.2 07/01/23 11:46:03 tomas@stripped +0 -0
    Merge rename: ndb/src/ndbapi/SignalSender.cpp -> storage/ndb/src/ndbapi/SignalSender.cpp

  storage/ndb/src/ndbapi/ClusterMgr.hpp
    1.4.7.2 07/01/23 11:46:03 tomas@stripped +0 -0
    Merge rename: ndb/src/ndbapi/ClusterMgr.hpp -> storage/ndb/src/ndbapi/ClusterMgr.hpp

  storage/ndb/src/ndbapi/ClusterMgr.cpp
    1.17.10.2 07/01/23 11:46:03 tomas@stripped +0 -0
    Merge rename: ndb/src/ndbapi/ClusterMgr.cpp -> storage/ndb/src/ndbapi/ClusterMgr.cpp

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp
    1.73.43.2 07/01/23 11:46:03 tomas@stripped +0 -0
    Merge rename: ndb/src/mgmsrv/MgmtSrvr.cpp -> storage/ndb/src/mgmsrv/MgmtSrvr.cpp

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.mysql.com
# Root:	/home/tomas/mysql-5.1-new-ndb/RESYNC

--- 1.73.43.1/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-01-23 11:44:36 +07:00
+++ 1.116/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-01-23 11:46:03 +07:00
@@ -36,10 +36,10 @@
 #include <signaldata/EventReport.hpp>
 #include <signaldata/DumpStateOrd.hpp>
 #include <signaldata/BackupSignalData.hpp>
-#include <signaldata/GrepImpl.hpp>
 #include <signaldata/ManagementServer.hpp>
 #include <signaldata/NFCompleteRep.hpp>
 #include <signaldata/NodeFailRep.hpp>
+#include <signaldata/AllocNodeId.hpp>
 #include <NdbSleep.h>
 #include <EventLogger.hpp>
 #include <DebuggerNames.hpp>
@@ -501,10 +501,6 @@
       case NODE_TYPE_MGM:
 	nodeTypes[id] = NDB_MGM_NODE_TYPE_MGM;
 	break;
-      case NODE_TYPE_REP:
-	nodeTypes[id] = NDB_MGM_NODE_TYPE_REP;
-	break;
-      case NODE_TYPE_EXT_REP:
       default:
 	break;
       }
@@ -587,8 +583,7 @@
       DBUG_RETURN(false);
     }
   }
-  theFacade= TransporterFacade::theFacadeInstance
-    = new TransporterFacade();
+  theFacade= new TransporterFacade();
   
   if(theFacade == 0) {
     DEBUG("MgmtSrvr.cpp: theFacade is NULL.");
@@ -985,6 +980,15 @@
   StopReq* const stopReq = CAST_PTR(StopReq, ssig.getDataPtrSend());
   ssig.set(ss, TestOrd::TraceAPI, NDBCNTR, GSN_STOP_REQ, StopReq::SignalLength);
 
+  NdbNodeBitmask notstarted;
+  for (Uint32 i = 0; i<node_ids.size(); i++)
+  {
+    Uint32 nodeId = node_ids[i];
+    ClusterMgr::Node node = theFacade->theClusterMgr->getNodeInfo(nodeId);
+    if (node.m_state.startLevel != NodeState::SL_STARTED)
+      notstarted.set(nodeId);
+  }
+  
   stopReq->requestInfo = 0;
   stopReq->apiTimeout = 5000;
   stopReq->transactionTimeout = 1000;
@@ -1155,6 +1159,14 @@
     case GSN_NODE_FAILREP:{
       const NodeFailRep * const rep =
 	CAST_CONSTPTR(NodeFailRep, signal->getDataPtr());
+      NdbNodeBitmask mask;
+      char buf[100];
+      mask.assign(NdbNodeBitmask::Size, rep->theNodes);
+      mask.bitAND(notstarted);
+      nodes.bitANDC(mask);
+      
+      if (singleUserNodeId == 0)
+	stoppedNodes.bitOR(mask);
       break;
     }
     default:
@@ -1894,9 +1906,6 @@
     break;
   case GSN_EVENT_REP:
   {
-    EventReport *rep = (EventReport*) signal->getDataPtr();
-    if (rep->getNodeId() == 0)
-      rep->setNodeId(refToNode(signal->theSendersBlockRef));
     eventReport(signal->getDataPtr());
     break;
   }
@@ -1940,7 +1949,6 @@
       DBUG_VOID_RETURN;
     }
   }
-  
   rep->setNodeId(_ownNodeId);
   eventReport(theData);
   DBUG_VOID_RETURN;
@@ -2013,6 +2021,92 @@
   }
 }
 
+int
+MgmtSrvr::alloc_node_id_req(NodeId free_node_id, enum ndb_mgm_node_type type)
+{
+  SignalSender ss(theFacade);
+  ss.lock(); // lock will be released on exit
+
+  SimpleSignal ssig;
+  AllocNodeIdReq* req = CAST_PTR(AllocNodeIdReq, ssig.getDataPtrSend());
+  ssig.set(ss, TestOrd::TraceAPI, QMGR, GSN_ALLOC_NODEID_REQ,
+	   AllocNodeIdReq::SignalLength);
+  
+  req->senderRef = ss.getOwnRef();
+  req->senderData = 19;
+  req->nodeId = free_node_id;
+  req->nodeType = type;
+
+  int do_send = 1;
+  NodeId nodeId = 0;
+  while (1)
+  {
+    if (nodeId == 0)
+    {
+      bool next;
+      while((next = getNextNodeId(&nodeId, NDB_MGM_NODE_TYPE_NDB)) == true &&
+            theFacade->get_node_alive(nodeId) == false);
+      if (!next)
+        return NO_CONTACT_WITH_DB_NODES;
+      do_send = 1;
+    }
+    if (do_send)
+    {
+      if (ss.sendSignal(nodeId, &ssig) != SEND_OK) {
+        return SEND_OR_RECEIVE_FAILED;
+      }
+      do_send = 0;
+    }
+    
+    SimpleSignal *signal = ss.waitFor();
+
+    int gsn = signal->readSignalNumber();
+    switch (gsn) {
+    case GSN_ALLOC_NODEID_CONF:
+    {
+      const AllocNodeIdConf * const conf =
+        CAST_CONSTPTR(AllocNodeIdConf, signal->getDataPtr());
+      return 0;
+    }
+    case GSN_ALLOC_NODEID_REF:
+    {
+      const AllocNodeIdRef * const ref =
+        CAST_CONSTPTR(AllocNodeIdRef, signal->getDataPtr());
+      if (ref->errorCode == AllocNodeIdRef::NotMaster ||
+          ref->errorCode == AllocNodeIdRef::Busy)
+      {
+        do_send = 1;
+        nodeId = refToNode(ref->masterRef);
+        continue;
+      }
+      return ref->errorCode;
+    }
+    case GSN_NF_COMPLETEREP:
+    {
+      const NFCompleteRep * const rep =
+        CAST_CONSTPTR(NFCompleteRep, signal->getDataPtr());
+#ifdef VM_TRACE
+      ndbout_c("Node %d fail completed", rep->failedNodeId);
+#endif
+      if (rep->failedNodeId == nodeId)
+      {
+	do_send = 1;
+        nodeId = 0;
+      }
+      continue;
+    }
+    case GSN_NODE_FAILREP:{
+      // ignore NF_COMPLETEREP will come
+      continue;
+    }
+    default:
+      report_unknown_signal(signal);
+      return SEND_OR_RECEIVE_FAILED;
+    }
+  }
+  return 0;
+}
+
 bool
 MgmtSrvr::alloc_node_id(NodeId * nodeId, 
 			enum ndb_mgm_node_type type,
@@ -2143,6 +2237,39 @@
   }
   NdbMutex_Unlock(m_configMutex);
 
+  if (id_found && client_addr != 0)
+  {
+    int res = alloc_node_id_req(id_found, type);
+    unsigned save_id_found = id_found;
+    switch (res)
+    {
+    case 0:
+      // ok continue
+      break;
+    case NO_CONTACT_WITH_DB_NODES:
+      // ok continue
+      break;
+    default:
+      // something wrong
+      id_found = 0;
+      break;
+
+    }
+    if (id_found == 0)
+    {
+      char buf[128];
+      ndb_error_string(res, buf, sizeof(buf));
+      error_string.appfmt("Cluster refused allocation of id %d. Error: %d (%s).",
+			  save_id_found, res, buf);
+      g_eventLogger.warning("Cluster refused allocation of id %d. "
+                            "Connection from ip %s. "
+                            "Returned error string \"%s\"", save_id_found,
+                            inet_ntoa(((struct sockaddr_in *)(client_addr))->sin_addr),
+                            error_string.c_str());
+      DBUG_RETURN(false);
+    }
+  }
+
   if (id_found)
   {
     *nodeId= id_found;
@@ -2409,7 +2536,7 @@
       const BackupCompleteRep * const rep = 
 	CAST_CONSTPTR(BackupCompleteRep, signal->getDataPtr());
 #ifdef VM_TRACE
-      ndbout_c("Backup(%d) completed %d", rep->backupId);
+      ndbout_c("Backup(%d) completed", rep->backupId);
 #endif
       event.Event = BackupEvent::BackupCompleted;
       event.Completed.BackupId = rep->backupId;
@@ -2517,17 +2644,6 @@
 }
 
 
-/*****************************************************************************
- * Global Replication
- *****************************************************************************/
-
-int
-MgmtSrvr::repCommand(Uint32* repReqId, Uint32 request, bool waitCompleted)
-{
-  require(false);
-  return 0;
-}
-
 MgmtSrvr::Allocated_resources::Allocated_resources(MgmtSrvr &m)
   : m_mgmsrv(m)
 {
@@ -2676,7 +2792,7 @@
       break;
     case 1:
       res = i2.set(param, val_64);
-      ndbout_c("Updating node %d param: %d to %Ld",  node, param, val_32);
+      ndbout_c("Updating node %d param: %d to %u",  node, param, val_32);
       break;
     case 2:
       res = i2.set(param, val_char);

--- 1.17.10.1/ndb/src/ndbapi/ClusterMgr.cpp	2007-01-23 11:44:36 +07:00
+++ 1.33/storage/ndb/src/ndbapi/ClusterMgr.cpp	2007-01-23 11:46:03 +07:00
@@ -36,6 +36,7 @@
 #include <mgmapi_configuration.hpp>
 #include <mgmapi_config_parameters.h>
 
+int global_flag_skip_invalidate_cache = 0;
 //#define DEBUG_REG
 
 // Just a C wrapper for threadMain
@@ -44,15 +45,7 @@
 runClusterMgr_C(void * me)
 {
   ((ClusterMgr*) me)->threadMain();
-  /** 
-   * Sleep to allow another thread that is not exiting to take control 
-   * of signals allocated by this thread
-   *
-   * see Ndb::~Ndb() in Ndbinit.cpp
-   */  
-#ifdef NDB_OSE
-  NdbSleep_MilliSleep(50);
-#endif
+
   return NULL;
 }
 
@@ -72,6 +65,7 @@
   noOfConnectedNodes= 0;
   theClusterMgrThread= 0;
   m_connect_count = 0;
+  m_cluster_state = CS_waiting_for_clean_cache;
   DBUG_VOID_RETURN;
 }
 
@@ -112,18 +106,6 @@
     case NODE_TYPE_MGM:
       theNodes[tmp].m_info.m_type = NodeInfo::MGM;
       break;
-    case NODE_TYPE_REP:
-      theNodes[tmp].m_info.m_type = NodeInfo::REP;
-      break;
-    case NODE_TYPE_EXT_REP:
-      theNodes[tmp].m_info.m_type = NodeInfo::REP;
-      {
-	Uint32 hbFreq = 10000;
-	//ndb_mgm_get_int_parameter(iter, CFG_, &hbFreq);
-	theNodes[tmp].hbFrequency = hbFreq;
-	assert(100 <= hbFreq && hbFreq < 60 * 60 * 1000);
-      }
-      break;
     default:
       type = type;
 #if 0
@@ -250,6 +232,16 @@
     /**
      * Start of Secure area for use of Transporter
      */
+    if (m_cluster_state == CS_waiting_for_clean_cache)
+    {
+      theFacade.m_globalDictCache.lock();
+      unsigned sz= theFacade.m_globalDictCache.get_size();
+      theFacade.m_globalDictCache.unlock();
+      if (sz)
+        goto next;
+      m_cluster_state = CS_waiting_for_first_connect;
+    }
+
     theFacade.lock_mutex();
     for (int i = 1; i < MAX_NODES; i++){
       /**
@@ -281,13 +273,6 @@
 	  theNode.hbCounter = 0;
 	}
 
-	/**
-	 * If the node is of type REP, 
-	 * then the receiver of the signal should be API_CLUSTERMGR
-	 */
-	if (theNode.m_info.m_type == NodeInfo::REP) {
-	  signal.theReceiversBlockNumber = API_CLUSTERMGR;
-	}
 #ifdef DEBUG_REG
 	ndbout_c("ClusterMgr: Sending API_REGREQ to node %d", (int)nodeId);
 #endif
@@ -304,6 +289,7 @@
      */
     theFacade.unlock_mutex();
     
+next:
     // Sleep for 100 ms between each Registration Heartbeat
     Uint64 before = now;
     NdbSleep_MilliSleep(100); 
@@ -410,9 +396,6 @@
   }//if
   node.m_info.m_heartbeat_cnt = 0;
   node.hbCounter = 0;
-  if (node.m_info.m_type != NodeInfo::REP) {
-    node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50;
-  }
 
   if(waitingForHB)
   {
@@ -424,6 +407,7 @@
       NdbCondition_Broadcast(waitForHBCond);
     }
   }
+  node.hbFrequency = (apiRegConf->apiHeartbeatFrequency * 10) - 50;
 }
 
 void
@@ -481,6 +465,8 @@
 
 void
 ClusterMgr::reportConnected(NodeId nodeId){
+  DBUG_ENTER("ClusterMgr::reportConnected");
+  DBUG_PRINT("info", ("nodeId: %u", nodeId));
   /**
    * Ensure that we are sending heartbeat every 100 ms
    * until we have got the first reply from NDB providing
@@ -500,16 +486,14 @@
    * if first API_REGCONF has not arrived
    */
   theNode.m_state.m_connected_nodes.set(nodeId);
-
-  if (theNode.m_info.m_type != NodeInfo::REP) {
-    theNode.hbFrequency = 0;
-  }
+  theNode.hbFrequency = 0;
   theNode.m_info.m_version = 0;
   theNode.compatible = true;
   theNode.nfCompleteRep = true;
   theNode.m_state.startLevel = NodeState::SL_NOTHING;
   
   theFacade.ReportNodeAlive(nodeId);
+  DBUG_VOID_RETURN;
 }
 
 void
@@ -548,10 +532,14 @@
   theNode.nfCompleteRep = false;
   if(noOfAliveNodes == 0)
   {
-    theFacade.m_globalDictCache.lock();
-    theFacade.m_globalDictCache.invalidate_all();
-    theFacade.m_globalDictCache.unlock();
-    m_connect_count ++;
+    if (!global_flag_skip_invalidate_cache)
+    {
+      theFacade.m_globalDictCache.lock();
+      theFacade.m_globalDictCache.invalidate_all();
+      theFacade.m_globalDictCache.unlock();
+      m_connect_count ++;
+      m_cluster_state = CS_waiting_for_clean_cache;
+    }
     NFCompleteRep rep;
     for(Uint32 i = 1; i<MAX_NODES; i++){
       if(theNodes[i].defined && theNodes[i].nfCompleteRep == false){

--- 1.4.7.1/ndb/src/ndbapi/ClusterMgr.hpp	2007-01-23 11:44:36 +07:00
+++ 1.14/storage/ndb/src/ndbapi/ClusterMgr.hpp	2007-01-23 11:46:03 +07:00
@@ -58,6 +58,11 @@
   class TransporterFacade & theFacade;
   
 public:
+  enum Cluster_state {
+    CS_waiting_for_clean_cache = 0,
+    CS_waiting_for_first_connect,
+    CS_connected
+  };
   struct Node {
     Node();
     bool defined;
@@ -78,6 +83,7 @@
   
   const Node &  getNodeInfo(NodeId) const;
   Uint32        getNoOfConnectedNodes() const;
+  bool          isClusterAlive() const;
   void          hb_received(NodeId);
 
   Uint32        m_connect_count;
@@ -91,6 +97,7 @@
   NdbCondition* waitForHBCond;
   bool          waitingForHB;
 
+  enum Cluster_state m_cluster_state;
   /**
    * Used for controlling start/stop of the thread
    */
@@ -135,6 +142,11 @@
 }
 
 inline
+bool
+ClusterMgr::isClusterAlive() const {
+  return noOfAliveNodes != 0;
+}
+inline
 void
 ClusterMgr::hb_received(NodeId nodeId) {
   theNodes[nodeId].m_info.m_heartbeat_cnt= 0;
@@ -178,6 +190,8 @@
     GlobalSignalNumber gsn;
     ArbitSignalData data;
     NDB_TICKS timestamp;
+
+    ArbitSignal() {}
 
     inline void init(GlobalSignalNumber aGsn, const Uint32* aData) {
       gsn = aGsn;

--- 1.3.5.1/ndb/src/ndbapi/SignalSender.cpp	2007-01-23 11:44:36 +07:00
+++ 1.10/storage/ndb/src/ndbapi/SignalSender.cpp	2007-01-23 11:46:03 +07:00
@@ -138,15 +138,6 @@
   return theFacade->theClusterMgr->getNoOfConnectedNodes();
 }
 
-SendStatus
-SignalSender::sendSignal(Uint16 nodeId, const SimpleSignal * s){
-  return theFacade->theTransporterRegistry->prepareSend(&s->header,
-							1, // JBB
-							&s->theData[0],
-							nodeId, 
-							&s->ptr[0]);
-}
-
 template<class T>
 SimpleSignal *
 SignalSender::waitFor(Uint32 timeOutMillis, T & t)
Thread
bk commit into 5.1 tree (tomas:1.2399)tomas23 Jan