List:Commits« Previous MessageNext Message »
From:tomas Date:January 31 2007 8:32am
Subject:bk commit into 5.1 tree (tomas:1.2418)
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.2418 07/01/31 14:32:20 tomas@stripped +14 -0
  (recommit from 5.1-wl2325-5.0-drop6)
  WAN settings for TCP transporters

  storage/ndb/src/mgmsrv/ConfigInfo.cpp
    1.98 07/01/31 14:32:12 tomas@stripped +167 -11
    Add parameters for TCP connections

  storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.135 07/01/31 14:32:12 tomas@stripped +103 -6
    Add routing of TCKEY_FAIL/CONF

  storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp
    1.20 07/01/31 14:32:12 tomas@stripped +1 -0
    Add routing of TCKEY_FAIL/CONF

  storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp
    1.48 07/01/31 14:32:12 tomas@stripped +3 -0
    Add routing of TCKEY_FAIL/CONF

  storage/ndb/src/common/transporter/TransporterRegistry.cpp
    1.69 07/01/31 14:32:12 tomas@stripped +5 -1
    Add parameters for TCP connections

  storage/ndb/src/common/transporter/Transporter.hpp
    1.17 07/01/31 14:32:12 tomas@stripped +1 -0
    Add parameters for TCP connections

  storage/ndb/src/common/transporter/Transporter.cpp
    1.28 07/01/31 14:32:12 tomas@stripped +4 -0
    Add parameters for TCP connections

  storage/ndb/src/common/transporter/TCP_Transporter.hpp
    1.9 07/01/31 14:32:12 tomas@stripped +2 -11
    Add parameters for TCP connections

  storage/ndb/src/common/transporter/TCP_Transporter.cpp
    1.15 07/01/31 14:32:12 tomas@stripped +74 -39
    Add parameters for TCP connections

  storage/ndb/src/common/mgmcommon/IPCConfig.cpp
    1.29 07/01/31 14:32:12 tomas@stripped +5 -0
    Add parameters for TCP connections

  storage/ndb/include/util/SocketClient.hpp
    1.9 07/01/31 14:32:12 tomas@stripped +2 -1
    Add parameters for TCP connections

  storage/ndb/include/transporter/TransporterDefinitions.hpp
    1.20 07/01/31 14:32:12 tomas@stripped +3 -0
    Add parameters for TCP connections

  storage/ndb/include/mgmapi/mgmapi_config_parameters.h
    1.32 07/01/31 14:32:11 tomas@stripped +3 -0
    Add parameters for TCP connections

  storage/ndb/include/kernel/GlobalSignalNumbers.h
    1.34 07/01/31 14:32:11 tomas@stripped +2 -1
    Add routing of TCKEY_FAIL/CONF

# 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-telco-next

--- 1.31/storage/ndb/include/mgmapi/mgmapi_config_parameters.h	2006-12-31 07:06:42 +07:00
+++ 1.32/storage/ndb/include/mgmapi/mgmapi_config_parameters.h	2007-01-31 14:32:11 +07:00
@@ -152,6 +152,9 @@
 #define CFG_TCP_SEND_BUFFER_SIZE      454
 #define CFG_TCP_RECEIVE_BUFFER_SIZE   455
 #define CFG_TCP_PROXY                 456
+#define CFG_TCP_RCV_BUF_SIZE          457
+#define CFG_TCP_SND_BUF_SIZE          458
+#define CFG_TCP_MAXSEG_SIZE           459
 
 #define CFG_SHM_SEND_SIGNAL_ID        500
 #define CFG_SHM_CHECKSUM              501

--- 1.33/storage/ndb/include/kernel/GlobalSignalNumbers.h	2007-01-24 12:20:34 +07:00
+++ 1.34/storage/ndb/include/kernel/GlobalSignalNumbers.h	2007-01-31 14:32:11 +07:00
@@ -90,7 +90,8 @@
 #define GSN_TCSEIZEREF                  38
 #define GSN_TCSEIZEREQ                  39
 
-/* 40 unused */
+#define GSN_TCKEY_FAILREFCONF_R         40
+
 /* 41 unused */
 /* 42 unused */
 /* 43 unused */

--- 1.19/storage/ndb/include/transporter/TransporterDefinitions.hpp	2007-01-06 07:21:21
+07:00
+++ 1.20/storage/ndb/include/transporter/TransporterDefinitions.hpp	2007-01-31 14:32:12
+07:00
@@ -69,6 +69,9 @@
     struct {
       Uint32 sendBufferSize;     // Size of SendBuffer of priority B 
       Uint32 maxReceiveSize;     // Maximum no of bytes to receive
+      Uint32 tcpSndBufSize;
+      Uint32 tcpRcvBufSize;
+      Uint32 tcpMaxsegSize;
     } tcp;
     
     struct {

--- 1.97/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2007-01-24 12:20:36 +07:00
+++ 1.98/storage/ndb/src/mgmsrv/ConfigInfo.cpp	2007-01-31 14:32:12 +07:00
@@ -22,6 +22,7 @@
 #include <ndb_limits.h>
 #include "InitConfigFileParser.hpp"
 #include <m_string.h>
+#include <Bitmask.hpp>
 
 extern my_bool opt_ndb_shm;
 extern my_bool opt_core;
@@ -1317,6 +1318,19 @@
   },
 
   {
+    KEY_INTERNAL,
+    "wan",
+    API_TOKEN,
+    "Use WAN TCP setting as default",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_BOOL,
+    "false",
+    "false",
+    "true"
+  },
+  
+  {
     CFG_NODE_HOST,
     "HostName",
     API_TOKEN,
@@ -1433,6 +1447,20 @@
     "1",
     STR_VALUE(MAX_PARALLEL_OP_PER_SCAN) },
 
+  {
+    KEY_INTERNAL,
+    "ConnectionMap",
+    "API",
+    "Specifies which DB nodes to connect",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_STRING,
+    UNDEFINED,
+    0,
+    0
+  },
+
+
   /****************************************************************************
    * MGM
    ***************************************************************************/
@@ -1449,6 +1477,19 @@
   },
 
   {
+    KEY_INTERNAL,
+    "wan",
+    MGM_TOKEN,
+    "Use WAN TCP setting as default",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_BOOL,
+    "false",
+    "false",
+    "true"
+  },
+  
+  {
     CFG_NODE_HOST,
     "HostName",
     MGM_TOKEN,
@@ -1761,8 +1802,46 @@
     ConfigInfo::CI_STRING,
     UNDEFINED,
     0, 0 },
-  
 
+  {
+    CFG_TCP_SND_BUF_SIZE,
+    "TCP_SND_BUF_SIZE",
+    "TCP",
+    "Value used for SO_SNDBUF",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_INT,
+    "71540",
+    "1", 
+    "2G"
+  },
+
+  {
+    CFG_TCP_RCV_BUF_SIZE,
+    "TCP_RCV_BUF_SIZE",
+    "TCP",
+    "Value used for SO_RCVBUF",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_INT,
+    "70080",
+    "1", 
+    "2G" 
+  },
+  
+  {
+    CFG_TCP_MAXSEG_SIZE,
+    "TCP_MAXSEG_SIZE",
+    "TCP",
+    "Value used for TCP_MAXSEG",
+    ConfigInfo::CI_USED,
+    false,
+    ConfigInfo::CI_INT,
+    "0",
+    "0", 
+    "2G" 
+  },
+  
   /****************************************************************************
    * SHM
    ***************************************************************************/
@@ -3478,20 +3557,83 @@
   return true;
 }
 
-static void
+static
+int
+check_connection(struct InitConfigFileParser::Context &ctx,
+		 const char * map,
+		 Uint32 nodeId1, const char * hostname,
+		 Uint32 nodeId2)
+{
+  Bitmask<(MAX_NODES+31)/32> bitmap;
+
+  BaseString str(map);
+  Vector<BaseString> arr;
+  str.split(arr, ",");
+  for (Uint32 i = 0; i<arr.size(); i++)
+  {
+    char *endptr = 0;
+    long val = strtol(arr[i].c_str(), &endptr, 10);
+    if (*endptr)
+    {
+      ctx.reportError("Unable to parse ConnectionMap(\"%s\" for "
+		      "node: %d, hostname: %s",
+		      map, nodeId1, hostname);
+      return -1;
+    }
+    if (! (val > 0 && val < MAX_NDB_NODES))
+    {
+      ctx.reportError("Invalid node in in ConnectionMap(\"%s\" for "
+		      "node: %d, hostname: %s",
+		      map, nodeId1, hostname);
+      return -1;
+    }
+    bitmap.set(val);
+  }
+  return bitmap.get(nodeId2);
+}
+
+static
+bool
 add_a_connection(Vector<ConfigInfo::ConfigRuleSection>&sections,
 		 struct InitConfigFileParser::Context &ctx,
 		 Uint32 nodeId1, Uint32 nodeId2, bool use_shm)
 {
+  int ret;
   ConfigInfo::ConfigRuleSection s;
+  const char * map = 0;
   const char *hostname1= 0, *hostname2= 0;
   const Properties *tmp;
   
+  Uint32 wan = 0;
   require(ctx.m_config->get("Node", nodeId1, &tmp));
   tmp->get("HostName", &hostname1);
-  
+  if (!wan)
+  {
+    tmp->get("wan", &wan);
+  }
+
+  if (tmp->get("ConnectionMap", &map))
+{
+    if ((ret = check_connection(ctx, map, nodeId1, hostname1, nodeId2)) != 1)
+    {
+      return ret == 0 ? true : false;
+    }
+  }
+
   require(ctx.m_config->get("Node", nodeId2, &tmp));
   tmp->get("HostName", &hostname2);
+  if (!wan)
+  {
+    tmp->get("wan", &wan);
+  }
+  
+  if (tmp->get("ConnectionMap", &map))
+  {
+    if ((ret = check_connection(ctx, map, nodeId2, hostname2, nodeId1)) != 1)
+    {
+      return ret == 0 ? true : false;
+    }
+  }
   
   char buf[16];
   s.m_sectionData= new Properties(true);
@@ -3512,15 +3654,23 @@
   {
     s.m_sectionType= BaseString("TCP");
     DBUG_PRINT("info",("adding TCP connection %d %d",nodeId1,nodeId2));
-  }
 
+    if (wan)
+    {
+      s.m_sectionData->put("TCP_RCV_BUF_SIZE", 4194304);
+      s.m_sectionData->put("TCP_SND_BUF_SIZE", 4194304);
+      s.m_sectionData->put("TCP_MAXSEG_SIZE", 61440);
+    }
+  }
+  
   sections.push_back(s);
+  return true;
 }
 
 static bool
 add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, 
-		   struct InitConfigFileParser::Context &ctx, 
-		   const char * rule_data)
+  struct InitConfigFileParser::Context &ctx, 
+  const char * rule_data)
 {
   DBUG_ENTER("add_node_connections");
   Uint32 i;
@@ -3572,8 +3722,10 @@
   for (i= 0; p_db_nodes.get("", i, &nodeId1); i++){
     for (Uint32 j= i+1;; j++){
       if(!p_db_nodes.get("", j, &nodeId2)) break;
-      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) {
-	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
+      if(!p_connections2.get("", nodeId1+nodeId2<<16, &dummy)) 
+      {
+	if (!add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm))
+	  goto err;
       }
     }
   }
@@ -3582,7 +3734,8 @@
     if(!p_connections.get("", nodeId1, &dummy)) {
       for (Uint32 j= 0;; j++){
 	if(!p_db_nodes.get("", j, &nodeId2)) break;
-	add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm);
+	if (!add_a_connection(sections,ctx,nodeId1,nodeId2,opt_ndb_shm))
+	  goto err;
       }
     }
   }
@@ -3591,12 +3744,15 @@
     if(!p_connections.get("", nodeId1, &dummy)) {
       for (Uint32 j= 0;; j++){
 	if(!p_db_nodes.get("", j, &nodeId2)) break;
-	add_a_connection(sections,ctx,nodeId1,nodeId2,0);
+	if (!add_a_connection(sections,ctx,nodeId1,nodeId2,0))
+	  goto err;
       }
     }
   }
-
+  
   DBUG_RETURN(true);
+err:
+  DBUG_RETURN(false);
 }
 
 static bool
set_connection_priorities(Vector<ConfigInfo::ConfigRuleSection>&sections, 

--- 1.28/storage/ndb/src/common/mgmcommon/IPCConfig.cpp	2006-12-24 02:20:11 +07:00
+++ 1.29/storage/ndb/src/common/mgmcommon/IPCConfig.cpp	2007-01-31 14:32:12 +07:00
@@ -203,6 +203,7 @@
   
   for(iter.first(); iter.valid(); iter.next()){
     
+    bzero(&conf, sizeof(conf));
     Uint32 nodeId1, nodeId2, remoteNodeId;
     const char * remoteHostName= 0, * localHostName= 0;
     if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
@@ -346,6 +347,10 @@
 	  conf.s_port = atoi(proxy);
 	}
       }
+
+      iter.get(CFG_TCP_SND_BUF_SIZE, &conf.tcp.tcpSndBufSize);
+      iter.get(CFG_TCP_RCV_BUF_SIZE, &conf.tcp.tcpRcvBufSize);
+      iter.get(CFG_TCP_MAXSEG_SIZE, &conf.tcp.tcpMaxsegSize);
       
       if(!tr.createTCPTransporter(&conf)){
 	ndbout << "Failed to create TCP Transporter from: " 

--- 1.14/storage/ndb/src/common/transporter/TCP_Transporter.cpp	2006-12-24 02:20:12 +07:00
+++ 1.15/storage/ndb/src/common/transporter/TCP_Transporter.cpp	2007-01-31 14:32:12 +07:00
@@ -59,36 +59,45 @@
 #define ndbstrerror strerror
 #endif
 
+static
+void
+setIf(int& ref, Uint32 val, Uint32 def)
+{
+  if (val)
+    ref = val;
+  else
+    ref = def;
+}
+
 TCP_Transporter::TCP_Transporter(TransporterRegistry &t_reg,
-				 int sendBufSize, int maxRecvSize, 
-                                 const char *lHostName,
-                                 const char *rHostName, 
-                                 int r_port,
-				 bool isMgmConnection,
-				 NodeId lNodeId,
-                                 NodeId rNodeId,
-				 NodeId serverNodeId,
-                                 bool chksm, bool signalId,
-                                 Uint32 _reportFreq) :
+				 const TransporterConfiguration* conf)
+  :
   Transporter(t_reg, tt_TCP_TRANSPORTER,
-	      lHostName, rHostName, r_port, isMgmConnection,
-	      lNodeId, rNodeId, serverNodeId,
-	      0, false, chksm, signalId),
-  m_sendBuffer(sendBufSize)
+	      conf->localHostName,
+	      conf->remoteHostName,
+	      conf->s_port,
+	      conf->isMgmConnection,
+	      conf->localNodeId,
+	      conf->remoteNodeId,
+	      conf->serverNodeId,
+	      0, false, 
+	      conf->checksum,
+	      conf->signalId),
+  m_sendBuffer(conf->tcp.sendBufferSize)
 {
-  maxReceiveSize = maxRecvSize;
+  maxReceiveSize = conf->tcp.maxReceiveSize;
   
   // Initialize member variables
   theSocket     = NDB_INVALID_SOCKET;
   
   sendCount      = receiveCount = 0;
   sendSize       = receiveSize  = 0;
-  reportFreq     = _reportFreq;
-
-  sockOptRcvBufSize = 70080;
-  sockOptSndBufSize = 71540;
+  reportFreq     = 4096; 
+  
   sockOptNodelay    = 1;
-  sockOptTcpMaxSeg  = 4096;
+  setIf(sockOptRcvBufSize, conf->tcp.tcpRcvBufSize, 70080);
+  setIf(sockOptSndBufSize, conf->tcp.tcpSndBufSize, 71540);
+  setIf(sockOptTcpMaxSeg, conf->tcp.tcpMaxsegSize, 0);
 }
 
 TCP_Transporter::~TCP_Transporter() {
@@ -150,34 +159,60 @@
   return true;
 }
 
+static
 void
-TCP_Transporter::setSocketOptions(){
-  if (setsockopt(theSocket, SOL_SOCKET, SO_RCVBUF,
-                 (char*)&sockOptRcvBufSize, sizeof(sockOptRcvBufSize)) < 0) {
-#ifdef DEBUG_TRANSPORTER
-    g_eventLogger.error("The setsockopt SO_RCVBUF error code = %d", InetErrno);
-#endif
-  }//if
+set_get(NDB_SOCKET_TYPE fd, int level, int optval, const char *optname, 
+	int val)
+{
+  int actual = 0, defval = 0;
+  socklen_t len = sizeof(actual);
+
+  getsockopt(fd, level, optval, (char*)&defval, &len);
   
-  if (setsockopt(theSocket, SOL_SOCKET, SO_SNDBUF,
-                 (char*)&sockOptSndBufSize, sizeof(sockOptSndBufSize)) < 0) {
+  if (setsockopt(fd, level, optval,
+		 (char*)&val, sizeof(val)) < 0)
+  {
 #ifdef DEBUG_TRANSPORTER
-    g_eventLogger.error("The setsockopt SO_SNDBUF error code = %d", InetErrno);
+    g_eventLogger.error("setsockopt(%s, %d) errno: %d %s", 
+                        optname, val, errno, strerror(errno));
 #endif
-  }//if
+  }
   
-  //-----------------------------------------------
-  // Set the TCP_NODELAY option so also small packets are sent
-  // as soon as possible
-  //-----------------------------------------------
-  if (setsockopt(theSocket, IPPROTO_TCP, TCP_NODELAY, 
-                 (char*)&sockOptNodelay, sizeof(sockOptNodelay)) < 0) {
+  len = sizeof(actual);
+  if ((getsockopt(fd, level, optval,
+		  (char*)&actual, &len) == 0) &&
+      actual != val)
+  {
 #ifdef DEBUG_TRANSPORTER
-    g_eventLogger.error("The setsockopt TCP_NODELAY error code = %d", InetErrno);
+    g_eventLogger.error("setsockopt(%s, %d) - actual %d default: %d", 
+                        optname, val, actual, defval);
 #endif
-  }//if
+  }
+}
+
+int
+TCP_Transporter::pre_connect_options(NDB_SOCKET_TYPE sockfd)
+{
+  if (sockOptTcpMaxSeg)
+  {
+    set_get(sockfd, IPPROTO_TCP, TCP_MAXSEG, "TCP_MAXSEG", sockOptTcpMaxSeg);
+  }
+  return 0;
 }
 
+void
+TCP_Transporter::setSocketOptions(){
+
+  set_get(theSocket, SOL_SOCKET, SO_RCVBUF, "SO_RCVBUF", sockOptRcvBufSize);
+  set_get(theSocket, SOL_SOCKET, SO_SNDBUF, "SO_SNDBUF", sockOptSndBufSize);
+  set_get(theSocket, IPPROTO_TCP, TCP_NODELAY, "TCP_NODELAY", sockOptNodelay);
+
+  if (sockOptTcpMaxSeg)
+  {
+    set_get(theSocket, IPPROTO_TCP, TCP_MAXSEG, "TCP_MAXSEG", 
+	    sockOptTcpMaxSeg);
+  }
+}
 
 #ifdef NDB_WIN32
 

--- 1.8/storage/ndb/src/common/transporter/TCP_Transporter.hpp	2006-12-24 02:20:13 +07:00
+++ 1.9/storage/ndb/src/common/transporter/TCP_Transporter.hpp	2007-01-31 14:32:12 +07:00
@@ -44,17 +44,7 @@
   friend class TransporterRegistry;
 private:
   // Initialize member variables
-  TCP_Transporter(TransporterRegistry&,
-		  int sendBufferSize, int maxReceiveSize,
-		  const char *lHostName,
-		  const char *rHostName, 
-		  int r_port,
-		  bool isMgmConnection,
-		  NodeId lHostId,
-		  NodeId rHostId,
-		  NodeId serverNodeId,
-		  bool checksum, bool signalId,
-		  Uint32 reportFreq = 4096);
+  TCP_Transporter(TransporterRegistry&, const TransporterConfiguration* conf);
   
   // Disconnect, delete send buffers and receive buffer
   virtual ~TCP_Transporter();
@@ -139,6 +129,7 @@
   void setSocketOptions();
 
   static bool setSocketNonBlocking(NDB_SOCKET_TYPE aSocket);
+  virtual int pre_connect_options(NDB_SOCKET_TYPE aSocket);
   
   bool sendIsPossible(struct timeval * timeout);
 

--- 1.27/storage/ndb/src/common/transporter/Transporter.cpp	2007-01-23 20:34:06 +07:00
+++ 1.28/storage/ndb/src/common/transporter/Transporter.cpp	2007-01-31 14:32:12 +07:00
@@ -137,6 +137,10 @@
     {
       return false;
     }
+    if (pre_connect_options(m_socket_client->m_sockfd) != 0)
+    {
+      return false;
+    }
     if (strlen(localHostName) > 0)
     {
       if (m_socket_client->bind(localHostName, 0) != 0)

--- 1.16/storage/ndb/src/common/transporter/Transporter.hpp	2006-12-24 02:20:13 +07:00
+++ 1.17/storage/ndb/src/common/transporter/Transporter.hpp	2007-01-31 14:32:12 +07:00
@@ -108,6 +108,7 @@
    */
   virtual bool connect_server_impl(NDB_SOCKET_TYPE sockfd) = 0;
   virtual bool connect_client_impl(NDB_SOCKET_TYPE sockfd) = 0;
+  virtual int pre_connect_options(NDB_SOCKET_TYPE sockfd) { return 0;}
   
   /**
    * Blocking

--- 1.68/storage/ndb/src/common/transporter/TransporterRegistry.cpp	2006-12-24 02:20:13
+07:00
+++ 1.69/storage/ndb/src/common/transporter/TransporterRegistry.cpp	2007-01-31 14:32:12
+07:00
@@ -280,7 +280,9 @@
   if(theTransporters[config->remoteNodeId] != NULL)
     return false;
    
-  TCP_Transporter * t = new TCP_Transporter(*this,
+  TCP_Transporter * t = new TCP_Transporter(*this, config);
+
+#if 0
 					    config->tcp.sendBufferSize,
 					    config->tcp.maxReceiveSize,
 					    config->localHostName,
@@ -292,6 +294,8 @@
 					    config->serverNodeId,
 					    config->checksum,
 					    config->signalId);
+#endif
+
   if (t == NULL) 
     return false;
   else if (!t->initTransporter()) {

--- 1.47/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2007-01-31 14:19:45 +07:00
+++ 1.48/storage/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2007-01-31 14:32:12 +07:00
@@ -1385,6 +1385,9 @@
                        TcConnectRecord * const regTcPtr);
   void sendTCKEY_FAILREF(Signal* signal, const ApiConnectRecord *);
   void sendTCKEY_FAILCONF(Signal* signal, ApiConnectRecord *);
+  void routeTCKEY_FAILREFCONF(Signal* signal, const ApiConnectRecord *, 
+			      Uint32 gsn, Uint32 len);
+  void execTCKEY_FAILREFCONF_R(Signal* signal);
   void checkStartTimeout(Signal* signal);
   void checkStartFragTimeout(Signal* signal);
   void timeOutFoundFragLab(Signal* signal, Uint32 TscanConPtr);

--- 1.19/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp	2006-12-24 02:20:16 +07:00
+++ 1.20/storage/ndb/src/kernel/blocks/dbtc/DbtcInit.cpp	2007-01-31 14:32:12 +07:00
@@ -279,6 +279,7 @@
   
   addRecSignal(GSN_ALTER_TAB_REQ, &Dbtc::execALTER_TAB_REQ);
   addRecSignal(GSN_ROUTE_ORD, &Dbtc::execROUTE_ORD);
+  addRecSignal(GSN_TCKEY_FAILREFCONF_R, &Dbtc::execTCKEY_FAILREFCONF_R);
   
   cacheRecord = 0;
   apiConnectRecord = 0;

--- 1.134/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2007-01-31 14:19:45 +07:00
+++ 1.135/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2007-01-31 14:32:12 +07:00
@@ -70,6 +70,7 @@
 
 #include <NdbOut.hpp>
 #include <DebuggerNames.hpp>
+#include <signaldata/CheckNodeGroups.hpp>
 
 #include <signaldata/RouteOrd.hpp>
 
@@ -7514,12 +7515,24 @@
   jam();
 
   const Uint32 ref = regApiPtr->ndbapiBlockref;
-  if(ref != 0){
+  const Uint32 nodeId = refToNode(ref);
+  if(ref != 0)
+  {
+    jam();
+    bool connectedToNode = getNodeInfo(nodeId).m_connected;
     signal->theData[0] = regApiPtr->ndbapiConnect;
     signal->theData[1] = regApiPtr->transid[0];
     signal->theData[2] = regApiPtr->transid[1];
-  
-    sendSignal(ref, GSN_TCKEY_FAILREF, signal, 3, JBB);
+    
+    if (likely(connectedToNode))
+    {
+      jam();
+      sendSignal(ref, GSN_TCKEY_FAILREF, signal, 3, JBB);
+    }
+    else
+    {
+      routeTCKEY_FAILREFCONF(signal, regApiPtr, GSN_TCKEY_FAILREF, 3);
+    }
   }
 }
 
@@ -7530,15 +7543,99 @@
   
   const Uint32 ref = regApiPtr->ndbapiBlockref;
   const Uint32 marker = regApiPtr->commitAckMarker;
-  if(ref != 0){
+  const Uint32 nodeId = refToNode(ref);
+  if(ref != 0)
+  {
+    jam()
     failConf->apiConnectPtr = regApiPtr->ndbapiConnect | (marker != RNIL);
     failConf->transId1 = regApiPtr->transid[0];
     failConf->transId2 = regApiPtr->transid[1];
     
-    sendSignal(regApiPtr->ndbapiBlockref,
-	       GSN_TCKEY_FAILCONF, signal, TcKeyFailConf::SignalLength, JBB);
+    bool connectedToNode = getNodeInfo(nodeId).m_connected;
+    if (likely(connectedToNode))
+    {
+      jam();
+      sendSignal(ref, GSN_TCKEY_FAILCONF, signal, 
+		 TcKeyFailConf::SignalLength, JBB);
+    }
+    else
+    {
+      routeTCKEY_FAILREFCONF(signal, regApiPtr,
+			     GSN_TCKEY_FAILCONF, TcKeyFailConf::SignalLength);
+    }
   }
   regApiPtr->commitAckMarker = RNIL;
+}
+
+void
+Dbtc::routeTCKEY_FAILREFCONF(Signal* signal, const ApiConnectRecord* regApiPtr,
+			     Uint32 gsn, Uint32 len)
+{
+  jam();
+
+  Uint32 ref = regApiPtr->ndbapiBlockref;
+
+  /**
+   * We're not connected
+   *   so we find another node in same node group as died node
+   *   and send to it, so that it can forward
+   */
+  tcNodeFailptr.i = regApiPtr->takeOverRec;
+  ptrCheckGuard(tcNodeFailptr, 1, tcFailRecord);
+
+  /**
+   * Save signal
+   */
+  Uint32 save[25];
+  ndbrequire(len <= 25);
+  memcpy(save, signal->theData, 4*len);
+  
+  Uint32 node = tcNodeFailptr.p->takeOverNode;
+  
+  CheckNodeGroups * sd = (CheckNodeGroups*)signal->getDataPtrSend();
+  sd->blockRef = reference();
+  sd->requestType =
+    CheckNodeGroups::Direct |
+    CheckNodeGroups::GetNodeGroupMembers;
+  sd->nodeId = node;
+  EXECUTE_DIRECT(DBDIH, GSN_CHECKNODEGROUPSREQ, signal, 
+		 CheckNodeGroups::SignalLength);
+  jamEntry();
+  
+  NdbNodeBitmask mask;
+  mask.assign(sd->mask);
+  mask.clear(getOwnNodeId());
+  memcpy(signal->theData, save, 4*len);
+  
+  Uint32 i = 0;
+  while((i = mask.find(i + 1)) != NdbNodeBitmask::NotFound)
+  {
+    jam();
+    HostRecordPtr localHostptr;
+    localHostptr.i = i;
+    ptrCheckGuard(localHostptr, chostFilesize, hostRecord);
+    if (localHostptr.p->hostStatus == HS_ALIVE) 
+    {
+      jam();
+      signal->theData[len] = gsn;
+      signal->theData[len+1] = ref;
+      sendSignal(calcTcBlockRef(i), GSN_TCKEY_FAILREFCONF_R, 
+		 signal, len+2, JBB);
+      return;
+    }
+  }
+  
+  ndbrequire(false); // Unable to find alive node in node group...
+}
+
+void
+Dbtc::execTCKEY_FAILREFCONF_R(Signal* signal)
+{
+  jamEntry();
+  Uint32 len = signal->getLength();
+  Uint32 gsn = signal->theData[len-2];
+  Uint32 ref = signal->theData[len-1];
+  sendSignal(ref, gsn, signal, len-2, JBB);
 }
 
 /*------------------------------------------------------------*/

--- 1.8/storage/ndb/include/util/SocketClient.hpp	2007-01-23 20:34:06 +07:00
+++ 1.9/storage/ndb/include/util/SocketClient.hpp	2007-01-31 14:32:12 +07:00
@@ -21,7 +21,6 @@
 
 class SocketClient
 {
-  NDB_SOCKET_TYPE m_sockfd;
   struct sockaddr_in m_servaddr;
   unsigned int m_connect_timeout_sec;
   unsigned short m_port;
@@ -43,6 +42,8 @@
   int bind(const char* toaddress, unsigned short toport);
   NDB_SOCKET_TYPE connect(const char* toaddress = 0, unsigned short port = 0);
   bool close();
+
+  NDB_SOCKET_TYPE m_sockfd;
 };
 
 #endif // SOCKET_ClIENT_HPP
Thread
bk commit into 5.1 tree (tomas:1.2418)tomas31 Jan