diff options
Diffstat (limited to 'ndb')
-rw-r--r-- | ndb/src/common/logger/Logger.cpp | 4 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/ConfigRetriever.cpp | 4 | ||||
-rw-r--r-- | ndb/src/cw/cpcd/main.cpp | 6 | ||||
-rw-r--r-- | ndb/src/kernel/SimBlockList.cpp | 1 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/dbtc/DbtcMain.cpp | 16 | ||||
-rw-r--r-- | ndb/src/ndbapi/NdbDictionaryImpl.cpp | 7 | ||||
-rw-r--r-- | ndb/test/ndbapi/testBlobs.cpp | 15 | ||||
-rw-r--r-- | ndb/test/ndbapi/testTimeout.cpp | 86 | ||||
-rwxr-xr-x | ndb/test/run-test/make-config.sh | 34 | ||||
-rwxr-xr-x | ndb/test/run-test/ndb-autotest.sh | 17 | ||||
-rw-r--r-- | ndb/tools/restore/consumer_restore.cpp | 24 |
11 files changed, 146 insertions, 68 deletions
diff --git a/ndb/src/common/logger/Logger.cpp b/ndb/src/common/logger/Logger.cpp index 7f18f5bd3ec..4a48236053d 100644 --- a/ndb/src/common/logger/Logger.cpp +++ b/ndb/src/common/logger/Logger.cpp @@ -352,11 +352,11 @@ Logger::log(LoggerLevel logLevel, const char* pMsg, va_list ap) const { if (m_logLevels[LL_ON] && m_logLevels[logLevel]) { + char buf[MAX_LOG_MESSAGE_SIZE]; + BaseString::vsnprintf(buf, sizeof(buf), pMsg, ap); LogHandler* pHandler = NULL; while ( (pHandler = m_pHandlerList->next()) != NULL) { - char buf[MAX_LOG_MESSAGE_SIZE]; - BaseString::vsnprintf(buf, sizeof(buf), pMsg, ap); pHandler->append(m_pCategory, logLevel, buf); } } diff --git a/ndb/src/common/mgmcommon/ConfigRetriever.cpp b/ndb/src/common/mgmcommon/ConfigRetriever.cpp index fd04ad393eb..648f3b4a52c 100644 --- a/ndb/src/common/mgmcommon/ConfigRetriever.cpp +++ b/ndb/src/common/mgmcommon/ConfigRetriever.cpp @@ -138,7 +138,9 @@ ConfigRetriever::getConfig(NdbMgmHandle m_handle){ setError(CR_ERROR, ndb_mgm_get_latest_error_desc(m_handle)); return 0; } - + + ndb_mgm_disconnect(m_handle); + return conf; } diff --git a/ndb/src/cw/cpcd/main.cpp b/ndb/src/cw/cpcd/main.cpp index 25632f132e9..ba877095a04 100644 --- a/ndb/src/cw/cpcd/main.cpp +++ b/ndb/src/cw/cpcd/main.cpp @@ -32,10 +32,9 @@ #include "common.hpp" static const char *work_dir = CPCD_DEFAULT_WORK_DIR; -static int port; +static int unsigned port; static int use_syslog; static const char *logfile = NULL; -static const char *config_file = CPCD_DEFAULT_CONFIG_FILE; static const char *user = 0; static struct my_option my_long_options[] = @@ -55,9 +54,6 @@ static struct my_option my_long_options[] = { "debug", 'D', "Enable debug mode", (gptr*) &debug, (gptr*) &debug, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, - { "config", 'c', "Config file", - (gptr*) &config_file, (gptr*) &config_file, 0, - GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "user", 'u', "Run as user", (gptr*) &user, (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, diff --git a/ndb/src/kernel/SimBlockList.cpp b/ndb/src/kernel/SimBlockList.cpp index 75a52ae0c4b..bf3958cf137 100644 --- a/ndb/src/kernel/SimBlockList.cpp +++ b/ndb/src/kernel/SimBlockList.cpp @@ -39,7 +39,6 @@ #else enum SIMBLOCKLIST_DUMMY { A_VALUE = 0 }; -static void * operator new (size_t sz, SIMBLOCKLIST_DUMMY dummy){ char * tmp = (char *)malloc(sz); diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index ca97a5bce6d..736a660f396 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -722,11 +722,14 @@ Dbtc::set_timeout_value(Uint32 timeOut) void Dbtc::set_appl_timeout_value(Uint32 timeOut) { - timeOut /= 10; - if (timeOut < ctimeOutValue) { - jam(); - c_appl_timeout_value = ctimeOutValue; - }//if + if (timeOut) + { + timeOut /= 10; + if (timeOut < ctimeOutValue) { + jam(); + c_appl_timeout_value = ctimeOutValue; + }//if + } c_appl_timeout_value = timeOut; } @@ -6133,7 +6136,8 @@ void Dbtc::timeOutFoundLab(Signal* signal, Uint32 TapiConPtr) particular state we will use the application timeout parameter rather than the shorter Deadlock detection timeout. */ - if ((ctcTimer - getApiConTimer(apiConnectptr.i)) <= c_appl_timeout_value) { + if (c_appl_timeout_value == 0 || + (ctcTimer - getApiConTimer(apiConnectptr.i)) <= c_appl_timeout_value) { jam(); return; }//if diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 4523ae2c261..645aa333ea7 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -1004,6 +1004,11 @@ NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) return 0; } + // avoid alignment problem and memory overrun + Uint32 name_buf[(MAX_TAB_NAME_SIZE + 3) / 4]; + strncpy((char*)name_buf, name, sizeof(name_buf)); // strncpy null-pads + name = (char*)name_buf; + req->senderRef = m_reference; req->senderData = 0; req->requestType = @@ -1015,7 +1020,7 @@ NdbDictInterface::getTable(const char * name, bool fullyQualifiedNames) tSignal.theLength = GetTabInfoReq::SignalLength; LinearSectionPtr ptr[1]; ptr[0].p = (Uint32*)name; - ptr[0].sz = strLen; + ptr[0].sz = (strLen + 3) / 4; return getTable(&tSignal, ptr, 1, fullyQualifiedNames); } diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 7b30777456f..efbdceac5a6 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -365,7 +365,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) { if (b.m_nullable && urandom(10) == 0) { v.m_len = 0; - delete v.m_val; + delete [] v.m_val; v.m_val = 0; v.m_buf = new char [1]; } else { @@ -375,7 +375,7 @@ calcBval(const Bcol& b, Bval& v, bool keepsize) v.m_len = urandom(b.m_inline); else v.m_len = urandom(b.m_inline + g_opt.m_parts * b.m_partsize + 1); - delete v.m_val; + delete [] v.m_val; v.m_val = new char [v.m_len + 1]; for (unsigned i = 0; i < v.m_len; i++) v.m_val[i] = 'a' + urandom(25); @@ -1449,6 +1449,7 @@ testperf() if (! testcase('p')) return 0; DBG("=== perf test ==="); + g_bh1 = g_bh2 = 0; g_ndb = new Ndb(g_ncc, "TEST_DB"); CHK(g_ndb->init() == 0); CHK(g_ndb->waitUntilReady() == 0); @@ -1547,11 +1548,11 @@ testperf() } if (n != 0) { CHK(g_con->execute(Commit) == 0); + g_ndb->closeTransaction(g_con); g_con = 0; n = 0; } g_bh1 = 0; g_opr = 0; - g_con = 0; } // pk read char (one trans) { @@ -1575,7 +1576,7 @@ testperf() t1.off(g_opt.m_rowsperf); DBG(t1.time()); g_opr = 0; - g_con = 0; + g_ndb->closeTransaction(g_con); g_con = 0; } // pk read text (one trans) { @@ -1600,7 +1601,7 @@ testperf() CHK(g_con->execute(Commit) == 0); t2.off(g_opt.m_rowsperf); DBG(t2.time()); - g_opr = 0; + g_ndb->closeTransaction(g_con); g_opr = 0; g_con = 0; } // pk read overhead @@ -1634,7 +1635,7 @@ testperf() CHK(n == g_opt.m_rowsperf); t1.off(g_opt.m_rowsperf); DBG(t1.time()); - g_ops = 0; + g_ndb->closeTransaction(g_con); g_ops = 0; g_con = 0; } // scan read text @@ -1668,7 +1669,7 @@ testperf() DBG(t2.time()); g_bh1 = 0; g_ops = 0; - g_con = 0; + g_ndb->closeTransaction(g_con); g_con = 0; } // scan read overhead DBG("scan read overhead: " << t2.over(t1)); diff --git a/ndb/test/ndbapi/testTimeout.cpp b/ndb/test/ndbapi/testTimeout.cpp index e310e12df81..71c11b25859 100644 --- a/ndb/test/ndbapi/testTimeout.cpp +++ b/ndb/test/ndbapi/testTimeout.cpp @@ -22,14 +22,14 @@ #include <NdbConfig.hpp> #include <signaldata/DumpStateOrd.hpp> -#define TIMEOUT 3000 - +#define TIMEOUT (Uint32)3000 Uint32 g_org_timeout = 3000; int setTransactionTimeout(NDBT_Context* ctx, NDBT_Step* step){ NdbRestarter restarter; - + int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); + NdbConfig conf(GETNDB(step)->getNodeId()+1); unsigned int nodeId = conf.getMasterNodeId(); if (!conf.getProperty(nodeId, @@ -39,7 +39,7 @@ setTransactionTimeout(NDBT_Context* ctx, NDBT_Step* step){ return NDBT_FAILED; } - int val[] = { DumpStateOrd::TcSetApplTransactionTimeout, TIMEOUT }; + int val[] = { DumpStateOrd::TcSetApplTransactionTimeout, timeout }; if(restarter.dumpStateAllNodes(val, 2) != 0){ return NDBT_FAILED; } @@ -94,9 +94,11 @@ int runTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ unsigned int nodeId = conf.getMasterNodeId(); int stepNo = step->getStepNo(); - int minSleep = (int)(TIMEOUT * 1.5); - int maxSleep = TIMEOUT * 2; - ndbout << "TransactionInactiveTimeout="<< TIMEOUT + int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); + + int minSleep = (int)(timeout * 1.5); + int maxSleep = timeout * 2; + ndbout << "TransactionInactiveTimeout="<< timeout << ", minSleep="<<minSleep << ", maxSleep="<<maxSleep<<endl; @@ -134,8 +136,10 @@ int runTimeoutTrans2(NDBT_Context* ctx, NDBT_Step* step){ int mul2 = ctx->getProperty("Op2", (Uint32)0); int records = ctx->getNumRecords(); - int minSleep = (int)(TIMEOUT * 1.5); - int maxSleep = TIMEOUT * 2; + int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); + + int minSleep = (int)(timeout * 1.5); + int maxSleep = timeout * 2; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); @@ -148,7 +152,7 @@ int runTimeoutTrans2(NDBT_Context* ctx, NDBT_Step* step){ op1 = (op1 % 5); op2 = (op2 % 5); - ndbout << stepNo << ": TransactionInactiveTimeout="<< TIMEOUT + ndbout << stepNo << ": TransactionInactiveTimeout="<< timeout << ", minSleep="<<minSleep << ", maxSleep="<<maxSleep << ", op1=" << op1 @@ -250,8 +254,10 @@ int runDontTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ int loops = ctx->getNumLoops(); int stepNo = step->getStepNo(); - int maxSleep = (int)(TIMEOUT * 0.5); - ndbout << "TransactionInactiveTimeout="<< TIMEOUT + int timeout = ctx->getProperty("TransactionInactiveTimeout",TIMEOUT); + + int maxSleep = (int)(timeout * 0.5); + ndbout << "TransactionInactiveTimeout="<< timeout << ", maxSleep="<<maxSleep<<endl; @@ -281,6 +287,51 @@ int runDontTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ return result; } +int runDeadlockTimeoutTrans(NDBT_Context* ctx, NDBT_Step* step){ + int result = NDBT_OK; + int loops = ctx->getNumLoops(); + int stepNo = step->getStepNo(); + + Uint32 deadlock_timeout; + NdbConfig conf(GETNDB(step)->getNodeId()+1); + unsigned int nodeId = conf.getMasterNodeId(); + if (!conf.getProperty(nodeId, + NODE_TYPE_DB, + CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, + &deadlock_timeout)){ + return NDBT_FAILED; + } + + + int do_sleep = (int)(deadlock_timeout * 0.5); + + + HugoOperations hugoOps(*ctx->getTab()); + Ndb* pNdb = GETNDB(step); + + for (int l = 0; l < loops && result == NDBT_OK; l++){ + + do{ + // Commit transaction + CHECK(hugoOps.startTransaction(pNdb) == 0); + CHECK(hugoOps.pkReadRecord(pNdb, stepNo) == 0); + CHECK(hugoOps.execute_NoCommit(pNdb) == 0); + + int sleep = deadlock_timeout * 1.5 + myRandom48(do_sleep); + ndbout << "Sleeping for " << sleep << " milliseconds" << endl; + NdbSleep_MilliSleep(sleep); + + // Expect that transaction has NOT timed-out + CHECK(hugoOps.execute_Commit(pNdb) == 0); + + } while(false); + + hugoOps.closeTransaction(pNdb); + } + + return result; +} + int runBuddyTransNoTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); @@ -334,6 +385,17 @@ TESTCASE("DontTimeoutTransaction", FINALIZER(resetTransactionTimeout); FINALIZER(runClearTable); } +TESTCASE("Bug11290", + "Setting TransactionInactiveTimeout to 0(zero) "\ + "should result in infinite timeout, and not as "\ + "was the bug, a timeout that is equal to the deadlock timeout"){ + TC_PROPERTY("TransactionInactiveTimeout",(Uint32)0); + INITIALIZER(runLoadTable); + INITIALIZER(setTransactionTimeout); + STEPS(runDeadlockTimeoutTrans, 1); + FINALIZER(resetTransactionTimeout); + FINALIZER(runClearTable); +} TESTCASE("DontTimeoutTransaction5", "Test that the transaction does not timeout "\ "if we sleep during the transaction. Use a sleep "\ diff --git a/ndb/test/run-test/make-config.sh b/ndb/test/run-test/make-config.sh index 1321ce4e9f0..e82acb8a7dd 100755 --- a/ndb/test/run-test/make-config.sh +++ b/ndb/test/run-test/make-config.sh @@ -20,40 +20,40 @@ add_procs(){ } add_proc (){ - dir="" - conf="" case $type in mgm) - dir="ndb_mgmd" - conf="[ndb_mgmd]\nId: $node_id\nHostName: $2\n" + echo "$proc_no.ndb_mgmd" >> $dir_file + echo "[ndb_mgmd]" >> $config_file + echo "Id: $node_id" >> $config_file + echo "HostName: $2" >> $config_file node_id=`expr $node_id + 1` ;; api) - dir="ndb_api" - conf="[api]\nId: $node_id\nHostName: $2\n" + echo "$proc_no.ndb_api" >> $dir_file + echo "[api]" >> $config_file + echo "Id: $node_id" >> $config_file + echo "HostName: $2" >> $config_file node_id=`expr $node_id + 1` ;; ndb) - dir="ndbd" - conf="[ndbd]\nId: $node_id\nHostName: $2\n" + echo "$proc_no.ndbd" >> $dir_file + echo "[ndbd]" >> $config_file + echo "Id: $node_id" >> $config_file + echo "HostName: $2" >> $config_file node_id=`expr $node_id + 1` ;; mysqld) - dir="mysqld" - conf="[mysqld]\nId: $node_id\nHostName: $2\n" + echo "$proc_no.mysqld" >> $dir_file + echo "[ndb_mgmd]" >> $config_file + echo "Id: $node_id" >> $config_file + echo "HostName: $2" >> $config_file node_id=`expr $node_id + 1` ;; mysql) - dir="mysql" + echo "$proc_no.mysql" >> $dir_file ;; esac - dir="$proc_no.$dir" proc_no=`expr $proc_no + 1` - echo -e $dir >> $dir_file - if [ "$conf" ] - then - echo -e $conf >> $config_file - fi } diff --git a/ndb/test/run-test/ndb-autotest.sh b/ndb/test/run-test/ndb-autotest.sh index 09087a8a8c7..573a9953924 100755 --- a/ndb/test/run-test/ndb-autotest.sh +++ b/ndb/test/run-test/ndb-autotest.sh @@ -66,7 +66,7 @@ done if [ -f $conf ] then - . $conf + . ./$conf else echo "Can't find config file: $conf" exit @@ -131,8 +131,10 @@ echo "$DATE $RUN" > $LOCK # trap them, and remove the # # Lock file before exit # ############################# - -trap "rm -f $LOCK" ERR +if [ `uname -s` != "SunOS" ] +then + trap "rm -f $LOCK" ERR +fi # You can add more to this path# ################################ @@ -191,7 +193,7 @@ then else echo $VERSION > /tmp/version.$$ fi -match=`grep -c "$VERSION" /tmp/version.$$` +match=`grep -c "$VERSION" /tmp/version.$$ | xargs echo` rm -f /tmp/version.$$ if [ $match -eq 0 ] then @@ -229,7 +231,7 @@ filter(){ shift while [ $# -gt 0 ] do - if [ `grep -c $1 $neg` -eq 0 ] ; then echo $1; fi + if [ `grep -c $1 $neg | xargs echo` -eq 0 ] ; then echo $1; fi shift done } @@ -294,13 +296,12 @@ choose_conf(){ if [ -f $test_dir/conf-$1-$HOST.txt ] then echo "$test_dir/conf-$1-$HOST.txt" - echo "$test_dir/conf-$1-$host.txt" elif [ -f $test_dir/conf-$1.txt ] then echo "$test_dir/conf-$1.txt" else echo "Unable to find conf file looked for" 1>&2 - echo "$testdir/conf-$1-host.txt and" 1>&2 + echo "$testdir/conf-$1-$HOST.txt and" 1>&2 echo "$testdir/conf-$1.txt" 1>&2 exit fi @@ -343,7 +344,7 @@ start(){ count_hosts(){ cnt=`grep "CHOOSE_host" $1 | awk '{for(i=1; i<=NF;i++) \ - if(match($i, "CHOOSE_host") > 0) print $i;}' | sort | uniq | wc -l` + if(index($i, "CHOOSE_host") > 0) print $i;}' | sort | uniq | wc -l` echo $cnt } ####################################################### diff --git a/ndb/tools/restore/consumer_restore.cpp b/ndb/tools/restore/consumer_restore.cpp index 9d161773bd2..d782a561e6a 100644 --- a/ndb/tools/restore/consumer_restore.cpp +++ b/ndb/tools/restore/consumer_restore.cpp @@ -288,12 +288,11 @@ void BackupRestore::tuple_a(restore_callback_t *cb) cb->connection = m_ndb->startTransaction(); if (cb->connection == NULL) { - /* - if (errorHandler(cb)) - { + if (errorHandler(cb)) + { + m_ndb->sendPollNdb(3000, 1); continue; - } - */ + } exitHandler(); } // if @@ -409,9 +408,17 @@ void BackupRestore::cback(int result, restore_callback_t *cb) */ bool BackupRestore::errorHandler(restore_callback_t *cb) { - NdbError error= cb->connection->getNdbError(); - m_ndb->closeTransaction(cb->connection); - cb->connection= 0; + NdbError error; + if(cb->connection) + { + error= cb->connection->getNdbError(); + m_ndb->closeTransaction(cb->connection); + cb->connection= 0; + } + else + { + error= m_ndb->getNdbError(); + } Uint32 sleepTime = 100 + cb->retries * 300; @@ -426,6 +433,7 @@ bool BackupRestore::errorHandler(restore_callback_t *cb) break; case NdbError::TemporaryError: + err << "Temporary error: " << error << endl; NdbSleep_MilliSleep(sleepTime); return true; // RETRY |