List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:August 11 2009 8:10am
Subject:bzr commit into mysql-5.1-telco-7.0 branch (jonas:2952) Bug#46552
View as plain text  
#At file:///home/jonas/src/telco-6.4/ based on revid:jack@stripped

 2952 Jonas Oreland	2009-08-11
      ndb - bug#46552
        Fix so that trigger ids are always *re-allocated* on SR

    modified:
      storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
      storage/ndb/test/include/NdbRestarter.hpp
      storage/ndb/test/ndbapi/testDict.cpp
      storage/ndb/test/run-test/daily-basic-tests.txt
      storage/ndb/test/src/NdbRestarter.cpp
=== modified file 'storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2009-08-10 08:46:05 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp	2009-08-11 08:10:20 +0000
@@ -4596,31 +4596,41 @@ void Dbdict::handleTabInfoInit(SimplePro
     jam();
     tablePtr.p->primaryTableId = c_tableDesc.PrimaryTableId;
     tablePtr.p->indexState = (TableRecord::IndexState)c_tableDesc.IndexState;
-    tablePtr.p->triggerId = c_tableDesc.CustomTriggerId;
 
-    if (c_tableDesc.InsertTriggerId != RNIL ||
-        c_tableDesc.UpdateTriggerId != RNIL ||
-        c_tableDesc.DeleteTriggerId != RNIL)
+    if (getNodeState().getSystemRestartInProgress())
     {
       jam();
-      /**
-       * Upgrade...unique index
-       */
-      ndbrequire(tablePtr.p->isUniqueIndex());
-      ndbrequire(c_tableDesc.CustomTriggerId == RNIL);
-      ndbrequire(c_tableDesc.InsertTriggerId != RNIL);
-      ndbrequire(c_tableDesc.UpdateTriggerId != RNIL);
-      ndbrequire(c_tableDesc.DeleteTriggerId != RNIL);
-      ndbout_c("table: %u UPGRADE saving (%u/%u/%u)",
-               tablePtr.i,
-               c_tableDesc.InsertTriggerId,
-               c_tableDesc.UpdateTriggerId,
-               c_tableDesc.DeleteTriggerId);
-      tablePtr.p->triggerId = c_tableDesc.InsertTriggerId;
-      tablePtr.p->m_upgrade_trigger_handling.m_upgrade = true;
-      tablePtr.p->m_upgrade_trigger_handling.insertTriggerId = c_tableDesc.InsertTriggerId;
-      tablePtr.p->m_upgrade_trigger_handling.updateTriggerId = c_tableDesc.UpdateTriggerId;
-      tablePtr.p->m_upgrade_trigger_handling.deleteTriggerId = c_tableDesc.DeleteTriggerId;
+      tablePtr.p->triggerId = RNIL;
+    }
+    else
+    {
+      jam();
+      tablePtr.p->triggerId = c_tableDesc.CustomTriggerId;
+
+      if (c_tableDesc.InsertTriggerId != RNIL ||
+          c_tableDesc.UpdateTriggerId != RNIL ||
+          c_tableDesc.DeleteTriggerId != RNIL)
+      {
+        jam();
+        /**
+         * Upgrade...unique index
+         */
+        ndbrequire(tablePtr.p->isUniqueIndex());
+        ndbrequire(c_tableDesc.CustomTriggerId == RNIL);
+        ndbrequire(c_tableDesc.InsertTriggerId != RNIL);
+        ndbrequire(c_tableDesc.UpdateTriggerId != RNIL);
+        ndbrequire(c_tableDesc.DeleteTriggerId != RNIL);
+        ndbout_c("table: %u UPGRADE saving (%u/%u/%u)",
+                 tablePtr.i,
+                 c_tableDesc.InsertTriggerId,
+                 c_tableDesc.UpdateTriggerId,
+                 c_tableDesc.DeleteTriggerId);
+        tablePtr.p->triggerId = c_tableDesc.InsertTriggerId;
+        tablePtr.p->m_upgrade_trigger_handling.m_upgrade = true;
+        tablePtr.p->m_upgrade_trigger_handling.insertTriggerId = c_tableDesc.InsertTriggerId;
+        tablePtr.p->m_upgrade_trigger_handling.updateTriggerId = c_tableDesc.UpdateTriggerId;
+        tablePtr.p->m_upgrade_trigger_handling.deleteTriggerId = c_tableDesc.DeleteTriggerId;
+      }
     }
   }
   else
@@ -11477,7 +11487,8 @@ Dbdict::alterIndex_toCreateTrigger(Signa
 
   Uint32 forceTriggerId = indexPtr.p->triggerId;
   D(V(getNodeState().startLevel) << V(NodeState::SL_STARTED));
-  if (getNodeState().startLevel == NodeState::SL_STARTED) {
+  if (getNodeState().startLevel == NodeState::SL_STARTED)
+  {
     ndbrequire(forceTriggerId == RNIL);
   }
   req->forceTriggerId = forceTriggerId;
@@ -16359,6 +16370,12 @@ Dbdict::createTrigger_abortParse(Signal*
     jam();
 
     TriggerRecordPtr triggerPtr;
+    if (! (triggerId < c_triggerRecordPool.getSize()))
+    {
+      jam();
+      goto done;
+    }
+
     c_triggerRecordPool.getPtr(triggerPtr, triggerId);
 
     if (triggerPtr.p->triggerState == TriggerRecord::TS_DEFINING)
@@ -16384,6 +16401,8 @@ Dbdict::createTrigger_abortParse(Signal*
     }
   }
 
+done:
+
   sendTransConf(signal, op_ptr);
 }
 

=== modified file 'storage/ndb/test/include/NdbRestarter.hpp'
--- a/storage/ndb/test/include/NdbRestarter.hpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/test/include/NdbRestarter.hpp	2009-08-11 08:10:20 +0000
@@ -57,6 +57,8 @@ public:
                       flags & NRRF_NOSTART,
                       flags & NRRF_ABORT);
   }
+
+  int restartNodes(int * nodes, int num_nodes, Uint32 flags);
   
   int startAll();
   int startNodes(const int * _nodes, int _num_nodes);

=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp	2009-08-11 08:10:20 +0000
@@ -6816,6 +6816,139 @@ out:
   return NDBT_OK;
 }
 
+static
+int
+createIndexes(NdbDictionary::Dictionary* pDic,
+              const NdbDictionary::Table & tab, int cnt)
+{
+  for (int i = 0; i<cnt && i < tab.getNoOfColumns(); i++)
+  {
+    char buf[256];
+    NdbDictionary::Index idx0;
+    BaseString::snprintf(buf, sizeof(buf), "%s-idx-%u", tab.getName(), i);
+    idx0.setName(buf);
+    idx0.setType(NdbDictionary::Index::OrderedIndex);
+    idx0.setTable(tab.getName());
+    idx0.setStoredIndex(false);
+    idx0.addIndexColumn(tab.getColumn(i)->getName());
+
+    if (pDic->createIndex(idx0))
+    {
+      ndbout << pDic->getNdbError() << endl;
+      return NDBT_FAILED;
+    }
+  }
+
+  return 0;
+}
+
+int
+runBug46552(NDBT_Context* ctx, NDBT_Step* step)
+{
+  Ndb* pNdb = GETNDB(step);
+  const NdbDictionary::Table* pTab = ctx->getTab();
+  NdbDictionary::Dictionary* pDic = pNdb->getDictionary();
+
+  NdbRestarter res;
+  if (res.getNumDbNodes() < 2)
+    return NDBT_OK;
+
+  NdbDictionary::Table tab0 = *pTab;
+  NdbDictionary::Table tab1 = *pTab;
+
+  BaseString name;
+  name.assfmt("%s_0", tab0.getName());
+  tab0.setName(name.c_str());
+  name.assfmt("%s_1", tab1.getName());
+  tab1.setName(name.c_str());
+
+  pDic->dropTable(tab0.getName());
+  pDic->dropTable(tab1.getName());
+
+  if (pDic->createTable(tab0))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  if (pDic->createTable(tab1))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  if (createIndexes(pDic, tab1, 4))
+    return NDBT_FAILED;
+
+  Vector<int> group1;
+  Vector<int> group2;
+  Bitmask<256/32> nodeGroupMap;
+  for (int j = 0; j<res.getNumDbNodes(); j++)
+  {
+    int node = res.getDbNodeId(j);
+    int ng = res.getNodeGroup(node);
+    if (nodeGroupMap.get(ng))
+    {
+      group2.push_back(node);
+    }
+    else
+    {
+      group1.push_back(node);
+      nodeGroupMap.set(ng);
+    }
+  }
+
+  res.restartNodes(group1.getBase(), (int)group1.size(),
+                   NdbRestarter::NRRF_NOSTART |
+                   NdbRestarter::NRRF_ABORT);
+
+  res.waitNodesNoStart(group1.getBase(), (int)group1.size());
+  res.startNodes(group1.getBase(), (int)group1.size());
+  res.waitClusterStarted();
+
+  res.restartNodes(group2.getBase(), (int)group2.size(),
+                   NdbRestarter::NRRF_NOSTART |
+                   NdbRestarter::NRRF_ABORT);
+  res.waitNodesNoStart(group2.getBase(), (int)group2.size());
+  res.startNodes(group2.getBase(), (int)group2.size());
+  res.waitClusterStarted();
+
+  if (pDic->dropTable(tab0.getName()))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  if (pDic->createTable(tab0))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  if (createIndexes(pDic, tab0, 4))
+    return NDBT_FAILED;
+
+  res.restartAll2(NdbRestarter::NRRF_NOSTART | NdbRestarter::NRRF_ABORT);
+  res.waitClusterNoStart();
+  res.startAll();
+  res.waitClusterStarted();
+
+  if (pDic->dropTable(tab0.getName()))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  if (pDic->dropTable(tab1.getName()))
+  {
+    ndbout << pDic->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
+
+  return NDBT_OK;
+}
+
+
 /** telco-6.4 **/
  
 NDBT_TESTSUITE(testDict);
@@ -7035,6 +7168,10 @@ TESTCASE("Bug41905",
   STEP(runBug41905);
   STEP(runBug41905getTable);
 }
+TESTCASE("Bug46552", "")
+{
+  INITIALIZER(runBug46552);
+}
 /** telco-6.4 **/
 NDBT_TESTSUITE_END(testDict);
 

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2009-08-07 12:02:25 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2009-08-11 08:10:20 +0000
@@ -1326,3 +1326,7 @@ max-time: 300
 cmd: testSystemRestart
 args: -n Bug45154 D1
 
+max-time: 300
+cmd: testDict
+args: -n Bug46552 T1
+

=== modified file 'storage/ndb/test/src/NdbRestarter.cpp'
--- a/storage/ndb/test/src/NdbRestarter.cpp	2009-05-27 12:11:46 +0000
+++ b/storage/ndb/test/src/NdbRestarter.cpp	2009-08-11 08:10:20 +0000
@@ -74,13 +74,26 @@ NdbRestarter::restartOneDbNode(int _node
 			       bool inital,
 			       bool nostart,
 			       bool abort){
+  return restartNodes(&_nodeId, 1,
+                      (inital ? NRRF_INITIAL : 0) |
+                      (nostart ? NRRF_NOSTART : 0) |
+                      (abort ? NRRF_ABORT : 0));
+}
+
+int
+NdbRestarter::restartNodes(int * nodes, int cnt,
+                           Uint32 flags)
+{
   if (!isConnected())
     return -1;
 
   int ret = 0;
   
-  if ((ret = ndb_mgm_restart2(handle, 1, &_nodeId,
-			      inital, nostart, abort)) <= 0) {
+  if ((ret = ndb_mgm_restart2(handle, cnt, nodes,
+                              (flags & NRRF_INITIAL),
+                              (flags & NRRF_NOSTART),
+                              (flags & NRRF_ABORT))) <= 0)
+  {
     /**
      * ndb_mgm_restart2 returned error, one reason could
      * be that the node have not stopped fast enough!
@@ -91,25 +104,30 @@ NdbRestarter::restartOneDbNode(int _node
     if (getStatus() != 0)
       return -1;
 
-    g_info << "ndb_mgm_restart2 returned with error, checking node state" << endl;
+    g_info << "ndb_mgm_restart2 returned with error, checking node state"
+           << endl;
 
-    for(size_t i = 0; i < ndbNodes.size(); i++){
-      if(ndbNodes[i].node_id == _nodeId){
-	g_info <<_nodeId<<": status="<<ndbNodes[i].node_status<<endl;
-	/* Node found check state */
-	switch(ndbNodes[i].node_status){
-	case NDB_MGM_NODE_STATUS_RESTARTING:
-	case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
-	  return 0;
-	default:
-	  break;
-	}
+    for (int j = 0; j<cnt; j++)
+    {
+      int _nodeId = nodes[j];
+      for(size_t i = 0; i < ndbNodes.size(); i++)
+      {
+        if(ndbNodes[i].node_id == _nodeId)
+        {
+          g_info <<_nodeId<<": status="<<ndbNodes[i].node_status<<endl;
+          /* Node found check state */
+          switch(ndbNodes[i].node_status){
+          case NDB_MGM_NODE_STATUS_RESTARTING:
+          case NDB_MGM_NODE_STATUS_SHUTTING_DOWN:
+            break;
+          default:
+            MGMERR(handle);
+            g_err  << "Could not stop node with id = "<< _nodeId << endl;
+            return -1;
+          }
+        }
       }
     }
-    
-    MGMERR(handle);
-    g_err  << "Could not stop node with id = "<< _nodeId << endl;
-    return -1;
   }
 
   return 0;


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20090811081020-yo6hvn9p2mmsbep9.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (jonas:2952) Bug#46552Jonas Oreland11 Aug