Commit d212891f authored by unknown's avatar unknown

ndb - scan bug fix + more test cases


ndb/include/ndbapi/NdbScanOperation.hpp:
  Improved doc. a bit
ndb/src/ndbapi/NdbConnectionScan.cpp:
  Set error code
ndb/src/ndbapi/NdbScanOperation.cpp:
  Check error directly after taking mutex
ndb/test/ndbapi/testScan.cpp:
  new scan test with lots of threads
ndb/test/run-test/daily-basic-tests.txt:
  Added two more scan tests
  Collapsed testTransactions & testOperations
parent 8d117174
......@@ -127,14 +127,23 @@ protected:
NdbReceiver** m_receivers; // All receivers
Uint32* m_prepared_receivers; // These are to be sent
/**
* owned by API/user thread
*/
Uint32 m_current_api_receiver;
Uint32 m_api_receivers_count;
NdbReceiver** m_api_receivers; // These are currently used by api
/**
* owned by receiver thread
*/
Uint32 m_conf_receivers_count; // NOTE needs mutex to access
NdbReceiver** m_conf_receivers; // receive thread puts them here
/**
* owned by receiver thread
*/
Uint32 m_sent_receivers_count; // NOTE needs mutex to access
NdbReceiver** m_sent_receivers; // receive thread puts them here
......
......@@ -56,7 +56,7 @@ NdbConnection::receiveSCAN_TABREF(NdbApiSignal* aSignal){
const ScanTabRef * ref = CAST_CONSTPTR(ScanTabRef, aSignal->getDataPtr());
if(checkState_TransId(&ref->transId1)){
theScanningOp->theError.code = ref->errorCode;
theScanningOp->setErrorCode(ref->errorCode);
theScanningOp->execCLOSE_SCAN_REP();
if(!ref->closeNeeded){
return 0;
......
......@@ -277,9 +277,9 @@ NdbScanOperation::fix_receivers(Uint32 parallel){
void
NdbScanOperation::receiver_delivered(NdbReceiver* tRec){
if(theError.code == 0){
if(DEBUG_NEXT_RESULT)
ndbout_c("receiver_delivered");
if(DEBUG_NEXT_RESULT)
ndbout_c("receiver_delivered");
Uint32 idx = tRec->m_list_index;
Uint32 last = m_sent_receivers_count - 1;
if(idx != last){
......@@ -492,6 +492,9 @@ int NdbScanOperation::nextResult(bool fetchAllowed)
Uint32 nodeId = theNdbCon->theDBnode;
TransporterFacade* tp = TransporterFacade::instance();
Guard guard(tp->theMutexPtr);
if(theError.code)
return -1;
Uint32 seq = theNdbCon->theNodeSequence;
if(seq == tp->getNodeSequence(nodeId) && send_next_scan(idx, false) == 0){
......@@ -685,10 +688,8 @@ void NdbScanOperation::closeScan()
void
NdbScanOperation::execCLOSE_SCAN_REP(){
m_api_receivers_count = 0;
m_conf_receivers_count = 0;
m_sent_receivers_count = 0;
m_current_api_receiver = m_ordered ? theParallelism : 0;
}
void NdbScanOperation::release()
......@@ -1333,6 +1334,8 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){
if(DEBUG_NEXT_RESULT) ndbout_c("performing fetch...");
TransporterFacade* tp = TransporterFacade::instance();
Guard guard(tp->theMutexPtr);
if(theError.code)
return -1;
Uint32 seq = theNdbCon->theNodeSequence;
Uint32 nodeId = theNdbCon->theDBnode;
if(seq == tp->getNodeSequence(nodeId) && !send_next_scan_ordered(s_idx)){
......@@ -1346,6 +1349,13 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){
continue;
}
if(DEBUG_NEXT_RESULT) ndbout_c("return -1");
setErrorCode(4028);
return -1;
}
if(theError.code){
setErrorCode(theError.code);
if(DEBUG_NEXT_RESULT) ndbout_c("return -1");
return -1;
}
......@@ -1355,11 +1365,9 @@ NdbIndexScanOperation::next_result_ordered(bool fetchAllowed){
memcpy(arr, m_conf_receivers, u_last * sizeof(char*));
if(DEBUG_NEXT_RESULT) ndbout_c("sent: %d recv: %d", tmp, u_last);
if(theError.code){
setErrorCode(theError.code);
if(DEBUG_NEXT_RESULT) ndbout_c("return -1");
return -1;
}
} else {
setErrorCode(4028);
return -1;
}
} else {
if(DEBUG_NEXT_RESULT) ndbout_c("return 2");
......@@ -1497,6 +1505,13 @@ NdbScanOperation::close_impl(TransporterFacade* tp){
}
}
if(theError.code)
{
m_api_receivers_count = 0;
m_current_api_receiver = m_ordered ? theParallelism : 0;
}
/**
* move all conf'ed into api
* so that send_next_scan can check if they needs to be closed
......
......@@ -90,11 +90,59 @@ int runLoadAllTables(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
char orderedPkIdxName[255];
int createOrderedPkIndex(NDBT_Context* ctx, NDBT_Step* step){
const NdbDictionary::Table* pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
// Create index
BaseString::snprintf(orderedPkIdxName, sizeof(orderedPkIdxName),
"IDC_O_PK_%s", pTab->getName());
NdbDictionary::Index pIdx(orderedPkIdxName);
pIdx.setTable(pTab->getName());
pIdx.setType(NdbDictionary::Index::OrderedIndex);
pIdx.setLogging(false);
for (int c = 0; c< pTab->getNoOfColumns(); c++){
const NdbDictionary::Column * col = pTab->getColumn(c);
if(col->getPrimaryKey()){
pIdx.addIndexColumn(col->getName());
}
}
if (pNdb->getDictionary()->createIndex(pIdx) != 0){
ndbout << "FAILED! to create index" << endl;
const NdbError err = pNdb->getDictionary()->getNdbError();
ERR(err);
return NDBT_FAILED;
}
return NDBT_OK;
}
int createOrderedPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
const NdbDictionary::Table* pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
// Drop index
if (pNdb->getDictionary()->dropIndex(orderedPkIdxName,
pTab->getName()) != 0){
ndbout << "FAILED! to drop index" << endl;
ERR(pNdb->getDictionary()->getNdbError());
return NDBT_FAILED;
}
return NDBT_OK;
}
int runScanReadRandomTable(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb");
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
while (i<loops) {
......@@ -218,7 +266,7 @@ int runScanRead(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb");
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
......@@ -232,11 +280,58 @@ int runScanRead(NDBT_Context* ctx, NDBT_Step* step){
return NDBT_OK;
}
int runRandScanRead(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
while (i<loops && !ctx->isTestStopped()) {
g_info << i << ": ";
NdbOperation::LockMode lm = (NdbOperation::LockMode)(rand() % 3);
if (hugoTrans.scanReadRecords(GETNDB(step),
records, abort, parallelism,
lm) != 0){
return NDBT_FAILED;
}
i++;
}
return NDBT_OK;
}
int runScanReadIndex(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb", 5);
const NdbDictionary::Index * pIdx =
GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName,
ctx->getTab()->getName());
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
while (pIdx && i<loops && !ctx->isTestStopped()) {
g_info << i << ": ";
bool sort = (rand() % 100) > 50 ? true : false;
NdbOperation::LockMode lm = (NdbOperation::LockMode)(rand() % 3);
if (hugoTrans.scanReadRecords(GETNDB(step), pIdx,
records, abort, parallelism,
lm,
sort) != 0){
return NDBT_FAILED;
}
i++;
}
return NDBT_OK;
}
int runScanReadCommitted(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb");
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
......@@ -425,7 +520,7 @@ int runScanUpdate(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 1);
int abort = ctx->getProperty("AbortProb");
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
while (i<loops) {
......@@ -465,7 +560,7 @@ int runScanUpdate2(NDBT_Context* ctx, NDBT_Step* step){
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
int parallelism = ctx->getProperty("Parallelism", 240);
int abort = ctx->getProperty("AbortProb");
int abort = ctx->getProperty("AbortProb", 5);
int i = 0;
HugoTransactions hugoTrans(*ctx->getTab());
while (i<loops) {
......@@ -1080,7 +1175,30 @@ TESTCASE("ScanRead488",
"When this limit is exceeded the scan will be aborted with errorcode "\
"488."){
INITIALIZER(runLoadTable);
STEPS(runScanRead, 70);
STEPS(runRandScanRead, 70);
FINALIZER(runClearTable);
}
TESTCASE("ScanRead488O",
"Verify scan requirement: It's only possible to have 11 concurrent "\
"scans per fragment running in Ndb kernel at the same time. "\
"When this limit is exceeded the scan will be aborted with errorcode "\
"488."){
INITIALIZER(createOrderedPkIndex);
INITIALIZER(runLoadTable);
STEPS(runScanReadIndex, 70);
FINALIZER(createOrderedPkIndex_Drop);
FINALIZER(runClearTable);
}
TESTCASE("ScanRead488_Mixed",
"Verify scan requirement: It's only possible to have 11 concurrent "\
"scans per fragment running in Ndb kernel at the same time. "\
"When this limit is exceeded the scan will be aborted with errorcode "\
"488."){
INITIALIZER(createOrderedPkIndex);
INITIALIZER(runLoadTable);
STEPS(runRandScanRead, 50);
STEPS(runScanReadIndex, 50);
FINALIZER(createOrderedPkIndex_Drop);
FINALIZER(runClearTable);
}
TESTCASE("ScanRead488Timeout",
......
......@@ -222,6 +222,14 @@ max-time: 500
cmd: testScan
args: -n ScanRead488 -l 10 T6
max-time: 500
cmd: testScan
args: -n ScanRead488O -l 10 T6
max-time: 1000
cmd: testScan
args: -n ScanRead488_Mixed -l 10 T6
max-time: 500
cmd: testScan
args: -n ScanRead488Timeout -l 10 T6
......@@ -478,493 +486,13 @@ args: -n UpdateWithoutValues T6
#cmd: testInterpreter
#args: T1
#
max-time: 1500
cmd: testOperations
args: -n ReadRead
max-time: 1500
cmd: testOperations
args: -n ReadReadEx
max-time: 1500
cmd: testOperations
args: -n ReadInsert
max-time: 1500
cmd: testOperations
args: -n ReadUpdate
max-time: 1500
cmd: testOperations
args: -n ReadDelete
max-time: 1500
cmd: testOperations
args: -n FReadRead
max-time: 1500
cmd: testOperations
args: -n FReadReadEx
max-time: 1500
cmd: testOperations
args: -n FReadInsert
max-time: 1500
cmd: testOperations
args: -n FReadUpdate
max-time: 1500
cmd: testOperations
args: -n FReadDelete
max-time: 1500
cmd: testOperations
args: -n ReadExRead
max-time: 1500
cmd: testOperations
args: -n ReadExReadEx
max-time: 1500
cmd: testOperations
args: -n ReadExInsert
max-time: 1500
cmd: testOperations
args: -n ReadExUpdate
max-time: 1500
cmd: testOperations
args: -n ReadExDelete
max-time: 1500
cmd: testOperations
args: -n InsertRead
max-time: 1500
cmd: testOperations
args: -n InsertReadEx
max-time: 1500
cmd: testOperations
args: -n InsertInsert
max-time: 1500
cmd: testOperations
args: -n InsertUpdate
max-time: 1500
cmd: testOperations
args: -n InsertDelete
max-time: 1500
cmd: testOperations
args: -n UpdateRead
max-time: 1500
cmd: testOperations
args: -n UpdateReadEx
max-time: 1500
cmd: testOperations
args: -n UpdateInsert
max-time: 1500
cmd: testOperations
args: -n UpdateUpdate
max-time: 1500
cmd: testOperations
args: -n UpdateDelete
max-time: 1500
cmd: testOperations
args: -n DeleteRead
max-time: 1500
cmd: testOperations
args: -n DeleteReadEx
max-time: 1500
cmd: testOperations
args: -n DeleteInsert
max-time: 1500
cmd: testOperations
args: -n DeleteUpdate
max-time: 1500
max-time: 150000
cmd: testOperations
args: -n DeleteDelete
max-time: 1500
cmd: testOperations
args: -n ReadSimpleRead
max-time: 1500
cmd: testOperations
args: -n ReadDirtyRead
max-time: 1500
cmd: testOperations
args: -n FReadSimpleRead
max-time: 1500
cmd: testOperations
args: -n FReadDirtyRead
max-time: 1500
cmd: testOperations
args: -n ReadExSimpleRead
max-time: 1500
cmd: testOperations
args: -n ReadExDirtyRead
max-time: 1500
cmd: testOperations
args: -n InsertSimpleRead
max-time: 1500
cmd: testOperations
args: -n InsertDirtyRead
max-time: 1500
cmd: testOperations
args: -n UpdateSimpleRead
max-time: 1500
cmd: testOperations
args: -n UpdateDirtyRead
max-time: 1500
cmd: testOperations
args: -n DeleteSimpleRead
max-time: 1500
cmd: testOperations
args: -n DeleteDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ReadRead
max-time: 1500
cmd: testTransactions
args: -n ReadReadEx
max-time: 1500
cmd: testTransactions
args: -n ReadInsert
max-time: 1500
cmd: testTransactions
args: -n ReadUpdate
max-time: 1500
cmd: testTransactions
args: -n ReadDelete
max-time: 1500
cmd: testTransactions
args: -n ReadExRead
max-time: 1500
cmd: testTransactions
args: -n ReadExReadEx
max-time: 1500
cmd: testTransactions
args: -n ReadExInsert
max-time: 1500
cmd: testTransactions
args: -n ReadExUpdate
max-time: 1500
cmd: testTransactions
args: -n ReadExDelete
max-time: 1500
cmd: testTransactions
args: -n InsertRead
max-time: 1500
cmd: testTransactions
args: -n InsertReadEx
max-time: 1500
cmd: testTransactions
args: -n InsertInsert
max-time: 1500
cmd: testTransactions
args: -n InsertUpdate
max-time: 1500
cmd: testTransactions
args: -n InsertDelete
max-time: 1500
cmd: testTransactions
args: -n UpdateRead
max-time: 1500
cmd: testTransactions
args: -n UpdateReadEx
max-time: 1500
cmd: testTransactions
args: -n UpdateInsert
max-time: 1500
cmd: testTransactions
args: -n UpdateUpdate
max-time: 1500
cmd: testTransactions
args: -n UpdateDelete
max-time: 1500
cmd: testTransactions
args: -n DeleteRead
max-time: 1500
cmd: testTransactions
args: -n DeleteReadEx
max-time: 1500
cmd: testTransactions
args: -n DeleteInsert
max-time: 1500
cmd: testTransactions
args: -n DeleteUpdate
max-time: 1500
cmd: testTransactions
args: -n DeleteDelete
max-time: 1500
cmd: testTransactions
args: -n ReadSimpleRead
max-time: 1500
cmd: testTransactions
args: -n ReadDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ReadExSimpleRead
max-time: 1500
cmd: testTransactions
args: -n ReadExDirtyRead
max-time: 1500
cmd: testTransactions
args: -n InsertSimpleRead
max-time: 1500
cmd: testTransactions
args: -n InsertDirtyRead
max-time: 1500
cmd: testTransactions
args: -n UpdateSimpleRead
max-time: 1500
cmd: testTransactions
args: -n UpdateDirtyRead
max-time: 1500
cmd: testTransactions
args: -n DeleteSimpleRead
max-time: 1500
cmd: testTransactions
args: -n DeleteDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ReadScan
max-time: 1500
cmd: testTransactions
args: -n ReadScanHl
max-time: 1500
cmd: testTransactions
args: -n ReadScanEx
max-time: 1500
cmd: testTransactions
args: -n ScanRead
max-time: 1500
cmd: testTransactions
args: -n ScanReadEx
max-time: 1500
cmd: testTransactions
args: -n ScanSimpleRead
max-time: 1500
cmd: testTransactions
args: -n ScanDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ScanInsert
max-time: 1500
cmd: testTransactions
args: -n ScanUpdate
max-time: 1500
cmd: testTransactions
args: -n ScanDelete
max-time: 1500
cmd: testTransactions
args: -n ScanScan
max-time: 1500
cmd: testTransactions
args: -n ScanScanHl
max-time: 1500
cmd: testTransactions
args: -n ScanScanEx
max-time: 1500
cmd: testTransactions
args: -n ScanHlRead
max-time: 1500
cmd: testTransactions
args: -n ScanHlReadEx
max-time: 1500
cmd: testTransactions
args: -n ScanHlSimpleRead
max-time: 1500
cmd: testTransactions
args: -n ScanHlDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ScanHlInsert
max-time: 1500
cmd: testTransactions
args: -n ScanHlUpdate
max-time: 1500
cmd: testTransactions
args: -n ScanHlDelete
max-time: 1500
cmd: testTransactions
args: -n ScanHlScan
max-time: 1500
cmd: testTransactions
args: -n ScanHlScanHl
max-time: 1500
cmd: testTransactions
args: -n ScanHlScanEx
max-time: 1500
cmd: testTransactions
args: -n ScanExRead
max-time: 1500
cmd: testTransactions
args: -n ScanExReadEx
max-time: 1500
cmd: testTransactions
args: -n ScanExSimpleRead
max-time: 1500
cmd: testTransactions
args: -n ScanExDirtyRead
max-time: 1500
cmd: testTransactions
args: -n ScanExInsert
max-time: 1500
cmd: testTransactions
args: -n ScanExUpdate
max-time: 1500
cmd: testTransactions
args: -n ScanExDelete
max-time: 1500
cmd: testTransactions
args: -n ScanExScan
max-time: 1500
cmd: testTransactions
args: -n ScanExScanHl
max-time: 1500
cmd: testTransactions
args: -n ScanExScanEx
max-time: 1500
cmd: testTransactions
args: -n ReadExScan
max-time: 1500
cmd: testTransactions
args: -n ReadExScanHl
max-time: 1500
cmd: testTransactions
args: -n ReadExScanEx
max-time: 1500
cmd: testTransactions
args: -n InsertScan
max-time: 1500
cmd: testTransactions
args: -n InsertScanHl
max-time: 1500
cmd: testTransactions
args: -n InsertScanEx
max-time: 1500
cmd: testTransactions
args: -n UpdateScan
max-time: 1500
cmd: testTransactions
args: -n UpdateScanHl
max-time: 1500
cmd: testTransactions
args: -n UpdateScanEx
max-time: 1500
cmd: testTransactions
args: -n DeleteScan
max-time: 1500
cmd: testTransactions
args: -n DeleteScanHl
args:
max-time: 1500
max-time: 150000
cmd: testTransactions
args: -n DeleteScanEx
args:
max-time: 1500
cmd: testRestartGci
......
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