From 3962e2d47271aee3a0e115145767a2cbc25b26f8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 May 2007 07:49:05 +0200 Subject: [PATCH] ndb - bug#27437 bug in interpretedupdate (used for auto-increment) that made TUPKEYREF be sent twice this was however "normally" shadowed, but made LQH crash when LCP was about to start mysql-test/r/ndb_basic.result: testcase mysql-test/t/ndb_basic.test: testcase ndb/src/kernel/blocks/dblqh/Dblqh.hpp: add extra variable to make sure TUPKEYREF is not received twice (VM_TRACE) ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: add extra variable to make sure TUPKEYREF is not received twice (VM_TRACE) ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp: make sure TUPKEYREF is not sent twice in case of "error" in interpreted program --- mysql-test/r/ndb_basic.result | 6 ++++++ mysql-test/t/ndb_basic.test | 15 +++++++++++++++ ndb/src/kernel/blocks/dblqh/Dblqh.hpp | 3 +++ ndb/src/kernel/blocks/dblqh/DblqhMain.cpp | 17 +++++++++++++++++ ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp | 6 +++++- 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 09c4f9b29f9..91427701c05 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -667,6 +667,12 @@ counter datavalue 57 newval 58 newval drop table t1; +create table t1 (a int primary key auto_increment) engine = ndb; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +insert into t1(a) values (20),(28); +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +insert into t1() values (21), (22); +drop table t1; CREATE TABLE t1 ( b INT ) PACK_KEYS = 0 ENGINE = ndb; select * from t1; b diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 5d79d5eb9f9..5b13eab546e 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -606,6 +606,21 @@ select * from t1 order by counter; drop table t1; +# +# bug#27437 +connection con1; +create table t1 (a int primary key auto_increment) engine = ndb; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +connection con2; +insert into t1(a) values (20),(28); +connection con1; +insert into t1() values (),(),(),(),(),(),(),(),(),(),(),(); +connection con2; +insert into t1() values (21), (22); +connection con1; + +drop table t1; + # # BUG#14514 Creating table with packed key fails silently # diff --git a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp index 0691e52d0ee..3c0faff7236 100644 --- a/ndb/src/kernel/blocks/dblqh/Dblqh.hpp +++ b/ndb/src/kernel/blocks/dblqh/Dblqh.hpp @@ -2059,6 +2059,9 @@ public: Uint8 simpleRead; Uint8 seqNoReplica; Uint8 tcNodeFailrec; +#ifdef VM_TRACE + Uint8 tupkeyref; +#endif }; /* p2c: size = 280 bytes */ typedef Ptr TcConnectionrecPtr; diff --git a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp index 5847e1063aa..b8ab0eec902 100644 --- a/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp +++ b/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp @@ -2766,6 +2766,12 @@ void Dblqh::execTUPKEYREF(Signal* signal) tcConnectptr.i = tupKeyRef->userRef; terrorCode = tupKeyRef->errorCode; ptrCheckGuard(tcConnectptr, ctcConnectrecFileSize, tcConnectionrec); + +#ifdef VM_TRACE + ndbrequire(tcConnectptr.p->tupkeyref == 0); + tcConnectptr.p->tupkeyref = 1; +#endif + switch (tcConnectptr.p->transactionState) { case TcConnectionrec::WAIT_TUP: jam(); @@ -3331,6 +3337,10 @@ void Dblqh::seizeTcrec() locTcConnectptr.p->tcTimer = cLqhTimeOutCount; locTcConnectptr.p->tableref = RNIL; locTcConnectptr.p->savePointId = 0; +#ifdef VM_TRACE + locTcConnectptr.p->tupkeyref = 0; +#endif + cfirstfreeTcConrec = nextTc; tcConnectptr = locTcConnectptr; locTcConnectptr.p->connectState = TcConnectionrec::CONNECTED; @@ -5861,6 +5871,10 @@ void Dblqh::completeUnusualLab(Signal* signal) void Dblqh::releaseTcrec(Signal* signal, TcConnectionrecPtr locTcConnectptr) { jam(); +#ifdef VM_TRACE + locTcConnectptr.p->tupkeyref = 0; +#endif + locTcConnectptr.p->tcTimer = 0; locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED; locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec; @@ -5883,6 +5897,9 @@ void Dblqh::releaseTcrec(Signal* signal, TcConnectionrecPtr locTcConnectptr) void Dblqh::releaseTcrecLog(Signal* signal, TcConnectionrecPtr locTcConnectptr) { jam(); +#ifdef VM_TRACE + locTcConnectptr.p->tupkeyref = 0; +#endif locTcConnectptr.p->tcTimer = 0; locTcConnectptr.p->transactionState = TcConnectionrec::TC_NOT_CONNECTED; locTcConnectptr.p->nextTcConnectrec = cfirstfreeTcConrec; diff --git a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp index 15ce54e594c..a94d2f70343 100644 --- a/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp +++ b/ndb/src/kernel/blocks/dbtup/DbtupExecQuery.cpp @@ -1139,7 +1139,11 @@ Dbtup::updateStartLab(Signal* signal, regOperPtr->attrinbufLen); } else { jam(); - retValue = interpreterStartLab(signal, pagePtr, regOperPtr->pageOffset); + if (interpreterStartLab(signal, pagePtr, regOperPtr->pageOffset) == -1) + { + jam(); + return -1; + } }//if if (retValue == -1) {