From 464b4a2a03ec3cfdc84acfed55ff51e668395bf3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2006 13:09:30 +0100 Subject: [PATCH 1/5] ndb - bug#22773 Fix correct log event on db-node disconnect ndb/src/mgmsrv/MgmtSrvr.cpp: Fix typo --- ndb/src/mgmsrv/MgmtSrvr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ndb/src/mgmsrv/MgmtSrvr.cpp b/ndb/src/mgmsrv/MgmtSrvr.cpp index 69c0286a1de..5c4a5ef7d17 100644 --- a/ndb/src/mgmsrv/MgmtSrvr.cpp +++ b/ndb/src/mgmsrv/MgmtSrvr.cpp @@ -1900,7 +1900,7 @@ MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete) m_started_nodes.push_back(nodeId); rep->setEventType(NDB_LE_Connected); } else { - rep->setEventType(NDB_LE_Connected); + rep->setEventType(NDB_LE_Disconnected); if(nfComplete) { DBUG_VOID_RETURN; From 6e47c11c7abac4cd66806b48e07c9b179e2662e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Dec 2006 15:49:59 +0100 Subject: [PATCH 2/5] Bug#24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld: Added test case --- mysql-test/r/ndb_index_unique.result | 15 +++++++++++++++ mysql-test/t/ndb_index_unique.test | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/mysql-test/r/ndb_index_unique.result b/mysql-test/r/ndb_index_unique.result index f9fb6f89aa2..3bc41e8a197 100644 --- a/mysql-test/r/ndb_index_unique.result +++ b/mysql-test/r/ndb_index_unique.result @@ -133,6 +133,21 @@ a b c 6 7 2 7 8 3 8 2 3 +create unique index bi using hash on t2(b); +insert into t2 values(9, 3, 1); +ERROR 23000: Duplicate entry '' for key 0 +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; +a b c +2 3 5 +3 4 6 +4 5 8 +5 6 2 +6 7 2 +7 8 3 +8 2 3 +9 3 1 drop table t2; CREATE TABLE t2 ( a int unsigned NOT NULL PRIMARY KEY, diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 458f6a165f8..2bf4a763313 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -83,6 +83,14 @@ delete from t2 where a = 1; insert into t2 values(8, 2, 3); select * from t2 order by a; +# Bug #24818 CREATE UNIQUE INDEX (...) USING HASH on a NDB table crashes mysqld +create unique index bi using hash on t2(b); +-- error 1062 +insert into t2 values(9, 3, 1); +alter table t2 drop index bi; +insert into t2 values(9, 3, 1); +select * from t2 order by a; + drop table t2; -- error 1121 From 52fad14534d6b75d6917a6107e8507d81dc2eb65 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 12:37:55 +0100 Subject: [PATCH 3/5] ndb - bug#25090 make sure apicon timer is reset when setting CS_CONNECTED ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: make sure apicon timer is reset when setting CS_CONNECTED --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index a436316f7c9..1af8337e3b6 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -5220,6 +5220,8 @@ void Dbtc::execLQHKEYREF(Signal* signal) jam(); sendtckeyconf(signal, 1); regApiPtr->apiConnectstate = CS_CONNECTED; + regApiPtr->m_transaction_nodes.clear(); + setApiConTimer(apiConnectptr.i, 0,__LINE__); } return; } else if (regApiPtr->tckeyrec > 0 || regApiPtr->m_exec_flag) { From 04ce9e4b48cf896abf9cc8aead4f1b6031f1e32b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 13:31:31 +0100 Subject: [PATCH 4/5] ndb - bug#25090 add testcase ndb/test/ndbapi/testBasic.cpp: add testcase for bug#25090 ndb/test/run-test/daily-basic-tests.txt: add testcase for bug#25090 --- ndb/test/ndbapi/testBasic.cpp | 26 +++++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/ndb/test/ndbapi/testBasic.cpp b/ndb/test/ndbapi/testBasic.cpp index 4d64b15ecfa..10235eef6d7 100644 --- a/ndb/test/ndbapi/testBasic.cpp +++ b/ndb/test/ndbapi/testBasic.cpp @@ -1034,6 +1034,28 @@ runMassiveRollback2(NDBT_Context* ctx, NDBT_Step* step){ return result; } +int +runBug25090(NDBT_Context* ctx, NDBT_Step* step){ + + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary * dict = pNdb->getDictionary(); + + HugoOperations ops(*ctx->getTab()); + + int loops = ctx->getNumLoops(); + const int rows = ctx->getNumRecords(); + + while (loops--) + { + ops.startTransaction(pNdb); + ops.pkReadRecord(pNdb, 1, 1); + ops.execute_Commit(pNdb, AO_IgnoreError); + sleep(10); + ops.closeTransaction(pNdb); + } + + return NDBT_OK; +} NDBT_TESTSUITE(testBasic); TESTCASE("PkInsert", @@ -1277,6 +1299,10 @@ TESTCASE("Fill", INITIALIZER(runPkRead); FINALIZER(runClearTable2); } +TESTCASE("Bug25090", + "Verify what happens when we fill the db" ){ + STEP(runBug25090); +} NDBT_TESTSUITE_END(testBasic); #if 0 diff --git a/ndb/test/run-test/daily-basic-tests.txt b/ndb/test/run-test/daily-basic-tests.txt index 031c519ae6d..84982dd96f1 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -211,6 +211,10 @@ max-time: 500 cmd: testTimeout args: T1 +max-time: 500 +cmd: testBasic +args: -n Bug25090 T1 + # SCAN TESTS # max-time: 500 From 9a79c0dc68eb2359771546a0151a185f8eed90f1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 15:39:45 +0100 Subject: [PATCH 5/5] ndb - bug#25059 incorrect handling of commit/ignore error in unique index code ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: 1) handle potential ptr error 2) remove incorrect commit-handling in uk code ndb/src/ndbapi/NdbTransaction.cpp: 1) force 4012 2) handle AO_IgnoreError in uk code ndb/src/ndbapi/Ndbif.cpp: force 4012 ndb/test/ndbapi/testIndex.cpp: test program for 25059 ndb/test/run-test/daily-basic-tests.txt: add testcase --- ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 15 +----- ndb/src/ndbapi/NdbTransaction.cpp | 9 ++++ ndb/src/ndbapi/Ndbif.cpp | 1 + ndb/test/ndbapi/testIndex.cpp | 65 +++++++++++++++++++++++++ ndb/test/run-test/daily-basic-tests.txt | 4 ++ 5 files changed, 81 insertions(+), 13 deletions(-) diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 1af8337e3b6..9f1426109d4 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -5084,7 +5084,7 @@ void Dbtc::execLQHKEYREF(Signal* signal) ptrAss(tcConnectptr, tcConnectRecord); TcConnectRecord * const regTcPtr = tcConnectptr.p; if (regTcPtr->tcConnectstate == OS_OPERATING) { - apiConnectptr.i = regTcPtr->apiConnect; + Uint32 save = apiConnectptr.i = regTcPtr->apiConnect; ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord); ApiConnectRecord * const regApiPtr = apiConnectptr.p; compare_transid1 = regApiPtr->transid[0] ^ lqhKeyRef->transId1; @@ -5195,7 +5195,7 @@ void Dbtc::execLQHKEYREF(Signal* signal) regApiPtr->lqhkeyreqrec--; // Compensate for extra during read tcKeyRef->connectPtr = indexOp; EXECUTE_DIRECT(DBTC, GSN_TCKEYREF, signal, TcKeyRef::SignalLength); - apiConnectptr.i = regTcPtr->apiConnect; + apiConnectptr.i = save; apiConnectptr.p = regApiPtr; } else { jam(); @@ -11880,17 +11880,6 @@ void Dbtc::execTCKEYREF(Signal* signal) case(IOS_INDEX_ACCESS_WAIT_FOR_TRANSID_AI): case(IOS_INDEX_ACCESS_WAIT_FOR_TCKEYCONF): { jam(); - // If we fail index access for a non-read operation during commit - // we abort transaction - if (commitFlg == 1) { - jam(); - releaseIndexOperation(regApiPtr, indexOp); - apiConnectptr.i = indexOp->connectionIndex; - ptrCheckGuard(apiConnectptr, capiConnectFilesize, apiConnectRecord); - terrorCode = tcKeyRef->errorCode; - abortErrorLab(signal); - break; - } /** * Increase count as it will be decreased below... * (and the code is written to handle failing lookup on "real" table diff --git a/ndb/src/ndbapi/NdbTransaction.cpp b/ndb/src/ndbapi/NdbTransaction.cpp index 62bbcefd025..1be11254fc3 100644 --- a/ndb/src/ndbapi/NdbTransaction.cpp +++ b/ndb/src/ndbapi/NdbTransaction.cpp @@ -474,6 +474,7 @@ NdbTransaction::executeNoBlobs(ExecType aTypeOfExec, * This timeout situation can occur if NDB crashes. */ ndbout << "This timeout should never occur, execute(..)" << endl; + theError.code = 4012; setOperationErrorCodeAbort(4012); // Error code for "Cluster Failure" DBUG_RETURN(-1); }//if @@ -1965,6 +1966,14 @@ NdbTransaction::receiveTCINDXCONF(const TcIndxConf * indxConf, theGlobalCheckpointId = tGCI; } else if ((tNoComp >= tNoSent) && (theLastExecOpInList->theCommitIndicator == 1)){ + + if (m_abortOption == AO_IgnoreError && theError.code != 0){ + /** + * There's always a TCKEYCONF when using IgnoreError + */ + return -1; + } + /**********************************************************************/ // We sent the transaction with Commit flag set and received a CONF with // no Commit flag set. This is clearly an anomaly. diff --git a/ndb/src/ndbapi/Ndbif.cpp b/ndb/src/ndbapi/Ndbif.cpp index 6aaf44d0168..0c52e6bd120 100644 --- a/ndb/src/ndbapi/Ndbif.cpp +++ b/ndb/src/ndbapi/Ndbif.cpp @@ -952,6 +952,7 @@ Ndb::check_send_timeout() //abort(); #endif a_con->theReleaseOnClose = true; + a_con->theError.code = 4012; a_con->setOperationErrorCodeAbort(4012); a_con->theCommitStatus = NdbTransaction::NeedAbort; a_con->theCompletionStatus = NdbTransaction::CompletedFailure; diff --git a/ndb/test/ndbapi/testIndex.cpp b/ndb/test/ndbapi/testIndex.cpp index c25aae55897..bec649cf84d 100644 --- a/ndb/test/ndbapi/testIndex.cpp +++ b/ndb/test/ndbapi/testIndex.cpp @@ -1239,7 +1239,64 @@ runBug21384(NDBT_Context* ctx, NDBT_Step* step) return NDBT_OK; } +int +runBug25059(NDBT_Context* ctx, NDBT_Step* step) +{ + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary * dict = pNdb->getDictionary(); + const NdbDictionary::Index * idx = dict->getIndex(pkIdxName, *ctx->getTab()); + HugoOperations ops(*ctx->getTab(), idx); + + int res = NDBT_OK; + int loops = ctx->getNumLoops(); + const int rows = ctx->getNumRecords(); + + while (res == NDBT_OK && loops--) + { + ops.startTransaction(pNdb); + ops.pkReadRecord(pNdb, 10 + rand() % rows, rows); + int tmp; + if (tmp = ops.execute_Commit(pNdb, AO_IgnoreError)) + { + if (tmp == 4012) + res = NDBT_FAILED; + else + if (ops.getTransaction()->getNdbError().code == 4012) + res = NDBT_FAILED; + } + ops.closeTransaction(pNdb); + } + + loops = ctx->getNumLoops(); + while (res == NDBT_OK && loops--) + { + ops.startTransaction(pNdb); + ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows); + int tmp; + int arg; + switch(rand() % 2){ + case 0: + arg = AbortOnError; + break; + case 1: + arg = AO_IgnoreError; + ndbout_c("ignore error"); + break; + } + if (tmp = ops.execute_Commit(pNdb, (AbortOption)arg)) + { + if (tmp == 4012) + res = NDBT_FAILED; + else + if (ops.getTransaction()->getNdbError().code == 4012) + res = NDBT_FAILED; + } + ops.closeTransaction(pNdb); + } + + return res; +} NDBT_TESTSUITE(testIndex); TESTCASE("CreateAll", @@ -1564,6 +1621,14 @@ TESTCASE("Bug21384", FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable); } +TESTCASE("Bug25059", + "Test that unique indexes and nulls"){ + TC_PROPERTY("LoggedIndexes", (unsigned)0); + INITIALIZER(createPkIndex); + INITIALIZER(runLoadTable); + STEP(runBug25059); + FINALIZER(createPkIndex_Drop); +} NDBT_TESTSUITE_END(testIndex); 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 84982dd96f1..a1443970388 100644 --- a/ndb/test/run-test/daily-basic-tests.txt +++ b/ndb/test/run-test/daily-basic-tests.txt @@ -215,6 +215,10 @@ max-time: 500 cmd: testBasic args: -n Bug25090 T1 +max-time: 500 +cmd: testIndex +args: -n Bug25059 -r 3000 T1 + # SCAN TESTS # max-time: 500