From 3d42abedaeeed352ea08887a3e757c3a5fa9758c Mon Sep 17 00:00:00 2001 From: "jonas@perch.ndb.mysql.com" <> Date: Tue, 1 Aug 2006 17:10:17 +0200 Subject: [PATCH] ndb - add abort flag to hugoLoad --- storage/ndb/test/include/HugoTransactions.hpp | 3 ++- storage/ndb/test/src/HugoTransactions.cpp | 23 +++++++++++++++---- storage/ndb/test/tools/hugoLoad.cpp | 11 +++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/storage/ndb/test/include/HugoTransactions.hpp b/storage/ndb/test/include/HugoTransactions.hpp index 5c987a576bc..f9acaf322f7 100644 --- a/storage/ndb/test/include/HugoTransactions.hpp +++ b/storage/ndb/test/include/HugoTransactions.hpp @@ -34,7 +34,8 @@ public: bool allowConstraintViolation = true, int doSleep = 0, bool oneTrans = false, - int updateValue = 0); + int updateValue = 0, + bool abort = false); int scanReadRecords(Ndb*, int records, diff --git a/storage/ndb/test/src/HugoTransactions.cpp b/storage/ndb/test/src/HugoTransactions.cpp index 74aab2aa55a..525f50f5231 100644 --- a/storage/ndb/test/src/HugoTransactions.cpp +++ b/storage/ndb/test/src/HugoTransactions.cpp @@ -519,7 +519,8 @@ HugoTransactions::loadTable(Ndb* pNdb, bool allowConstraintViolation, int doSleep, bool oneTrans, - int value){ + int value, + bool abort){ int check, a; int retryAttempt = 0; int retryMax = 5; @@ -585,10 +586,22 @@ HugoTransactions::loadTable(Ndb* pNdb, if (!oneTrans || (c + batch) >= records) { // closeTrans = true; closeTrans = false; - check = pTrans->execute( Commit ); - if(check != -1) - m_latest_gci = pTrans->getGCI(); - pTrans->restart(); + if (!abort) + { + check = pTrans->execute( Commit ); + if(check != -1) + m_latest_gci = pTrans->getGCI(); + pTrans->restart(); + } + else + { + check = pTrans->execute( NoCommit ); + if (check != -1) + { + check = pTrans->execute( Rollback ); + closeTransaction(pNdb); + } + } } else { closeTrans = false; check = pTrans->execute( NoCommit ); diff --git a/storage/ndb/test/tools/hugoLoad.cpp b/storage/ndb/test/tools/hugoLoad.cpp index 49c489e5db5..870ce8b0289 100644 --- a/storage/ndb/test/tools/hugoLoad.cpp +++ b/storage/ndb/test/tools/hugoLoad.cpp @@ -31,6 +31,8 @@ int main(int argc, const char** argv){ int _batch = 512; int _loops = -1; int _rand = 0; + int _onetrans = 0; + int _abort = 0; const char* db = 0; struct getargs args[] = { @@ -39,7 +41,9 @@ int main(int argc, const char** argv){ { "loops", 'l', arg_integer, &_loops, "Number of loops", "" }, { "database", 'd', arg_string, &db, "Database", "" }, { "usage", '?', arg_flag, &_help, "Print help", "" }, - { "rnd-rows", 0, arg_flag, &_rand, "Rand number of records", "recs" } + { "rnd-rows", 0, arg_flag, &_rand, "Rand number of records", "recs" }, + { "one-trans", 0, arg_flag, &_onetrans, "Insert as 1 trans", "" }, + { "abort", 0, arg_integer, &_abort, "Abort probability", "" } }; int num_args = sizeof(args) / sizeof(args[0]); int optind = 0; @@ -92,10 +96,13 @@ int main(int argc, const char** argv){ HugoTransactions hugoTrans(*pTab); loop: int rows = (_rand ? rand() % _records : _records); + int abort = (rand() % 100) < _abort ? 1 : 0; + if (abort) + ndbout << "load+abort" << endl; if (hugoTrans.loadTable(&MyNdb, rows, _batch, - true, 0, false, _loops) != 0){ + true, 0, _onetrans, _loops, abort) != 0){ return NDBT_ProgramExit(NDBT_FAILED); }