List:Commits« Previous MessageNext Message »
From:Pekka Nousiainen Date:December 19 2011 12:19pm
Subject:bzr push into mysql-5.1-telco-7.0 branch (pekka.nousiainen:4755 to 4756)
WL#4124
View as plain text  
 4756 Pekka Nousiainen	2011-12-19 [merge]
      merge 7.0 into wl#4124

    modified:
      mysql-test/suite/ndb/r/ndb_alter_table_online2.result
      mysql-test/suite/ndb/t/ndb_alter_table_online2.test
      storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp
      storage/ndb/test/include/NDBT_Test.hpp
      storage/ndb/test/include/NdbRestarts.hpp
      storage/ndb/test/ndbapi/testDict.cpp
      storage/ndb/test/ndbapi/testNodeRestart.cpp
      storage/ndb/test/run-test/atrt.hpp
      storage/ndb/test/run-test/daily-basic-tests.txt
      storage/ndb/test/run-test/daily-perf-tests.txt
      storage/ndb/test/run-test/db.cpp
      storage/ndb/test/run-test/main.cpp
      storage/ndb/test/run-test/test-tests.txt
      storage/ndb/test/src/NDBT_Test.cpp
      storage/ndb/test/src/NdbRestarts.cpp
 4755 Pekka Nousiainen	2011-12-18
      wl#4124 k03_mutex.diff
      handler: safe_mutex asserts

    modified:
      sql/ha_ndb_index_stat.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_alter_table_online2.result'
--- a/mysql-test/suite/ndb/r/ndb_alter_table_online2.result	2011-05-13 11:42:59 +0000
+++ b/mysql-test/suite/ndb/r/ndb_alter_table_online2.result	2011-12-15 21:55:36 +0000
@@ -49,7 +49,7 @@ name
 ~ Starting mysqlslap using column b
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 
-update t1 set b= 0;
+update t1 set b = 0 where pk = 1;
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~ Alter table t1 add column c
@@ -74,10 +74,10 @@ name
 ~ Starting mysqlslap using column c
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-update t1 set c= 0;
+update t1 set c = 0 where pk = 1;
 select * from t1;
 pk	a	b	c
-1	5000	5000	5000
+1	2000	2000	2000
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~ Alter table t1 and try to add partitions

=== modified file 'mysql-test/suite/ndb/t/ndb_alter_table_online2.test'
--- a/mysql-test/suite/ndb/t/ndb_alter_table_online2.test	2011-12-08 10:42:28 +0000
+++ b/mysql-test/suite/ndb/t/ndb_alter_table_online2.test	2011-12-15 21:55:36 +0000
@@ -58,8 +58,8 @@ set @t1_id = (select id from ndb_show_ta
 --echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 --echo
 
-let $end_mysqlslap= 5000;
---exec $MYSQL_SLAP --query="update test.t1 set a=a+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
+let $end_mysqlslap= 2000;
+--exec $MYSQL_SLAP --query="update test.t1 set a=a+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
 # wait for 100 updates
 --disable_result_log
@@ -99,8 +99,8 @@ select name from ndb_show_tables_results
 --echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
 --echo
 
-update t1 set b= 0;
---exec $MYSQL_SLAP --query="update test.t1 set b=b+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
+update t1 set b = 0 where pk = 1;
+--exec $MYSQL_SLAP --query="update test.t1 set b=b+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
 # wait for 100 updates
 --disable_result_log
@@ -140,8 +140,8 @@ select name from ndb_show_tables_results
 --echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 --echo
 
-update t1 set c= 0;
---exec $MYSQL_SLAP --query="update test.t1 set c=c+1 where pk=1" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
+update t1 set c = 0 where pk = 1;
+--exec $MYSQL_SLAP --query="update test.t1 set c=c+1 where pk=1; select sleep(0.01);" -i $end_mysqlslap >> $NDB_TOOLS_OUTPUT &
 
 # wait for mysqlslap to end
 --disable_result_log

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp	2011-12-06 08:25:46 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/Dbdih.hpp	2011-12-15 10:01:04 +0000
@@ -1886,7 +1886,8 @@ private:
   } m_local_lcp_state;
 
   // MT LQH
-  Uint32 c_fragments_per_node;
+  Uint32 c_fragments_per_node_;
+  Uint32 getFragmentsPerNode();
   Uint32 dihGetInstanceKey(FragmentstorePtr tFragPtr) {
     ndbrequire(!tFragPtr.isNull());
     Uint32 log_part_id = tFragPtr.p->m_log_part_id;

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp	2011-09-15 20:21:59 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihInit.cpp	2011-12-15 10:01:04 +0000
@@ -319,7 +319,7 @@ Dbdih::Dbdih(Block_context& ctx):
   nodeGroupRecord = 0;
   nodeRecord = 0;
   c_nextNodeGroup = 0;
-  c_fragments_per_node = 1;
+  c_fragments_per_node_ = 0;
   bzero(c_node_groups, sizeof(c_node_groups));
   if (globalData.ndbMtTcThreads == 0)
   {

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2011-12-07 10:01:04 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2011-12-15 10:01:04 +0000
@@ -1312,14 +1312,13 @@ void Dbdih::execREAD_CONFIG_REQ(Signal*
   if (isNdbMtLqh())
   {
     jam();
-    c_fragments_per_node = getLqhWorkers();
+    c_fragments_per_node_ = 0;
     // try to get some LQH workers which initially handle no fragments
     if (ERROR_INSERTED(7215)) {
-      c_fragments_per_node = 1;
+      c_fragments_per_node_ = 1;
+      ndbout_c("Using %u fragments per node", c_fragments_per_node_);
     }
   }
-  ndbout_c("Using %u fragments per node", c_fragments_per_node);
-  
   ndb_mgm_get_int_parameter(p, CFG_DB_LCP_TRY_LOCK_TIMEOUT, 
                             &c_lcpState.m_lcp_trylock_timeout);
 
@@ -7545,6 +7544,42 @@ static Uint32 find_min_index(const Uint3
   return m;
 }
 
+Uint32
+Dbdih::getFragmentsPerNode()
+{
+  jam();
+  if (c_fragments_per_node_ != 0)
+  {
+    return c_fragments_per_node_;
+  }
+
+  c_fragments_per_node_ = getLqhWorkers();
+  if (c_fragments_per_node_ == 0)
+    c_fragments_per_node_ = 1; // ndbd
+
+  NodeRecordPtr nodePtr;
+  nodePtr.i = cfirstAliveNode;
+  do
+  {
+    jam();
+    ptrCheckGuard(nodePtr, MAX_NDB_NODES, nodeRecord);
+    Uint32 workers = getNodeInfo(nodePtr.i).m_lqh_workers;
+    if (workers == 0) // ndbd
+      workers = 1;
+
+    c_fragments_per_node_ = MIN(workers, c_fragments_per_node_);
+    nodePtr.i = nodePtr.p->nextNode;
+  } while (nodePtr.i != RNIL);
+
+  if (c_fragments_per_node_ == 0)
+  {
+    ndbassert(false);
+    c_fragments_per_node_ = 1;
+  }
+  ndbout_c("Using %u fragments per node", c_fragments_per_node_);
+  return c_fragments_per_node_;
+}
+
 void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal)
 {
   Uint16 node_group_id[MAX_NDB_PARTITIONS];
@@ -7561,11 +7596,9 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ
   const Uint32 flags = req->requestInfo;
 
   Uint32 err = 0;
-  const Uint32 defaultFragments = 
-    c_fragments_per_node * cnoOfNodeGroups * cnoReplicas;
-  const Uint32 maxFragments =
-    MAX_FRAG_PER_LQH * (getLqhWorkers() ? getLqhWorkers() : 1) *
-    cnoOfNodeGroups * cnoReplicas;
+  const Uint32 defaultFragments =
+    getFragmentsPerNode() * cnoOfNodeGroups * cnoReplicas;
+  const Uint32 maxFragments = MAX_FRAG_PER_LQH * defaultFragments;
 
   do {
     NodeGroupRecordPtr NGPtr;
@@ -16190,8 +16223,8 @@ void Dbdih::execCHECKNODEGROUPSREQ(Signa
   case CheckNodeGroups::GetDefaultFragments:
     jam();
     ok = true;
-    sd->output = (cnoOfNodeGroups + sd->extraNodeGroups) 
-      * c_fragments_per_node * cnoReplicas;
+    sd->output = (cnoOfNodeGroups + sd->extraNodeGroups)
+      * getFragmentsPerNode() * cnoReplicas;
     break;
   }
   ndbrequire(ok);

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2011-10-21 08:59:23 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2011-12-15 10:00:05 +0000
@@ -4397,6 +4397,7 @@ MgmtSrvr::request_events(NdbNodeBitmask
                          Vector<SimpleSignal>& events)
 {
   int nodes_counter[MAX_NDB_NODES];
+  NdbNodeBitmask save = nodes;
   SignalSender ss(theFacade);
   ss.lock();
 
@@ -4447,6 +4448,10 @@ MgmtSrvr::request_events(NdbNodeBitmask
       if (!nodes.get(nodeid))
       {
         // The reporting node was not expected
+#ifndef NDEBUG
+        ndbout_c("nodeid: %u", nodeid);
+        ndbout_c("save: %s", BaseString::getPrettyText(save).c_str());
+#endif
         assert(false);
         return false;
       }

=== modified file 'storage/ndb/test/include/NDBT_Test.hpp'
--- a/storage/ndb/test/include/NDBT_Test.hpp	2011-06-30 15:59:25 +0000
+++ b/storage/ndb/test/include/NDBT_Test.hpp	2011-12-16 13:57:51 +0000
@@ -100,6 +100,13 @@ public:
    */
   void sync_down(const char * key);
   void sync_up_and_wait(const char * key, Uint32 count = 0);
+
+  /**
+   * safety for slow machines...
+   * 0 means no safety
+   */
+  bool closeToTimeout(int safety_percent = 0);
+
 private:
   friend class NDBT_Step;
   friend class NDBT_TestSuite;
@@ -120,6 +127,9 @@ private:
   Properties props;
   NdbMutex* propertyMutexPtr;
   NdbCondition* propertyCondPtr;
+
+  int m_env_timeout;
+  Uint64 m_test_start_time;
 };
 
 typedef int (NDBT_TESTFUNC)(NDBT_Context*, NDBT_Step*);

=== modified file 'storage/ndb/test/include/NdbRestarts.hpp'
--- a/storage/ndb/test/include/NdbRestarts.hpp	2011-06-30 15:59:25 +0000
+++ b/storage/ndb/test/include/NdbRestarts.hpp	2011-12-16 13:57:51 +0000
@@ -56,7 +56,8 @@ public:
   };
 
   struct NdbRestart {
-    typedef int (restartFunc)(NDBT_Context*, NdbRestarter&, const NdbRestart*);
+    typedef int (restartFunc)(NDBT_Context*, NdbRestarter&, const NdbRestart*,
+                              int safety);
     
     NdbRestart(const char* _name,
 	       NdbRestartType _type,
@@ -74,13 +75,16 @@ public:
 
   int getNumRestarts();
 
-  int executeRestart(NDBT_Context*, int _num, unsigned int _to = 120);
-  int executeRestart(NDBT_Context*, const char* _name, unsigned int _to = 120);
+  int executeRestart(NDBT_Context*, int _num,
+                     unsigned int _to = 120, int safety = 0);
+  int executeRestart(NDBT_Context*, const char* _name,
+                     unsigned int _to = 120, int safety = 0);
 
   void listRestarts();
   void listRestarts(NdbRestartType _type);
 private:
-  int executeRestart(NDBT_Context*, const NdbRestart*, unsigned int _timeout);
+  int executeRestart(NDBT_Context*, const NdbRestart*,
+                     unsigned int _timeout, int safety);
 
   struct NdbErrorInsert {
     NdbErrorInsert(const char* _name,

=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp	2011-12-10 18:51:37 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp	2011-12-15 08:28:12 +0000
@@ -9007,9 +9007,10 @@ runIndexStatCreate(NDBT_Context* ctx, ND
        * OK
        */
     }
-    else if (! (is.getNdbError().code == 721 ||
-                is.getNdbError().code == 4244 ||
-                is.getNdbError().code == 4009)) // no connection
+    else if (! (is.getNdbError().code == 701  || // timeout
+                is.getNdbError().code == 721  || // already exists
+                is.getNdbError().code == 4244 || // already exists
+                is.getNdbError().code == 4009))  // no connection
     {
       ndbout << is.getNdbError() << endl;
       return NDBT_FAILED;

=== modified file 'storage/ndb/test/ndbapi/testNodeRestart.cpp'
--- a/storage/ndb/test/ndbapi/testNodeRestart.cpp	2011-12-08 07:39:03 +0000
+++ b/storage/ndb/test/ndbapi/testNodeRestart.cpp	2011-12-16 13:57:51 +0000
@@ -450,13 +450,20 @@ int runRestarts(NDBT_Context* ctx, NDBT_
   int i = 0;
   int timeout = 240;
 
-  while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
-    
-    if(restarts.executeRestart(ctx, pCase->getName(), timeout) != 0){
+  while (i<loops && result != NDBT_FAILED && !ctx->isTestStopped())
+  {
+    int safety = 0;
+    if (i > 0)
+      safety = 15;
+
+    if (ctx->closeToTimeout(safety))
+      break;
+
+    if(restarts.executeRestart(ctx, pCase->getName(), timeout, safety) != 0){
       g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
       result = NDBT_FAILED;
       break;
-    }    
+    }
     i++;
   }
   ctx->stopTest();

=== modified file 'storage/ndb/test/run-test/atrt.hpp'
--- a/storage/ndb/test/run-test/atrt.hpp	2011-10-20 11:43:11 +0000
+++ b/storage/ndb/test/run-test/atrt.hpp	2011-12-16 09:13:46 +0000
@@ -118,9 +118,15 @@ struct atrt_testcase
   bool m_report;
   bool m_run_all;
   time_t m_max_time;
-  BaseString m_command;
-  BaseString m_args;
   BaseString m_name;
+  BaseString m_mysqld_options;
+
+  struct Command
+  {
+    atrt_process::Type m_cmd_type;
+    BaseString m_exe;
+    BaseString m_args;
+  } m_cmd; // Todo make array of these...
 };
 
 extern Logger g_logger;
@@ -155,6 +161,9 @@ bool do_command(atrt_config& config);
 bool start_process(atrt_process & proc);
 bool stop_process(atrt_process & proc);
 
+bool connect_mysqld(atrt_process & proc);
+bool disconnect_mysqld(atrt_process & proc);
+
 /**
  * check configuration if any changes has been 
  *   done for the duration of the latest running test

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2011-12-10 18:51:37 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2011-12-16 13:57:51 +0000
@@ -12,7 +12,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
-max-time: 900
+max-time: 1800
 cmd: testIndex
 args: -n DeferredError
 
@@ -20,7 +20,7 @@ max-time: 900
 cmd: testIndex
 args: -n DeferredMixedLoad T1 T6 T13
 
-max-time: 1800
+max-time: 2000
 cmd: testIndex
 args: -n DeferredMixedLoadError T1 T6 T13
 
@@ -28,7 +28,7 @@ max-time: 900
 cmd: testIndex
 args: -n NF_DeferredMixed T1 T6 T13
 
-max-time: 900
+max-time: 1800
 cmd: testIndex
 args: -n NF_Mixed T1 T6 T13
 
@@ -1751,7 +1751,7 @@ max-time: 300
 cmd: testBasic
 args: -n UnlockUpdateBatch T3
 
-max-time: 300
+max-time: 600
 cmd: testNodeRestart
 args: -n MixReadUnlockRestart T1
 

=== modified file 'storage/ndb/test/run-test/daily-perf-tests.txt'
--- a/storage/ndb/test/run-test/daily-perf-tests.txt	2011-10-16 18:36:16 +0000
+++ b/storage/ndb/test/run-test/daily-perf-tests.txt	2011-12-16 09:13:46 +0000
@@ -79,62 +79,72 @@ type: bench
 
 # sql
 max-time: 600
-client: ndb-sql-perf-create-table.sh
-args: t1
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-create-table.sh t1
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-select.sh
-args: t1 1 64
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-select.sh t1 1 64
 mysqld: --ndb-cluster-connection-pool=1
 type: bench
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-select.sh
-args: t1 1 64
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-select.sh t1 1 64
 mysqld: --ndb-cluster-connection-pool=4
 type: bench
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-update.sh
-args: t1 1 64
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-update.sh t1 1 64
 mysqld: --ndb-cluster-connection-pool=1
 type: bench
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-update.sh
-args: t1 1 64
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-update.sh t1 1 64
 mysqld: --ndb-cluster-connection-pool=4
 type: bench
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-drop-table.sh
-args: t1
-mysqld:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-drop-table.sh t1
+cmd-type: mysql
 
 # sql join
 max-time: 600
-client: ndb-sql-perf-load-tpcw.sh
-args:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-load-tpcw.sh
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-tpcw-getBestSeller.sh
-args:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-tpcw-getBestSeller.sh
+cmd-type: mysql
 type: bench
 
 max-time: 600
-client: ndb-sql-perf-drop-tpcw.sh
-args:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-drop-tpcw.sh
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-load-music-store.sh
-args:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-load-music-store.sh
+cmd-type: mysql
 
 max-time: 600
-client: ndb-sql-perf-select-music-store.sh
-args:
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-select-music-store.sh
+cmd-type: mysql
 type: bench
 
 max-time: 600
-client: ndb-sql-perf-drop-music-store.sh
-args:
-
+cmd: ndb-sql-perf.sh
+args: ndb-sql-perf-drop-music-store.sh
+cmd-type: mysql

=== modified file 'storage/ndb/test/run-test/db.cpp'
--- a/storage/ndb/test/run-test/db.cpp	2011-06-30 15:59:25 +0000
+++ b/storage/ndb/test/run-test/db.cpp	2011-12-16 09:13:46 +0000
@@ -18,7 +18,6 @@
 #include "atrt.hpp"
 #include <NdbSleep.h>
 
-static bool connect_mysqld(atrt_process* proc);
 static bool populate_db(atrt_config&, atrt_process*);
 static bool setup_repl(atrt_config&);
 
@@ -132,7 +131,7 @@ setup_db(atrt_config& config)
     atrt_process * proc = config.m_processes[i];
     if (proc->m_type == atrt_process::AP_MYSQLD)
     {
-      if (!connect_mysqld(config.m_processes[i]))
+      if (!connect_mysqld(* config.m_processes[i]))
 	return false;
     }
   }    
@@ -177,16 +176,16 @@ find(atrt_process* proc, const char * ke
 }
 
 bool
-connect_mysqld(atrt_process* proc)
+connect_mysqld(atrt_process& proc)
 {
-  if ( !mysql_init(&proc->m_mysql))
+  if ( !mysql_init(&proc.m_mysql))
   {
     g_logger.error("Failed to init mysql");
     return false;
   }
 
-  const char * port = find(proc, "--port=");
-  const char * socket = find(proc, "--socket=");
+  const char * port = find(&proc, "--port=");
+  const char * socket = find(&proc, "--socket=");
   if (port == 0 && socket == 0)
   {
     g_logger.error("Neither socket nor port specified...cant connect to mysql");
@@ -198,10 +197,10 @@ connect_mysqld(atrt_process* proc)
     if (port)
     {
       mysql_protocol_type val = MYSQL_PROTOCOL_TCP;
-      mysql_options(&proc->m_mysql, MYSQL_OPT_PROTOCOL, &val);
+      mysql_options(&proc.m_mysql, MYSQL_OPT_PROTOCOL, &val);
     }
-    if (mysql_real_connect(&proc->m_mysql,
-			   proc->m_host->m_hostname.c_str(),
+    if (mysql_real_connect(&proc.m_mysql,
+			   proc.m_host->m_hostname.c_str(),
 			   "root", "", "test",
 			   port ? atoi(port) : 0,
 			   socket,
@@ -210,17 +209,24 @@ connect_mysqld(atrt_process* proc)
       return true;
     }
     g_logger.info("Retrying connect to %s:%u 3s",
-		  proc->m_host->m_hostname.c_str(),atoi(port));
-    NdbSleep_SecSleep(3); 
+		  proc.m_host->m_hostname.c_str(),atoi(port));
+    NdbSleep_SecSleep(3);
   }
-  
+
   g_logger.error("Failed to connect to mysqld err: >%s< >%s:%u:%s<",
-		 mysql_error(&proc->m_mysql),
-		 proc->m_host->m_hostname.c_str(), port ? atoi(port) : 0,
+		 mysql_error(&proc.m_mysql),
+		 proc.m_host->m_hostname.c_str(), port ? atoi(port) : 0,
 		 socket ? socket : "<null>");
   return false;
 }
 
+bool
+disconnect_mysqld(atrt_process& proc)
+{
+  mysql_close(&proc.m_mysql);
+  return true;
+}
+
 void
 BINDI(MYSQL_BIND& bind, int * i)
 {

=== modified file 'storage/ndb/test/run-test/main.cpp'
--- a/storage/ndb/test/run-test/main.cpp	2011-10-20 11:43:11 +0000
+++ b/storage/ndb/test/run-test/main.cpp	2011-12-16 16:28:41 +0000
@@ -422,17 +422,17 @@ main(int argc, char ** argv)
     if(!read_test_case(g_test_case_file, test_case, lineno))
       goto end;
     
-    g_logger.info("#%d - %s %s", 
+    g_logger.info("#%d - %s",
 		  test_no,
-		  test_case.m_command.c_str(), test_case.m_args.c_str());
-    
+		  test_case.m_name.c_str());
+
     // Assign processes to programs
-    if(!setup_test_case(g_config, test_case))
+    if (!setup_test_case(g_config, test_case))
     {
       g_logger.critical("Failed to setup test case");
       goto end;
     }
-    
+
     if(!start_processes(g_config, p_clients))
     {
       g_logger.critical("Failed to start client processes");
@@ -1091,6 +1091,11 @@ stop_process(atrt_process & proc){
     return true;
   }
 
+  if (proc.m_type == atrt_process::AP_MYSQLD)
+  {
+    disconnect_mysqld(proc);
+  }
+
   {
     Properties reply;
     if(proc.m_host->m_cpcd->stop_process(proc.m_proc.m_id, reply) != 0){
@@ -1248,24 +1253,24 @@ read_test_case(FILE * file, atrt_testcas
       tmp.trim(" \t\n\r");
       Vector<BaseString> split;
       tmp.split(split, " ", 2);
-      tc.m_command = split[0];
+      tc.m_cmd.m_exe = split[0];
       if(split.size() == 2)
-	tc.m_args = split[1];
+	tc.m_cmd.m_args = split[1];
       else
-	tc.m_args = "";
+	tc.m_cmd.m_args = "";
       tc.m_max_time = 60000;
       return true;
     }
     return false;
   }
 
-  if(!p.get("cmd", tc.m_command)){
+  if(!p.get("cmd", tc.m_cmd.m_exe)){
     g_logger.critical("Invalid test file: cmd is missing near line: %d", line);
     return false;
   }
   
-  if(!p.get("args", tc.m_args))
-    tc.m_args = "";
+  if(!p.get("args", tc.m_cmd.m_args))
+    tc.m_cmd.m_args = "";
 
   const char * mt = 0;
   if(!p.get("max-time", &mt))
@@ -1283,17 +1288,33 @@ read_test_case(FILE * file, atrt_testcas
   else
     tc.m_run_all= false;
 
+  const char * str;
+  if (p.get("mysqld", &str))
+  {
+    tc.m_mysqld_options.assign(str);
+  }
+  else
+  {
+    tc.m_mysqld_options.assign("");
+  }
+
+  tc.m_cmd.m_cmd_type = atrt_process::AP_NDB_API;
+  if (p.get("cmd-type", &str) && strcmp(str, "mysql") == 0)
+  {
+    tc.m_cmd.m_cmd_type = atrt_process::AP_CLIENT;
+  }
+
   if (!p.get("name", &mt))
   {
     tc.m_name.assfmt("%s %s", 
-		     tc.m_command.c_str(),
-		     tc.m_args.c_str());
+		     tc.m_cmd.m_exe.c_str(),
+		     tc.m_cmd.m_args.c_str());
   }
   else
   {
     tc.m_name.assign(mt);
   }
-  
+
   return true;
 }
 
@@ -1306,46 +1327,87 @@ setup_test_case(atrt_config& config, con
     return false;
   }
 
-  size_t i = 0;
-  for(; i<config.m_processes.size(); i++)
+  for (size_t i = 0; i<config.m_processes.size(); i++)
   {
-    atrt_process & proc = *config.m_processes[i]; 
-    if(proc.m_type == atrt_process::AP_NDB_API || 
-       proc.m_type == atrt_process::AP_CLIENT)
+    atrt_process & proc = *config.m_processes[i];
+    if (proc.m_type == atrt_process::AP_NDB_API ||
+        proc.m_type == atrt_process::AP_CLIENT)
     {
-      BaseString cmd;
-      char * p = find_bin_path(tc.m_command.c_str());
-      if (p == 0)
-      {
-        g_logger.critical("Failed to locate '%s'", tc.m_command.c_str());
-        return false;
-      }
-      cmd.assign(p);
-      free(p);
+      proc.m_proc.m_path.assign("");
+      proc.m_proc.m_args.assign("");
+    }
+  }
 
+  BaseString cmd;
+  char * p = find_bin_path(tc.m_cmd.m_exe.c_str());
+  if (p == 0)
+  {
+    g_logger.critical("Failed to locate '%s'", tc.m_cmd.m_exe.c_str());
+    return false;
+  }
+  cmd.assign(p);
+  free(p);
+
+  for (size_t i = 0; i<config.m_processes.size(); i++)
+  {
+    atrt_process & proc = *config.m_processes[i];
+    if (proc.m_type == tc.m_cmd.m_cmd_type &&
+        proc.m_proc.m_path == "")
+    {
+      proc.m_save.m_proc = proc.m_proc;
+      proc.m_save.m_saved = true;
+
+      proc.m_proc.m_env.appfmt(" ATRT_TIMEOUT=%ld", tc.m_max_time);
       if (0) // valgrind
       {
         proc.m_proc.m_path = "/usr/bin/valgrind";
-        proc.m_proc.m_args.appfmt("%s %s", cmd.c_str(), tc.m_args.c_str());
+        proc.m_proc.m_args.appfmt("%s %s", cmd.c_str(),
+                                  tc.m_cmd.m_args.c_str());
       }
       else
       {
         proc.m_proc.m_path = cmd;
-        proc.m_proc.m_args.assign(tc.m_args);
+        proc.m_proc.m_args.assign(tc.m_cmd.m_args.c_str());
       }
-      if(!tc.m_run_all)
+      if (!tc.m_run_all)
         break;
     }
   }
-  for(i++; i<config.m_processes.size(); i++){
-    atrt_process & proc = *config.m_processes[i]; 
-    if(proc.m_type == atrt_process::AP_NDB_API || 
-       proc.m_type == atrt_process::AP_CLIENT)
+
+  if (tc.m_mysqld_options != "")
+  {
+    g_logger.info("restarting mysqld with extra options: %s",
+                  tc.m_mysqld_options.c_str());
+
+    /**
+     * Apply testcase specific mysqld options
+     */
+    for (size_t i = 0; i<config.m_processes.size(); i++)
     {
-      proc.m_proc.m_path.assign("");
-      proc.m_proc.m_args.assign("");
+      atrt_process & proc = *config.m_processes[i];
+      if (proc.m_type == atrt_process::AP_MYSQLD)
+      {
+        proc.m_save.m_proc = proc.m_proc;
+        proc.m_save.m_saved = true;
+        proc.m_proc.m_args.appfmt(" %s", tc.m_mysqld_options.c_str());
+        if (!stop_process(proc))
+        {
+          return false;
+        }
+
+        if (!start_process(proc))
+        {
+          return false;
+        }
+
+        if (!connect_mysqld(proc))
+        {
+          return false;
+        }
+      }
     }
   }
+
   return true;
 }
 
@@ -1562,10 +1624,14 @@ reset_config(atrt_config & config)
     atrt_process & proc = *config.m_processes[i]; 
     if (proc.m_save.m_saved)
     {
-      if (!stop_process(proc))
-        return false;
-      
-      changed = true;
+      if (proc.m_proc.m_status == "running")
+      {
+        if (!stop_process(proc))
+          return false;
+
+        changed = true;
+      }
+
       proc.m_save.m_saved = false;
       proc.m_proc = proc.m_save.m_proc;
       proc.m_proc.m_id = -1;

=== modified file 'storage/ndb/test/run-test/test-tests.txt'
--- a/storage/ndb/test/run-test/test-tests.txt	2008-12-10 15:40:44 +0000
+++ b/storage/ndb/test/run-test/test-tests.txt	2011-12-16 09:13:46 +0000
@@ -1,4 +1,17 @@
 max-time: 600
 cmd: testBasic
 args: -n PkRead T1
+type: bench
+
+max-time: 60
+cmd: mysql
+args: -u root information_schema -e show\ tables
+cmd-type: mysql
+type: bench
+mysqld: --ndb-cluster-connection-pool=4
+
+max-time: 6000
+cmd: testBasic
+args: -n PkRead T1
+type: bench
 

=== modified file 'storage/ndb/test/src/NDBT_Test.cpp'
--- a/storage/ndb/test/src/NDBT_Test.cpp	2011-11-23 09:54:30 +0000
+++ b/storage/ndb/test/src/NDBT_Test.cpp	2011-12-16 14:43:13 +0000
@@ -20,6 +20,7 @@
 
 #include "NDBT.hpp"
 #include "NDBT_Test.hpp"
+#include <portlib/NdbEnv.h>
 
 static int opt_stop_on_error = 0;
 
@@ -34,9 +35,10 @@ NDBT_Context::NDBT_Context(Ndb_cluster_c
   stopped = false;
   propertyMutexPtr = NdbMutex_Create();
   propertyCondPtr = NdbCondition_Create();
+  m_env_timeout = 0;
+  m_test_start_time = NdbTick_CurrentMillisecond();
 }
 
-
 NDBT_Context::~NDBT_Context(){
   NdbCondition_Destroy(propertyCondPtr);
   NdbMutex_Destroy(propertyMutexPtr);
@@ -318,7 +320,6 @@ NDBT_Step::tearDown(){
   m_ndb = NULL;
 }
 
-
 Ndb* NDBT_Step::getNdb() const {
   assert(m_ndb != NULL);
   return m_ndb;
@@ -970,8 +971,8 @@ NDBT_TestSuite::executeOneCtx(Ndb_cluste
       if (opt_stop_on_error != 0 && numTestsFail > 0)
         break;
 
-      if (_testname != NULL && 
-	      strcasecmp(tests[t]->getName(), _testname) != 0)
+      if (_testname != NULL &&
+          strcasecmp(tests[t]->getName(), _testname) != 0)
         continue;
 
       tests[t]->initBeforeTest();
@@ -1648,6 +1649,42 @@ NDBT_Context::sync_up_and_wait(const cha
   getPropertyWait(key, (unsigned)0);
 }
 
+bool
+NDBT_Context::closeToTimeout(int safety)
+{
+  if (safety == 0)
+    return false;
+
+  if (m_env_timeout == 0)
+  {
+    char buf[1024];
+    const char * p = NdbEnv_GetEnv("ATRT_TIMEOUT", buf, sizeof(buf));
+    if (p)
+    {
+      m_env_timeout = atoi(p);
+      ndbout_c("FOUND ATRT_TIMEOUT: %d", m_env_timeout);
+    }
+    else
+    {
+      m_env_timeout = -1;
+    }
+  }
+
+  if (m_env_timeout < 0)
+    return false;
+
+  Uint64 to = (1000 * m_env_timeout * (100 - safety)) / 100;
+  Uint64 now = NdbTick_CurrentMillisecond();
+  if (now >= m_test_start_time + to)
+  {
+    ndbout_c("closeToTimeout(%d) => true env(timeout): %d",
+             safety, m_env_timeout);
+    return true;
+  }
+
+  return false;
+}
+
 template class Vector<NDBT_TestCase*>;
 template class Vector<NDBT_TestCaseResult*>;
 template class Vector<NDBT_Step*>;

=== modified file 'storage/ndb/test/src/NdbRestarts.cpp'
--- a/storage/ndb/test/src/NdbRestarts.cpp	2011-06-30 15:59:25 +0000
+++ b/storage/ndb/test/src/NdbRestarts.cpp	2011-12-16 13:57:51 +0000
@@ -24,7 +24,7 @@
 #include <NdbEnv.h>
 #include <NDBT_Test.hpp>
 
-#define F_ARGS NDBT_Context* ctx, NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart
+#define F_ARGS NDBT_Context* ctx, NdbRestarter& _restarter, const NdbRestarts::NdbRestart* _restart, int
 
 int restartRandomNodeGraceful(F_ARGS);
 int restartRandomNodeAbort(F_ARGS);
@@ -242,7 +242,8 @@ const NdbRestarts::NdbRestart* NdbRestar
 
 int NdbRestarts::executeRestart(NDBT_Context* ctx,
                                 const NdbRestarts::NdbRestart* _restart,
-				unsigned int _timeout){
+				unsigned int _timeout,
+                                int safety){
   // Check that there are enough nodes in the cluster
   // for this test
   NdbRestarter restarter;
@@ -258,7 +259,7 @@ int NdbRestarts::executeRestart(NDBT_Con
     return NDBT_FAILED;
   }
   
-  int res = _restart->m_restartFunc(ctx, restarter, _restart);
+  int res = _restart->m_restartFunc(ctx, restarter, _restart, safety);
 
   // Sleep a little waiting for nodes to react to command
   NdbSleep_SecSleep(2);
@@ -280,23 +281,25 @@ int NdbRestarts::executeRestart(NDBT_Con
 
 int NdbRestarts::executeRestart(NDBT_Context* ctx,
                                 int _num,
-				unsigned int _timeout){
+				unsigned int _timeout,
+                                int safety){
   const NdbRestarts::NdbRestart* r = getRestart(_num);
   if (r == NULL)
     return NDBT_FAILED;
 
-  int res = executeRestart(ctx, r, _timeout);
+  int res = executeRestart(ctx, r, _timeout, safety);
   return res;
 }
 
 int NdbRestarts::executeRestart(NDBT_Context* ctx,
                                 const char* _name,
-				unsigned int _timeout){
+				unsigned int _timeout,
+                                int safety){
   const NdbRestarts::NdbRestart* r = getRestart(_name);
   if (r == NULL)
     return NDBT_FAILED;
 
-  int res = executeRestart(ctx, r, _timeout);
+  int res = executeRestart(ctx, r, _timeout, safety);
   return res;
 }
 
@@ -658,12 +661,12 @@ NFDuringNR_codes[] = {
   5002
 };
 
-int restartNFDuringNR(F_ARGS){
+int restartNFDuringNR(F_ARGS safety){
 
   myRandom48Init((long)NdbTick_CurrentMillisecond());
   int i;
   const int sz = sizeof(NFDuringNR_codes)/sizeof(NFDuringNR_codes[0]);
-  for(i = 0; i<sz; i++){
+  for(i = 0; i<sz && !ctx->closeToTimeout(safety); i++){
     int randomId = myRandom48(_restarter.getNumDbNodes());
     int nodeId = _restarter.getDbNodeId(randomId);
     int error = NFDuringNR_codes[i];
@@ -708,7 +711,7 @@ int restartNFDuringNR(F_ARGS){
   if(NdbEnv_GetEnv("USER", buf, 256) == 0 || strcmp(buf, "ejonore") != 0)
     return NDBT_OK;
   
-  for(i = 0; i<sz && !ctx->isTestStopped(); i++){
+  for(i = 0; i<sz && !ctx->isTestStopped() && !ctx->closeToTimeout(safety);i++){
     const int randomId = myRandom48(_restarter.getNumDbNodes());
     int nodeId = _restarter.getDbNodeId(randomId);
     const int error = NFDuringNR_codes[i];
@@ -786,7 +789,7 @@ NRDuringLCP_NonMaster_codes[] = {
   7018  // Crash in !master when changing state to LCP_TAB_SAVED
 };
 
-int restartNodeDuringLCP(F_ARGS) {
+int restartNodeDuringLCP(F_ARGS safety) {
   int i;
   // Master
   int val = DumpStateOrd::DihMinTimeBetweenLCP;
@@ -794,8 +797,8 @@ int restartNodeDuringLCP(F_ARGS) {
 	"Failed to set LCP to min value"); // Set LCP to min val
   int sz = sizeof(NRDuringLCP_Master_codes)/
            sizeof(NRDuringLCP_Master_codes[0]);
-  for(i = 0; i<sz; i++) {
-
+  for(i = 0; i<sz && !ctx->closeToTimeout(safety); i++)
+  {
     int error = NRDuringLCP_Master_codes[i];
     int masterNodeId = _restarter.getMasterNodeId();
 
@@ -832,7 +835,7 @@ int restartNodeDuringLCP(F_ARGS) {
   // NON-Master
   sz = sizeof(NRDuringLCP_NonMaster_codes)/
        sizeof(NRDuringLCP_NonMaster_codes[0]);
-  for(i = 0; i<sz; i++) {
+  for(i = 0; i<sz && !ctx->closeToTimeout(safety) ; i++) {
 
     int error = NRDuringLCP_NonMaster_codes[i];
     int nodeId = getRandomNodeId(_restarter);

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.1-telco-7.0 branch (pekka.nousiainen:4755 to 4756)WL#4124Pekka Nousiainen19 Dec