From 7a7ee30cb5a26f8e0f2edb560be36e6219e6a4a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 Nov 2004 17:34:34 +0100 Subject: ndb: fix bug-4644 Err Out of fragment operations sql/ha_ndbcluster.cc: compile fix in DBUG code ndb/src/kernel/blocks/dbtux/DbtuxGen.cpp: fix count of metadata pages ndb/include/kernel/signaldata/TupFrag.hpp: bug-4644 fix ndb/src/kernel/blocks/ERROR_codes.txt: bug-4644 fix ndb/src/kernel/blocks/dblqh/Dblqh.hpp: bug-4644 fix ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: bug-4644 fix ndb/src/kernel/blocks/dbtup/Dbtup.hpp: bug-4644 fix ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: bug-4644 fix ndb/src/kernel/blocks/dbtux/Dbtux.hpp: bug-4644 fix ndb/src/kernel/blocks/dbtux/DbtuxDebug.cpp: bug-4644 fix ndb/src/kernel/blocks/dbtux/DbtuxMeta.cpp: bug-4644 fix ndb/test/ndbapi/testDict.cpp: bug-4644 fix --- ndb/test/ndbapi/testDict.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index 9552e321f00..b832cb7039b 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1479,6 +1479,69 @@ runTestDictionaryPerf(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_OK; } +int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ + static int tuplst[] = { 4007, 4008, 4009, 4010, 4011, 4012 }; + static int tuxlst[] = { 12001, 12002, 12003, 12004, 12005, 12006 }; + static unsigned tupcnt = sizeof(tuplst)/sizeof(tuplst[0]); + static unsigned tuxcnt = sizeof(tuxlst)/sizeof(tuxlst[0]); + + NdbRestarter restarter; + int nodeId = restarter.getMasterNodeId(); + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary* pDic = pNdb->getDictionary(); + NdbDictionary::Table tab(*ctx->getTab()); + tab.setFragmentType(NdbDictionary::Object::FragAllLarge); + + // ordered index on first few columns + NdbDictionary::Index idx("X"); + idx.setTable(tab.getName()); + idx.setType(NdbDictionary::Index::OrderedIndex); + idx.setLogging(false); + for (int i_hate_broken_compilers = 0; + i_hate_broken_compilers < 3 && + i_hate_broken_compilers < tab.getNoOfColumns(); + i_hate_broken_compilers++) { + idx.addColumn(*tab.getColumn(i_hate_broken_compilers)); + } + + const int loops = ctx->getNumLoops(); + int result = NDBT_OK; + (void)pDic->dropTable(tab.getName()); + + for (int l = 0; l < loops; l++) { + for (unsigned i = 0; i < tupcnt; i++) { + unsigned j = (l == 0 ? i : myRandom48(tupcnt)); + int errval = tuplst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } + for (unsigned i = 0; i < tuxcnt; i++) { + unsigned j = (l == 0 ? i : myRandom48(tuxcnt)); + int errval = tuxlst[j]; + g_info << "insert error node=" << nodeId << " value=" << errval << endl; + CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, + "failed to set error insert"); + CHECK2(pDic->createTable(tab) == 0, + pDic->getNdbError()); + CHECK2(pDic->createIndex(idx) != 0, + "failed to fail after error insert " << errval); + CHECK2(pDic->createIndex(idx) == 0, + pDic->getNdbError()); + CHECK2(pDic->dropTable(tab.getName()) == 0, + pDic->getNdbError()); + } + } +end: + return result; +} + NDBT_TESTSUITE(testDict); TESTCASE("CreateAndDrop", "Try to create and drop the table loop number of times\n"){ @@ -1574,6 +1637,10 @@ TESTCASE("DictionaryPerf", ""){ INITIALIZER(runTestDictionaryPerf); } +TESTCASE("FailAddFragment", + "Fail add fragment or attribute in TUP or TUX\n"){ + INITIALIZER(runFailAddFragment); +} NDBT_TESTSUITE_END(testDict); int main(int argc, const char** argv){ -- cgit v1.2.1 From 03d6e2453b3a421a6ab97ec1abd84cc22c9fa158 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 13 Nov 2004 17:49:20 +0100 Subject: ndb: minor ndb/test/ndbapi/testDict.cpp: compile fix --- ndb/test/ndbapi/testDict.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testDict.cpp b/ndb/test/ndbapi/testDict.cpp index b832cb7039b..712ab2e4d25 100644 --- a/ndb/test/ndbapi/testDict.cpp +++ b/ndb/test/ndbapi/testDict.cpp @@ -1509,8 +1509,8 @@ int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ (void)pDic->dropTable(tab.getName()); for (int l = 0; l < loops; l++) { - for (unsigned i = 0; i < tupcnt; i++) { - unsigned j = (l == 0 ? i : myRandom48(tupcnt)); + for (unsigned i1 = 0; i1 < tupcnt; i1++) { + unsigned j = (l == 0 ? i1 : myRandom48(tupcnt)); int errval = tuplst[j]; g_info << "insert error node=" << nodeId << " value=" << errval << endl; CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, @@ -1522,8 +1522,8 @@ int runFailAddFragment(NDBT_Context* ctx, NDBT_Step* step){ CHECK2(pDic->dropTable(tab.getName()) == 0, pDic->getNdbError()); } - for (unsigned i = 0; i < tuxcnt; i++) { - unsigned j = (l == 0 ? i : myRandom48(tuxcnt)); + for (unsigned i2 = 0; i2 < tuxcnt; i2++) { + unsigned j = (l == 0 ? i2 : myRandom48(tuxcnt)); int errval = tuxlst[j]; g_info << "insert error node=" << nodeId << " value=" << errval << endl; CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0, -- cgit v1.2.1 From 6a87e0060d7e137e5d306237676ed07c44adf3ce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Nov 2004 20:54:35 +0100 Subject: wl2077 moved inline to .hpp file --- ndb/test/ndbapi/testScan.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testScan.cpp b/ndb/test/ndbapi/testScan.cpp index 0cd30dfefde..51913e8fbf9 100644 --- a/ndb/test/ndbapi/testScan.cpp +++ b/ndb/test/ndbapi/testScan.cpp @@ -242,8 +242,9 @@ int runScanReadCommitted(NDBT_Context* ctx, NDBT_Step* step){ HugoTransactions hugoTrans(*ctx->getTab()); while (iisTestStopped()) { g_info << i << ": "; - if (hugoTrans.scanReadCommittedRecords(GETNDB(step), records, - abort, parallelism) != 0){ + if (hugoTrans.scanReadRecords(GETNDB(step), records, + abort, parallelism, + NdbOperation::LM_CommittedRead) != 0){ return NDBT_FAILED; } i++; @@ -639,7 +640,7 @@ int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){ g_info << (unsigned)i << endl; if(utilTrans.scanReadRecords(GETNDB(step), parallelism, - false, + NdbOperation::LM_Read, records, alist.attriblist[i]->numAttribs, alist.attriblist[i]->attribs) != 0){ @@ -647,7 +648,7 @@ int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){ } if(utilTrans.scanReadRecords(GETNDB(step), parallelism, - true, + NdbOperation::LM_Read, records, alist.attriblist[i]->numAttribs, alist.attriblist[i]->attribs) != 0){ -- cgit v1.2.1 From f080e78f628b9f2bc0613f35de5f5cd298ed73ce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Nov 2004 22:41:31 +0100 Subject: wl2077 - ndb scan optimizations ndb/test/ndbapi/testScanPerf.cpp: Add reset_bounds option Impl. eq bound queries --- ndb/test/ndbapi/testScanPerf.cpp | 78 +++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 24 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testScanPerf.cpp b/ndb/test/ndbapi/testScanPerf.cpp index c1334125978..fca67c6abcb 100644 --- a/ndb/test/ndbapi/testScanPerf.cpp +++ b/ndb/test/ndbapi/testScanPerf.cpp @@ -39,8 +39,9 @@ struct Parameter { #define P_LOOPS 8 #define P_CREATE 9 #define P_LOAD 10 +#define P_RESET 11 -#define P_MAX 11 +#define P_MAX 12 static Parameter @@ -55,7 +56,8 @@ g_paramters[] = { { "size", 1000000, 1, ~0 }, { "iterations", 3, 1, ~0 }, { "create_drop", 1, 0, 1 }, - { "data", 1, 0, 1 } + { "data", 1, 0, 1 }, + { "q-reset bounds", 0, 1, 0 } }; static Ndb* g_ndb = 0; @@ -218,21 +220,29 @@ run_scan(){ NDB_TICKS start1, stop; int sum_time= 0; + int sample_rows = 0; + NDB_TICKS sample_start = NdbTick_CurrentMillisecond(); + Uint32 tot = g_paramters[P_ROWS].value; + if(g_paramters[P_BOUND].value == 2 || g_paramters[P_FILT].value == 2) + iter *= g_paramters[P_ROWS].value; + + NdbScanOperation * pOp = 0; + NdbIndexScanOperation * pIOp = 0; + NdbConnection * pTrans = 0; + NdbResultSet * rs = 0; + int check = 0; + for(int i = 0; istartTransaction(); + pTrans = pTrans ? pTrans : g_ndb->startTransaction(); if(!pTrans){ g_err << "Failed to start transaction" << endl; err(g_ndb->getNdbError()); return -1; } - NdbScanOperation * pOp; - NdbIndexScanOperation * pIOp; - - NdbResultSet * rs; int par = g_paramters[P_PARRA].value; int bat = g_paramters[P_BATCH].value; NdbScanOperation::LockMode lm; @@ -255,9 +265,17 @@ run_scan(){ assert(pOp); rs = pOp->readTuples(lm, bat, par); } else { - pOp = pIOp = pTrans->getNdbIndexScanOperation(g_indexname, g_tablename); - bool ord = g_paramters[P_ACCESS].value == 2; - rs = pIOp->readTuples(lm, bat, par, ord); + if(g_paramters[P_RESET].value == 0 || pIOp == 0) + { + pOp= pIOp= pTrans->getNdbIndexScanOperation(g_indexname, g_tablename); + bool ord = g_paramters[P_ACCESS].value == 2; + rs = pIOp->readTuples(lm, bat, par, ord); + } + else + { + pIOp->reset_bounds(); + } + switch(g_paramters[P_BOUND].value){ case 0: // All break; @@ -267,20 +285,22 @@ run_scan(){ case 2: { // 1 row default: assert(g_table->getNoOfPrimaryKeys() == 1); // only impl. so far - abort(); -#if 0 int tot = g_paramters[P_ROWS].value; int row = rand() % tot; +#if 0 fix_eq_bound(pIOp, row); +#else + pIOp->setBound((Uint32)0, NdbIndexScanOperation::BoundEQ, &row); #endif break; } } + if(g_paramters[P_RESET].value == 1) + goto execute; } assert(pOp); assert(rs); - int check = 0; switch(g_paramters[P_FILT].value){ case 0: // All check = pOp->interpret_exit_ok(); @@ -312,7 +332,7 @@ run_scan(){ for(int i = 0; igetNoOfColumns(); i++){ pOp->getValue(i); } - +execute: int rows = 0; check = pTrans->execute(NoCommit); assert(check == 0); @@ -333,19 +353,29 @@ run_scan(){ return -1; } assert(check == 1); - g_info << "Found " << rows << " rows" << endl; - - pTrans->close(); - + if(g_paramters[P_RESET].value == 0) + { + pTrans->close(); + pTrans = 0; + } stop = NdbTick_CurrentMillisecond(); + int time_passed= (int)(stop - start1); - g_err.println("Time: %d ms = %u rows/sec", time_passed, - (1000*tot)/time_passed); + sample_rows += rows; sum_time+= time_passed; + + if(sample_rows >= tot) + { + int sample_time = (int)(stop - sample_start); + g_info << "Found " << sample_rows << " rows" << endl; + g_err.println("Time: %d ms = %u rows/sec", sample_time, + (1000*sample_rows)/sample_time); + sample_rows = 0; + sample_start = stop; + } } - sum_time= sum_time / iter; - - g_err.println("Avg time: %d ms = %u rows/sec", sum_time, - (1000*tot)/sum_time); + + g_err.println("Avg time: %d ms = %u rows/sec", sum_time/iter, + (1000*tot*iter)/sum_time); return 0; } -- cgit v1.2.1 From 018cac958838511ae0fbed9441aa08c16bd3bd8c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Nov 2004 11:37:16 +0100 Subject: wl2077 - scan optimizations (recommit in clean clone) ndb/src/kernel/blocks/dbdih/Dbdih.hpp: removed unused variable ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Always give all nodes in DIGETPRIMREQ ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Allow readcommited-scans to scan backup fragments ndb/test/ndbapi/testReadPerf.cpp: better printous --- ndb/test/ndbapi/testReadPerf.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testReadPerf.cpp b/ndb/test/ndbapi/testReadPerf.cpp index 8d0d78cbe8c..f8ecc6192dc 100644 --- a/ndb/test/ndbapi/testReadPerf.cpp +++ b/ndb/test/ndbapi/testReadPerf.cpp @@ -390,8 +390,15 @@ run_read(){ void print_result(){ + int tmp = 1; + tmp *= g_paramters[P_RANGE].value; + tmp *= g_paramters[P_LOOPS].value; + + int t, t2; for(int i = 0; i Date: Fri, 26 Nov 2004 10:00:33 +0100 Subject: ndb - bugfix testScanPerf ndb/test/ndbapi/testScanPerf.cpp: 1) Fix so that values are read even when using -q 2) Divide by correct number --- ndb/test/ndbapi/testScanPerf.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testScanPerf.cpp b/ndb/test/ndbapi/testScanPerf.cpp index ee2a92e88a9..45f0468bc70 100644 --- a/ndb/test/ndbapi/testScanPerf.cpp +++ b/ndb/test/ndbapi/testScanPerf.cpp @@ -222,6 +222,7 @@ run_scan(){ int sum_time= 0; int sample_rows = 0; + int tot_rows = 0; NDB_TICKS sample_start = NdbTick_CurrentMillisecond(); Uint32 tot = g_paramters[P_ROWS].value; @@ -296,7 +297,7 @@ run_scan(){ break; } } - if(g_paramters[P_RESET].value == 1) + if(g_paramters[P_RESET].value == 2) goto execute; } assert(pOp); @@ -330,6 +331,9 @@ run_scan(){ } assert(check == 0); + if(g_paramters[P_RESET].value == 1) + g_paramters[P_RESET].value = 2; + for(int i = 0; igetNoOfColumns(); i++){ pOp->getValue(i); } @@ -364,6 +368,7 @@ execute: int time_passed= (int)(stop - start1); sample_rows += rows; sum_time+= time_passed; + tot_rows+= rows; if(sample_rows >= tot) { @@ -375,8 +380,8 @@ execute: sample_start = stop; } } - - g_err.println("Avg time: %d ms = %u rows/sec", sum_time/iter, - (1000*tot*iter)/sum_time); + + g_err.println("Avg time: %d ms = %u rows/sec", sum_time/tot_rows, + (1000*tot_rows)/sum_time); return 0; } -- cgit v1.2.1 From d212891f6f0c0de275190f52672f3346979e07c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Nov 2004 09:00:39 +0100 Subject: 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 --- ndb/test/ndbapi/testScan.cpp | 130 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 124 insertions(+), 6 deletions(-) (limited to 'ndb/test/ndbapi') diff --git a/ndb/test/ndbapi/testScan.cpp b/ndb/test/ndbapi/testScan.cpp index 51913e8fbf9..22ec3fff327 100644 --- a/ndb/test/ndbapi/testScan.cpp +++ b/ndb/test/ndbapi/testScan.cpp @@ -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 (igetNumLoops(); 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 (iisTestStopped()) { + 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 && iisTestStopped()) { + 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 (igetNumLoops(); 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