From af0287be3c97eb1a4e42c6dd1b32e47b918139ce Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Jun 2005 08:07:48 +0200 Subject: [PATCH 1/2] ndb - autotest small script fixes - Don't use hostname -s as it's linux specific - Don't remove result unless scp worked ndb/test/run-test/ndb-autotest.sh: Don't use hostname -s as it's linux specific Don't remove result unless scp worked --- ndb/test/run-test/ndb-autotest.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ndb/test/run-test/ndb-autotest.sh b/ndb/test/run-test/ndb-autotest.sh index 3ba4d1928d5..09087a8a8c7 100755 --- a/ndb/test/run-test/ndb-autotest.sh +++ b/ndb/test/run-test/ndb-autotest.sh @@ -13,7 +13,7 @@ save_args=$* VERSION="ndb-autotest.sh version 1.04" DATE=`date '+%Y-%m-%d'` -HOST=`hostname -s` +HOST=`hostname` export DATE HOST set -e @@ -330,7 +330,10 @@ start(){ tar cfz /tmp/res.$2.$$.tgz `basename $p2`/$DATE scp /tmp/res.$2.$$.tgz \ $result_host:$result_path/res.$DATE.$HOST.$2.$$.tgz - rm -f /tmp/res.$2.$$.tgz + if [ $? -eq 0 ] + then + rm -f /tmp/res.$2.$$.tgz + fi fi } From 2f2ab54691698b6ce21308f6dcbd85738d658173 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Jun 2005 15:39:14 +0200 Subject: [PATCH 2/2] bug#11205 - ndb - 4006 when starting scan mysql-test/r/ndb_subquery.result: Add testing of new 4006 handling mysql-test/t/ndb_subquery.test: Add testing of new 4006 handling ndb/include/ndbapi/Ndb.hpp: Check #transactions in startTransaction instead of getNdbCon ndb/src/ndbapi/Ndb.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/src/ndbapi/NdbScanOperation.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/src/ndbapi/Ndbif.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/src/ndbapi/Ndbinit.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/src/ndbapi/Ndblist.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/test/ndbapi/testNdbApi.cpp: Check #transactions in startTransaction instead of getNdbCon ndb/test/run-test/daily-basic-tests.txt: Check #transactions in startTransaction instead of getNdbCon sql/ha_ndbcluster.cc: Check #transactions in startTransaction instead of getNdbCon --- mysql-test/r/ndb_subquery.result | 19 +++++ mysql-test/t/ndb_subquery.test | 23 ++++++ ndb/include/ndbapi/Ndb.hpp | 2 +- ndb/src/ndbapi/Ndb.cpp | 9 +++ ndb/src/ndbapi/NdbScanOperation.cpp | 4 + ndb/src/ndbapi/Ndbif.cpp | 8 +- ndb/src/ndbapi/Ndbinit.cpp | 2 +- ndb/src/ndbapi/Ndblist.cpp | 11 +-- ndb/test/ndbapi/testNdbApi.cpp | 102 ++++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 + sql/ha_ndbcluster.cc | 2 +- 11 files changed, 169 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/ndb_subquery.result b/mysql-test/r/ndb_subquery.result index f65f09b71b3..b19571b05c1 100644 --- a/mysql-test/r/ndb_subquery.result +++ b/mysql-test/r/ndb_subquery.result @@ -40,3 +40,22 @@ p u o 5 5 5 drop table t1; drop table t2; +create table t1 (p int not null primary key, u int not null) engine=ndb; +insert into t1 values (1,1),(2,2),(3,3); +create table t2 as +select t1.* +from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8 +where t1.u = t2.u +and t2.u = t3.u +and t3.u = t4.u +and t4.u = t5.u +and t5.u = t6.u +and t6.u = t7.u +and t7.u = t8.u; +select * from t2 order by 1; +p u +1 1 +2 2 +3 3 +drop table t1; +drop table t2; diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test index 9d3a256a263..095fdbcfa13 100644 --- a/mysql-test/t/ndb_subquery.test +++ b/mysql-test/t/ndb_subquery.test @@ -37,3 +37,26 @@ drop table t1; drop table t2; # bug#5367 ########## + +### +# bug#11205 +create table t1 (p int not null primary key, u int not null) engine=ndb; +insert into t1 values (1,1),(2,2),(3,3); + +create table t2 as +select t1.* +from t1 as t1, t1 as t2, t1 as t3, t1 as t4, t1 as t5, t1 as t6, t1 as t7, t1 as t8 +where t1.u = t2.u + and t2.u = t3.u + and t3.u = t4.u + and t4.u = t5.u + and t5.u = t6.u + and t6.u = t7.u + and t7.u = t8.u; + +select * from t2 order by 1; + +drop table t1; +drop table t2; + + diff --git a/ndb/include/ndbapi/Ndb.hpp b/ndb/include/ndbapi/Ndb.hpp index 766409d64e2..0299d337757 100644 --- a/ndb/include/ndbapi/Ndb.hpp +++ b/ndb/include/ndbapi/Ndb.hpp @@ -1543,7 +1543,7 @@ private: Uint32 theNoOfPreparedTransactions; Uint32 theNoOfSentTransactions; Uint32 theNoOfCompletedTransactions; - Uint32 theNoOfAllocatedTransactions; + Uint32 theRemainingStartTransactions; Uint32 theMaxNoOfTransactions; Uint32 theMinNoOfEventsToWakeUp; diff --git a/ndb/src/ndbapi/Ndb.cpp b/ndb/src/ndbapi/Ndb.cpp index 1ae1030e463..43fb34b8b99 100644 --- a/ndb/src/ndbapi/Ndb.cpp +++ b/ndb/src/ndbapi/Ndb.cpp @@ -390,6 +390,14 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId) DBUG_ENTER("Ndb::startTransactionLocal"); DBUG_PRINT("enter", ("nodeid: %d", nodeId)); + if(unlikely(theRemainingStartTransactions == 0)) + { + theError.code = 4006; + DBUG_RETURN(0); + } + + theRemainingStartTransactions--; + NdbConnection* tConnection; Uint64 tFirstTransId = theFirstTransId; tConnection = doConnect(nodeId); @@ -446,6 +454,7 @@ Ndb::closeTransaction(NdbConnection* aConnection) CHECK_STATUS_MACRO_VOID; tCon = theTransactionList; + theRemainingStartTransactions++; DBUG_PRINT("info",("close trans: 0x%x transid: 0x%llx", aConnection, aConnection->getTransactionId())); diff --git a/ndb/src/ndbapi/NdbScanOperation.cpp b/ndb/src/ndbapi/NdbScanOperation.cpp index fc5a22cce17..4fee0e658f2 100644 --- a/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/ndb/src/ndbapi/NdbScanOperation.cpp @@ -104,14 +104,17 @@ NdbScanOperation::init(const NdbTableImpl* tab, NdbConnection* myConnection) { m_transConnection = myConnection; //NdbConnection* aScanConnection = theNdb->startTransaction(myConnection); + theNdb->theRemainingStartTransactions++; // will be checked in hupp... NdbConnection* aScanConnection = theNdb->hupp(myConnection); if (!aScanConnection){ + theNdb->theRemainingStartTransactions--; setErrorCodeAbort(theNdb->getNdbError().code); return -1; } // NOTE! The hupped trans becomes the owner of the operation if(NdbOperation::init(tab, aScanConnection) != 0){ + theNdb->theRemainingStartTransactions--; return -1; } @@ -705,6 +708,7 @@ void NdbScanOperation::closeScan(bool forceSend, bool releaseOp) tCon->theScanningOp = 0; theNdb->closeTransaction(tCon); + theNdb->theRemainingStartTransactions--; } void diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 1caebe436ef..2d14e087f62 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -107,12 +107,10 @@ Ndb::init(int aMaxNoOfTransactions) goto error_handler; } - tMaxNoOfTransactions = aMaxNoOfTransactions * 3; - if (tMaxNoOfTransactions > 1024) { - tMaxNoOfTransactions = 1024; - }//if + + tMaxNoOfTransactions = aMaxNoOfTransactions; theMaxNoOfTransactions = tMaxNoOfTransactions; - + theRemainingStartTransactions= tMaxNoOfTransactions; thePreparedTransactionsArray = new NdbConnection* [tMaxNoOfTransactions]; theSentTransactionsArray = new NdbConnection* [tMaxNoOfTransactions]; theCompletedTransactionsArray = new NdbConnection* [tMaxNoOfTransactions]; diff --git a/ndb/src/ndbapi/Ndbinit.cpp b/ndb/src/ndbapi/Ndbinit.cpp index a11dd842495..43d4c7b0707 100644 --- a/ndb/src/ndbapi/Ndbinit.cpp +++ b/ndb/src/ndbapi/Ndbinit.cpp @@ -95,7 +95,7 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, theNoOfPreparedTransactions= 0; theNoOfSentTransactions= 0; theNoOfCompletedTransactions= 0; - theNoOfAllocatedTransactions= 0; + theRemainingStartTransactions= 0; theMaxNoOfTransactions= 0; theMinNoOfEventsToWakeUp= 0; prefixEnd= NULL; diff --git a/ndb/src/ndbapi/Ndblist.cpp b/ndb/src/ndbapi/Ndblist.cpp index 5902aa413dc..4e6045f8058 100644 --- a/ndb/src/ndbapi/Ndblist.cpp +++ b/ndb/src/ndbapi/Ndblist.cpp @@ -94,7 +94,6 @@ Ndb::createConIdleList(int aNrOfCon) } tNdbCon->Status(NdbConnection::NotConnected); } - theNoOfAllocatedTransactions = aNrOfCon; return aNrOfCon; } @@ -194,14 +193,8 @@ Ndb::getNdbCon() { NdbConnection* tNdbCon; if ( theConIdleList == NULL ) { - if (theNoOfAllocatedTransactions < theMaxNoOfTransactions) { - tNdbCon = new NdbConnection(this); - if (tNdbCon == NULL) { - return NULL; - }//if - theNoOfAllocatedTransactions++; - } else { - ndbout << "theNoOfAllocatedTransactions = " << theNoOfAllocatedTransactions << " theMaxNoOfTransactions = " << theMaxNoOfTransactions << endl; + tNdbCon = new NdbConnection(this); + if (tNdbCon == NULL) { return NULL; }//if tNdbCon->next(NULL); diff --git a/ndb/test/ndbapi/testNdbApi.cpp b/ndb/test/ndbapi/testNdbApi.cpp index de731a5eeec..d38ac460dfb 100644 --- a/ndb/test/ndbapi/testNdbApi.cpp +++ b/ndb/test/ndbapi/testNdbApi.cpp @@ -1281,6 +1281,102 @@ int runBug_11133(NDBT_Context* ctx, NDBT_Step* step){ return result; } +int runScan_4006(NDBT_Context* ctx, NDBT_Step* step){ + int result = NDBT_OK; + const Uint32 max= 5; + const NdbDictionary::Table* pTab = ctx->getTab(); + + Ndb* pNdb = new Ndb("TEST_DB"); + if (pNdb == NULL){ + ndbout << "pNdb == NULL" << endl; + return NDBT_FAILED; + } + if (pNdb->init(max)){ + ERR(pNdb->getNdbError()); + delete pNdb; + return NDBT_FAILED; + } + + NdbConnection* pCon = pNdb->startTransaction(); + if (pCon == NULL){ + pNdb->closeTransaction(pCon); + delete pNdb; + return NDBT_FAILED; + } + + Uint32 i; + Vector scans; + for(i = 0; i<10*max; i++) + { + NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName()); + if (pOp == NULL){ + ERR(pCon->getNdbError()); + pNdb->closeTransaction(pCon); + delete pNdb; + return NDBT_FAILED; + } + + NdbResultSet* rs; + if ((rs= pOp->readTuples()) == 0){ + pNdb->closeTransaction(pCon); + ERR(pOp->getNdbError()); + delete pNdb; + return NDBT_FAILED; + } + scans.push_back(rs); + } + + // Dont' call any equal or setValues + + // Execute should not work + int check = pCon->execute(NoCommit); + if (check == 0){ + ndbout << "execute worked" << endl; + } else { + ERR(pCon->getNdbError()); + } + + for(i= 0; inextResult()) == 0); + if(check != 1) + { + ERR(pOp->getOperation()->getNdbError()); + pNdb->closeTransaction(pCon); + delete pNdb; + return NDBT_FAILED; + } + } + + pNdb->closeTransaction(pCon); + + Vector cons; + for(i= 0; i<10*max; i++) + { + pCon= pNdb->startTransaction(); + if(pCon) + cons.push_back(pCon); + else + break; + } + + for(i= 0; iclose(); + } + + if(cons.size() != max) + { + result= NDBT_FAILED; + } + + delete pNdb; + + return result; +} + +template class Vector; NDBT_TESTSUITE(testNdbApi); @@ -1363,6 +1459,12 @@ TESTCASE("Bug_11133", INITIALIZER(runBug_11133); FINALIZER(runClearTable); } +TESTCASE("Scan_4006", + "Check that getNdbScanOperation does not get 4006\n"){ + INITIALIZER(runLoadTable); + INITIALIZER(runScan_4006); + FINALIZER(runClearTable); +} NDBT_TESTSUITE_END(testNdbApi); int main(int argc, const char** argv){ diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index a28f8fe0bd0..9eb15a5c3d7 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -550,6 +550,10 @@ max-time: 500 cmd: testNdbApi args: -n Bug_11133 T1 +max-time: 500 +cmd: testNdbApi +args: -n Scan_4006 T1 + #max-time: 500 #cmd: testInterpreter #args: T1 diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index a0080af1dfb..18c061f7bec 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -41,7 +41,7 @@ static const int parallelism= 240; // Default value for max number of transactions // createable against NDB from this handler -static const int max_transactions= 256; +static const int max_transactions= 2; static const char *ha_ndb_ext=".ndb";