Commit a20e1b41 authored by joreland@mysql.com's avatar joreland@mysql.com

ndb -

  add abort to multi op test case
parent 4ece8ae4
...@@ -688,7 +688,7 @@ private: ...@@ -688,7 +688,7 @@ private:
void remove_list(NdbOperation*& head, NdbOperation*); void remove_list(NdbOperation*& head, NdbOperation*);
void define_scan_op(NdbIndexScanOperation*); void define_scan_op(NdbIndexScanOperation*);
friend int runOperations(class NDBT_Context*, class NDBT_Step*); friend class HugoOperations;
}; };
inline inline
......
...@@ -30,6 +30,8 @@ public: ...@@ -30,6 +30,8 @@ public:
int closeTransaction(Ndb*); int closeTransaction(Ndb*);
NdbConnection* getTransaction(); NdbConnection* getTransaction();
void refresh(); void refresh();
void setTransactionId(Uint64);
int pkInsertRecord(Ndb*, int pkInsertRecord(Ndb*,
int recordNo, int recordNo,
......
...@@ -103,6 +103,10 @@ OperationTestCase matrix[] = { ...@@ -103,6 +103,10 @@ OperationTestCase matrix[] = {
<< " failed on line " << __LINE__ << endl; \ << " failed on line " << __LINE__ << endl; \
abort(); return NDBT_FAILED; } abort(); return NDBT_FAILED; }
#define C3(b) if (!(b)) { \
g_err << "ERR: failed on line " << __LINE__ << endl; \
return NDBT_FAILED; }
int int
runOp(HugoOperations & hugoOps, runOp(HugoOperations & hugoOps,
Ndb * pNdb, Ndb * pNdb,
...@@ -326,18 +330,122 @@ generate(Vector<int>& out, size_t len) ...@@ -326,18 +330,122 @@ generate(Vector<int>& out, size_t len)
} }
} }
static const Uint32 DUMMY = 0;
static const Uint32 ROW = 1;
int
verify_other(NDBT_Context* ctx,
Ndb* pNdb, int seq, OPS latest, bool initial_row, bool commit)
{
Uint32 no_wait = NdbOperation::LM_CommittedRead*
ctx->getProperty("NoWait", (Uint32)1);
for(size_t j = no_wait; j<3; j++)
{
HugoOperations other(*ctx->getTab());
C3(other.startTransaction(pNdb) == 0);
C3(other.pkReadRecord(pNdb, ROW, 1, (NdbOperation::LockMode)j) == 0);
int tmp= other.execute_Commit(pNdb);
if(seq == 0){
if(j == NdbOperation::LM_CommittedRead)
{
C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626);
}
else
{
C3(tmp == 266);
}
}
else if(commit)
{
switch(latest){
case o_INS:
case o_UPD:
C3(tmp == 0 && other.verifyUpdatesValue(seq) == 0);
break;
case o_DEL:
C3(tmp == 626);
break;
case o_DONE:
abort();
}
}
else
{
// rollback
C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626);
}
}
return NDBT_OK;
}
int
verify_savepoint(NDBT_Context* ctx,
Ndb* pNdb, int seq, OPS latest,
Uint64 transactionId)
{
bool initial_row= (seq == 0) && latest == o_INS;
for(size_t j = 0; j<3; j++)
{
const NdbOperation::LockMode lm= (NdbOperation::LockMode)j;
HugoOperations same(*ctx->getTab());
C3(same.startTransaction(pNdb) == 0);
same.setTransactionId(transactionId); // Cheat
/**
* Increase savepoint to <em>k</em>
*/
for(size_t l = 1; l<=seq; l++)
{
C3(same.pkReadRecord(pNdb, DUMMY, 1, lm) == 0); // Read dummy row
C3(same.execute_NoCommit(pNdb) == 0);
g_info << "savepoint: " << l << endl;
}
g_info << "op(" << seq << "): "
<< " lock mode " << lm << endl;
C3(same.pkReadRecord(pNdb, ROW, 1, lm) == 0); // Read real row
int tmp= same.execute_Commit(pNdb);
if(seq == 0)
{
if(initial_row)
{
C3(tmp == 0 && same.verifyUpdatesValue(0) == 0);
} else
{
C3(tmp == 626);
}
}
else
{
switch(latest){
case o_INS:
case o_UPD:
C3(tmp == 0 && same.verifyUpdatesValue(seq) == 0);
break;
case o_DEL:
C3(tmp == 626);
break;
case o_DONE:
abort();
}
}
}
return NDBT_OK;
}
int int
runOperations(NDBT_Context* ctx, NDBT_Step* step) runOperations(NDBT_Context* ctx, NDBT_Step* step)
{ {
const Uint32 DUMMY = 0;
const Uint32 ROW = 1;
int tmp; int tmp;
Ndb* pNdb = GETNDB(step); Ndb* pNdb = GETNDB(step);
Uint32 seqNo = ctx->getProperty("Sequence", (Uint32)0); Uint32 seqNo = ctx->getProperty("Sequence", (Uint32)0);
Uint32 no_wait = NdbOperation::LM_CommittedRead* Uint32 commit= ctx->getProperty("Commit", (Uint32)1);
ctx->getProperty("NoWait", (Uint32)1);
if(seqNo == 0) if(seqNo == 0)
{ {
...@@ -355,8 +463,8 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step) ...@@ -355,8 +463,8 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
C3(hugoOps.execute_Commit(pNdb) == 0); C3(hugoOps.execute_Commit(pNdb) == 0);
} }
const bool inital_row= (seq[0] != o_INS); const bool initial_row= (seq[0] != o_INS);
if(inital_row) if(initial_row)
{ {
HugoOperations hugoOps(*ctx->getTab()); HugoOperations hugoOps(*ctx->getTab());
C3(hugoOps.startTransaction(pNdb) == 0); C3(hugoOps.startTransaction(pNdb) == 0);
...@@ -389,80 +497,36 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step) ...@@ -389,80 +497,36 @@ runOperations(NDBT_Context* ctx, NDBT_Step* step)
/** /**
* Verify other transaction * Verify other transaction
*/ */
for(size_t j = no_wait; j<3; j++) if(verify_other(ctx, pNdb, 0, seq[0], initial_row, commit) != NDBT_OK)
{ return NDBT_FAILED;
HugoOperations other(*ctx->getTab());
C3(other.startTransaction(pNdb) == 0);
C3(other.pkReadRecord(pNdb, ROW, 1, (NdbOperation::LockMode)j) == 0);
tmp= other.execute_Commit(pNdb);
if(j == NdbOperation::LM_CommittedRead)
{
C3(inital_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626);
}
else
{
C3(tmp == 266);
}
}
/** /**
* Verify savepoint read * Verify savepoint read
*/ */
Uint64 transactionId= trans1.getTransaction()->getTransactionId(); Uint64 transactionId= trans1.getTransaction()->getTransactionId();
for(size_t k=0; k<=i+1; k++) for(size_t k=0; k<=i+1; k++)
{ {
for(size_t j = 0; j<3; j++) if(verify_savepoint(ctx, pNdb, k,
{ k>0 ? seq[k-1] : initial_row ? o_INS : o_DONE,
const NdbOperation::LockMode lm= (NdbOperation::LockMode)j; transactionId) != NDBT_OK)
return NDBT_FAILED;
HugoOperations same(*ctx->getTab()); }
C3(same.startTransaction(pNdb) == 0); }
same.getTransaction()->setTransactionId(transactionId); // Cheat
if(commit)
/** {
* Increase savepoint to <em>k</em> C3(trans1.execute_Commit(pNdb) == 0);
*/ }
for(size_t l = 1; l<=k; l++) else
{ {
C3(same.pkReadRecord(pNdb, DUMMY, 1, lm) == 0); // Read dummy row C3(trans1.execute_Rollback(pNdb) == 0);
C3(same.execute_NoCommit(pNdb) == 0);
g_info << "savepoint: " << l << endl;
}
g_info << "op(" << k << ", " << i << "): "
<< " lock mode " << lm << endl;
C3(same.pkReadRecord(pNdb, ROW, 1, lm) == 0); // Read real row
tmp= same.execute_Commit(pNdb);
if(k == 0)
{
if(inital_row)
{
C3(tmp == 0 && same.verifyUpdatesValue(0) == 0);
} else
{
C3(tmp == 626);
}
}
else
{
switch(seq[k-1]){
case o_INS:
case o_UPD:
C3(tmp == 0 && same.verifyUpdatesValue(k) == 0);
break;
case o_DEL:
C3(tmp == 626);
break;
case o_DONE:
abort();
}
}
}
}
} }
C3(trans1.execute_Commit(pNdb) == 0);
if(verify_other(ctx, pNdb, seq.size(), seq.back(),
initial_row, commit) != NDBT_OK)
return NDBT_FAILED;
return NDBT_OK; return NDBT_OK;
} }
...@@ -495,16 +559,20 @@ main(int argc, const char** argv){ ...@@ -495,16 +559,20 @@ main(int argc, const char** argv){
} }
} }
BaseString n1;
n1.append(name);
n1.append("_COMMIT");
NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts,
name.c_str()+1, ""); n1.c_str()+1, "");
pt->setProperty("Sequence", tmp[i]); pt->setProperty("Sequence", tmp[i]);
pt->addInitializer(new NDBT_Initializer(pt, pt->addInitializer(new NDBT_Initializer(pt,
"runClearTable", "runClearTable",
runClearTable)); runClearTable));
pt->addStep(new NDBT_ParallelStep(pt, pt->addStep(new NDBT_ParallelStep(pt,
name.c_str()+1, "run",
runOperations)); runOperations));
pt->addFinalizer(new NDBT_Finalizer(pt, pt->addFinalizer(new NDBT_Finalizer(pt,
...@@ -512,8 +580,26 @@ main(int argc, const char** argv){ ...@@ -512,8 +580,26 @@ main(int argc, const char** argv){
runClearTable)); runClearTable));
ts.addTest(pt); ts.addTest(pt);
}
name.append("_ABORT");
pt = new NDBT_TestCaseImpl1(&ts, name.c_str()+1, "");
pt->setProperty("Sequence", tmp[i]);
pt->setProperty("Commit", (Uint32)0);
pt->addInitializer(new NDBT_Initializer(pt,
"runClearTable",
runClearTable));
pt->addStep(new NDBT_ParallelStep(pt,
"run",
runOperations));
pt->addFinalizer(new NDBT_Finalizer(pt,
"runClearTable",
runClearTable));
ts.addTest(pt);
}
for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){ for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){
NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, matrix[i].name, ""); NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, matrix[i].name, "");
......
...@@ -32,6 +32,13 @@ int HugoOperations::startTransaction(Ndb* pNdb){ ...@@ -32,6 +32,13 @@ int HugoOperations::startTransaction(Ndb* pNdb){
return NDBT_OK; return NDBT_OK;
} }
void
HugoOperations::setTransactionId(Uint64 id){
if (pTrans != NULL){
pTrans->setTransactionId(id);
}
}
int HugoOperations::closeTransaction(Ndb* pNdb){ int HugoOperations::closeTransaction(Ndb* pNdb){
if (pTrans != NULL){ if (pTrans != NULL){
......
...@@ -92,7 +92,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -92,7 +92,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
if((row.attributeStore(a) = if((row.attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) { pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -102,13 +102,13 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -102,13 +102,13 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
retryAttempt++; retryAttempt++;
continue; continue;
} }
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -127,7 +127,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -127,7 +127,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
while((eof = rs->nextResult(true)) == 0){ while((eof = rs->nextResult(true)) == 0){
rows++; rows++;
if (calc.verifyRowValues(&row) != 0){ if (calc.verifyRowValues(&row) != 0){
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -137,11 +137,11 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -137,11 +137,11 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
rs->close(); rs->close();
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_OK; return NDBT_OK;
} }
} }
...@@ -150,7 +150,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -150,7 +150,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
ERR_INFO(err); ERR_INFO(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
switch (err.code){ switch (err.code){
case 488: case 488:
...@@ -164,17 +164,17 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -164,17 +164,17 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
continue; continue;
} }
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
g_info << rows << " rows have been read" << endl; g_info << rows << " rows have been read" << endl;
if (records != 0 && rows != records){ if (records != 0 && rows != records){
g_err << "Check expected number of records failed" << endl g_err << "Check expected number of records failed" << endl
<< " expected=" << records <<", " << endl << " expected=" << records <<", " << endl
<< " read=" << rows << endl; << " read=" << rows << endl;
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -248,7 +248,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -248,7 +248,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
if((row.attributeStore(a) = if((row.attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) { pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -258,13 +258,13 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -258,13 +258,13 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
retryAttempt++; retryAttempt++;
continue; continue;
} }
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -283,7 +283,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -283,7 +283,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
while((eof = rs->nextResult(true)) == 0){ while((eof = rs->nextResult(true)) == 0){
rows++; rows++;
if (calc.verifyRowValues(&row) != 0){ if (calc.verifyRowValues(&row) != 0){
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -293,11 +293,11 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -293,11 +293,11 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
rs->close(); rs->close();
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_OK; return NDBT_OK;
} }
} }
...@@ -306,7 +306,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -306,7 +306,7 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
ERR_INFO(err); ERR_INFO(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
switch (err.code){ switch (err.code){
case 488: case 488:
...@@ -320,17 +320,17 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -320,17 +320,17 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
continue; continue;
} }
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
g_info << rows << " rows have been read" << endl; g_info << rows << " rows have been read" << endl;
if (records != 0 && rows != records){ if (records != 0 && rows != records){
g_err << "Check expected number of records failed" << endl g_err << "Check expected number of records failed" << endl
<< " expected=" << records <<", " << endl << " expected=" << records <<", " << endl
<< " read=" << rows << endl; << " read=" << rows << endl;
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -344,9 +344,9 @@ HugoTransactions::scanReadRecords(Ndb* pNdb, ...@@ -344,9 +344,9 @@ HugoTransactions::scanReadRecords(Ndb* pNdb,
int int
HugoTransactions::scanUpdateRecords(Ndb* pNdb, HugoTransactions::scanUpdateRecords(Ndb* pNdb,
int records, int records,
int abortPercent, int abortPercent,
int parallelism){ int parallelism){
if(m_defaultScanUpdateMethod == 1){ if(m_defaultScanUpdateMethod == 1){
return scanUpdateRecords1(pNdb, records, abortPercent, parallelism); return scanUpdateRecords1(pNdb, records, abortPercent, parallelism);
} else if(m_defaultScanUpdateMethod == 2){ } else if(m_defaultScanUpdateMethod == 2){
...@@ -707,7 +707,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -707,7 +707,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
while (true){ while (true){
restart: restart:
if (retryAttempt++ >= retryMax){ if (retryAttempt++ >= retryMax){
g_info << "ERROR: has retried this operation " << retryAttempt g_info << "ERROR: has retried this operation " << retryAttempt
<< " times, failing!" << endl; << " times, failing!" << endl;
...@@ -743,7 +743,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -743,7 +743,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
for(a=0; a<tab.getNoOfColumns(); a++){ for(a=0; a<tab.getNoOfColumns(); a++){
if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == NULL){ if((row.attributeStore(a) = pOp->getValue(tab.getColumn(a)->getName())) == NULL){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -752,7 +752,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -752,7 +752,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
if( check == -1 ) { if( check == -1 ) {
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
continue; continue;
...@@ -777,7 +777,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -777,7 +777,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
NdbOperation* pUp = rs->updateTuple(); NdbOperation* pUp = rs->updateTuple();
if(pUp == 0){ if(pUp == 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
const int updates = calc.getUpdatesValue(&row) + 1; const int updates = calc.getUpdatesValue(&row) + 1;
...@@ -786,7 +786,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -786,7 +786,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == false){ if (tab.getColumn(a)->getPrimaryKey() == false){
if(setValueForAttr(pUp, a, r, updates ) != 0){ if(setValueForAttr(pUp, a, r, updates ) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -795,7 +795,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -795,7 +795,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
if (rows == abortCount && abortTrans == true){ if (rows == abortCount && abortTrans == true){
g_info << "Scan is aborted" << endl; g_info << "Scan is aborted" << endl;
// This scan should be aborted // This scan should be aborted
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_OK; return NDBT_OK;
} }
} while((check = rs->nextResult(false)) == 0); } while((check = rs->nextResult(false)) == 0);
...@@ -807,7 +807,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -807,7 +807,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
if( check == -1 ) { if( check == -1 ) {
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
ERR(err); ERR(err);
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
...@@ -819,7 +819,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -819,7 +819,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
if( check == -1 ) { if( check == -1 ) {
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
ERR(err); ERR(err);
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
...@@ -828,7 +828,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb, ...@@ -828,7 +828,7 @@ HugoTransactions::scanUpdateRecords3(Ndb* pNdb,
return NDBT_FAILED; return NDBT_FAILED;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
g_info << rows << " rows have been updated" << endl; g_info << rows << " rows have been updated" << endl;
return NDBT_OK; return NDBT_OK;
...@@ -1772,7 +1772,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, ...@@ -1772,7 +1772,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
pUpdOp = pTrans->getNdbOperation(tab.getName()); pUpdOp = pTrans->getNdbOperation(tab.getName());
if (pUpdOp == NULL) { if (pUpdOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -1788,7 +1788,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, ...@@ -1788,7 +1788,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == true){ if (tab.getColumn(a)->getPrimaryKey() == true){
if(equalForAttr(pUpdOp, a, r) != 0){ if(equalForAttr(pUpdOp, a, r) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -1805,7 +1805,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, ...@@ -1805,7 +1805,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
check = pUpdOp->incValue(attr->getName(), valToIncWith); check = pUpdOp->incValue(attr->getName(), valToIncWith);
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -1817,7 +1817,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, ...@@ -1817,7 +1817,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
(calc.isUpdateCol(a) == false)){ (calc.isUpdateCol(a) == false)){
if(setValueForAttr(pUpdOp, a, r, updates ) != 0){ if(setValueForAttr(pUpdOp, a, r, updates ) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -1846,7 +1846,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, ...@@ -1846,7 +1846,7 @@ HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb,
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
r++; // Read next record r++; // Read next record
...@@ -1900,7 +1900,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, ...@@ -1900,7 +1900,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb,
pOp = pTrans->getNdbOperation(tab.getName()); pOp = pTrans->getNdbOperation(tab.getName());
if (pOp == NULL) { if (pOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -1928,7 +1928,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb, ...@@ -1928,7 +1928,7 @@ HugoTransactions::pkDelRecords(Ndb* pNdb,
switch(err.status){ switch(err.status){
case NdbError::TemporaryError: case NdbError::TemporaryError:
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
retryAttempt++; retryAttempt++;
continue; continue;
...@@ -2066,18 +2066,18 @@ HugoTransactions::lockRecords(Ndb* pNdb, ...@@ -2066,18 +2066,18 @@ HugoTransactions::lockRecords(Ndb* pNdb,
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
retryAttempt++; retryAttempt++;
continue; continue;
} }
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
for (int b=0; (b<lockBatch) && (r+b<records); b++){ for (int b=0; (b<lockBatch) && (r+b<records); b++){
if (calc.verifyRowValues(rows[b]) != 0){ if (calc.verifyRowValues(rows[b]) != 0){
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2178,7 +2178,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2178,7 +2178,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
pOp = pTrans->getNdbIndexOperation(idxName, tab.getName()); pOp = pTrans->getNdbIndexOperation(idxName, tab.getName());
if (pOp == NULL) { if (pOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pOp->readTuple(); check = pOp->readTuple();
...@@ -2186,7 +2186,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2186,7 +2186,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName()); pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName());
if (sOp == NULL) { if (sOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -2196,7 +2196,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2196,7 +2196,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -2205,7 +2205,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2205,7 +2205,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == true){ if (tab.getColumn(a)->getPrimaryKey() == true){
if(equalForAttr(pOp, a, r+b) != 0){ if(equalForAttr(pOp, a, r+b) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2216,7 +2216,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2216,7 +2216,7 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
if((rows[b]->attributeStore(a) = if((rows[b]->attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) { pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2257,11 +2257,11 @@ HugoTransactions::indexReadRecords(Ndb* pNdb, ...@@ -2257,11 +2257,11 @@ HugoTransactions::indexReadRecords(Ndb* pNdb,
if(ordered && rs->nextResult(true) == 0){ if(ordered && rs->nextResult(true) == 0){
ndbout << "Error when comparing records " ndbout << "Error when comparing records "
<< " - index op next_result to many" << endl; << " - index op next_result to many" << endl;
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
} }
deallocRows(); deallocRows();
g_info << reads << " records read" << endl; g_info << reads << " records read" << endl;
...@@ -2322,21 +2322,21 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2322,21 +2322,21 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
pOp = pTrans->getNdbIndexOperation(idxName, tab.getName()); pOp = pTrans->getNdbIndexOperation(idxName, tab.getName());
if (pOp == NULL) { if (pOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
check = pOp->readTupleExclusive(); check = pOp->readTupleExclusive();
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} else { } else {
pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName()); pOp = sOp = pTrans->getNdbIndexScanOperation(idxName, tab.getName());
if (pOp == NULL) { if (pOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -2349,7 +2349,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2349,7 +2349,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == true){ if (tab.getColumn(a)->getPrimaryKey() == true){
if(equalForAttr(pOp, a, r+b) != 0){ if(equalForAttr(pOp, a, r+b) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2371,7 +2371,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2371,7 +2371,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
if( check == -1 ) { if( check == -1 ) {
const NdbError err = pTrans->getNdbError(); const NdbError err = pTrans->getNdbError();
ERR(err); ERR(err);
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
if (err.status == NdbError::TemporaryError){ if (err.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50); NdbSleep_MilliSleep(50);
...@@ -2405,13 +2405,13 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2405,13 +2405,13 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
if (pUpdOp == NULL) { if (pUpdOp == NULL) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -2420,7 +2420,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2420,7 +2420,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == true){ if (tab.getColumn(a)->getPrimaryKey() == true){
if(equalForAttr(pUpdOp, a, r+b) != 0){ if(equalForAttr(pUpdOp, a, r+b) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2431,7 +2431,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2431,7 +2431,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
if (tab.getColumn(a)->getPrimaryKey() == false){ if (tab.getColumn(a)->getPrimaryKey() == false){
if(setValueForAttr(pUpdOp, a, r+b, updates ) != 0){ if(setValueForAttr(pUpdOp, a, r+b, updates ) != 0){
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
return NDBT_FAILED; return NDBT_FAILED;
} }
} }
...@@ -2455,7 +2455,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb, ...@@ -2455,7 +2455,7 @@ HugoTransactions::indexUpdateRecords(Ndb* pNdb,
updated += batchsize; updated += batchsize;
} }
pNdb->closeTransaction(pTrans); closeTransaction(pNdb);
r+= batchsize; // Read next record r+= batchsize; // Read next record
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment