MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:pekka Date:February 5 2006 9:12pm
Subject:bk commit into 4.1 tree (pekka:1.2472) BUG#16693
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of pekka. When pekka 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.2472 06/02/05 22:12:06 pekka@stripped +2 -0
  ndb - bug#16693 (4.1) test + workaround, analyze later

  ndb/tools/delete_all.cpp
    1.12 06/02/05 22:10:18 pekka@stripped +25 -5
    if blobs, no commit across open cursor (single trans)
    cases listed in testBlobs.cpp, analyze later (in 5.0 maybe)

  ndb/test/ndbapi/testBlobs.cpp
    1.24 06/02/05 22:06:16 pekka@stripped +63 -19
    do batched deletes + list commit across open cursor test cases

# 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:	pekka
# Host:	orca.ndb.mysql.com
# Root:	/space/pekka/ndb/version/my41

--- 1.23/ndb/test/ndbapi/testBlobs.cpp	2006-01-31 08:12:02 +01:00
+++ 1.24/ndb/test/ndbapi/testBlobs.cpp	2006-02-05 22:06:16 +01:00
@@ -841,9 +841,6 @@
       CHK(g_con->execute(NoCommit) == 0);
       CHK(writeBlobData(tup) == 0);
     }
-    // just another trap
-    if (urandom(10) == 0)
-      CHK(g_con->execute(NoCommit) == 0);
     if (++n == g_opt.m_batch) {
       CHK(g_con->execute(Commit) == 0);
       g_ndb->closeTransaction(g_con);
@@ -965,21 +962,31 @@
 deletePk()
 {
   DBG("--- deletePk ---");
+  unsigned n = 0;
+  CHK((g_con = g_ndb->startTransaction()) != 0);
   for (unsigned k = 0; k < g_opt.m_rows; k++) {
     Tup& tup = g_tups[k];
     DBG("deletePk pk1=" << hex << tup.m_pk1);
-    CHK((g_con = g_ndb->startTransaction()) != 0);
     CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
     CHK(g_opr->deleteTuple() == 0);
     CHK(g_opr->equal("PK1", tup.m_pk1) == 0);
     if (g_opt.m_pk2len != 0)
       CHK(g_opr->equal("PK2", tup.m_pk2) == 0);
-    CHK(g_con->execute(Commit) == 0);
-    g_ndb->closeTransaction(g_con);
+    if (++n == g_opt.m_batch) {
+      CHK(g_con->execute(Commit) == 0);
+      g_ndb->closeTransaction(g_con);
+      CHK((g_con = g_ndb->startTransaction()) != 0);
+      n = 0;
+    }
     g_opr = 0;
-    g_con = 0;
     tup.m_exists = false;
   }
+  if (n != 0) {
+    CHK(g_con->execute(Commit) == 0);
+    n = 0;
+  }
+  g_ndb->closeTransaction(g_con);
+  g_con = 0;
   return 0;
 }
 
@@ -1082,19 +1089,27 @@
 deleteIdx()
 {
   DBG("--- deleteIdx ---");
+  unsigned n = 0;
+  CHK((g_con = g_ndb->startTransaction()) != 0);
   for (unsigned k = 0; k < g_opt.m_rows; k++) {
     Tup& tup = g_tups[k];
     DBG("deleteIdx pk1=" << hex << tup.m_pk1);
-    CHK((g_con = g_ndb->startTransaction()) != 0);
     CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0);
     CHK(g_opx->deleteTuple() == 0);
     CHK(g_opx->equal("PK2", tup.m_pk2) == 0);
-    CHK(g_con->execute(Commit) == 0);
-    g_ndb->closeTransaction(g_con);
+    if (++n == g_opt.m_batch) {
+      CHK(g_con->execute(Commit) == 0);
+      g_ndb->closeTransaction(g_con);
+      CHK((g_con = g_ndb->startTransaction()) != 0);
+      n = 0;
+    }
     g_opx = 0;
-    g_con = 0;
     tup.m_exists = false;
   }
+  if (n != 0) {
+    CHK(g_con->execute(Commit) == 0);
+    n = 0;
+  }
   return 0;
 }
 
@@ -1225,20 +1240,49 @@
     CHK(g_ops->getValue("PK2", tup.m_pk2) != 0);
   CHK(g_con->execute(NoCommit) == 0);
   unsigned rows = 0;
+  unsigned n = 0;
   while (1) {
     int ret;
     tup.m_pk1 = (Uint32)-1;
     memset(tup.m_pk2, 'x', g_opt.m_pk2len);
-    CHK((ret = rs->nextResult()) == 0 || ret == 1);
+    CHK((ret = rs->nextResult(true)) == 0 || ret == 1);
     if (ret == 1)
       break;
-    DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
-    CHK(rs->deleteTuple() == 0);
-    CHK(g_con->execute(NoCommit) == 0);
-    Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
-    CHK(k < g_opt.m_rows && g_tups[k].m_exists);
-    g_tups[k].m_exists = false;
-    rows++;
+    while (1) {
+      DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
+      Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
+      CHK(k < g_opt.m_rows && g_tups[k].m_exists);
+      g_tups[k].m_exists = false;
+      CHK(rs->deleteTuple() == 0);
+      rows++;
+      tup.m_pk1 = (Uint32)-1;
+      memset(tup.m_pk2, 'x', g_opt.m_pk2len);
+      CHK((ret = rs->nextResult(false)) == 0 || ret == 1 || ret == 2);
+      if (++n == g_opt.m_batch || ret == 2) {
+        DBG("execute batch: n=" << n << " ret=" << ret);
+        switch (0) {
+        case 0: // works normally
+          CHK(g_con->execute(NoCommit) == 0);
+          CHK(true || g_con->restart() == 0);
+          break;
+        case 1: // nonsense - g_con is invalid for 2nd batch
+          CHK(g_con->execute(Commit) == 0);
+          CHK(true || g_con->restart() == 0);
+          break;
+        case 2: // DBTC sendSignalErrorRefuseLab
+          CHK(g_con->execute(NoCommit) == 0);
+          CHK(g_con->restart() == 0);
+          break;
+        case 3: // 266 time-out
+          CHK(g_con->execute(Commit) == 0);
+          CHK(g_con->restart() == 0);
+          break;
+        }
+        n = 0;
+      }
+      if (ret == 2)
+        break;
+    }
   }
   CHK(g_con->execute(Commit) == 0);
   g_ndb->closeTransaction(g_con);

--- 1.11/ndb/tools/delete_all.cpp	2005-01-28 00:42:34 +01:00
+++ 1.12/ndb/tools/delete_all.cpp	2006-02-05 22:10:18 +01:00
@@ -22,7 +22,8 @@
 #include <NdbSleep.h>
 #include <NDBT.hpp>
 
-static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism=240);
+static int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
+                       bool commit_across_open_cursor, int parallelism=240);
 
 NDB_STD_OPTS_VARS;
 
@@ -81,8 +82,18 @@
       ndbout << " Table " << argv[i] << " does not exist!" << endl;
       return NDBT_ProgramExit(NDBT_WRONGARGS);
     }
+    // Check if we have any blobs
+    bool commit_across_open_cursor = true;
+    for (int j = 0; j < pTab->getNoOfColumns(); j++) {
+      NdbDictionary::Column::Type t = pTab->getColumn(j)->getType();
+      if (t == NdbDictionary::Column::Blob ||
+          t == NdbDictionary::Column::Text) {
+        commit_across_open_cursor = false;
+        break;
+      }
+    }
     ndbout << "Deleting all from " << argv[i] << "...";
-    if(clear_table(&MyNdb, pTab) == NDBT_FAILED){
+    if(clear_table(&MyNdb, pTab, commit_across_open_cursor) == NDBT_FAILED){
       res = NDBT_FAILED;
       ndbout << "FAILED" << endl;
     }
@@ -91,7 +102,8 @@
 }
 
 
-int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism)
+int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab,
+                bool commit_across_open_cursor, int parallelism)
 {
   // Scan all records exclusive and delete 
   // them one by one
@@ -153,8 +165,12 @@
       } while((check = rs->nextResult(false)) == 0);
       
       if(check != -1){
-	check = pTrans->execute(Commit);   
-	pTrans->restart();
+        if (commit_across_open_cursor) {
+          check = pTrans->execute(Commit);   
+          pTrans->restart(); // new tx id
+        } else {
+          check = pTrans->execute(NoCommit);
+        }
       }
       
       err = pTrans->getNdbError();    
@@ -178,6 +194,10 @@
 	par = 1;
 	goto restart;
       }
+      goto failed;
+    }
+    if (! commit_across_open_cursor && pTrans->execute(Commit) != 0) {
+      err = pTrans->getNdbError();
       goto failed;
     }
     pNdb->closeTransaction(pTrans);
Thread
bk commit into 4.1 tree (pekka:1.2472) BUG#16693pekka5 Feb