List:Internals« Previous MessageNext Message »
From:jonas.oreland Date:July 1 2005 9:57am
Subject:bk commit into 4.1 tree (joreland:1.2326) BUG#11133
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jonas. When jonas 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.2326 05/07/01 09:57:48 joreland@stripped +4 -0
  bug#11133 - ndb write handling
    fix handling of write's in lock queue
    add test case
    add support for pkWrite+async exec in HugoOperations

  ndb/test/src/HugoOperations.cpp
    1.13 05/07/01 09:57:44 joreland@stripped +87 -4
    Add support for 
    1) pkWriteRecord 
    2) async execute            

  ndb/test/ndbapi/testNdbApi.cpp
    1.13 05/07/01 09:57:44 joreland@stripped +71 -222
    Extend test case for bug#11133 with multi transaction tests aswell...

  ndb/test/include/HugoOperations.hpp
    1.7 05/07/01 09:57:44 joreland@stripped +14 -0
    Add support for 
    1) pkWriteRecord 
    2) async execute            

  ndb/src/kernel/blocks/dbacc/DbaccMain.cpp
    1.33 05/07/01 09:57:44 joreland@stripped +18 -1
    Handle operation type wrt ZWRITE when restarting operations

# 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:	joreland
# Host:	eel.ndb.mysql.com.hemma.oreland.se
# Root:	/home/jonas/src/mysql-4.1

--- 1.32/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp	2005-06-07 15:10:54 +02:00
+++ 1.33/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp	2005-07-01 09:57:44 +02:00
@@ -6198,7 +6198,24 @@
       sendSignal(operationRecPtr.p->userblockref, GSN_ACCKEYREF, signal, 2, JBB);
       return operationRecPtr.p->elementIsDisappeared;
     }//if
-  }//if
+  } 
+  else if(operationRecPtr.p->operation == ZWRITE)
+  {
+    jam();
+    operationRecPtr.p->operation = ZINSERT;
+    if (operationRecPtr.p->prevParallelQue != RNIL) {
+      OperationrecPtr prevOpPtr;
+      jam();
+      prevOpPtr.i = operationRecPtr.p->prevParallelQue;
+      ptrCheckGuard(prevOpPtr, coprecsize, operationrec);
+      if (prevOpPtr.p->operation != ZDELETE) 
+      {
+        jam();
+        operationRecPtr.p->operation = ZUPDATE;
+      }
+    }
+  }
+
   if (operationRecPtr.p->operation == ZSCAN_OP &&
       ! operationRecPtr.p->isAccLockReq) {
     jam();

--- 1.6/ndb/test/include/HugoOperations.hpp	2005-02-12 15:12:50 +01:00
+++ 1.7/ndb/test/include/HugoOperations.hpp	2005-07-01 09:57:44 +02:00
@@ -38,6 +38,11 @@
 		     int numRecords = 1,
 		     int updatesValue = 0);
   
+  int pkWriteRecord(Ndb*,
+		    int recordNo,
+		    int numRecords = 1,
+		    int updatesValue = 0);
+  
   int pkReadRecord(Ndb*,
 		   int recordNo,
 		   int numRecords = 1,
@@ -88,6 +93,10 @@
 		      NdbScanOperation::LM_CommittedRead, 
 		      int numRecords = 1);
 
+
+  int execute_async(Ndb*, ExecType, AbortOption = AbortOnError);
+  int wait_async(Ndb*, int timeout = -1);
+
 protected:
   void allocRows(int rows);
   void deallocRows();
@@ -102,6 +111,11 @@
   Vector<RsPair> m_executed_result_sets;
 
   NdbConnection* pTrans;
+
+  int m_async_reply;
+  int m_async_return;
+  friend void HugoOperations_async_callback(int, NdbConnection*, void*);
+  void callback(int res, NdbConnection*);
 };
 
 #endif

--- 1.12/ndb/test/ndbapi/testNdbApi.cpp	2005-06-07 15:10:54 +02:00
+++ 1.13/ndb/test/ndbapi/testNdbApi.cpp	2005-07-01 09:57:44 +02:00
@@ -1049,6 +1049,8 @@
   return result;
 }
 
+#define C2(x) { int _x= (x); if(_x == 0) return NDBT_FAILED; }
+
 int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){
   int result = NDBT_OK;
   const NdbDictionary::Table* pTab = ctx->getTab();
@@ -1056,228 +1058,76 @@
   HugoOperations hugoOps(*pTab);
 
   Ndb* pNdb = GETNDB(step);
-  Uint32 lm;
 
-  NdbConnection* pCon = pNdb->startTransaction();
-  if (pCon == NULL){
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  NdbOperation* pOp = pCon->getNdbOperation(pTab->getName());
-  if (pOp == NULL){
-    ERR(pCon->getNdbError());
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  if (pOp->readTuple(NdbOperation::LM_Exclusive) != 0){
-    pNdb->closeTransaction(pCon);
-    ERR(pOp->getNdbError());
-    return NDBT_FAILED;
-  }
-      
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() == true){
-      if(hugoOps.equalForAttr(pOp, a, 1) != 0){
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() != true){
-      if (pOp->getValue(pTab->getColumn(a)->getName()) == NULL) {
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  int check = pCon->execute(NoCommit);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-  
-  pOp = pCon->getNdbOperation(pTab->getName());
-  if (pOp == NULL){
-    ERR(pCon->getNdbError());
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  if (pOp->deleteTuple() != 0){
-    pNdb->closeTransaction(pCon);
-    ERR(pOp->getNdbError());
-    return NDBT_FAILED;
-  }
-      
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() == true){
-      if(hugoOps.equalForAttr(pOp, a, 1) != 0){
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-
-  check = pCon->execute(NoCommit);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-
-  pOp = pCon->getNdbOperation(pTab->getName());
-  if (pOp == NULL){
-    ERR(pCon->getNdbError());
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  if (pOp->writeTuple() != 0){
-    pNdb->closeTransaction(pCon);
-    ERR(pOp->getNdbError());
-    return NDBT_FAILED;
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() == true){
-      if(hugoOps.equalForAttr(pOp, a, 1) != 0){
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() != true){
-      if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0)
-      {
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  check = pCon->execute(NoCommit);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-
-  pOp = pCon->getNdbOperation(pTab->getName());
-  if (pOp == NULL){
-    ERR(pCon->getNdbError());
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  if (pOp->writeTuple() != 0){
-    pNdb->closeTransaction(pCon);
-    ERR(pOp->getNdbError());
-    return NDBT_FAILED;
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() == true){
-      if(hugoOps.equalForAttr(pOp, a, 1) != 0){
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() != true){
-      if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0)
-      {
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  check = pCon->execute(NoCommit);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-  
-  check = pCon->execute(Rollback);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-  
-  pCon->close();
-
-  pCon = pNdb->startTransaction();
-  if (pCon == NULL){
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-
-  pOp = pCon->getNdbOperation(pTab->getName());
-  if (pOp == NULL){
-    ERR(pCon->getNdbError());
-    pNdb->closeTransaction(pCon);  
-    return NDBT_FAILED;
-  }
-  
-  if (pOp->writeTuple() != 0){
-    pNdb->closeTransaction(pCon);
-    ERR(pOp->getNdbError());
-    return NDBT_FAILED;
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() == true){
-      if(hugoOps.equalForAttr(pOp, a, 1) != 0){
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  for(int a = 0; a<pTab->getNoOfColumns(); a++){
-    if (pTab->getColumn(a)->getPrimaryKey() != true){
-      if(hugoOps.setValueForAttr(pOp, a, 1, 1) != 0)
-      {
-	ERR(pCon->getNdbError());
-	pNdb->closeTransaction(pCon);
-	return NDBT_FAILED;
-      }
-    }
-  }
-  
-  check = pCon->execute(Commit);
-  if (check == 0){
-    ndbout << "execute worked" << endl;
-  } else {
-    ERR(pCon->getNdbError());
-    result = NDBT_FAILED;
-  }
-  
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Exclusive) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkWriteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+
+  Ndb ndb2("TEST_DB");
+  C2(ndb2.init() == 0);
+  C2(ndb2.waitUntilReady() == 0);
+  HugoOperations hugoOps2(*pTab);  
+
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkInsertRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps2.startTransaction(&ndb2) == 0);
+  C2(hugoOps2.pkWriteRecord(&ndb2, 0, 1) == 0);
+  C2(hugoOps2.execute_async(&ndb2, NoCommit) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps2.wait_async(&ndb2) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+  C2(hugoOps2.closeTransaction(&ndb2) == 0);  
+
+  C2(hugoOps.startTransaction(pNdb) == 0);
+  C2(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
+  C2(hugoOps.execute_NoCommit(pNdb) == 0);
+  C2(hugoOps2.startTransaction(&ndb2) == 0);
+  C2(hugoOps2.pkWriteRecord(&ndb2, 0, 1) == 0);
+  C2(hugoOps2.execute_async(&ndb2, NoCommit) == 0);
+  C2(hugoOps.execute_Commit(pNdb) == 0);
+  C2(hugoOps2.wait_async(&ndb2) == 0);
+  C2(hugoOps.closeTransaction(pNdb) == 0);
+  C2(hugoOps2.closeTransaction(&ndb2) == 0);  
+
   return result;
 }
 
@@ -1359,7 +1209,6 @@
 }
 TESTCASE("Bug_11133", 
 	 "Test ReadEx-Delete-Write\n"){ 
-  INITIALIZER(runLoadTable);
   INITIALIZER(runBug_11133);
   FINALIZER(runClearTable);
 }

--- 1.12/ndb/test/src/HugoOperations.cpp	2005-02-02 21:03:44 +01:00
+++ 1.13/ndb/test/src/HugoOperations.cpp	2005-07-01 09:57:44 +02:00
@@ -16,7 +16,6 @@
 
 #include <HugoOperations.hpp>
 
-
 int HugoOperations::startTransaction(Ndb* pNdb){
   
   if (pTrans != NULL){
@@ -199,6 +198,48 @@
   return NDBT_OK;
 }
 
+int HugoOperations::pkWriteRecord(Ndb* pNdb,
+				  int recordNo,
+				  int numRecords,
+				  int updatesValue){
+  
+  int a, check;
+  for(int r=0; r < numRecords; r++){
+    NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());	
+    if (pOp == NULL) {
+      ERR(pTrans->getNdbError());
+      return NDBT_FAILED;
+    }
+    
+    check = pOp->writeTuple();
+    if( check == -1 ) {
+      ERR(pTrans->getNdbError());
+      return NDBT_FAILED;
+    }
+    
+    // Define primary keys
+    for(a = 0; a<tab.getNoOfColumns(); a++){
+      if (tab.getColumn(a)->getPrimaryKey() == true){
+	if(equalForAttr(pOp, a, r+recordNo) != 0){
+	  ERR(pTrans->getNdbError());
+	  return NDBT_FAILED;
+	}
+      }
+    }
+    
+    // Define attributes to update
+    for(a = 0; a<tab.getNoOfColumns(); a++){
+      if (tab.getColumn(a)->getPrimaryKey() == false){
+	if(setValueForAttr(pOp, a, recordNo+r, updatesValue ) != 0){ 
+	  ERR(pTrans->getNdbError());
+	  return NDBT_FAILED;
+	}
+      }
+    } 
+  }
+  return NDBT_OK;
+}
+
 int HugoOperations::pkDeleteRecord(Ndb* pNdb,
 				   int recordNo,
 				   int numRecords){
@@ -399,16 +440,58 @@
   return NDBT_OK;
 }
 
+void
+HugoOperations_async_callback(int res, NdbConnection* pCon, void* ho)
+{
+  ((HugoOperations*)ho)->callback(res, pCon);
+}
+
+void
+HugoOperations::callback(int res, NdbConnection* pCon)
+{
+  assert(pCon == pTrans);
+  m_async_reply= 1;
+  m_async_return= res;
+}
+
+int 
+HugoOperations::execute_async(Ndb* pNdb, ExecType et, AbortOption eao){
+  
+  m_async_reply= 0;
+  pTrans->executeAsynchPrepare(et,
+			       HugoOperations_async_callback,
+			       this,
+			       eao);
+  
+  pNdb->sendPreparedTransactions();
+  
+  return NDBT_OK;
+}
+
+int
+HugoOperations::wait_async(Ndb* pNdb, int timeout)
+{
+  pNdb->pollNdb(1000);
+
+  if(m_async_reply)
+  {
+    return m_async_return;
+  }
+  ndbout_c("wait returned nothing...");
+  return -1;
+}
+
 HugoOperations::HugoOperations(const NdbDictionary::Table& _tab):
   UtilTransactions(_tab),
   calc(_tab),
-  pTrans(NULL){
-
+  pTrans(NULL)
+{
 }
 
 HugoOperations::~HugoOperations(){
   deallocRows();
-  if (pTrans != NULL){
+  if (pTrans != NULL)
+  {
     pTrans->close();
     pTrans = NULL;
   }
Thread
bk commit into 4.1 tree (joreland:1.2326) BUG#11133jonas.oreland1 Jul