int runInsertRememberGci(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int records = ctx->getNumRecords(); HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); int i = 0; while(ctx->isTestStopped() == false && i < records){ // Insert record and read it in same transaction CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.pkInsertRecord(pNdb, i) == 0); if (hugoOps.execute_NoCommit(pNdb) != 0){ ndbout << "Could not insert record " << i << endl; result = NDBT_FAILED; break; } CHECK(hugoOps.pkReadRecord(pNdb, i) == 0); if (hugoOps.execute_Commit(pNdb) != 0){ ndbout << "Did not find record in DB " << i << endl; result = NDBT_FAILED; break; } savedRecords.push_back(SavedRecord(hugoOps.getRecordGci(0), hugoOps.getRecordStr(0))); CHECK(hugoOps.closeTransaction(pNdb) == 0); i++; }; return result; }
int runScanRefreshNoTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); int maxSleep = (int)(TIMEOUT * 0.3); ndbout << "TransactionInactiveTimeout="<< TIMEOUT << ", maxSleep="<<maxSleep<<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ do{ // Start an insert trans CHECK(hugoOps.startTransaction(pNdb) == 0); int recordNo = records + (stepNo*loops) + l; CHECK(hugoOps.pkInsertRecord(pNdb, recordNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); for (int i = 0; i < 3; i++) { NdbTransaction* pTrans = hugoOps.getTransaction(); Vector<NdbScanOperation*> ops; for (int j = 0; j <= i; j++) { // Perform buddy scan reads NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp != 0); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); ops.push_back(pOp); } CHECK(pTrans->execute(NoCommit) == 0); for (unsigned i = 0; i<TIMEOUT; i += 1000) { pTrans->refresh(); NdbSleep_MilliSleep(1000); } int res; for (unsigned j = 0; j < ops.size(); j++) { while((res = ops[j]->nextResult()) == 0); CHECK(res != -1); } } // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } 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; }
int runPkReadPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int records = ctx->getNumRecords(); Ndb* pNdb = GETNDB(step); int i = 0; HugoOperations hugoOps(*ctx->getTab()); while (ctx->isTestStopped() == false) { g_info << i++ << ": "; int rows = (rand()%records)+1; int batch = (rand()%rows)+1; int row = (records - rows) ? rand() % (records - rows) : 0; int j,k; for(j = 0; j<rows; j += batch) { k = batch; if(j+k > rows) k = rows - j; if(hugoOps.startTransaction(pNdb) != 0) goto err; if(hugoOps.pkReadRecord(pNdb, row+j, k, NdbOperation::LM_Exclusive) != 0) goto err; if(hugoOps.execute_NoCommit(pNdb) != 0) goto err; if(hugoOps.pkUpdateRecord(pNdb, row+j, k, rand()) != 0) goto err; if(hugoOps.execute_Commit(pNdb) != 0) goto err; if(hugoOps.closeTransaction(pNdb) != 0) return NDBT_FAILED; } continue; err: NdbConnection* pCon = hugoOps.getTransaction(); if(pCon == 0) continue; NdbError error = pCon->getNdbError(); hugoOps.closeTransaction(pNdb); if (error.status == NdbError::TemporaryError){ NdbSleep_MilliSleep(50); continue; } return NDBT_FAILED; } return NDBT_OK; }
/* Producer thread */ int runV2MultiWait_Producer(NDBT_Context* ctx, NDBT_Step* step, int thd_id, int nthreads) { int records = ctx->getNumRecords(); HugoOperations hugoOps(*ctx->getTab()); /* For three threads (2 producers + 1 consumer) we loop 0-7. producer 0 is slow if (loop & 1) producer 1 is slow if (loop & 2) consumer is slow if (loop & 4) */ for (int loop = 0; loop < V2_NLOOPS; loop++) { ctx->getPropertyWait("LOOP", loop+1); bool slow = loop & (thd_id+1); for (int j=0; j < records; j++) { if(j % nthreads == thd_id) { Ndb* ndb = global_ndb_pool->getNdb(); NdbTransaction* trans = ndb->startTransaction(); check(trans != NULL, (*ndb)); ndb->setCustomData(trans); NdbOperation* readOp = trans->getNdbOperation(ctx->getTab()); check(readOp != NULL, (*trans)); check(readOp->readTuple() == 0, (*readOp)); check(hugoOps.equalForRow(readOp, j) == 0, hugoOps); /* Read all other cols */ for (int k=0; k < ctx->getTab()->getNoOfColumns(); k++) { check(readOp->getValue(ctx->getTab()->getColumn(k)) != NULL, (*readOp)); } trans->executeAsynchPrepare(NdbTransaction::Commit, NULL, NULL, NdbOperation::AbortOnError); ndb->sendPreparedTransactions(); global_poll_group->push(ndb); if(slow) { int tm = myRandom48(3) * myRandom48(3); if(tm) NdbSleep_MilliSleep(tm); } } } } return NDBT_OK; }
int runBuddyTransNoTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); int maxSleep = (int)(TIMEOUT * 0.3); ndbout << "TransactionInactiveTimeout="<< TIMEOUT << ", maxSleep="<<maxSleep<<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ do{ // Start an insert trans CHECK(hugoOps.startTransaction(pNdb) == 0); int recordNo = records + (stepNo*loops) + l; CHECK(hugoOps.pkInsertRecord(pNdb, recordNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); int remain = maxSleep; for (int i = 0; i < 3; i++) { NdbTransaction* pTrans = hugoOps.getTransaction(); // Perform buddy scan reads NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp != 0); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); CHECK(pTrans->execute(NoCommit) == 0); while(pOp->nextResult() == 0); int sleep = myRandom48(remain); remain = remain - sleep + 1; ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); } // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runPkReadMultiWakeupT2(NDBT_Context* ctx, NDBT_Step* step) { ndbout << "Thread 2 : Waiting for phase 1 notification from Thread 1" << endl; ctx->getPropertyWait("PHASE", 1); /* Ok, now thread 1 has locked row 1, we'll attempt to read * it, using the multi_ndb_wait Api to block */ HugoOperations hugoOps(*ctx->getTab()); Ndb* ndb = GETNDB(step); ndbout << "Thread 2 : Starting async transaction to read row" << endl; check(hugoOps.startTransaction(ndb) == 0, hugoOps); check(hugoOps.pkReadRecord(ndb, 0, 1, NdbOperation::LM_Exclusive) == 0, hugoOps); /* Prepare, Send */ check(hugoOps.execute_async(ndb, NdbTransaction::Commit, NdbOperation::AbortOnError) == 0, hugoOps); global_poll_group->addNdb(ndb); Ndb ** ready_ndbs; int wait_rc = 0; int acknowledged = 0; do { ndbout << "Thread 2 : Calling NdbWaitGroup::wait()" << endl; wait_rc = global_poll_group->wait(ready_ndbs, 10000); ndbout << " Result : " << wait_rc << endl; if (wait_rc == 0) { if (!acknowledged) { ndbout << "Thread 2 : Woken up, moving to phase 2" << endl; ctx->incProperty("PHASE"); acknowledged = 1; } } else if (wait_rc > 0) { ndbout << "Thread 2 : Transaction completed" << endl; ndb->pollNdb(1,0); hugoOps.closeTransaction(ndb); } } while (wait_rc == 0); return (wait_rc == 1 ? NDBT_OK : NDBT_FAILED); }
int runBug20185(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); NdbRestarter restarter; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); int dump[] = { 7090, 20 } ; if (restarter.dumpStateAllNodes(dump, 2)) return NDBT_FAILED; NdbSleep_MilliSleep(3000); if(hugoOps.startTransaction(pNdb) != 0) return NDBT_FAILED; if(hugoOps.pkUpdateRecord(pNdb, 1, 1) != 0) return NDBT_FAILED; if (hugoOps.execute_NoCommit(pNdb) != 0) return NDBT_FAILED; int nodeId; const int node = hugoOps.getTransaction()->getConnectedNodeId(); do { nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes()); } while (nodeId == node); if (restarter.insertErrorInAllNodes(7030)) return NDBT_FAILED; if (restarter.insertErrorInNode(nodeId, 7031)) return NDBT_FAILED; NdbSleep_MilliSleep(500); if (hugoOps.execute_Commit(pNdb) == 0) return NDBT_FAILED; NdbSleep_MilliSleep(3000); restarter.waitClusterStarted(); if (restarter.dumpStateAllNodes(dump, 1)) return NDBT_FAILED; return NDBT_OK; }
int runDirtyRead(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); NdbRestarter restarter; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); int i = 0; while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){ g_info << i << ": "; int id = i % restarter.getNumDbNodes(); int nodeId = restarter.getDbNodeId(id); ndbout << "Restart node " << nodeId << endl; restarter.insertErrorInNode(nodeId, 5041); restarter.insertErrorInAllNodes(8048 + (i & 1)); for(int j = 0; j<records; j++){ if(hugoOps.startTransaction(pNdb) != 0) return NDBT_FAILED; if(hugoOps.pkReadRecord(pNdb, j, 1, NdbOperation::LM_CommittedRead) != 0) goto err; int res; if((res = hugoOps.execute_Commit(pNdb)) == 4119) goto done; if(res != 0) goto err; if(hugoOps.closeTransaction(pNdb) != 0) return NDBT_FAILED; } done: if(hugoOps.closeTransaction(pNdb) != 0) return NDBT_FAILED; i++; restarter.waitClusterStarted(60) ; } return result; err: hugoOps.closeTransaction(pNdb); return NDBT_FAILED; }
int runPkReadMultiWakeupT1(NDBT_Context* ctx, NDBT_Step* step) { HugoOperations hugoOps(*ctx->getTab()); Ndb* ndb = GETNDB(step); Uint32 phase = ctx->getProperty("PHASE"); if (phase != 0) { ndbout << "Thread 1 : Error, initial phase should be 0 not " << phase << endl; return NDBT_FAILED; }; /* We now start a transaction, locking row 0 */ ndbout << "Thread 1 : Starting transaction locking row 0..." << endl; check(hugoOps.startTransaction(ndb) == 0, hugoOps); check(hugoOps.pkReadRecord(ndb, 0, 1, NdbOperation::LM_Exclusive) == 0, hugoOps); check(hugoOps.execute_NoCommit(ndb) == 0, hugoOps); ndbout << "Thread 1 : Lock taken." << endl; ndbout << "Thread 1 : Triggering Thread 2 by move to phase 1" << endl; /* Ok, now get thread 2 to try to read row */ ctx->incProperty("PHASE"); /* Set to 1 */ /* Here, loop waking up waiter on the cluster connection */ /* Check the property has not moved to phase 2 */ ndbout << "Thread 1 : Performing async wakeup until phase changes to 2" << endl; while (ctx->getProperty("PHASE") != 2) { global_poll_group->wakeup(); NdbSleep_MilliSleep(500); } ndbout << "Thread 1 : Phase changed to 2, committing transaction " << "and releasing lock" << endl; /* Ok, give them a break, commit transaction */ check(hugoOps.execute_Commit(ndb) ==0, hugoOps); hugoOps.closeTransaction(ndb); ndbout << "Thread 1 : Finished" << endl; return NDBT_OK; }
int runDeadlockTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int stepNo = step->getStepNo(); Uint32 deadlock_timeout; NdbConfig conf(GETNDB(step)->getNodeId()+1); unsigned int nodeId = conf.getMasterNodeId(); if (!conf.getProperty(nodeId, NODE_TYPE_DB, CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, &deadlock_timeout)){ return NDBT_FAILED; } int do_sleep = (int)(deadlock_timeout * 0.5); HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 0; l < loops && result == NDBT_OK; l++){ do{ // Commit transaction CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.pkReadRecord(pNdb, stepNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); int sleep = deadlock_timeout * 1.5 + myRandom48(do_sleep); ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runBug15685(NDBT_Context* ctx, NDBT_Step* step){ Ndb* pNdb = GETNDB(step); HugoOperations hugoOps(*ctx->getTab()); NdbRestarter restarter; HugoTransactions hugoTrans(*ctx->getTab()); if (hugoTrans.loadTable(GETNDB(step), 10) != 0){ return NDBT_FAILED; } if(hugoOps.startTransaction(pNdb) != 0) goto err; if(hugoOps.pkUpdateRecord(pNdb, 0, 1, rand()) != 0) goto err; if(hugoOps.execute_NoCommit(pNdb) != 0) goto err; if (restarter.insertErrorInAllNodes(5100)) return NDBT_FAILED; hugoOps.execute_Rollback(pNdb); if (restarter.waitClusterStarted() != 0) goto err; if (restarter.insertErrorInAllNodes(0)) return NDBT_FAILED; ctx->stopTest(); return NDBT_OK; err: ctx->stopTest(); return NDBT_FAILED; }
int runBuddyTransTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); ndbout << "TransactionInactiveTimeout="<< TIMEOUT <<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ NdbTransaction* pTrans = 0; do{ pTrans = pNdb->startTransaction(); NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); CHECK(pTrans->execute(NoCommit) == 0); int sleep = 2 * TIMEOUT; ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); int res = 0; while((res = pOp->nextResult()) == 0); ndbout_c("res: %d", res); CHECK(res == -1); } while(false); if (pTrans) { pTrans->close(); } } return result; }
int runDontTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int stepNo = step->getStepNo(); int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); int maxSleep = (int)(timeout * 0.5); ndbout << "TransactionInactiveTimeout="<< timeout << ", maxSleep="<<maxSleep<<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 0; l < loops && result == NDBT_OK; l++){ do{ // Commit transaction CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.pkReadRecord(pNdb, stepNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); int sleep = myRandom48(maxSleep); ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runPkReadMultiBasic(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); const int MAX_NDBS = 200; Ndb* pNdb = GETNDB(step); Ndb_cluster_connection* conn = &pNdb->get_ndb_cluster_connection(); int i = 0; HugoOperations hugoOps(*ctx->getTab()); Ndb* ndbObjs[ MAX_NDBS ]; NdbTransaction* transArray[ MAX_NDBS ]; Ndb ** ready_ndbs; for (int j=0; j < MAX_NDBS; j++) { Ndb* ndb = new Ndb(conn); check(ndb->init() == 0, (*ndb)); ndbObjs[ j ] = ndb; } while (i<loops) { ndbout << "Loop : " << i << ": "; int recordsLeft = records; do { /* Define and execute Pk read requests on * different Ndb objects */ int ndbcnt = 0; int pollcnt = 0; int lumpsize = 1 + myRandom48(MIN(recordsLeft, MAX_NDBS)); while(lumpsize && recordsLeft && ndbcnt < MAX_NDBS) { Ndb* ndb = ndbObjs[ ndbcnt ]; NdbTransaction* trans = ndb->startTransaction(); check(trans != NULL, (*ndb)); NdbOperation* readOp = trans->getNdbOperation(ctx->getTab()); check(readOp != NULL, (*trans)); check(readOp->readTuple() == 0, (*readOp)); check(hugoOps.equalForRow(readOp, recordsLeft) == 0, hugoOps); /* Read all other cols */ for (int k=0; k < ctx->getTab()->getNoOfColumns(); k++) { check(readOp->getValue(ctx->getTab()->getColumn(k)) != NULL, (*readOp)); } /* Now send em off */ trans->executeAsynchPrepare(NdbTransaction::Commit, NULL, NULL, NdbOperation::AbortOnError); ndb->sendPreparedTransactions(); transArray[ndbcnt] = trans; global_poll_group->addNdb(ndb); ndbcnt++; pollcnt++; recordsLeft--; lumpsize--; }; /* Ok, now wait for the Ndbs to complete */ while (pollcnt) { /* Occasionally check with no timeout */ Uint32 timeout_millis = myRandom48(2)?10000:0; int count = global_poll_group->wait(ready_ndbs, timeout_millis); if (count > 0) { for (int y=0; y < count; y++) { Ndb *ndb = ready_ndbs[y]; check(ndb->pollNdb(0, 1) != 0, (*ndb)); } pollcnt -= count; } } /* Ok, now close the transactions */ for (int t=0; t < ndbcnt; t++) { transArray[t]->close(); } } while (recordsLeft); i++; } for (int j=0; j < MAX_NDBS; j++) { delete ndbObjs[ j ]; } return NDBT_OK; }
int runVerifyInserts(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; Ndb* pNdb = GETNDB(step); UtilTransactions utilTrans(*ctx->getTab()); HugoOperations hugoOps(*ctx->getTab()); NdbRestarter restarter; int restartGCI = pNdb->NdbTamper(Ndb::ReadRestartGCI, 0); ndbout << "restartGCI = " << restartGCI << endl; int count = 0; if (utilTrans.selectCount(pNdb, 64, &count) != 0){ return NDBT_FAILED; } // RULE1: The vector with saved records should have exactly as many // records with lower or same gci as there are in DB int recordsWithLowerOrSameGci = 0; unsigned i; for (i = 0; i < savedRecords.size(); i++){ if (savedRecords[i].m_gci <= restartGCI) recordsWithLowerOrSameGci++; } if (recordsWithLowerOrSameGci != count){ ndbout << "ERR: Wrong number of expected records" << endl; result = NDBT_FAILED; } // RULE2: The records found in db should have same or lower // gci as in the vector for (i = 0; i < savedRecords.size(); i++){ CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.pkReadRecord(pNdb, i) == 0); if (hugoOps.execute_Commit(pNdb) != 0){ // Record was not found in db' // Check record gci if (savedRecords[i].m_gci <= restartGCI){ ndbout << "ERR: Record "<<i<<" should have existed" << endl; result = NDBT_FAILED; } } else { // Record was found in db BaseString str = hugoOps.getRecordStr(0); // Check record string if (!(savedRecords[i].m_str == str)){ ndbout << "ERR: Record "<<i<<" str did not match "<< endl; result = NDBT_FAILED; } // Check record gci if (savedRecords[i].m_gci > restartGCI){ ndbout << "ERR: Record "<<i<<" should not have existed" << endl; result = NDBT_FAILED; } } CHECK(hugoOps.closeTransaction(pNdb) == 0); } ndbout << "There are " << count << " records in db" << endl; ndbout << "There are " << savedRecords.size() << " records in vector" << endl; ndbout << "There are " << recordsWithLowerOrSameGci << " records with lower or same gci than " << restartGCI << endl; return result; }
int runTimeoutTrans2(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int stepNo = step->getStepNo(); int mul1 = ctx->getProperty("Op1", (Uint32)0); int mul2 = ctx->getProperty("Op2", (Uint32)0); int records = ctx->getNumRecords(); int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); int minSleep = (int)(timeout * 1.5); int maxSleep = timeout * 2; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 0; l<loops && !ctx->isTestStopped() && result == NDBT_OK; l++){ int op1 = 0 + (l + stepNo) * mul1; int op2 = 0 + (l + stepNo) * mul2; op1 = (op1 % 5); op2 = (op2 % 5); ndbout << stepNo << ": TransactionInactiveTimeout="<< timeout << ", minSleep="<<minSleep << ", maxSleep="<<maxSleep << ", op1=" << op1 << ", op2=" << op2 << endl;; do{ // Commit transaction CHECK(hugoOps.startTransaction(pNdb) == 0); switch(op1){ case 0: break; case 1: if(hugoOps.pkReadRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 2: if(hugoOps.pkUpdateRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 3: if(hugoOps.pkDeleteRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 4: if(hugoOps.pkInsertRecord(pNdb, stepNo+records+l) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; } if(result != NDBT_OK) break; int res = hugoOps.execute_NoCommit(pNdb); if(res != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } int sleep = minSleep + myRandom48(maxSleep-minSleep); ndbout << stepNo << ": Sleeping for "<< sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); switch(op2){ case 0: break; case 1: if(hugoOps.pkReadRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 2: if(hugoOps.pkUpdateRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 3: if(hugoOps.pkDeleteRecord(pNdb, stepNo) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; case 4: if(hugoOps.pkInsertRecord(pNdb, stepNo+2*records+l) != 0){ g_err << stepNo << ": Fail" << __LINE__ << endl; result = NDBT_FAILED; break; } break; } // Expect that transaction has timed-out res = hugoOps.execute_Commit(pNdb); if(op1 != 0 && res != 266){ g_err << stepNo << ": Fail: " << res << "!= 237, op1=" << op1 << ", op2=" << op2 << endl; result = NDBT_FAILED; break; } } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runLateCommit(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); NdbRestarter restarter; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); int i = 0; while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){ g_info << i << ": "; if(hugoOps.startTransaction(pNdb) != 0) return NDBT_FAILED; if(hugoOps.pkUpdateRecord(pNdb, 1, 128) != 0) return NDBT_FAILED; if(hugoOps.execute_NoCommit(pNdb) != 0) return NDBT_FAILED; Uint32 transNode= hugoOps.getTransaction()->getConnectedNodeId(); int id = i % restarter.getNumDbNodes(); int nodeId; while((nodeId = restarter.getDbNodeId(id)) == transNode) id = (id + 1) % restarter.getNumDbNodes(); ndbout << "Restart node " << nodeId << endl; restarter.restartOneDbNode(nodeId, /** initial */ false, /** nostart */ true, /** abort */ true); restarter.waitNodesNoStart(&nodeId, 1); int res; if(i & 1) res= hugoOps.execute_Commit(pNdb); else res= hugoOps.execute_Rollback(pNdb); ndbout_c("res= %d", res); hugoOps.closeTransaction(pNdb); restarter.startNodes(&nodeId, 1); restarter.waitNodesStarted(&nodeId, 1); if(i & 1) { if(res != 286) return NDBT_FAILED; } else { if(res != 0) return NDBT_FAILED; } i++; } return NDBT_OK; }
int runBug18414(NDBT_Context* ctx, NDBT_Step* step){ NdbRestarter restarter; if (restarter.getNumDbNodes() < 2) { ctx->stopTest(); return NDBT_OK; } Ndb* pNdb = GETNDB(step); HugoOperations hugoOps(*ctx->getTab()); HugoTransactions hugoTrans(*ctx->getTab()); int loop = 0; do { if(hugoOps.startTransaction(pNdb) != 0) goto err; if(hugoOps.pkUpdateRecord(pNdb, 0, 128, rand()) != 0) goto err; if(hugoOps.execute_NoCommit(pNdb) != 0) goto err; int node1 = hugoOps.getTransaction()->getConnectedNodeId(); int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand()); if (node1 == -1 || node2 == -1) break; if (loop & 1) { if (restarter.insertErrorInNode(node1, 8050)) goto err; } int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 }; if (restarter.dumpStateOneNode(node2, val2, 2)) goto err; if (restarter.insertErrorInNode(node2, 5003)) goto err; int res= hugoOps.execute_Rollback(pNdb); if (restarter.waitNodesNoStart(&node2, 1) != 0) goto err; if (restarter.insertErrorInAllNodes(0)) goto err; if (restarter.startNodes(&node2, 1) != 0) goto err; if (restarter.waitClusterStarted() != 0) goto err; if (hugoTrans.scanUpdateRecords(pNdb, 128) != 0) goto err; hugoOps.closeTransaction(pNdb); } while(++loop < 5); return NDBT_OK; err: hugoOps.closeTransaction(pNdb); return NDBT_FAILED; }