List:Commits« Previous MessageNext Message »
From:tomas Date:March 22 2007 9:36am
Subject:bk commit into 5.1 tree (tomas:1.2493)
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@stripped, 2007-03-22 10:36:26+01:00, tomas@stripped +1 -0
  Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
  into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.1-new-ndb
  MERGE: 1.1810.2374.86

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-03-22 10:36:22+01:00, tomas@stripped +0 -0
    Auto merged
    MERGE: 1.73.52.2

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-03-22 10:36:22+01:00, 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:	whalegate.ndb.mysql.com
# Root:	/home/tomas/mysql-5.1-new-ndb/RESYNC

--- 1.73.52.1/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-03-21 09:06:11 +01:00
+++ 1.124/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-03-22 10:36:22 +01: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>
@@ -101,7 +101,6 @@
 extern EventLogger g_eventLogger;
 
 #ifdef NOT_USED
-
 static NdbOut&
 operator<<(NdbOut& out, const LogLevel & ll)
 {
@@ -504,10 +503,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;
       }
@@ -590,8 +585,7 @@
       DBUG_RETURN(false);
     }
   }
-  theFacade= TransporterFacade::theFacadeInstance
-    = new TransporterFacade();
+  theFacade= new TransporterFacade();
   
   if(theFacade == 0) {
     DEBUG("MgmtSrvr.cpp: theFacade is NULL.");
@@ -988,6 +982,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;
@@ -1126,6 +1129,9 @@
       break;
     }
     case GSN_STOP_CONF:{
+#ifdef NOT_USED
+      const StopConf * const ref = CAST_CONSTPTR(StopConf, signal->getDataPtr());
+#endif
       const NodeId nodeId = refToNode(signal->header.theSendersBlockRef);
 #ifdef VM_TRACE
       ndbout_c("Node %d single user mode", nodeId);
@@ -1155,6 +1161,15 @@
       break;
     }
     case GSN_NODE_FAILREP:{
+      const NodeFailRep * const rep =
+	CAST_CONSTPTR(NodeFailRep, signal->getDataPtr());
+      NdbNodeBitmask mask;
+      mask.assign(NdbNodeBitmask::Size, rep->theNodes);
+      mask.bitAND(notstarted);
+      nodes.bitANDC(mask);
+      
+      if (singleUserNodeId == 0)
+	stoppedNodes.bitOR(mask);
       break;
     }
     default:
@@ -1342,7 +1357,7 @@
 
   for (unsigned i = 0; i < node_ids.size(); i++)
   {
-    start(node_ids[i]);
+    (void) start(node_ids[i]);
   }
   return 0;
 }
@@ -1948,9 +1963,6 @@
     break;
   case GSN_EVENT_REP:
   {
-    EventReport *rep = (EventReport*) signal->getDataPtr();
-    if (rep->getNodeId() == 0)
-      rep->setNodeId(refToNode(signal->theSendersBlockRef));
     eventReport(signal->getDataPtr());
     break;
   }
@@ -1994,7 +2006,6 @@
       DBUG_VOID_RETURN;
     }
   }
-  
   rep->setNodeId(_ownNodeId);
   eventReport(theData);
   DBUG_VOID_RETURN;
@@ -2067,6 +2078,96 @@
   }
 }
 
+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:
+    {
+#ifdef NOT_USED
+      const AllocNodeIdConf * const conf =
+        CAST_CONSTPTR(AllocNodeIdConf, signal->getDataPtr());
+#endif
+      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);
+	if (!theFacade->get_node_alive(nodeId))
+	  nodeId = 0;
+        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,
@@ -2197,6 +2298,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;
@@ -2463,7 +2597,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;
@@ -2573,17 +2707,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)
 {
@@ -2732,7 +2855,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);
Thread
bk commit into 5.1 tree (tomas:1.2493)tomas22 Mar