Commit 46b2eae0 authored by joreland@mysql.com's avatar joreland@mysql.com

Test prg update

- make test node restart test harder
parent 07359aef
...@@ -3379,8 +3379,6 @@ void Dbtc::releaseSimpleRead(Signal* signal, ...@@ -3379,8 +3379,6 @@ void Dbtc::releaseSimpleRead(Signal* signal,
(state == CS_START_COMMITTING ? CS_CONNECTED : state); (state == CS_START_COMMITTING ? CS_CONNECTED : state);
setApiConTimer(regApiPtr.i, 0, __LINE__); setApiConTimer(regApiPtr.i, 0, __LINE__);
if(state != regApiPtr.p->apiConnectstate)
ndbout_c("resettting state from %d to %d", state, regApiPtr.p->apiConnectstate);
return; return;
} }
......
...@@ -38,16 +38,8 @@ public: ...@@ -38,16 +38,8 @@ public:
int pkReadRecord(Ndb*, int pkReadRecord(Ndb*,
int recordNo, int recordNo,
bool exclusive = false, int numRecords = 1,
int numRecords = 1); NdbOperation::LockMode lm = NdbOperation::LM_Read);
int pkSimpleReadRecord(Ndb*,
int recordNo,
int numRecords = 1);
int pkDirtyReadRecord(Ndb*,
int recordNo,
int numRecords = 1);
int pkUpdateRecord(Ndb*, int pkUpdateRecord(Ndb*,
int recordNo, int recordNo,
......
...@@ -48,8 +48,8 @@ public: ...@@ -48,8 +48,8 @@ public:
int pkReadRecords(Ndb*, int pkReadRecords(Ndb*,
int records, int records,
int batchsize = 1, int batchsize = 1,
bool dirty = false); NdbOperation::LockMode = NdbOperation::LM_Read);
int scanUpdateRecords(Ndb*, int scanUpdateRecords(Ndb*,
int records, int records,
int abort = 0, int abort = 0,
......
...@@ -160,8 +160,8 @@ int runPkDirtyRead(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -160,8 +160,8 @@ int runPkDirtyRead(NDBT_Context* ctx, NDBT_Step* step){
HugoTransactions hugoTrans(*ctx->getTab()); HugoTransactions hugoTrans(*ctx->getTab());
while (i<loops) { while (i<loops) {
g_info << i << ": "; g_info << i << ": ";
if (hugoTrans.pkReadRecords(GETNDB(step), records, if (hugoTrans.pkReadRecords(GETNDB(step), records, batchSize,
batchSize, dirty) != NDBT_OK){ NdbOperation::LM_CommittedRead) != NDBT_OK){
g_info << endl; g_info << endl;
return NDBT_FAILED; return NDBT_FAILED;
} }
...@@ -736,7 +736,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -736,7 +736,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){
// Read value and save it for later // Read value and save it for later
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 1, false, numRecords) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 1, numRecords) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 0); CHECK(hugoOps.execute_Commit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); // Update value 0 CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); // Update value 0
CHECK(hugoOps.closeTransaction(pNdb) == 0); CHECK(hugoOps.closeTransaction(pNdb) == 0);
...@@ -747,7 +747,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -747,7 +747,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
// Check record is updated // Check record is updated
CHECK(hugoOps.pkReadRecord(pNdb, 1, true, numRecords) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 1, numRecords, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(5) == NDBT_OK); // Updates value 5 CHECK(hugoOps.verifyUpdatesValue(5) == NDBT_OK); // Updates value 5
CHECK(hugoOps.execute_Rollback(pNdb) == 0); CHECK(hugoOps.execute_Rollback(pNdb) == 0);
...@@ -756,7 +756,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -756,7 +756,7 @@ int runCheckRollbackUpdate(NDBT_Context* ctx, NDBT_Step* step){
// Check record is back to original value // Check record is back to original value
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 1, true, numRecords) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 1, numRecords, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 0); CHECK(hugoOps.execute_Commit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); // Updates value 0 CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); // Updates value 0
...@@ -775,7 +775,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -775,7 +775,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
do{ do{
// Read value and save it for later // Read value and save it for later
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, false, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 0); CHECK(hugoOps.execute_Commit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK);
CHECK(hugoOps.closeTransaction(pNdb) == 0); CHECK(hugoOps.closeTransaction(pNdb) == 0);
...@@ -785,7 +785,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -785,7 +785,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
for(Uint32 i = 0; i<1; i++){ for(Uint32 i = 0; i<1; i++){
// Read record 5 - 10 // Read record 5 - 10
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
for(j = 0; j<10; j++){ for(j = 0; j<10; j++){
...@@ -794,7 +794,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -794,7 +794,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
CHECK(hugoOps.pkUpdateRecord(pNdb, 5, 10, updatesValue) == 0); CHECK(hugoOps.pkUpdateRecord(pNdb, 5, 10, updatesValue) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(updatesValue) == 0); CHECK(hugoOps.verifyUpdatesValue(updatesValue) == 0);
} }
...@@ -806,7 +806,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -806,7 +806,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
#if 0 #if 0
// Check records are deleted // Check records are deleted
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 626); CHECK(hugoOps.execute_NoCommit(pNdb) == 626);
#endif #endif
...@@ -814,7 +814,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -814,7 +814,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
CHECK(hugoOps.pkInsertRecord(pNdb, 5, 10, updatesValue) == 0); CHECK(hugoOps.pkInsertRecord(pNdb, 5, 10, updatesValue) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(updatesValue) == 0); CHECK(hugoOps.verifyUpdatesValue(updatesValue) == 0);
} }
...@@ -823,7 +823,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -823,7 +823,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
// Check records are deleted // Check records are deleted
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 626); CHECK(hugoOps.execute_NoCommit(pNdb) == 626);
CHECK(hugoOps.execute_Rollback(pNdb) == 0); CHECK(hugoOps.execute_Rollback(pNdb) == 0);
...@@ -833,7 +833,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -833,7 +833,7 @@ int runCheckRollbackDeleteMultiple(NDBT_Context* ctx, NDBT_Step* step){
// Check records are not deleted // Check records are not deleted
// after rollback // after rollback
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 0); CHECK(hugoOps.execute_Commit(pNdb) == 0);
CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK); CHECK(hugoOps.verifyUpdatesValue(0) == NDBT_OK);
...@@ -889,7 +889,7 @@ int runCheckCommitDelete(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -889,7 +889,7 @@ int runCheckCommitDelete(NDBT_Context* ctx, NDBT_Step* step){
do{ do{
// Read 10 records // Read 10 records
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_NoCommit(pNdb) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
// Update 10 records // Update 10 records
...@@ -905,7 +905,7 @@ int runCheckCommitDelete(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -905,7 +905,7 @@ int runCheckCommitDelete(NDBT_Context* ctx, NDBT_Step* step){
// Check record's are deleted // Check record's are deleted
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 626); CHECK(hugoOps.execute_Commit(pNdb) == 626);
}while(false); }while(false);
...@@ -930,7 +930,7 @@ int runRollbackNothing(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -930,7 +930,7 @@ int runRollbackNothing(NDBT_Context* ctx, NDBT_Step* step){
// Check records are not deleted // Check records are not deleted
CHECK(hugoOps.startTransaction(pNdb) == 0); CHECK(hugoOps.startTransaction(pNdb) == 0);
CHECK(hugoOps.pkReadRecord(pNdb, 5, true, 10) == 0); CHECK(hugoOps.pkReadRecord(pNdb, 5, 10, NdbOperation::LM_Exclusive) == 0);
CHECK(hugoOps.execute_Commit(pNdb) == 0); CHECK(hugoOps.execute_Commit(pNdb) == 0);
CHECK(hugoOps.closeTransaction(pNdb) == 0); CHECK(hugoOps.closeTransaction(pNdb) == 0);
......
...@@ -229,7 +229,7 @@ int runTestMaxOperations(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -229,7 +229,7 @@ int runTestMaxOperations(NDBT_Context* ctx, NDBT_Step* step){
int i = 0; int i = 0;
while (errors < maxErrors){ while (errors < maxErrors){
if(hugoOps.pkReadRecord(pNdb,1, false, 1) != NDBT_OK){ if(hugoOps.pkReadRecord(pNdb,1, 1) != NDBT_OK){
errors++; errors++;
continue; continue;
} }
......
...@@ -100,11 +100,16 @@ int runScanReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -100,11 +100,16 @@ int runScanReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
int runPkReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ int runPkReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK; int result = NDBT_OK;
int records = ctx->getNumRecords(); int records = ctx->getNumRecords();
NdbOperation::LockMode lm =
(NdbOperation::LockMode)ctx->getProperty("ReadLockMode",
(Uint32)NdbOperation::LM_Read);
int i = 0; int i = 0;
HugoTransactions hugoTrans(*ctx->getTab()); HugoTransactions hugoTrans(*ctx->getTab());
while (ctx->isTestStopped() == false) { while (ctx->isTestStopped() == false) {
g_info << i << ": "; g_info << i << ": ";
if (hugoTrans.pkReadRecords(GETNDB(step), records, 128) != 0){ int rows = (rand()%records)+1;
int batch = (rand()%rows)+1;
if (hugoTrans.pkReadRecords(GETNDB(step), rows, batch, lm) != 0){
return NDBT_FAILED; return NDBT_FAILED;
} }
i++; i++;
...@@ -119,7 +124,9 @@ int runPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -119,7 +124,9 @@ int runPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
HugoTransactions hugoTrans(*ctx->getTab()); HugoTransactions hugoTrans(*ctx->getTab());
while (ctx->isTestStopped() == false) { while (ctx->isTestStopped() == false) {
g_info << i << ": "; g_info << i << ": ";
if (hugoTrans.pkUpdateRecords(GETNDB(step), records) != 0){ int rows = (rand()%records)+1;
int batch = (rand()%rows)+1;
if (hugoTrans.pkUpdateRecords(GETNDB(step), rows, batch) != 0){
return NDBT_FAILED; return NDBT_FAILED;
} }
i++; i++;
...@@ -127,6 +134,60 @@ int runPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -127,6 +134,60 @@ int runPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
return result; 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;
}
int runScanUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){ int runScanUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK; int result = NDBT_OK;
int records = ctx->getNumRecords(); int records = ctx->getNumRecords();
...@@ -178,7 +239,7 @@ int runRestarter(NDBT_Context* ctx, NDBT_Step* step){ ...@@ -178,7 +239,7 @@ int runRestarter(NDBT_Context* ctx, NDBT_Step* step){
int id = lastId % restarter.getNumDbNodes(); int id = lastId % restarter.getNumDbNodes();
int nodeId = restarter.getDbNodeId(id); int nodeId = restarter.getDbNodeId(id);
ndbout << "Restart node " << nodeId << endl; ndbout << "Restart node " << nodeId << endl;
if(restarter.restartOneDbNode(nodeId) != 0){ if(restarter.restartOneDbNode(nodeId, false, false, true) != 0){
g_err << "Failed to restartNextDbNode" << endl; g_err << "Failed to restartNextDbNode" << endl;
result = NDBT_FAILED; result = NDBT_FAILED;
break; break;
...@@ -246,6 +307,27 @@ TESTCASE("NoLoad", ...@@ -246,6 +307,27 @@ TESTCASE("NoLoad",
TESTCASE("PkRead", TESTCASE("PkRead",
"Test that one node at a time can be stopped and then restarted "\ "Test that one node at a time can be stopped and then restarted "\
"perform pk read while restarting. Do this loop number of times"){ "perform pk read while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);
INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable);
STEP(runRestarter);
STEP(runPkReadUntilStopped);
FINALIZER(runClearTable);
}
TESTCASE("PkReadCommitted",
"Test that one node at a time can be stopped and then restarted "\
"perform pk read while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", NdbOperation::LM_CommittedRead);
INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable);
STEP(runRestarter);
STEP(runPkReadUntilStopped);
FINALIZER(runClearTable);
}
TESTCASE("MixedPkRead",
"Test that one node at a time can be stopped and then restarted "\
"perform pk read while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", -1);
INITIALIZER(runCheckAllNodesStarted); INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable); INITIALIZER(runLoadTable);
STEP(runRestarter); STEP(runRestarter);
...@@ -255,14 +337,31 @@ TESTCASE("PkRead", ...@@ -255,14 +337,31 @@ TESTCASE("PkRead",
TESTCASE("PkReadPkUpdate", TESTCASE("PkReadPkUpdate",
"Test that one node at a time can be stopped and then restarted "\ "Test that one node at a time can be stopped and then restarted "\
"perform pk read and pk update while restarting. Do this loop number of times"){ "perform pk read and pk update while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);
INITIALIZER(runCheckAllNodesStarted); INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable); INITIALIZER(runLoadTable);
STEP(runRestarter); STEP(runRestarter);
STEP(runPkReadUntilStopped); STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
STEP(runPkReadUntilStopped); STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
FINALIZER(runClearTable);
}
TESTCASE("MixedPkReadPkUpdate",
"Test that one node at a time can be stopped and then restarted "\
"perform pk read and pk update while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", -1);
INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable);
STEP(runRestarter);
STEP(runPkReadUntilStopped); STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
STEP(runPkReadUntilStopped); STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped); STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
FINALIZER(runClearTable); FINALIZER(runClearTable);
} }
TESTCASE("ReadUpdateScan", TESTCASE("ReadUpdateScan",
...@@ -273,6 +372,21 @@ TESTCASE("ReadUpdateScan", ...@@ -273,6 +372,21 @@ TESTCASE("ReadUpdateScan",
STEP(runRestarter); STEP(runRestarter);
STEP(runPkReadUntilStopped); STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped); STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
STEP(runScanReadUntilStopped);
STEP(runScanUpdateUntilStopped);
FINALIZER(runClearTable);
}
TESTCASE("MixedReadUpdateScan",
"Test that one node at a time can be stopped and then restarted "\
"perform pk read, pk update and scan reads while restarting. Do this loop number of times"){
TC_PROPERTY("ReadLockMode", -1);
INITIALIZER(runCheckAllNodesStarted);
INITIALIZER(runLoadTable);
STEP(runRestarter);
STEP(runPkReadUntilStopped);
STEP(runPkUpdateUntilStopped);
STEP(runPkReadPkUpdateUntilStopped);
STEP(runScanReadUntilStopped); STEP(runScanReadUntilStopped);
STEP(runScanUpdateUntilStopped); STEP(runScanUpdateUntilStopped);
FINALIZER(runClearTable); FINALIZER(runClearTable);
......
...@@ -110,13 +110,13 @@ runOp(HugoOperations & hugoOps, ...@@ -110,13 +110,13 @@ runOp(HugoOperations & hugoOps,
return NDBT_FAILED; }} return NDBT_FAILED; }}
if(strcmp(op, "READ") == 0){ if(strcmp(op, "READ") == 0){
C2(hugoOps.pkReadRecord(pNdb, 1, false, 1), 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read), 0);
} else if(strcmp(op, "READ-EX") == 0){ } else if(strcmp(op, "READ-EX") == 0){
C2(hugoOps.pkReadRecord(pNdb, 1, true, 1), 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Exclusive), 0);
} else if(strcmp(op, "S-READ") == 0){ } else if(strcmp(op, "S-READ") == 0){
C2(hugoOps.pkSimpleReadRecord(pNdb, 1, 1), 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read), 0);
} else if(strcmp(op, "D-READ") == 0){ } else if(strcmp(op, "D-READ") == 0){
C2(hugoOps.pkDirtyReadRecord(pNdb, 1, 1), 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_CommittedRead), 0);
} else if(strcmp(op, "INSERT") == 0){ } else if(strcmp(op, "INSERT") == 0){
C2(hugoOps.pkInsertRecord(pNdb, 1, 1, value), 0); C2(hugoOps.pkInsertRecord(pNdb, 1, 1, value), 0);
} else if(strcmp(op, "UPDATE") == 0){ } else if(strcmp(op, "UPDATE") == 0){
......
...@@ -190,13 +190,13 @@ runOp(HugoOperations & hugoOps, ...@@ -190,13 +190,13 @@ runOp(HugoOperations & hugoOps,
return NDBT_FAILED; } return NDBT_FAILED; }
if(strcmp(op, "READ") == 0){ if(strcmp(op, "READ") == 0){
C2(hugoOps.pkReadRecord(pNdb, 1, false, 1) == 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read) == 0);
} else if(strcmp(op, "READ-EX") == 0){ } else if(strcmp(op, "READ-EX") == 0){
C2(hugoOps.pkReadRecord(pNdb, 1, true, 1) == 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Exclusive) == 0);
} else if(strcmp(op, "S-READ") == 0){ } else if(strcmp(op, "S-READ") == 0){
C2(hugoOps.pkSimpleReadRecord(pNdb, 1, 1) == 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read) == 0);
} else if(strcmp(op, "D-READ") == 0){ } else if(strcmp(op, "D-READ") == 0){
C2(hugoOps.pkDirtyReadRecord(pNdb, 1, 1) == 0); C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_CommittedRead) == 0);
} else if(strcmp(op, "INSERT") == 0){ } else if(strcmp(op, "INSERT") == 0){
C2(hugoOps.pkInsertRecord(pNdb, 1, 1, value) == 0); C2(hugoOps.pkInsertRecord(pNdb, 1, 1, value) == 0);
} else if(strcmp(op, "UPDATE") == 0){ } else if(strcmp(op, "UPDATE") == 0){
......
...@@ -63,15 +63,15 @@ args: -n NoLoad T6 T8 T13 ...@@ -63,15 +63,15 @@ args: -n NoLoad T6 T8 T13
max-time: 2500 max-time: 2500
cmd: testNodeRestart cmd: testNodeRestart
args: -n PkRead T6 T8 T13 args: -n MixedPkRead T6 T8 T13
max-time: 2500 max-time: 2500
cmd: testNodeRestart cmd: testNodeRestart
args: -l 1 -n PkReadPkUpdate args: -l 1 -n MixedPkReadPkUpdate
max-time: 2500 max-time: 2500
cmd: testNodeRestart cmd: testNodeRestart
args: -l 1 -n ReadUpdateScan args: -l 1 -n MixedReadUpdateScan
max-time: 2500 max-time: 2500
cmd: testNodeRestart cmd: testNodeRestart
......
...@@ -52,8 +52,8 @@ NdbConnection* HugoOperations::getTransaction(){ ...@@ -52,8 +52,8 @@ NdbConnection* HugoOperations::getTransaction(){
int HugoOperations::pkReadRecord(Ndb* pNdb, int HugoOperations::pkReadRecord(Ndb* pNdb,
int recordNo, int recordNo,
bool exclusive, int numRecords,
int numRecords){ NdbOperation::LockMode lm){
int a; int a;
allocRows(numRecords); allocRows(numRecords);
int check; int check;
...@@ -64,94 +64,22 @@ int HugoOperations::pkReadRecord(Ndb* pNdb, ...@@ -64,94 +64,22 @@ int HugoOperations::pkReadRecord(Ndb* pNdb,
return NDBT_FAILED; return NDBT_FAILED;
} }
if (exclusive == true) rand_lock_mode:
check = pOp->readTupleExclusive(); switch(lm){
else case NdbOperation::LM_Read:
check = pOp->readTuple(); check = pOp->readTuple();
if( check == -1 ) { break;
ERR(pTrans->getNdbError()); case NdbOperation::LM_Exclusive:
return NDBT_FAILED; check = pOp->readTupleExclusive();
} break;
case NdbOperation::LM_CommittedRead:
// Define primary keys check = pOp->dirtyRead();
for(a = 0; a<tab.getNoOfColumns(); a++){ break;
if (tab.getColumn(a)->getPrimaryKey() == true){ default:
if(equalForAttr(pOp, a, r+recordNo) != 0){ lm = (NdbOperation::LockMode)((rand() >> 16) & 3);
ERR(pTrans->getNdbError()); goto rand_lock_mode;
return NDBT_FAILED;
}
}
}
// Define attributes to read
for(a = 0; a<tab.getNoOfColumns(); a++){
if((rows[r]->attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
}
}
return NDBT_OK;
}
int HugoOperations::pkDirtyReadRecord(Ndb* pNdb,
int recordNo,
int numRecords){
int a;
allocRows(numRecords);
int 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->dirtyRead();
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 read
for(a = 0; a<tab.getNoOfColumns(); a++){
if((rows[r]->attributeStore(a) =
pOp->getValue(tab.getColumn(a)->getName())) == 0) {
ERR(pTrans->getNdbError());
return NDBT_FAILED;
}
}
}
return NDBT_OK;
}
int HugoOperations::pkSimpleReadRecord(Ndb* pNdb,
int recordNo,
int numRecords){
int a;
allocRows(numRecords);
int 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->simpleRead();
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
return NDBT_FAILED; return NDBT_FAILED;
......
...@@ -1230,7 +1230,7 @@ int ...@@ -1230,7 +1230,7 @@ int
HugoTransactions::pkReadRecords(Ndb* pNdb, HugoTransactions::pkReadRecords(Ndb* pNdb,
int records, int records,
int batchsize, int batchsize,
bool dirty){ NdbOperation::LockMode lm){
int reads = 0; int reads = 0;
int r = 0; int r = 0;
int retryAttempt = 0; int retryAttempt = 0;
...@@ -1275,11 +1275,22 @@ HugoTransactions::pkReadRecords(Ndb* pNdb, ...@@ -1275,11 +1275,22 @@ HugoTransactions::pkReadRecords(Ndb* pNdb,
return NDBT_FAILED; return NDBT_FAILED;
} }
if (dirty == true){ rand_lock_mode:
check = pOp->dirtyRead(); switch(lm){
} else { case NdbOperation::LM_Read:
check = pOp->readTuple(); check = pOp->readTuple();
break;
case NdbOperation::LM_Exclusive:
check = pOp->readTupleExclusive();
break;
case NdbOperation::LM_CommittedRead:
check = pOp->dirtyRead();
break;
default:
lm = (NdbOperation::LockMode)((rand() >> 16) & 3);
goto rand_lock_mode;
} }
if( check == -1 ) { if( check == -1 ) {
ERR(pTrans->getNdbError()); ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans); pNdb->closeTransaction(pTrans);
......
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