List:Commits« Previous MessageNext Message »
From:tomas Date:March 27 2007 9:35am
Subject:bk commit into 5.1 tree (tomas:1.2520)
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-27 09:35:05+02:00, tomas@stripped +15 -0
  WL2793
  mysqld can use several cluster connections

  mysql-test/mysql-test-run.pl@stripped, 2007-03-27 09:35:01+02:00,
tomas@stripped +4 -0
    WL2793
    (also included wait connected patch as they where strongly linked)

  mysql-test/ndb/ndb_config_2_node.ini@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +1 -1
    WL2793

  sql/ha_ndbcluster.cc@stripped, 2007-03-27 09:35:02+02:00, tomas@stripped
+154 -12
    WL2793
    (also included wait connected patch as they where strongly linked)
    - array of cluster connection
    - mutex to protect round robin allocation to thd object
    - connect all

  sql/ha_ndbcluster.h@stripped, 2007-03-27 09:35:02+02:00, tomas@stripped +1
-0
    WL2793
    added cluster connection to thd object

  sql/ha_ndbcluster_binlog.cc@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +33 -16
    WL2793
    - get latest transaction now needs to be collected from several connections

  sql/ha_ndbcluster_binlog.h@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +2 -0
    WL2793

  sql/mysqld.cc@stripped, 2007-03-27 09:35:02+02:00, tomas@stripped +14 -2
    WL2793
    (also included wait connected patch as they where strongly linked)

  storage/ndb/include/ndbapi/ndb_cluster_connection.hpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +4 -0
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/mgmsrv/MgmtSrvr.cpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +1 -1
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/ClusterMgr.cpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +10 -8
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +2 -2
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/TransporterFacade.cpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +8 -5
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/TransporterFacade.hpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +2 -2
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/ndb_cluster_connection.cpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +30 -5
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

  storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp@stripped, 2007-03-27 09:35:02+02:00,
tomas@stripped +5 -1
    WL2793
    add possiblily to clone cluster conenctions to use same dictionary

# 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-multi-connect

--- 1.622/sql/mysqld.cc	2007-03-19 22:37:31 +01:00
+++ 1.623/sql/mysqld.cc	2007-03-27 09:35:02 +02:00
@@ -421,7 +421,8 @@
 char opt_ndb_constrbuf[1024];
 unsigned opt_ndb_constrbuf_len= 0;
 my_bool	opt_ndb_shm, opt_ndb_optimized_node_selection;
-ulong opt_ndb_cache_check_time;
+ulong opt_ndb_cache_check_time, opt_ndb_wait_connected;
+ulong opt_ndb_cluster_connection_pool;
 const char *opt_ndb_mgmd;
 ulong opt_ndb_nodeid;
 ulong ndb_extra_logging;
@@ -4902,6 +4903,8 @@
   OPT_NDB_USE_EXACT_COUNT, OPT_NDB_USE_TRANSACTIONS,
   OPT_NDB_FORCE_SEND, OPT_NDB_AUTOINCREMENT_PREFETCH_SZ,
   OPT_NDB_SHM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_NDB_CACHE_CHECK_TIME,
+  OPT_NDB_WAIT_CONNECTED,
+  OPT_NDB_CLUSTER_CONNECTION_POOL,
   OPT_NDB_MGMD, OPT_NDB_NODEID,
   OPT_NDB_DISTRIBUTION,
   OPT_NDB_INDEX_STAT_ENABLE,
@@ -5625,13 +5628,22 @@
    (gptr*) &global_system_variables.ndb_index_stat_enable,
    (gptr*) &max_system_variables.ndb_index_stat_enable,
    0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 0, 0},
-#endif
   {"ndb-use-copying-alter-table",
    OPT_NDB_USE_COPYING_ALTER_TABLE,
    "Force ndbcluster to always copy tables at alter table (should only be used if on-line
alter table fails).",
    (gptr*) &global_system_variables.ndb_use_copying_alter_table,
    (gptr*) &global_system_variables.ndb_use_copying_alter_table,
    0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},  
+  { "ndb-wait-connected", OPT_NDB_WAIT_CONNECTED,
+    "Time (in seconds) for mysqld to wait for connection to cluster management and data
nodes.",
+    (gptr*) &opt_ndb_wait_connected, (gptr*) &opt_ndb_wait_connected,
+    0, GET_ULONG, REQUIRED_ARG, 0, 0, LONG_TIMEOUT, 0, 0, 0},
+  { "ndb-cluster-connection-pool", OPT_NDB_CLUSTER_CONNECTION_POOL,
+    "Pool of cluster connections to cluster to be used by mysql server.",
+    (gptr*) &opt_ndb_cluster_connection_pool,
+    (gptr*) &opt_ndb_cluster_connection_pool,
+    0, GET_ULONG, REQUIRED_ARG, 1, 1, 63, 0, 0, 0},
+#endif
   {"new", 'n', "Use very new possible 'unsafe' functions.",
    (gptr*) &global_system_variables.new_mode,
    (gptr*) &max_system_variables.new_mode,

--- 1.288/mysql-test/mysql-test-run.pl	2007-03-22 01:04:26 +01:00
+++ 1.289/mysql-test/mysql-test-run.pl	2007-03-27 09:35:01 +02:00
@@ -3743,6 +3743,8 @@
       mtr_add_arg($args, "%s--ndbcluster", $prefix);
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 		  $cluster->{'connect_string'});
+      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
+      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
       if ( $mysql_version_id >= 50100 )
       {
 	mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);
@@ -3818,6 +3820,8 @@
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 		  $clusters->[$mysqld->{'cluster'}]->{'connect_string'});
 
+      mtr_add_arg($args, "%s--ndb-wait-connected=20", $prefix);
+      mtr_add_arg($args, "%s--ndb-cluster-connection-pool=3", $prefix);
       if ( $mysql_version_id >= 50100 )
       {
 	mtr_add_arg($args, "%s--ndb-extra-logging", $prefix);

--- 1.127/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-03-15 09:43:07 +01:00
+++ 1.128/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2007-03-27 09:35:02 +02:00
@@ -592,7 +592,7 @@
       DBUG_RETURN(false);
     }
   }
-  theFacade= new TransporterFacade();
+  theFacade= new TransporterFacade(0);
   
   if(theFacade == 0) {
     DEBUG("MgmtSrvr.cpp: theFacade is NULL.");

--- 1.36/storage/ndb/src/ndbapi/ClusterMgr.cpp	2007-03-08 18:49:04 +01:00
+++ 1.37/storage/ndb/src/ndbapi/ClusterMgr.cpp	2007-03-27 09:35:02 +02:00
@@ -232,11 +232,12 @@
     /**
      * Start of Secure area for use of Transporter
      */
-    if (m_cluster_state == CS_waiting_for_clean_cache)
+    if (m_cluster_state == CS_waiting_for_clean_cache &&
+        theFacade.m_globalDictCache)
     {
-      theFacade.m_globalDictCache.lock();
-      unsigned sz= theFacade.m_globalDictCache.get_size();
-      theFacade.m_globalDictCache.unlock();
+      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;
@@ -533,11 +534,12 @@
   theNode.nfCompleteRep = false;
   if(noOfAliveNodes == 0)
   {
-    if (!global_flag_skip_invalidate_cache)
+    if (!global_flag_skip_invalidate_cache &&
+        theFacade.m_globalDictCache)
     {
-      theFacade.m_globalDictCache.lock();
-      theFacade.m_globalDictCache.invalidate_all();
-      theFacade.m_globalDictCache.unlock();
+      theFacade.m_globalDictCache->lock();
+      theFacade.m_globalDictCache->invalidate_all();
+      theFacade.m_globalDictCache->unlock();
       m_connect_count ++;
       m_cluster_state = CS_waiting_for_clean_cache;
     }

--- 1.164/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2007-03-23 17:17:41 +01:00
+++ 1.165/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2007-03-27 09:35:02 +02:00
@@ -1520,7 +1520,7 @@
 NdbDictionaryImpl::setTransporter(class TransporterFacade * tf)
 {
   if(tf != 0){
-    m_globalHash = &tf->m_globalDictCache;
+    m_globalHash = tf->m_globalDictCache;
     return m_receiver.setTransporter(tf);
   }
   
@@ -1532,7 +1532,7 @@
 NdbDictionaryImpl::setTransporter(class Ndb* ndb, 
 				  class TransporterFacade * tf)
 {
-  m_globalHash = &tf->m_globalDictCache;
+  m_globalHash = tf->m_globalDictCache;
   if(m_receiver.setTransporter(ndb, tf)){
     return true;
   }

--- 1.61/storage/ndb/src/ndbapi/TransporterFacade.cpp	2007-02-26 17:58:47 +01:00
+++ 1.62/storage/ndb/src/ndbapi/TransporterFacade.cpp	2007-03-27 09:35:02 +02:00
@@ -311,14 +311,16 @@
 
      case GSN_ALTER_TABLE_REP:
      {
+       if (theFacade->m_globalDictCache == NULL)
+         break;
        const AlterTableRep* rep = (const AlterTableRep*)theData;
-       theFacade->m_globalDictCache.lock();
-       theFacade->m_globalDictCache.
+       theFacade->m_globalDictCache->lock();
+       theFacade->m_globalDictCache->
 	 alter_table_rep((const char*)ptr[0].p, 
 			 rep->tableId,
 			 rep->tableVersion,
 			 rep->changeType == AlterTableRep::CT_ALTERED);
-       theFacade->m_globalDictCache.unlock();
+       theFacade->m_globalDictCache->unlock();
        break;
      }
      case GSN_SUB_GCP_COMPLETE_REP:
@@ -641,12 +643,13 @@
   }
 }
 
-TransporterFacade::TransporterFacade() :
+TransporterFacade::TransporterFacade(GlobalDictCache *cache) :
   theTransporterRegistry(0),
   theStopReceive(0),
   theSendThread(NULL),
   theReceiveThread(NULL),
-  m_fragmented_signal_id(0)
+  m_fragmented_signal_id(0),
+  m_globalDictCache(cache)
 {
   DBUG_ENTER("TransporterFacade::TransporterFacade");
   init_cond_wait_queue();

--- 1.35/storage/ndb/src/ndbapi/TransporterFacade.hpp	2007-03-07 09:31:00 +01:00
+++ 1.36/storage/ndb/src/ndbapi/TransporterFacade.hpp	2007-03-27 09:35:02 +02:00
@@ -52,7 +52,7 @@
    * (Ndb objects should not be shared by different threads.)
    */
   STATIC_CONST( MAX_NO_THREADS = 4711 );
-  TransporterFacade();
+  TransporterFacade(GlobalDictCache *cache);
   virtual ~TransporterFacade();
   bool init(Uint32, const ndb_mgm_configuration *);
 
@@ -281,7 +281,7 @@
   NdbMutex* theMutexPtr;
 
 public:
-  GlobalDictCache m_globalDictCache;
+  GlobalDictCache *m_globalDictCache;
 };
 
 class PollGuard

--- 1.420/sql/ha_ndbcluster.cc	2007-03-23 17:12:04 +01:00
+++ 1.421/sql/ha_ndbcluster.cc	2007-03-27 09:35:02 +02:00
@@ -47,6 +47,8 @@
 extern my_bool opt_ndb_optimized_node_selection;
 extern const char *opt_ndbcluster_connectstring;
 extern ulong opt_ndb_cache_check_time;
+extern ulong opt_ndb_wait_connected;
+extern ulong opt_ndb_cluster_connection_pool;
 
 // ndb interface initialization/cleanup
 #ifdef  __cplusplus
@@ -137,6 +139,10 @@
 
 static Ndb* g_ndb= NULL;
 Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
+Ndb_cluster_connection **g_ndb_cluster_connection_pool= NULL;
+ulong g_ndb_cluster_connection_pool_alloc= 0;
+ulong g_ndb_cluster_connection_pool_pos= 0;
+pthread_mutex_t g_ndb_cluster_connection_pool_mutex;
 uchar g_node_id_map[max_ndb_nodes];
 
 // Handler synchronization
@@ -192,9 +198,15 @@
 
 static int update_status_variables(Ndb_cluster_connection *c)
 {
-  ndb_cluster_node_id=         c->node_id();
-  ndb_connected_port=          c->get_connected_port();
-  ndb_connected_host=          c->get_connected_host();
+  ndb_connected_port= c->get_connected_port();
+  ndb_connected_host= c->get_connected_host();
+  if (ndb_cluster_node_id != (int) c->node_id())
+  {
+    ndb_cluster_node_id= c->node_id();
+    sql_print_information("NDB: NodeID is %lu, management server '%s:%lu'",
+                          ndb_cluster_node_id, ndb_connected_host,
+                          ndb_connected_port);
+  }
   ndb_number_of_replicas=      0;
   ndb_number_of_ready_data_nodes= c->get_no_ready();
   ndb_number_of_data_nodes=     c->no_db_nodes();
@@ -344,7 +356,15 @@
 
 Thd_ndb::Thd_ndb()
 {
-  ndb= new Ndb(g_ndb_cluster_connection, "");
+  pthread_mutex_lock(&g_ndb_cluster_connection_pool_mutex);
+  connection=
+    g_ndb_cluster_connection_pool[g_ndb_cluster_connection_pool_pos];
+  g_ndb_cluster_connection_pool_pos++;
+  if (g_ndb_cluster_connection_pool_pos ==
+      g_ndb_cluster_connection_pool_alloc)
+    g_ndb_cluster_connection_pool_pos= 0;
+  pthread_mutex_unlock(&g_ndb_cluster_connection_pool_mutex);
+  ndb= new Ndb(connection, "");
   lock_count= 0;
   count= 0;
   all= NULL;
@@ -6792,6 +6812,8 @@
   if ((g_ndb_cluster_connection=
        new Ndb_cluster_connection(opt_ndbcluster_connectstring)) == 0)
   {
+    sql_print_error("NDB: failed to allocate global "
+                    "ndb cluster connection object");
     DBUG_PRINT("error",("Ndb_cluster_connection(%s)",
                         opt_ndbcluster_connectstring));
     goto ndbcluster_init_error;
@@ -6807,6 +6829,7 @@
   // Create a Ndb object to open the connection  to NDB
   if ( (g_ndb= new Ndb(g_ndb_cluster_connection, "sys")) == 0 )
   {
+    sql_print_error("NDB: failed to allocate global ndb object");
     DBUG_PRINT("error", ("failed to create global ndb object"));
     goto ndbcluster_init_error;
   }
@@ -6816,20 +6839,107 @@
     goto ndbcluster_init_error;
   }
 
-  if ((res= g_ndb_cluster_connection->connect(0,0,0)) == 0)
+  /* Connect to management server */
+
+  struct timeval end_time;
+  gettimeofday(&end_time, 0);
+  end_time.tv_sec+= opt_ndb_wait_connected;
+
+  while ((res= g_ndb_cluster_connection->connect(0,0,0)) == 1)
+  {
+    struct timeval now_time;
+    gettimeofday(&now_time, 0);
+    if (now_time.tv_sec > end_time.tv_sec ||
+        (now_time.tv_sec == end_time.tv_sec &&
+         now_time.tv_usec >= end_time.tv_usec))
+      break;
+    sleep(1);
+  }
+
+  {
+    g_ndb_cluster_connection_pool_alloc= opt_ndb_cluster_connection_pool;
+    g_ndb_cluster_connection_pool= (Ndb_cluster_connection**)
+      my_malloc(g_ndb_cluster_connection_pool_alloc *
+                sizeof(Ndb_cluster_connection*),
+                MYF(MY_WME | MY_ZEROFILL));
+    pthread_mutex_init(&g_ndb_cluster_connection_pool_mutex,
+                       MY_MUTEX_INIT_FAST);
+    g_ndb_cluster_connection_pool[0]= g_ndb_cluster_connection;
+    for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+    {
+      if ((g_ndb_cluster_connection_pool[i]=
+           new Ndb_cluster_connection(opt_ndbcluster_connectstring,
+                                      g_ndb_cluster_connection)) == 0)
+      {
+        sql_print_error("NDB[%u]: failed to allocate cluster connect object",
+                        i);
+        DBUG_PRINT("error",("Ndb_cluster_connection[%u](%s)",
+                            i, opt_ndbcluster_connectstring));
+        goto ndbcluster_init_error;
+      }
+      {
+        char buf[128];
+        my_snprintf(buf, sizeof(buf), "mysqld --server-id=%lu (connection %u)",
+                    server_id, i+1);
+        g_ndb_cluster_connection_pool[i]->set_name(buf);
+      }
+      g_ndb_cluster_connection_pool[i]->set_optimized_node_selection
+        (opt_ndb_optimized_node_selection);
+    }
+  }
+
+  if (res == 0)
   {
     connect_callback();
-    DBUG_PRINT("info",("NDBCLUSTER storage engine at %s on port %d",
-                       g_ndb_cluster_connection->get_connected_host(),
-                       g_ndb_cluster_connection->get_connected_port()));
-    g_ndb_cluster_connection->wait_until_ready(10,3);
+    for (unsigned i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+    {
+      if (g_ndb_cluster_connection_pool[i]->node_id() == 0)
+      {
+        // not connected to mgmd yet, try again
+        g_ndb_cluster_connection_pool[i]->connect(0,0,0);
+        if (g_ndb_cluster_connection_pool[i]->node_id() == 0)
+        {
+          sql_print_warning("NDB[%u]: starting connect thread", i);
+          g_ndb_cluster_connection_pool[i]->start_connect_thread();
+          continue;
+        }
+      }
+      DBUG_PRINT("info",
+                 ("NDBCLUSTER storage engine (%u) at %s on port %d", i,
+                  g_ndb_cluster_connection_pool[i]->get_connected_host(),
+                  g_ndb_cluster_connection_pool[i]->get_connected_port()));
+
+      struct timeval now_time;
+      gettimeofday(&now_time, 0);
+      ulong wait_until_ready_time = (end_time.tv_sec > now_time.tv_sec) ?
+        end_time.tv_sec - now_time.tv_sec : 1;
+      res= g_ndb_cluster_connection_pool[i]->
+        wait_until_ready(wait_until_ready_time,3);
+      if (res == 0)
+      {
+        sql_print_information("NDB[%u]: all storage nodes connected", i);
+      }
+      else if (res > 0)
+      {
+        sql_print_information("NDB[%u]: some storage nodes connected", i);
+      }
+      else if (res < 0)
+      {
+        sql_print_information("NDB[%u]: no storage nodes connected (timed out)", i);
+      }
+    }
   } 
   else if (res == 1)
   {
-    if (g_ndb_cluster_connection->start_connect_thread(connect_callback)) 
+    for (unsigned i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
     {
-      DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()"));
-      goto ndbcluster_init_error;
+      if (g_ndb_cluster_connection_pool[i]->
+          start_connect_thread(i == 0 ? connect_callback :  NULL)) 
+      {
+        sql_print_error("NDB[%u]: failed to start connect thread", i);
+        DBUG_PRINT("error", ("g_ndb_cluster_connection->start_connect_thread()"));
+        goto ndbcluster_init_error;
+      }
     }
 #ifndef DBUG_OFF
     {
@@ -6895,6 +7005,22 @@
   if (g_ndb)
     delete g_ndb;
   g_ndb= NULL;
+  {
+    if (g_ndb_cluster_connection_pool)
+    {
+      /* first in pool is the main one, wait with release */
+      for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+      {
+        if (g_ndb_cluster_connection_pool[i])
+          delete g_ndb_cluster_connection_pool[i];
+      }
+      my_free((gptr) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
+      pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
+      g_ndb_cluster_connection_pool= 0;
+    }
+    g_ndb_cluster_connection_pool_alloc= 0;
+    g_ndb_cluster_connection_pool_pos= 0;
+  }
   if (g_ndb_cluster_connection)
     delete g_ndb_cluster_connection;
   g_ndb_cluster_connection= NULL;
@@ -6957,6 +7083,22 @@
 #endif
     delete g_ndb;
     g_ndb= NULL;
+  }
+  {
+    if (g_ndb_cluster_connection_pool)
+    {
+      /* first in pool is the main one, wait with release */
+      for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+      {
+        if (g_ndb_cluster_connection_pool[i])
+          delete g_ndb_cluster_connection_pool[i];
+      }
+      my_free((gptr) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
+      pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
+      g_ndb_cluster_connection_pool= 0;
+    }
+    g_ndb_cluster_connection_pool_alloc= 0;
+    g_ndb_cluster_connection_pool_pos= 0;
   }
   delete g_ndb_cluster_connection;
   g_ndb_cluster_connection= NULL;

--- 1.170/sql/ha_ndbcluster.h	2007-03-22 13:20:36 +01:00
+++ 1.171/sql/ha_ndbcluster.h	2007-03-27 09:35:02 +02:00
@@ -613,6 +613,7 @@
   void init_open_tables();
   THD_NDB_SHARE *get_open_table(THD *thd, const void *key);
 
+  Ndb_cluster_connection *connection;
   Ndb *ndb;
   ulong count;
   uint lock_count;

--- 1.21/mysql-test/ndb/ndb_config_2_node.ini	2007-02-14 09:29:12 +01:00
+++ 1.22/mysql-test/ndb/ndb_config_2_node.ini	2007-03-27 09:35:02 +02:00
@@ -1,6 +1,6 @@
 [ndbd default]
 NoOfReplicas= 2
-MaxNoOfConcurrentTransactions= 64
+MaxNoOfConcurrentTransactions= 2048
 MaxNoOfConcurrentOperations= CHOOSE_MaxNoOfConcurrentOperations
 DataMemory= CHOOSE_DataMemory
 IndexMemory= CHOOSE_IndexMemory

--- 1.20/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	2007-03-07 15:32:21 +01:00
+++ 1.21/storage/ndb/include/ndbapi/ndb_cluster_connection.hpp	2007-03-27 09:35:02 +02:00
@@ -51,6 +51,10 @@
    *                      management server
    */
   Ndb_cluster_connection(const char * connectstring = 0);
+#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
+  Ndb_cluster_connection(const char * connectstring,
+                         Ndb_cluster_connection *main_connection);
+#endif
   ~Ndb_cluster_connection();
 
   /**

--- 1.50/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2007-03-07 15:50:45 +01:00
+++ 1.51/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2007-03-27 09:35:02 +02:00
@@ -46,7 +46,14 @@
  */
 
 Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string)
-  : m_impl(* new Ndb_cluster_connection_impl(connect_string))
+  : m_impl(* new Ndb_cluster_connection_impl(connect_string, 0))
+{
+}
+
+Ndb_cluster_connection::Ndb_cluster_connection(const char *connect_string,
+                                               Ndb_cluster_connection *
+                                               main_connection)
+  : m_impl(* new Ndb_cluster_connection_impl(connect_string, main_connection))
 {
 }
 
@@ -262,9 +269,12 @@
  * Ndb_cluster_connection_impl
  */
 
-Ndb_cluster_connection_impl::Ndb_cluster_connection_impl(const char *
-							 connect_string)
+Ndb_cluster_connection_impl::
+Ndb_cluster_connection_impl(const char *
+                            connect_string,
+                            Ndb_cluster_connection *main_connection)
   : Ndb_cluster_connection(*this),
+    m_main_connection(main_connection),
     m_optimized_node_selection(1),
     m_name(0),
     m_run_connect_thread(0),
@@ -302,8 +312,19 @@
     NdbMgmHandle h= m_config_retriever->get_mgmHandle();
     ndb_mgm_set_name(h, m_name);
   }
-  m_transporter_facade= new TransporterFacade();
-  
+  if (!m_main_connection)
+  {
+    m_globalDictCache = new GlobalDictCache;
+    m_transporter_facade= new TransporterFacade(m_globalDictCache);
+  }
+  else
+  {
+    assert(m_main_connection->m_impl.m_globalDictCache != NULL);
+    m_globalDictCache = 0;
+    m_transporter_facade=
+      new TransporterFacade(m_main_connection->m_impl.m_globalDictCache);
+  }
+
   NdbMutex_Lock(g_ndb_connection_mutex);
   if(g_ndb_connection_count++ == 0){
     NdbDictionary::Column::FRAGMENT= 
@@ -340,6 +361,10 @@
   if (m_transporter_facade != 0)
   {
     m_transporter_facade->stop_instance();
+  }
+  if (m_globalDictCache)
+  {
+    delete m_globalDictCache;
   }
   if (m_connect_thread)
   {

--- 1.10/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2007-01-29 00:47:32 +01:00
+++ 1.11/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2007-03-27 09:35:02 +02:00
@@ -20,6 +20,7 @@
 #include <ndb_cluster_connection.hpp>
 #include <Vector.hpp>
 #include <NdbMutex.h>
+#include "DictCache.hpp"
 
 extern NdbMutex *g_ndb_connection_mutex;
 
@@ -34,7 +35,8 @@
 
 class Ndb_cluster_connection_impl : public Ndb_cluster_connection
 {
-  Ndb_cluster_connection_impl(const char *connectstring);
+  Ndb_cluster_connection_impl(const char *connectstring,
+                              Ndb_cluster_connection *main_connection);
   ~Ndb_cluster_connection_impl();
 
   void do_test();
@@ -70,6 +72,8 @@
   void connect_thread();
   void set_name(const char *name);
   
+  Ndb_cluster_connection *m_main_connection;
+  GlobalDictCache *m_globalDictCache;
   TransporterFacade *m_transporter_facade;
   ConfigRetriever *m_config_retriever;
   NdbThread *m_connect_thread;

--- 1.105/sql/ha_ndbcluster_binlog.cc	2007-03-08 18:58:36 +01:00
+++ 1.106/sql/ha_ndbcluster_binlog.cc	2007-03-27 09:35:02 +02:00
@@ -116,8 +116,6 @@
 static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
                                    bool have_lock);
 
-static Uint64 *p_latest_trans_gci= 0;
-
 /*
   Global variables for holding the ndb_binlog_index table reference
 */
@@ -128,6 +126,28 @@
   Helper functions
 */
 
+static ulonglong get_latest_trans_gci()
+{
+  unsigned i;
+  ulonglong val= *g_ndb_cluster_connection->get_latest_trans_gci();
+  for (i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+  {
+    ulonglong tmp= *g_ndb_cluster_connection_pool[i]->get_latest_trans_gci();
+    if (tmp > val)
+      val= tmp;
+  }
+  return val;
+}
+
+static void set_latest_trans_gci(ulonglong val)
+{
+  unsigned i;
+  for (i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+  {
+    *g_ndb_cluster_connection_pool[i]->get_latest_trans_gci()= val;
+  }
+}
+
 #ifndef DBUG_OFF
 /* purecov: begin deadcode */
 static void print_records(TABLE *table, const char *record)
@@ -451,7 +471,7 @@
   {
     DBUG_ENTER("ndbcluster_binlog_wait");
     const char *save_info= thd ? thd->proc_info : 0;
-    ulonglong wait_epoch= *p_latest_trans_gci;
+    ulonglong wait_epoch= get_latest_trans_gci();
     int count= 30;
     if (thd)
       thd->proc_info= "Waiting for ndbcluster binlog update to "
@@ -3558,8 +3578,6 @@
   */
   injector_thd= thd;
   injector_ndb= i_ndb;
-  p_latest_trans_gci= 
-    injector_ndb->get_ndb_cluster_connection().get_latest_trans_gci();
   schema_ndb= s_ndb;
 
   if (opt_bin_log)
@@ -3657,7 +3675,7 @@
                         "ndb_latest_handled_binlog_epoch: %u, while current epoch: %u. "
                         "RESET MASTER should be issued. Resetting
ndb_latest_handled_binlog_epoch.",
                         (unsigned) ndb_latest_handled_binlog_epoch, (unsigned)
schema_gci);
-        *p_latest_trans_gci= 0;
+        set_latest_trans_gci(0);
         ndb_latest_handled_binlog_epoch= 0;
         ndb_latest_applied_binlog_epoch= 0;
         ndb_latest_received_binlog_epoch= 0;
@@ -3685,7 +3703,7 @@
   do_ndbcluster_binlog_close_connection= BCCC_running;
   for ( ; !((ndbcluster_binlog_terminating ||
              do_ndbcluster_binlog_close_connection) &&
-            ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci) &&
+            ndb_latest_handled_binlog_epoch >= get_latest_trans_gci()) &&
           do_ndbcluster_binlog_close_connection != BCCC_restart; )
   {
 #ifndef DBUG_OFF
@@ -3693,10 +3711,10 @@
     {
       DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection: %d, "
                           "ndb_latest_handled_binlog_epoch: %lu, "
-                          "*p_latest_trans_gci: %lu",
+                          "*get_latest_trans_gci(): %lu",
                           do_ndbcluster_binlog_close_connection,
                           (ulong) ndb_latest_handled_binlog_epoch,
-                          (ulong) *p_latest_trans_gci));
+                          (ulong) get_latest_trans_gci()));
     }
 #endif
 #ifdef RUN_NDB_BINLOG_TIMER
@@ -3733,7 +3751,7 @@
 
     if ((ndbcluster_binlog_terminating ||
          do_ndbcluster_binlog_close_connection) &&
-        (ndb_latest_handled_binlog_epoch >= *p_latest_trans_gci ||
+        (ndb_latest_handled_binlog_epoch >= get_latest_trans_gci() ||
          !ndb_binlog_running))
       break; /* Shutting down server */
 
@@ -3783,11 +3801,11 @@
           {
             DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection= BCCC_restart"));
             do_ndbcluster_binlog_close_connection= BCCC_restart;
-            if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci &&
ndb_binlog_running)
+            if (ndb_latest_received_binlog_epoch < get_latest_trans_gci() &&
ndb_binlog_running)
             {
               sql_print_error("NDB Binlog: latest transaction in epoch %lu not in binlog
"
                               "as latest received epoch is %lu",
-                              (ulong) *p_latest_trans_gci,
+                              (ulong) get_latest_trans_gci(),
                               (ulong) ndb_latest_received_binlog_epoch);
             }
           }
@@ -3979,11 +3997,11 @@
             {
               DBUG_PRINT("info", ("do_ndbcluster_binlog_close_connection=
BCCC_restart"));
               do_ndbcluster_binlog_close_connection= BCCC_restart;
-              if (ndb_latest_received_binlog_epoch < *p_latest_trans_gci &&
ndb_binlog_running)
+              if (ndb_latest_received_binlog_epoch < get_latest_trans_gci() &&
ndb_binlog_running)
               {
                 sql_print_error("NDB Binlog: latest transaction in epoch %lu not in
binlog "
                                 "as latest received epoch is %lu",
-                                (ulong) *p_latest_trans_gci,
+                                (ulong) get_latest_trans_gci(),
                                 (ulong) ndb_latest_received_binlog_epoch);
               }
             }
@@ -4058,7 +4076,6 @@
   /* don't mess with the injector_ndb anymore from other threads */
   injector_thd= 0;
   injector_ndb= 0;
-  p_latest_trans_gci= 0;
   schema_ndb= 0;
   pthread_mutex_unlock(&injector_mutex);
   thd->db= 0; // as not to try to free memory
@@ -4175,7 +4192,7 @@
                "latest_handled_binlog_epoch=%s, "
                "latest_applied_binlog_epoch=%s",
                llstr(ndb_latest_epoch, buff1),
-               llstr(*p_latest_trans_gci, buff2),
+               llstr(get_latest_trans_gci(), buff2),
                llstr(ndb_latest_received_binlog_epoch, buff3),
                llstr(ndb_latest_handled_binlog_epoch, buff4),
                llstr(ndb_latest_applied_binlog_epoch, buff5));

--- 1.22/sql/ha_ndbcluster_binlog.h	2007-02-05 07:21:09 +01:00
+++ 1.23/sql/ha_ndbcluster_binlog.h	2007-03-27 09:35:02 +02:00
@@ -111,6 +111,8 @@
 extern pthread_mutex_t ndbcluster_mutex;
 extern HASH ndbcluster_open_tables;
 extern Ndb_cluster_connection* g_ndb_cluster_connection;
+extern Ndb_cluster_connection **g_ndb_cluster_connection_pool;
+extern ulong g_ndb_cluster_connection_pool_alloc;
 extern long ndb_number_of_storage_nodes;
 
 /*
Thread
bk commit into 5.1 tree (tomas:1.2520)tomas27 Mar