List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:October 21 2010 10:37am
Subject:bzr push into mysql-5.1-telco-7.1 branch (jonas:3908 to 3909)
View as plain text  
 3909 Jonas Oreland	2010-10-21 [merge]
      ndb - merge 70 to 71

    modified:
      storage/ndb/tools/restore/consumer_restore.cpp
 3908 Pekka Nousiainen	2010-10-20 [merge]
      merge 7.0 to 7.1

    modified:
      mysql-test/suite/ndb/r/ndb_index_ordered.result
      mysql-test/suite/ndb/t/ndb_index_ordered.test
      storage/ndb/src/ndbapi/NdbScanOperation.cpp
=== modified file 'storage/ndb/tools/restore/consumer_restore.cpp'
--- a/storage/ndb/tools/restore/consumer_restore.cpp	2010-09-23 09:36:19 +0000
+++ b/storage/ndb/tools/restore/consumer_restore.cpp	2010-10-21 08:58:41 +0000
@@ -2027,20 +2027,48 @@ static Uint32 get_part_id(const NdbDicti
     return (hash_value % no_frags);
 }
 
+struct TransGuard
+{
+  NdbTransaction* pTrans;
+  TransGuard(NdbTransaction* p) : pTrans(p) {}
+  ~TransGuard() { if (pTrans) pTrans->close();}
+};
+
 void
 BackupRestore::logEntry(const LogEntry & tup)
 {
   if (!m_restore)
     return;
 
+
+  Uint32 retries = 0;
+  NdbError errobj;
+retry:
+  if (retries == 11)
+  {
+    err << "execute failed: " << errobj << endl;
+    exitHandler();
+  }
+  else if (retries > 0)
+  {
+    NdbSleep_MilliSleep(100 + (retries - 1) * 100);
+  }
+  
+  retries++;
+
   NdbTransaction * trans = m_ndb->startTransaction();
   if (trans == NULL) 
   {
-    // TODO: handle the error
-    err << "Cannot start transaction" << endl;
+    errobj = m_ndb->getNdbError();
+    if (errobj.status == NdbError::TemporaryError)
+    {
+      goto retry;
+    }
+    err << "Cannot start transaction: " << errobj << endl;
     exitHandler();
   } // if
   
+  TransGuard g(trans);
   const NdbDictionary::Table * table = get_table(tup.m_table->m_dictTable);
   NdbOperation * op = trans->getNdbOperation(table);
   if (op == NULL) 
@@ -2141,9 +2169,11 @@ BackupRestore::logEntry(const LogEntry &
   {
     // Both insert update and delete can fail during log running
     // and it's ok
-    // TODO: check that the error is either tuple exists or tuple does not exist?
     bool ok= false;
-    NdbError errobj= trans->getNdbError();
+    errobj= trans->getNdbError();
+    if (errobj.status == NdbError::TemporaryError)
+      goto retry;
+
     switch(tup.m_type)
     {
     case LogEntry::LE_INSERT:
@@ -2165,7 +2195,6 @@ BackupRestore::logEntry(const LogEntry &
     }
   }
   
-  m_ndb->closeTransaction(trans);
   m_logBytes+= n_bytes;
   m_logCount++;
 }


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20101021085946-oy5ut4hbcts3rpyk.bundle
Thread
bzr push into mysql-5.1-telco-7.1 branch (jonas:3908 to 3909) Jonas Oreland21 Oct