List:Commits« Previous MessageNext Message »
From:jonas Date:March 20 2006 2:49pm
Subject:bk commit into 4.1 tree (jonas:1.2473) BUG#18352
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.2473 06/03/20 14:49:46 jonas@stripped +6 -0
  ndb - bug#18352
    Use variable waitfor_response_timeout (depending on TransactionDeadLockTimeout)
    When getting 4012, set NeedAbort and ReleaseOnClose

  ndb/test/run-test/daily-basic-tests.txt
    1.26 06/03/20 14:49:44 jonas@stripped +4 -0
    Add testcase for 4012

  ndb/test/ndbapi/testTimeout.cpp
    1.12 06/03/20 14:49:44 jonas@stripped +101 -0
    Add testcase for 4012

  ndb/src/ndbapi/TransporterFacade.hpp
    1.20 06/03/20 14:49:44 jonas@stripped +1 -0
    Init wait_for_response_timoue as max TRANSACTION_DEADLOCK_TIMEOUT

  ndb/src/ndbapi/TransporterFacade.cpp
    1.33 06/03/20 14:49:44 jonas@stripped +14 -0
    Init wait_for_response_timoue as max TRANSACTION_DEADLOCK_TIMEOUT

  ndb/src/ndbapi/Ndbif.cpp
    1.27 06/03/20 14:49:44 jonas@stripped +7 -5
    Use variable timeout for waitfor, 
      when receiving 4012, set NeedAbort and ReleaseOnClose

  ndb/src/ndbapi/NdbConnection.cpp
    1.36 06/03/20 14:49:44 jonas@stripped +2 -2
    Use variable for WAITFOR_RESPONSE_TIMEOUT

# 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:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/41-work

--- 1.25/ndb/test/run-test/daily-basic-tests.txt	2006-03-17 10:55:00 +01:00
+++ 1.26/ndb/test/run-test/daily-basic-tests.txt	2006-03-20 14:49:44 +01:00
@@ -236,6 +236,10 @@
 cmd: testTimeout
 args: -n TimeoutRandTransaction T1
 
+max-time: 600
+cmd: testTimeout
+args: -n Error4012 T1
+
 # SCAN TESTS
 #
 max-time: 500

--- 1.35/ndb/src/ndbapi/NdbConnection.cpp	2005-09-02 11:09:14 +02:00
+++ 1.36/ndb/src/ndbapi/NdbConnection.cpp	2006-03-20 14:49:44 +01:00
@@ -450,12 +450,12 @@
 //------------------------------------------------------------------------
   Ndb* tNdb = theNdb;
 
+  Uint32 timeout = TransporterFacade::instance()->m_waitfor_timeout;
   m_waitForReply = false;
   executeAsynchPrepare(aTypeOfExec, NULL, NULL, abortOption);
   if (m_waitForReply){
     while (1) {
-      int noOfComp = tNdb->sendPollNdb((3 * WAITFOR_RESPONSE_TIMEOUT),
-                                       1, forceSend);
+      int noOfComp = tNdb->sendPollNdb(3 * timeout, 1, forceSend);
       if (noOfComp == 0) {
         /** 
          * This timeout situation can occur if NDB crashes.

--- 1.26/ndb/src/ndbapi/Ndbif.cpp	2005-09-16 11:26:31 +02:00
+++ 1.27/ndb/src/ndbapi/Ndbif.cpp	2006-03-20 14:49:44 +01:00
@@ -954,23 +954,25 @@
 void
 Ndb::check_send_timeout()
 {
+  Uint32 timeout = TransporterFacade::instance()->m_waitfor_timeout;
   NDB_TICKS current_time = NdbTick_CurrentMillisecond();
   if (current_time - the_last_check_time > 1000) {
     the_last_check_time = current_time;
     Uint32 no_of_sent = theNoOfSentTransactions;
     for (Uint32 i = 0; i < no_of_sent; i++) {
       NdbConnection* a_con = theSentTransactionsArray[i];
-      if ((current_time - a_con->theStartTransTime) >
-          WAITFOR_RESPONSE_TIMEOUT) {
+      if ((current_time - a_con->theStartTransTime) > timeout)
+      {
 #ifdef VM_TRACE
         a_con->printState();
 	Uint32 t1 = a_con->theTransactionId;
 	Uint32 t2 = a_con->theTransactionId >> 32;
-	ndbout_c("[%.8x %.8x]", t1, t2);
-	abort();
+	ndbout_c("4012 [%.8x %.8x]", t1, t2);
+	//abort();
 #endif
+        a_con->theReleaseOnClose = true;
         a_con->setOperationErrorCodeAbort(4012);
-        a_con->theCommitStatus = NdbConnection::Aborted;
+	a_con->theCommitStatus = NdbConnection::NeedAbort;
         a_con->theCompletionStatus = NdbConnection::CompletedFailure;
         a_con->handleExecuteCompletion();
         remove_sent_list(i);

--- 1.32/ndb/src/ndbapi/TransporterFacade.cpp	2005-08-18 14:04:50 +02:00
+++ 1.33/ndb/src/ndbapi/TransporterFacade.cpp	2006-03-20 14:49:44 +01:00
@@ -567,6 +567,20 @@
   }
 #endif
   
+  Uint32 timeout = 120000;
+  iter.first();
+  for (iter.first(); iter.valid(); iter.next())
+  {
+    Uint32 tmp1 = 0, tmp2 = 0;
+    iter.get(CFG_DB_TRANSACTION_CHECK_INTERVAL, &tmp1);
+    iter.get(CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, &tmp2);
+    tmp1 += tmp2;
+    if (tmp1 > timeout)
+      timeout = tmp1;
+  }
+  m_waitfor_timeout = timeout;
+  ndbout_c("Using waitfor: %d", timeout);
+  
   if (!theTransporterRegistry->start_service(m_socket_server)){
     ndbout_c("Unable to start theTransporterRegistry->start_service");
     DBUG_RETURN(false);

--- 1.19/ndb/src/ndbapi/TransporterFacade.hpp	2004-12-20 12:36:03 +01:00
+++ 1.20/ndb/src/ndbapi/TransporterFacade.hpp	2006-03-20 14:49:44 +01:00
@@ -172,6 +172,7 @@
    */
 public:
   STATIC_CONST( MAX_NO_THREADS = 4711 );
+  Uint32 m_waitfor_timeout; // in milli seconds...
 private:
 
   struct ThreadData {

--- 1.11/ndb/test/ndbapi/testTimeout.cpp	2005-06-13 19:44:00 +02:00
+++ 1.12/ndb/test/ndbapi/testTimeout.cpp	2006-03-20 14:49:44 +01:00
@@ -24,6 +24,7 @@
 
 #define TIMEOUT (Uint32)3000
 Uint32 g_org_timeout = 3000;
+Uint32 g_org_deadlock = 3000;
 
 int
 setTransactionTimeout(NDBT_Context* ctx, NDBT_Step* step){
@@ -59,6 +60,60 @@
   return NDBT_OK;
 }
 
+int
+setDeadlockTimeout(NDBT_Context* ctx, NDBT_Step* step){
+  NdbRestarter restarter;
+  int timeout = ctx->getProperty("TransactionDeadlockTimeout", TIMEOUT);
+  
+  NdbConfig conf(GETNDB(step)->getNodeId()+1);
+  unsigned int nodeId = conf.getMasterNodeId();
+  if (!conf.getProperty(nodeId,
+			NODE_TYPE_DB, 
+			CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
+			&g_org_deadlock))
+    return NDBT_FAILED;
+  
+  g_err << "Setting timeout: " << timeout << endl;
+  int val[] = { DumpStateOrd::TcSetTransactionTimeout, timeout };
+  if(restarter.dumpStateAllNodes(val, 2) != 0){
+    return NDBT_FAILED;
+  }
+  
+  return NDBT_OK;
+}
+
+int
+getDeadlockTimeout(NDBT_Context* ctx, NDBT_Step* step){
+  NdbRestarter restarter;
+  
+  Uint32 val = 0;
+  NdbConfig conf(GETNDB(step)->getNodeId()+1);
+  unsigned int nodeId = conf.getMasterNodeId();
+  if (!conf.getProperty(nodeId,
+			NODE_TYPE_DB, 
+			CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT,
+			&val))
+    return NDBT_FAILED;
+
+  if (val < 120000)
+    val = 120000;
+  ctx->setProperty("TransactionDeadlockTimeout", 4*val);
+  
+  return NDBT_OK;
+}
+
+int
+resetDeadlockTimeout(NDBT_Context* ctx, NDBT_Step* step){
+  NdbRestarter restarter;
+  
+  int val[] = { DumpStateOrd::TcSetTransactionTimeout, g_org_deadlock };
+  if(restarter.dumpStateAllNodes(val, 2) != 0){
+    return NDBT_FAILED;
+  }
+  
+  return NDBT_OK;
+}
+
 
 int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
 
@@ -374,6 +429,43 @@
   return result;
 }
 
+int 
+runError4012(NDBT_Context* ctx, NDBT_Step* step){
+  int result = NDBT_OK;
+  int loops = ctx->getNumLoops();
+  int stepNo = step->getStepNo();
+  
+  int timeout = ctx->getProperty("TransactionDeadlockTimeout", TIMEOUT);
+
+  HugoOperations hugoOps(*ctx->getTab());
+  Ndb* pNdb = GETNDB(step);
+
+  do{
+    // Commit transaction
+    CHECK(hugoOps.startTransaction(pNdb) == 0);
+    CHECK(hugoOps.pkUpdateRecord(pNdb, 0) == 0);
+    int ret = hugoOps.execute_NoCommit(pNdb);
+    if (ret == 0)
+    {
+      int sleep = timeout;
+      ndbout << "Sleeping for " << sleep << " milliseconds" <<
endl;
+      NdbSleep_MilliSleep(sleep);
+      
+      // Expect that transaction has NOT timed-out
+      CHECK(hugoOps.execute_Commit(pNdb) == 0);
+    }
+    else
+    {
+      CHECK(ret == 4012);
+    }
+  } while(false);
+  
+  hugoOps.closeTransaction(pNdb);
+  
+  return result;
+}
+
+
 NDBT_TESTSUITE(testTimeout);
 TESTCASE("DontTimeoutTransaction", 
 	 "Test that the transaction does not timeout "\
@@ -465,6 +557,15 @@
   FINALIZER(resetTransactionTimeout);
   FINALIZER(runClearTable);
 }
+TESTCASE("Error4012", ""){
+  TC_PROPERTY("TransactionDeadlockTimeout", 120000);
+  INITIALIZER(runLoadTable);
+  INITIALIZER(getDeadlockTimeout);
+  INITIALIZER(setDeadlockTimeout);
+  STEPS(runError4012, 2);
+  FINALIZER(runClearTable);
+}
+
 NDBT_TESTSUITE_END(testTimeout);
 
 int main(int argc, const char** argv){
Thread
bk commit into 4.1 tree (jonas:1.2473) BUG#18352jonas20 Mar