19 #include <NDBT_Test.hpp>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <NdbRestarter.hpp>
23 #include <NdbRestarts.hpp>
25 #include <signaldata/DumpStateOrd.hpp>
26 #include <NodeBitmask.hpp>
27 #include <NdbSqlUtil.hpp>
28 #include <BlockNumbers.h>
30 #define CHECK(b) if (!(b)) { \
31 g_err << "ERR: "<< step->getName() \
32 << " failed on line " << __LINE__ << endl; \
33 result = NDBT_FAILED; break;\
36 #define CHECKRET(b) if (!(b)) { \
37 g_err << "ERR: "<< step->getName() \
38 << " failed on line " << __LINE__ << endl; \
56 for(
size_t i = 0;
i < attriblist.size();
i++){
76 for(
int a = 0; a<
i; a++)
78 attriblist.push_back(attr);
85 for(
int a = 0; a<
i; a++)
86 attr->attribs[a] = a+b;
87 attriblist.push_back(attr);
94 attriblist.push_back(attr);
101 attriblist.push_back(attr);
105 attr->numAttribs = 2;
106 for(
int a = 0; a<2; a++){
109 attriblist.push_back(attr);
114 attr->numAttribs = 1;
116 attriblist.push_back(attr);
120 attr->numAttribs = 2;
122 attr->attribs[1] = 0;
123 attriblist.push_back(attr);
127 attr->numAttribs = 2;
128 attr->attribs[0] = 0;
130 attriblist.push_back(attr);
133 for(
size_t i = 0; i < attriblist.size(); i++){
135 ndbout << attriblist[
i]->numAttribs <<
": " ;
136 for(
int a = 0; a < attriblist[
i]->numAttribs; a++)
137 ndbout << attriblist[i]->attribs[a] <<
", ";
147 static const int SKIP_INDEX = 99;
152 bool orderedIndex = ctx->getProperty(
"OrderedIndex", (
unsigned)0);
153 bool notOnlyPkId = ctx->getProperty(
"NotOnlyPkId", (
unsigned)0);
154 int result = NDBT_OK;
158 if (attr->numAttribs == 1 &&
159 calc.isUpdateCol(attr->attribs[0]) ==
true){
168 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"ordered index "<<idxName <<
" (";
170 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"unique index "<<idxName <<
" (";
173 pIdx.setTable(pTab->
getName());
179 bool includesOnlyPkIdCols =
true;
180 for (
int c = 0; c< attr->numAttribs; c++){
181 int attrNo = attr->attribs[c];
189 ndbout << col->
getName() <<
" - bad type )" << endl;
194 if (col->getStorageType() == NDB_STORAGETYPE_DISK)
196 ndbout << col->
getName() <<
" - disk based )" << endl;
200 pIdx.addIndexColumn(col->
getName());
204 calc.isIdCol(attrNo)))
205 includesOnlyPkIdCols =
false;
208 if (notOnlyPkId && includesOnlyPkIdCols)
210 ndbout <<
" Only PK/id cols included - skipping" << endl;
224 for (
int j = 0; j<attr->numAttribs; j++)
226 if (attr->attribs[j] == i)
237 pIdx.setStoredIndex(logged);
239 bool noddl= ctx->getProperty(
"NoDDL");
244 getDictionary()->getIndex(pIdx.getName(), pTab->
getName());
248 ndbout <<
"Failed - Index does not exist and DDL not allowed" << endl;
253 attr->indexCreated =
false;
260 attr->indexCreated =
false;
261 ndbout <<
"FAILED!" << endl;
272 ndbout <<
"OK!" << endl;
273 attr->indexCreated =
true;
280 int drop_index(
int indxNum,
Ndb* pNdb,
282 int result = NDBT_OK;
284 if (attr->indexCreated ==
false)
290 ndbout <<
"Dropping index "<<idxName<<
"(" << pTab->
getName() <<
") ";
292 ndbout <<
"FAILED!" << endl;
294 result = NDBT_FAILED;
296 ndbout <<
"OK!" << endl;
302 int loops = ctx->getNumLoops();
305 Ndb* pNdb = GETNDB(step);
306 int result = NDBT_OK;
312 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
315 attrList.buildAttribList(pTab);
318 while (l < loops && result == NDBT_OK){
320 for (i = 0; i < attrList.attriblist.size(); i++){
323 if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
324 result = NDBT_FAILED;
328 for (i = 0; i < attrList.attriblist.size(); i++){
331 if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
332 result = NDBT_FAILED;
343 Ndb* pNdb = GETNDB(step);
344 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
347 attrList.buildAttribList(pTab);
351 const Uint32 i = rand() % attrList.attriblist.size();
352 int res = create_index(ctx, i, pTab, pNdb, attrList.attriblist[i],
354 if (res == SKIP_INDEX){
359 if (res == NDBT_FAILED){
363 ctx->setProperty(
"createRandomIndex", i);
373 Ndb* pNdb = GETNDB(step);
375 Uint32 i = ctx->getProperty(
"createRandomIndex");
380 ndbout <<
"Dropping index " << idxName <<
" ";
382 ctx->getTab()->
getName()) != 0){
383 ndbout <<
"FAILED!" << endl;
387 ndbout <<
"OK!" << endl;
394 bool orderedIndex = ctx->getProperty(
"OrderedIndex", (
unsigned)0);
397 Ndb* pNdb = GETNDB(step);
399 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
400 bool noddl= ctx->getProperty(
"NoDDL");
405 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"ordered index "
406 << pkIdxName <<
" (";
408 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"unique index "
409 << pkIdxName <<
" (";
412 pIdx.setTable(pTab->
getName());
420 pIdx.addIndexColumn(col->
getName());
421 ndbout << col->
getName() <<
" ";
425 pIdx.setStoredIndex(logged);
430 getDictionary()->getIndex(pkIdxName, pTab->
getName());
434 ndbout <<
"Failed - Index does not exist and DDL not allowed" << endl;
446 ndbout <<
"FAILED!" << endl;
453 ndbout <<
"OK!" << endl;
459 Ndb* pNdb = GETNDB(step);
461 bool noddl= ctx->getProperty(
"NoDDL");
466 ndbout <<
"Dropping index " << pkIdxName <<
" ";
469 ndbout <<
"FAILED!" << endl;
473 ndbout <<
"OK!" << endl;
484 Ndb* pNdb = GETNDB(step);
486 const int batchSize = ctx->getProperty(
"BatchSize", 16);
487 const int parallelism = batchSize > 240 ? 240 : batchSize;
490 if (utilTrans.verifyIndex(pNdb, idxName, parallelism,
true) != 0){
491 g_err <<
"Inconsistent index" << endl;
494 }
while(ctx->isTestStopped() ==
false);
502 Ndb* pNdb = GETNDB(step);
504 const int batchSize = ctx->getProperty(
"BatchSize", 50);
506 int rows = ctx->getNumRecords();
507 while (ctx->isTestStopped() ==
false) {
508 if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
509 g_err <<
"Updated table failed" << endl;
514 if(ctx->isTestStopped())
517 if (hugoTrans.scanUpdateRecords(pNdb, rows, batchSize) != 0){
518 g_err <<
"Updated table failed" << endl;
531 Ndb* pNdb = GETNDB(step);
533 const int batchSize = ctx->getProperty(
"BatchSize", 50);
535 int rows = ctx->getNumRecords();
536 while (ctx->isTestStopped() ==
false) {
538 if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
539 g_err <<
"Index read failed" << endl;
544 if(ctx->isTestStopped())
547 if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
548 g_err <<
"Index update failed" << endl;
561 Ndb* pNdb = GETNDB(step);
564 const int batchSize = ctx->getProperty(
"BatchSize", 32);
565 const int parallel = batchSize > 240 ? 240 : batchSize;
567 int rows = ctx->getNumRecords();
568 while (ctx->isTestStopped() ==
false) {
569 if(hugoTrans.loadTable(pNdb, rows, batchSize,
false) != 0){
570 g_err <<
"Load table failed" << endl;
574 if(ctx->isTestStopped())
577 if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
578 g_err <<
"Updated table failed" << endl;
583 if(ctx->isTestStopped())
586 if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
587 g_err <<
"Index read failed" << endl;
592 if(ctx->isTestStopped())
595 if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
596 g_err <<
"Index update failed" << endl;
601 if(ctx->isTestStopped())
604 if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
605 g_err <<
"Scan updated table failed" << endl;
610 if(ctx->isTestStopped())
613 if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
614 g_err <<
"Clear table failed" << endl;
619 if(ctx->isTestStopped())
623 if(utilTrans.selectCount(pNdb, 64, &count) != 0 || count != 0)
631 int result = NDBT_OK;
632 int loops = ctx->getNumLoops();
637 int sync_threads = ctx->getProperty(
"Threads", (
unsigned)0);
639 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
640 if(restarts.executeRestart(ctx,
"RestartRandomNodeAbort", timeout) != 0){
641 g_err <<
"Failed to executeRestart(" <<pCase->getName() <<
")" << endl;
642 result = NDBT_FAILED;
645 ctx->sync_up_and_wait(
"PauseThreads", sync_threads);
653 int loops = ctx->getNumLoops();
654 int records = ctx->getNumRecords();
657 Ndb* pNdb = GETNDB(step);
658 int result = NDBT_OK;
659 int batchSize = ctx->getProperty(
"BatchSize", 1);
660 int parallelism = batchSize > 240? 240: batchSize;
661 ndbout <<
"batchSize="<<batchSize<<endl;
662 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
667 attrList.buildAttribList(pTab);
669 for (
unsigned int i = 0; i < attrList.attriblist.size(); i++){
671 while (l < loops && result == NDBT_OK){
677 if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED){
678 result = NDBT_FAILED;
682 ndbout <<
"Loading data after" << endl;
683 CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
690 ndbout <<
"Loading data before" << endl;
691 CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
694 if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
695 result = NDBT_FAILED;
701 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
704 ndbout <<
"Doing it all"<<endl;
706 ndbout <<
" pkUpdateRecords" << endl;
707 CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
708 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
709 CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
710 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
711 ndbout <<
" pkDelRecords half" << endl;
712 CHECK(hugoTrans.pkDelRecords(pNdb, records/2, batchSize) == 0);
713 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
714 ndbout <<
" scanUpdateRecords" << endl;
715 CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2, parallelism) == 0);
716 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
717 ndbout <<
" clearTable" << endl;
718 CHECK(utilTrans.clearTable(pNdb, records/2, parallelism) == 0);
719 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
720 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
722 ndbout <<
" loadTable" << endl;
723 CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
724 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
725 ndbout <<
" loadTable again" << endl;
726 CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
727 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
728 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
729 CHECK(count == records);
736 if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK){
737 result = NDBT_FAILED;
741 ndbout <<
"Clearing table after" << endl;
742 CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
749 ndbout <<
"Clearing table before" << endl;
750 CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
753 if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
754 result = NDBT_FAILED;
757 ndbout <<
" Done!" << endl;
762 drop_index(i, pNdb, pTab, attrList.attriblist[i]);
770 int loops = ctx->getNumLoops();
771 int records = ctx->getNumRecords();
773 Ndb* pNdb = GETNDB(step);
774 int result = NDBT_OK;
775 int batchSize = ctx->getProperty(
"BatchSize", 1);
776 int parallelism = batchSize > 240? 240: batchSize;
777 ndbout <<
"batchSize="<<batchSize<<endl;
778 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
784 attrList.buildAttribList(pTab);
786 for (
unsigned int i = 0; i < attrList.attriblist.size(); i++){
788 Attrib* attr = attrList.attriblist[
i];
790 if (create_index(ctx, i, pTab, pNdb, attr, logged) == NDBT_OK){
792 while (l <= loops && result == NDBT_OK){
794 CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
795 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
796 CHECK(utilTrans.clearTable(pNdb, records, parallelism) == 0);
797 CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
802 if (drop_index(i, pNdb, pTab, attr) != NDBT_OK)
803 result = NDBT_FAILED;
810 int tryAddUniqueIndex(
Ndb* pNdb,
821 !calc.isUpdateCol(c) &&
823 col->getStorageType() != NDB_STORAGETYPE_DISK)
839 ndbout <<
"Creating unique index :" << idxName <<
" on ("
840 << colName <<
")" << endl;
843 idxDef.setTable(pTab->
getName());
846 idxDef.addIndexColumn(colName);
847 idxDef.setStoredIndex(
false);
851 ndbout <<
"FAILED!" << endl;
860 int tryInsertUniqueRecord(
NDBT_Step* step,
864 Ndb* pNdb = GETNDB(step);
867 CHECKRET(hugoOps.startTransaction(pNdb) == 0);
868 CHECKRET(hugoOps.pkInsertRecord(pNdb,
873 if (hugoOps.execute_Commit(pNdb) != 0)
876 hugoOps.closeTransaction(pNdb);
892 hugoOps.closeTransaction(pNdb);
903 Ndb* pNdb = GETNDB(step);
921 const char* idxName =
"constraintCheck";
923 int rc = tryAddUniqueIndex(pNdb, pTab, idxName, calc, chosenCol);
929 ndbout <<
"No suitable column in this table, skipping" << endl;
943 int firstRecordNum = 0;
944 CHECKRET(tryInsertUniqueRecord(step, hugoOps, firstRecordNum) == NDBT_OK);
945 int secondRecordNum = firstRecordNum + 1;
946 CHECKRET(tryInsertUniqueRecord(step, hugoOps, secondRecordNum) == NDBT_OK);
954 int maxBatchSize = 10;
955 int recordOffset = secondRecordNum + 1;
956 char buff[NDB_MAX_TUPLE_SIZE];
958 CHECKRET(calc.calcValue(firstRecordNum, chosenCol, 0, &buff[0],
959 pTab->
getColumn(chosenCol)->getSizeInBytes(),
962 for (
int optype = 0; optype < 2; optype ++)
964 bool useInsert = (optype == 0);
965 ndbout <<
"Verifying constraint violation for "
966 << (useInsert?
"Insert":
"Update")
967 <<
" operations" << endl;
969 for (
int batchSize = 1; batchSize <= maxBatchSize; batchSize++)
972 CHECKRET(trans != 0);
974 for (
int rows = 0; rows < batchSize; rows ++)
976 int rowId = recordOffset + rows;
983 CHECKRET(hugoOps.setValues(op, rowId, 0) == 0);
988 CHECKRET(op->
setValue(chosenCol, &buff[0], real_len) == 0);
996 CHECKRET(hugoOps.equalForRow(op, secondRecordNum) == 0);
998 CHECKRET(op->
setValue(chosenCol, &buff[0], real_len) == 0);
1002 CHECKRET(trans->
execute(Commit) == -1);
1008 CHECKRET(err.code == 893);
1014 int idxObjId = (int) ((UintPtr) err.details - UintPtr(0));
1015 char detailsBuff[100];
1016 const char* errIdxName = NULL;
1018 ndbout_c(
"Got details column val of %p and string of %s\n",
1039 for (
unsigned ind = 0; ind < tableIndices.
count; ind ++)
1041 if (tableIndices.
elements[ind].
id == (
unsigned) idxObjId)
1043 const char* otherIdxName = tableIndices.
elements[ind].
name;
1044 ndbout <<
"Found other violated constraint : " << otherIdxName << endl;
1048 CHECKRET(otherIndex != NULL);
1050 for (
unsigned col = 0; col < otherIndex->
getNoOfColumns(); col++)
1057 errIdxName = otherIndex->
getName();
1064 ndbout <<
" Constraint contains unique column " << endl;
1067 ndbout <<
" Constraint does not contain unique col - fail" << endl;
1074 ndbout <<
"Did not find violated constraint" << endl;
1084 expected.
assfmt(
"%s/%s/%s/%s",
1090 CHECKRET(strcmp(expected.
c_str(), &detailsBuff[0]) == 0);
1092 ndbout <<
" OK " << endl;
1102 int records = ctx->getNumRecords();
1105 int batchSize = ctx->getProperty(
"BatchSize", 1);
1106 if(hugoTrans.loadTable(GETNDB(step), records, batchSize) != 0){
1114 int records = ctx->getNumRecords();
1117 if (utilTrans.clearTable(GETNDB(step), records) != 0){
1124 Ndb* pNdb = GETNDB(step);
1125 int result = NDBT_OK;
1127 Uint32 loops = ctx->getNumLoops();
1128 int records = ctx->getNumRecords();
1135 while(i<=loops && result != NDBT_FAILED){
1137 ndbout <<
"Loop " << i <<
"/"<< loops <<
" started" << endl;
1152 ndbout <<
"Loading records..." << endl;
1153 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1154 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1156 ndbout <<
"Restarting cluster" << endl;
1157 CHECK(restarter.restartAll() == 0);
1158 CHECK(restarter.waitClusterStarted(timeout) == 0);
1161 ndbout <<
"Verifying records..." << endl;
1162 CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
1163 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1164 CHECK(count == records);
1165 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1167 ndbout <<
"Updating records..." << endl;
1168 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
1169 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1171 ndbout <<
"Restarting cluster..." << endl;
1172 CHECK(restarter.restartAll() == 0);
1173 CHECK(restarter.waitClusterStarted(timeout) == 0);
1176 ndbout <<
"Verifying records..." << endl;
1177 CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
1178 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1179 CHECK(count == records);
1180 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1182 ndbout <<
"Deleting 50% of records..." << endl;
1183 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
1184 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1186 ndbout <<
"Restarting cluster..." << endl;
1187 CHECK(restarter.restartAll() == 0);
1188 CHECK(restarter.waitClusterStarted(timeout) == 0);
1191 ndbout <<
"Verifying records..." << endl;
1192 CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
1193 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1194 CHECK(count == (records/2));
1195 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1197 ndbout <<
"Deleting all records..." << endl;
1198 CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
1199 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1201 ndbout <<
"Restarting cluster..." << endl;
1202 CHECK(restarter.restartAll() == 0);
1203 CHECK(restarter.waitClusterStarted(timeout) == 0);
1206 ndbout <<
"Verifying records..." << endl;
1207 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1209 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1211 ndbout <<
"Doing it all..." << endl;
1212 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1213 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1214 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
1215 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1216 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
1217 CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
1218 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1219 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1220 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1221 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1222 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1223 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
1224 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1226 ndbout <<
"Restarting cluster..." << endl;
1227 CHECK(restarter.restartAll() == 0);
1228 CHECK(restarter.waitClusterStarted(timeout) == 0);
1231 ndbout <<
"Verifying records..." << endl;
1232 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1235 ndbout <<
"Doing it all..." << endl;
1236 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1237 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1238 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
1239 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1240 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
1241 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1242 CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
1243 CHECK(utilTrans.verifyIndex(pNdb, idxName, 16,
false) == 0);
1244 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1245 CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
1246 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1248 ndbout <<
"Restarting cluster with error insert 5020..." << endl;
1249 CHECK(restarter.restartAll(
false,
true) == 0);
1250 CHECK(restarter.waitClusterNoStart(timeout) == 0);
1251 CHECK(restarter.insertErrorInAllNodes(5020) == 0);
1252 CHECK(restarter.startAll() == 0);
1253 CHECK(restarter.waitClusterStarted(timeout) == 0);
1260 ndbout <<
"runSystemRestart1 finished" << endl;
1265 #define CHECK2(b, t) if(!b){ g_err << __LINE__ << ": " << t << endl; break;}
1266 #define CHECKOKORTIMEOUT(e, t) { int rc= (e); \
1269 g_err << "Timeout : retries left : " \
1274 g_err << __LINE__ << ": " << (t) << endl; break; \
1282 Ndb* pNdb = GETNDB(step);
1289 g_err <<
"pkRead, indexRead, Commit" << endl;
1290 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1291 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
"indexReadRecords");
1292 CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0,
"pkReadRecord");
1293 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1294 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1297 g_err <<
"pkRead, indexRead, Commit" << endl;
1298 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1299 CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0,
"pkReadRecord");
1300 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
"indexReadRecords");
1301 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1302 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1306 g_err <<
"pkRead, indexRead, NoCommit, Commit" << endl;
1307 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1308 CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0,
"pkReadRecord");
1309 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
1310 "indexReadRecords");
1311 CHECK2(hugoOps.execute_NoCommit(pNdb) == 0,
"executeNoCommit");
1312 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1313 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1316 g_err <<
"pkRead, pkRead, Commit" << endl;
1317 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction ");
1318 CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0,
"pkReadRecords ");
1319 CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0,
"pkReadRecords ");
1320 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1321 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction ");
1324 g_err <<
"indexRead, indexRead, Commit" << endl;
1326 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction ");
1327 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
"indexReadRecords");
1328 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
"indexReadRecords");
1329 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1331 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction ");
1337 hugoOps.closeTransaction(pNdb);
1344 runMixedUpdateInterleaved(
Ndb* pNdb,
1359 if ((pkFailRec != -1) || (ixFailRec != -1))
1364 bool updateViaPk= whatToUpdate & 1;
1365 bool updateViaIx= whatToUpdate & 2;
1367 int ixOpNum= (ixFirst?0:1);
1368 int pkOpNum= (ixFirst?1:0);
1370 int timeoutRetries= 3;
1372 while (timeoutRetries--)
1374 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1375 for (
int i=0; i < testSize; i++)
1380 int indxKey= ((i == ixFailRec)^invertFail)? outOfRangeRec :
i;
1381 int pkKey= ((i == pkFailRec)^invertFail)? outOfRangeRec :
i;
1383 for (
int opNum=0; opNum < 2; opNum++)
1385 if (opNum == ixOpNum)
1389 CHECK2(hugoOps.indexUpdateRecord(pNdb, pkIdxName, indxKey, 1, updatesValue) == 0,
1390 "indexUpdateRecord");
1394 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, indxKey) == 0,
"indexReadRecords");
1398 if (opNum == pkOpNum)
1402 CHECK2(hugoOps.pkUpdateRecord(pNdb, pkKey, 1, updatesValue) == 0,
1407 CHECK2(hugoOps.pkReadRecord(pNdb, pkKey) == 0,
"pkReadRecord");
1414 int rc= hugoOps.execute_Commit(pNdb, ao);
1418 g_err <<
"Timeout : retries left=" << timeoutRetries << endl;
1419 hugoOps.closeTransaction(pNdb);
1422 CHECK2(rc == execRc,
"execute_Commit");
1424 CHECK2(err.
code == execRc,
"getNdbError");
1428 int rc= hugoOps.execute_NoCommit(pNdb, ao);
1432 g_err <<
"Timeout : retries left=" << timeoutRetries << endl;
1433 hugoOps.closeTransaction(pNdb);
1436 CHECK2(rc == execRc,
"execute_NoCommit");
1438 CHECK2(err.
code == execRc,
"getNdbError");
1439 if (execRc && (ao == AO_IgnoreError))
1442 CHECK2(hugoOps.execute_Commit(pNdb, ao) == 0,
"executeCommit");
1446 CHECK2(hugoOps.execute_Rollback(pNdb) == 0,
"executeRollback");
1449 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1454 hugoOps.closeTransaction(pNdb);
1462 Ndb* pNdb = GETNDB(step);
1465 int numRecordsInTable= ctx->getNumRecords();
1466 const int maxTestSize= 10000;
1467 int testSize= MIN(numRecordsInTable, maxTestSize);
1470 Uint32 rowSize= NdbDictionary::getRecordRowLength(ctx->getTab()->
getDefaultRecord());
1471 Uint32 dataXfer= 2 * rowSize * testSize;
1472 const Uint32 MaxDataXfer= 500000;
1474 if (dataXfer > MaxDataXfer)
1476 testSize= MIN((
int)(MaxDataXfer/rowSize), testSize);
1479 g_err <<
"testSize= " << testSize << endl;
1480 g_err <<
"rowSize= " << rowSize << endl;
1482 int updatesValue= 1;
1483 const int maxTimeoutRetries= 3;
1489 int timeoutRetries= maxTimeoutRetries;
1490 while (timeoutRetries--)
1492 g_err <<
"TC0 : indexRead, pkread, Commit" << endl;
1493 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1494 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1495 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecord");
1496 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1497 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1502 if (!ok) {
break; };
1509 int timeoutRetries= maxTimeoutRetries;
1510 while (timeoutRetries--)
1512 g_err <<
"TC1 : pkRead, indexRead, Commit" << endl;
1513 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1514 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecord");
1515 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1516 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1517 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1522 if (!ok) {
break; };
1528 int timeoutRetries= maxTimeoutRetries;
1529 while (timeoutRetries--)
1531 g_err <<
"TC2 : pkRead, indexRead, NoCommit, Commit" << endl;
1532 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1533 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecord");
1534 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
1535 "indexReadRecords");
1536 CHECKOKORTIMEOUT(hugoOps.execute_NoCommit(pNdb),
"executeNoCommit");
1537 CHECK2(hugoOps.execute_Commit(pNdb) == 0,
"executeCommit");
1538 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1542 if (!ok) {
break; };
1548 int timeoutRetries= maxTimeoutRetries;
1549 while (timeoutRetries--)
1551 g_err <<
"TC3 : pkRead, pkRead, Commit" << endl;
1552 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction ");
1553 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecords ");
1554 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecords ");
1555 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1556 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction ");
1560 if (!ok) {
break; };
1566 int timeoutRetries= maxTimeoutRetries;
1567 while (timeoutRetries--)
1569 g_err <<
"TC4 : indexRead, indexRead, Commit" << endl;
1570 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction ");
1571 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1572 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1573 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1574 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction ");
1578 if (!ok) {
break; };
1584 int timeoutRetries= maxTimeoutRetries;
1585 while (timeoutRetries--)
1587 g_err <<
"TC5 : indexRead, pkUpdate, Commit" << endl;
1588 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1589 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1590 CHECK2(hugoOps.pkUpdateRecord(pNdb, 0, testSize, updatesValue++) == 0,
"pkUpdateRecord");
1591 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1592 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1596 if (!ok) {
break; };
1602 int timeoutRetries= maxTimeoutRetries;
1603 while (timeoutRetries--)
1605 g_err <<
"TC6 : pkUpdate, indexRead, Commit" << endl;
1606 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1607 CHECK2(hugoOps.pkUpdateRecord(pNdb, 0, testSize, updatesValue++) == 0,
"pkUpdateRecord");
1608 CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0,
false, testSize) == 0,
"indexReadRecords");
1609 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1610 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1614 if (!ok) {
break; };
1620 int timeoutRetries= maxTimeoutRetries;
1621 while (timeoutRetries--)
1623 g_err <<
"TC7 : pkRead, indexUpdate, Commit" << endl;
1624 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction");
1625 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecord");
1626 CHECK2(hugoOps.indexUpdateRecord(pNdb, pkIdxName, 0, testSize, updatesValue++) == 0,
1627 "indexReadRecords");
1628 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1629 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction");
1633 if (!ok) {
break; };
1639 int timeoutRetries= maxTimeoutRetries;
1640 while (timeoutRetries--)
1642 g_err <<
"TC8 : indexUpdate, pkRead, Commit" << endl;
1643 CHECK2(hugoOps.startTransaction(pNdb) == 0,
"startTransaction ");
1644 CHECK2(hugoOps.indexUpdateRecord(pNdb, pkIdxName, 0, testSize, updatesValue++) == 0,
1645 "indexReadRecords ");
1646 CHECK2(hugoOps.pkReadRecord(pNdb, 0, testSize) == 0,
"pkReadRecords ");
1647 CHECKOKORTIMEOUT(hugoOps.execute_Commit(pNdb),
"executeCommit");
1648 CHECK2(hugoOps.closeTransaction(pNdb) == 0,
"closeTransaction ");
1652 if (!ok) {
break; };
1655 for (
int ao=0; ao < 2; ao++)
1657 AbortOption abortOption= ao?AO_IgnoreError:AbortOnError;
1659 for (
int exType=0; exType < 3; exType++)
1661 bool commit= (exType == 1);
1662 bool abort= (exType == 2);
1664 const char* exTypeStr= ((exType == 0) ?
"NoCommit" :
1665 (exType == 1) ?
"Commit" :
1668 for (
int failType= 0; failType < 4; failType++)
1670 for (
int failPos= 0; failPos < 2; failPos++)
1672 int failRec= (failPos == 0)? 0 : testSize -1;
1683 for (
int invFail= 0;
1684 invFail < ((failType==0)?1:2);
1687 bool invertFail= (invFail)?
true:
false;
1688 const char* failTypeStr= ((failType==0)?
"None" :
1689 ((failType==1)?
"Pk":
1690 ((failType==2)?
"Ix":
"Both")));
1691 for (
int updateVia= 0; updateVia < 3; updateVia++)
1693 const char* updateViaStr= ((updateVia == 0)?
"None" :
1694 (updateVia == 1)?
"Pk" :
1695 (updateVia == 2)?
"Ix" :
1697 for (
int updateOrder= 0; updateOrder < 2; updateOrder++)
1699 bool updateIxFirst= (updateOrder == 0);
1701 <<
"AbortOption : " << (ao?
"IgnoreError":
"AbortOnError") << endl
1702 <<
"ExecType : " << exTypeStr << endl
1703 <<
"Failtype : " << failTypeStr << endl
1704 <<
"Failpos : " << ((failPos == 0)?
"Early" :
"Late") << endl
1705 <<
"Failure scenarios : " << (invFail?
"All but one":
"one") << endl
1706 <<
"UpdateVia : " << updateViaStr << endl
1707 <<
"Order : " << (updateIxFirst?
"Index First" :
"Pk first") << endl;
1711 g_err <<
"Mixed read/update interleaved" << endl;
1712 CHECK2(runMixedUpdateInterleaved(pNdb, hugoOps, numRecordsInTable, testSize,
1729 hugoOps.closeTransaction(pNdb);
1743 hugoOps.closeTransaction(pNdb);
1747 #define check(b, e) \
1748 if (!(b)) { g_err << "ERR: " << step->getName() << " failed on line " << __LINE__ << ": " << e.getNdbError() << endl; return NDBT_FAILED; }
1751 int records = ctx->getNumRecords();
1752 int loops = ctx->getNumLoops();
1754 Ndb* ndb = GETNDB(step);
1760 if (tab.
getColumn(i)->getStorageType() == NDB_STORAGETYPE_DISK)
1762 g_err <<
"Table has disk column(s) skipping." << endl;
1768 g_err <<
"Loading table." << endl;
1770 check(hugoTrans.loadTable(ndb, records) == 0, hugoTrans);
1780 Uint32 numRefresh = 2 + rand() % 10;
1782 g_err <<
"Refresh, rollback * " << numRefresh << endl;
1784 while (--numRefresh)
1787 check(hugoOps.startTransaction(ndb) == 0, hugoOps);
1788 check(hugoOps.pkRefreshRecord(ndb, 0, records, 0) == 0, hugoOps);
1789 check(hugoOps.execute_NoCommit(ndb) == 0, hugoOps);
1790 check(hugoOps.execute_Rollback(ndb) == 0, hugoOps);
1791 check(hugoOps.closeTransaction(ndb) == 0, hugoOps);
1794 g_err <<
"Refresh, commit" << endl;
1796 check(hugoOps.startTransaction(ndb) == 0, hugoOps);
1797 check(hugoOps.pkRefreshRecord(ndb, 0, records, 0) == 0, hugoOps);
1798 check(hugoOps.execute_NoCommit(ndb) == 0, hugoOps);
1799 check(hugoOps.execute_Commit(ndb) == 0, hugoOps);
1800 check(hugoOps.closeTransaction(ndb) == 0, hugoOps);
1802 g_err <<
"Update, commit" << endl;
1804 check(hugoOps.startTransaction(ndb) == 0, hugoOps);
1805 check(hugoOps.pkUpdateRecord(ndb, 0, records, 2 + loops) == 0, hugoOps);
1806 check(hugoOps.execute_NoCommit(ndb) == 0, hugoOps);
1807 check(hugoOps.execute_Commit(ndb) == 0, hugoOps);
1808 check(hugoOps.closeTransaction(ndb) == 0, hugoOps);
1819 const int Threads = ctx->getProperty(
"Threads", (Uint32)0);
1820 const int loops = ctx->getNumLoops();
1822 for(
int i = 0; i<loops; i++){
1824 if(createPkIndex(ctx, step) != NDBT_OK){
1825 g_err <<
"Failed to create index" << endl;
1830 if(ctx->isTestStopped())
1834 if(createRandomIndex(ctx, step) != NDBT_OK){
1835 g_err <<
"Failed to create index" << endl;
1840 if(ctx->isTestStopped())
1843 ctx->setProperty(
"pause", 1);
1845 for(
int j = 0; count < Threads && !ctx->isTestStopped();
1846 j = (j+1) % Threads){
1848 sprintf(buf,
"Thread%d_paused", j);
1849 int tmp = ctx->getProperty(buf, (Uint32)0);
1853 if(ctx->isTestStopped())
1857 if(createPkIndex_Drop(ctx, step) != NDBT_OK){
1858 g_err <<
"Failed to drop index" << endl;
1863 if(ctx->isTestStopped())
1867 if(createRandomIndex_Drop(ctx, step) != NDBT_OK){
1868 g_err <<
"Failed to drop index" << endl;
1873 ctx->setProperty(
"pause", (Uint32)0);
1874 NdbSleep_SecSleep(2);
1882 static int threadCounter = 0;
1886 if(ctx->getProperty(
"pause", (Uint32)0) == 1){
1888 sprintf(buf,
"Thread%d_paused",
id);
1889 ctx->setProperty(buf, 1);
1890 while(!ctx->isTestStopped() && ctx->getProperty(
"pause", (Uint32)0) == 1){
1891 NdbSleep_MilliSleep(250);
1893 ctx->setProperty(buf, (Uint32)0);
1901 const int ThreadId = threadCounter++;
1906 Ndb* pNdb = GETNDB(step);
1909 const int batchSize = ctx->getProperty(
"BatchSize", 32);
1910 const int parallel = batchSize > 240 ? 240 : batchSize;
1912 int rows = ctx->getNumRecords();
1913 while (ctx->isTestStopped() ==
false) {
1914 if(hugoTrans.loadTable(pNdb, rows, batchSize,
false) != 0){
1915 g_err <<
"Load table failed" << endl;
1919 wait_paused(ctx, ThreadId);
1921 if(ctx->isTestStopped())
1924 if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
1925 g_err <<
"Updated table failed" << endl;
1929 wait_paused(ctx, ThreadId);
1931 if(ctx->isTestStopped())
1934 if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
1935 g_err <<
"Scan updated table failed" << endl;
1939 wait_paused(ctx, ThreadId);
1941 if(ctx->isTestStopped())
1944 if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
1945 g_err <<
"Clear table failed" << endl;
1954 Ndb* pNdb = GETNDB(step);
1956 bool logged = ctx->getProperty(
"LoggedIndexes", 1);
1957 bool orderedIndex = ctx->getProperty(
"OrderedIndex", (
unsigned)0);
1962 char nullIndex[255];
1965 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"ordered index "
1966 << pkIdxName <<
" (";
1968 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"unique index "
1969 << pkIdxName <<
" (";
1977 pIdx.setStoredIndex(logged);
1983 ndbout << col->
getName() <<
" ";
1992 ndbout << col->
getName() <<
" ";
2000 ndbout << endl <<
"No nullable column found -> NDBT_FAILED" << endl;
2004 bool noddl= ctx->getProperty(
"NoDDL");
2012 ndbout <<
"Failed - Index does not exist and DDL not allowed" << endl;
2024 ndbout <<
"FAILED!" << endl;
2031 int result = NDBT_OK;
2034 const int batchSize = ctx->getProperty(
"BatchSize", 50);
2035 int loops = ctx->getNumLoops();
2036 int rows = ctx->getNumRecords();
2037 while (loops-- > 0 && ctx->isTestStopped() ==
false) {
2038 if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
2039 g_err <<
"Updated table failed" << endl;
2040 result = NDBT_FAILED;
2045 if(ctx->isTestStopped()){
2051 NdbSleep_MilliSleep(100);
2054 result = NDBT_FAILED;
2059 if(!pTrans)
goto done;
2063 if(pTrans->
execute(NoCommit) == -1)
goto done;
2067 if(uOp == 0)
goto done;
2069 }
while((eof = sOp->
nextResult(
false)) == 0);
2070 eof = pTrans->
execute(Commit);
2071 if(eof == -1)
goto done;
2081 int loops = ctx->getNumLoops() * 100;
2084 myRandom48Init((
long)NdbTick_CurrentMillisecond());
2087 int val = DumpStateOrd::DihMinTimeBetweenLCP;
2088 if(restarter.dumpStateAllNodes(&val, 1) != 0){
2089 g_err <<
"Failed to dump DihMinTimeBetweenLCP" << endl;
2094 for(
int i = 0; i<loops && !ctx->isTestStopped(); i++){
2095 int randomId = myRandom48(restarter.getNumDbNodes());
2096 int nodeId = restarter.getDbNodeId(randomId);
2098 const Uint32 error = 5031 + (i % 3);
2100 if(restarter.insertErrorInNode(nodeId, error) != 0){
2101 g_err <<
"Failed to error insert( " << error <<
") in node "
2114 Ndb* pNdb = GETNDB(step);
2118 int loops = ctx->getNumLoops();
2119 const int rows = ctx->getNumRecords();
2120 const int batchsize = ctx->getProperty(
"BatchSize", 50);
2124 if(restarter.insertErrorInAllNodes(8037) != 0)
2126 g_err <<
"Failed to error insert(8037)" << endl;
2130 if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) == 0)
2132 g_err <<
"Index succeded (it should have failed" << endl;
2136 if(restarter.insertErrorInAllNodes(0) != 0)
2138 g_err <<
"Failed to error insert(0)" << endl;
2142 if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){
2143 g_err <<
"Index read failed" << endl;
2154 Ndb* pNdb = GETNDB(step);
2156 int rows = ctx->getNumRecords();
2157 while (!ctx->isTestStopped())
2159 hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, 1);
2167 Ndb* pNdb = GETNDB(step);
2175 int loops = ctx->getNumLoops();
2176 const int rows = ctx->getNumRecords();
2178 while (res == NDBT_OK && loops--)
2180 ops.startTransaction(pNdb);
2181 ops.pkReadRecord(pNdb, 10 + rand() % rows, rows);
2183 if ((tmp = ops.execute_Commit(pNdb, AO_IgnoreError)))
2188 if (ops.getTransaction()->getNdbError().code == 4012)
2191 ops.closeTransaction(pNdb);
2194 loops = ctx->getNumLoops();
2195 while (res == NDBT_OK && loops--)
2197 ops.startTransaction(pNdb);
2198 ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows);
2206 arg = AO_IgnoreError;
2207 ndbout_c(
"ignore error");
2210 if ((tmp = ops.execute_Commit(pNdb, (AbortOption)arg)))
2215 if (ops.getTransaction()->getNdbError().code == 4012)
2218 ops.closeTransaction(pNdb);
2235 int result= NDBT_OK;
2236 Ndb* pNdb = GETNDB(step);
2243 g_err <<
"Using INDEX: " << pkIdxName << endl;
2247 int loops = ctx->getNumLoops();
2248 const int rows = ctx->getNumRecords();
2250 for(
int bs=1; bs < loops; bs++)
2255 g_err <<
"BS " << bs <<
" LOOP #" << c << endl;
2257 g_err <<
"inserting error on op#" << c << endl;
2259 CHECK(ops.startTransaction(pNdb) == 0);
2260 for(
int i=1;i<=c;i++)
2264 if(restarter.insertErrorInAllNodes(inject_err)!=0)
2266 g_err <<
"**** FAILED to insert error" << endl;
2267 result= NDBT_FAILED;
2271 CHECK(ops.indexReadRecords(pNdb, pkIdxName, i,
false,1) == 0);
2276 if(ops.execute_NoCommit(pNdb, AO_IgnoreError)!=NDBT_OK)
2278 g_err <<
"**** executeNoCommit should have succeeded" << endl;
2279 result= NDBT_FAILED;
2284 if(ops.execute_NoCommit(pNdb, AO_IgnoreError)!=289)
2286 g_err <<
"**** executeNoCommit should have failed with 289"
2288 result= NDBT_FAILED;
2290 g_err <<
"NdbError.code= " <<
2291 ops.getTransaction()->getNdbError().code << endl;
2297 CHECK(ops.closeTransaction(pNdb) == 0);
2299 if(restarter.insertErrorInAllNodes(0) != 0)
2301 g_err <<
"**** Failed to error insert(0)" << endl;
2305 CHECK(ops.startTransaction(pNdb) == 0);
2306 if (ops.indexReadRecords(pNdb, pkIdxName,0,0,rows) != 0){
2307 g_err <<
"**** Index read failed" << endl;
2310 CHECK(ops.closeTransaction(pNdb) == 0);
2320 return tcSaveINDX_test(ctx, step, 8052);
2326 return tcSaveINDX_test(ctx, step, 8051);
2333 Ndb* pNdb = GETNDB(step);
2334 const int rows = ctx->getNumRecords();
2335 Uint32 threads = ctx->getProperty(
"THREADS", 12);
2336 int loops = ctx->getNumLoops();
2338 ctx->getPropertyWait(
"STARTED", threads);
2340 for (
int i = 0; i<loops; i++)
2342 ndbout <<
"Loop: " << i << endl;
2343 if (hugoTrans.loadTable(pNdb, rows) != 0)
2346 ctx->setProperty(
"STARTED", Uint32(0));
2347 ctx->getPropertyWait(
"STARTED", threads);
2358 Ndb* pNdb = GETNDB(step);
2359 const int rows = ctx->getNumRecords();
2361 while(!ctx->isTestStopped())
2363 ctx->incProperty(
"STARTED");
2364 ctx->getPropertyWait(
"STARTED", Uint32(0));
2365 if (ctx->isTestStopped())
2368 for (
int i = 0; i<rows && !ctx->isTestStopped(); )
2370 int cnt = (rows -
i);
2373 cnt = 1 + (rand() % cnt);
2374 if (hugoOps.startTransaction(pNdb) != 0)
2378 hugoOps.pkDeleteRecord(pNdb, i, cnt);
2379 int res = hugoOps.execute_Commit(pNdb, AO_IgnoreError);
2384 hugoOps.closeTransaction(pNdb);
2394 Ndb* pNdb = GETNDB(step);
2404 while(!ctx->isTestStopped())
2406 ctx->incProperty(
"STARTED");
2407 ctx->getPropertyWait(
"STARTED", Uint32(0));
2408 if (ctx->isTestStopped())
2411 hugoTrans.clearTable(pNdb);
2420 NdbSleep_MilliSleep(500);
2421 int loops = ctx->getNumLoops();
2424 createPkIndex_Drop(ctx, step);
2425 createPkIndex(ctx, step);
2437 Ndb* pNdb = GETNDB(step);
2441 unsigned numScenarios = 3;
2442 unsigned errorInserts[3] = {8085, 8086, 0};
2443 int results[3] = {218, 218, 0};
2445 unsigned iterations = 50;
2448 if (hugoOps.startTransaction(pNdb) ||
2449 hugoOps.pkInsertRecord(pNdb, 0, iterations) ||
2450 hugoOps.execute_Commit(pNdb))
2452 g_err <<
"Failed on initial insert "
2458 hugoOps.closeTransaction(pNdb);
2460 for(
unsigned i = 0 ; i < iterations; i++)
2462 unsigned scenario = i % numScenarios;
2463 unsigned errorVal = errorInserts[ scenario ];
2464 g_err <<
"Iteration :" << i
2465 <<
" inserting error " << errorVal
2466 <<
" expecting result : " << results[scenario]
2468 restarter.insertErrorInAllNodes(errorVal);
2471 CHECKRET(hugoOps.startTransaction(pNdb) == 0);
2473 CHECKRET(hugoOps.pkInsertRecord(pNdb, iterations + i, 1) == 0);
2475 hugoOps.execute_Commit(pNdb);
2479 if (errorCode != results[scenario])
2481 g_err <<
"For Insert in scenario " << scenario
2482 <<
" expected code " << results[scenario]
2483 <<
" but got " << hugoOps.getTransaction()->
getNdbError()
2488 hugoOps.closeTransaction(pNdb);
2490 CHECKRET(hugoOps.startTransaction(pNdb) == 0);
2492 CHECKRET(hugoOps.pkUpdateRecord(pNdb, i, 1, iterations) == 0);
2494 hugoOps.execute_Commit(pNdb);
2498 if (errorCode != results[scenario])
2500 g_err <<
"For Update in scenario " << scenario
2501 <<
" expected code " << results[scenario]
2502 <<
" but got " << hugoOps.getTransaction()->
getNdbError()
2507 hugoOps.closeTransaction(pNdb);
2509 CHECKRET(hugoOps.startTransaction(pNdb) == 0);
2511 CHECKRET(hugoOps.pkDeleteRecord(pNdb, i, 1) == 0);
2513 hugoOps.execute_Commit(pNdb);
2517 if (errorCode != results[scenario])
2519 g_err <<
"For Delete in scenario " << scenario
2520 <<
" expected code " << results[scenario]
2521 <<
" but got " << hugoOps.getTransaction()->
getNdbError()
2526 hugoOps.closeTransaction(pNdb);
2530 restarter.insertErrorInAllNodes(0);
2540 restarter.insertErrorInAllNodes(0);
2547 #undef CHECK2 // previous no good
2548 #define CHECK2(b, e) \
2550 g_err << "ERR: " << #b << " failed at line " << __LINE__ \
2551 << ": " << e << endl; \
2552 result = NDBT_FAILED; \
2559 int result = NDBT_OK;
2574 if (lem->block != DBTUP)
2577 CHECK2(dbmask.
get(nodeId),
"duplicate event from node " << nodeId);
2578 dbmask.
clear(nodeId);
2579 pages += lem->pages_used;
2580 g_info <<
"i:" << i <<
" node:" << le->
source_nodeid <<
" pages:" << lem->pages_used << endl;
2583 CHECK2(result == NDBT_OK,
"failed");
2585 char buf[NdbNodeBitmask::TextLength + 1];
2586 CHECK2(dbmask.
isclear(),
"no response from nodes " << dbmask.
getText(buf));
2597 Ndb* pNdb = GETNDB(step);
2599 const int loops = ctx->getNumLoops();
2600 int result = NDBT_OK;
2602 const int rows = ctx->getNumRecords();
2603 const char* mgm = 0;
2606 strcpy(tabname, tab.
getName());
2608 strcpy(indname, tabname);
2609 strcat(indname,
"X1");
2616 char* rowmask =
new char [rows];
2617 memset(rowmask, 0, rows);
2619 while (loop < loops)
2621 CHECK2(rows > 0,
"rows must be != 0");
2622 g_info <<
"loop " << loop <<
"<" << loops << endl;
2630 g_info <<
"mgm: connected to " << (mgm ? mgm :
"default") << endl;
2644 g_info <<
"added DB node " << ns->
node_id << endl;
2648 CHECK2(result == NDBT_OK,
"some DB nodes are not started");
2649 CHECK2(!dbmask.
isclear(),
"found no DB nodes");
2657 CHECK2(get_data_memory_pages(h, dbmask, &pages[0]) == NDBT_OK,
"failed");
2658 g_info <<
"initial pages " << pages[0] << endl;
2661 g_info <<
"create table " << tabname << endl;
2665 CHECK2(get_data_memory_pages(h, dbmask, &pages[1]) == NDBT_OK,
"failed");
2666 g_info <<
"create table pages " << pages[1] << endl;
2683 if (NdbSqlUtil::check_column_for_ordered_index(col->
getType(), col->
getCharset()) == 0)
2690 CHECK2(ind.
getNoOfColumns() == 1,
"cannot use table " << tabname);
2693 g_info <<
"create index " << indname <<
" on " << ind.
getColumn(0)->
getName() << endl;
2697 CHECK2(get_data_memory_pages(h, dbmask, &pages[2]) == NDBT_OK,
"failed");
2698 g_info <<
"create index pages " << pages[2] << endl;
2703 g_info <<
"load records" << endl;
2704 CHECK2(trans.loadTable(pNdb, rows) == 0, trans.
getNdbError());
2705 memset(rowmask, 1, rows);
2706 CHECK2(get_data_memory_pages(h, dbmask, &pages[3]) == NDBT_OK,
"failed");
2707 g_info <<
"load records pages " << pages[3] << endl;
2710 g_info <<
"test index ops" << endl;
2713 for (
int i = 0; i < rows; i++)
2715 CHECK2(ops.startTransaction(pNdb) == 0, ops.getNdbError());
2716 for (
int j = 0; j < 32; j++)
2718 int n = rand() % rows;
2721 CHECK2(ops.pkInsertRecord(pNdb, n) == 0, ops.getNdbError());
2724 else if (rand() % 2 == 0)
2726 CHECK2(ops.pkDeleteRecord(pNdb, n) == 0, ops.getNdbError());
2731 CHECK2(ops.pkUpdateRecord(pNdb, n) == 0, ops.getNdbError());
2734 CHECK2(result == NDBT_OK,
"index ops batch failed");
2735 CHECK2(ops.execute_Commit(pNdb) == 0, ops.getNdbError());
2736 ops.closeTransaction(pNdb);
2738 CHECK2(result == NDBT_OK,
"index ops failed");
2742 g_info <<
"delete records" << endl;
2743 CHECK2(trans.clearTable(pNdb) == 0, trans.
getNdbError());
2744 memset(rowmask, 0, rows);
2745 CHECK2(get_data_memory_pages(h, dbmask, &pages[4]) == NDBT_OK,
"failed");
2746 g_info <<
"delete records pages " << pages[4] << endl;
2749 g_info <<
"drop index" << endl;
2751 CHECK2(get_data_memory_pages(h, dbmask, &pages[5]) == NDBT_OK,
"failed");
2752 g_info <<
"drop index pages " << pages[5] << endl;
2755 g_info <<
"drop table" << endl;
2757 CHECK2(get_data_memory_pages(h, dbmask, &pages[6]) == NDBT_OK,
"failed");
2758 g_info <<
"drop table pages " << pages[6] << endl;
2761 CHECK2(pages[1] == pages[0],
"pages after create table " << pages[1]
2762 <<
" not == initial pages " << pages[0]);
2763 CHECK2(pages[2] == pages[0],
"pages after create index " << pages[2]
2764 <<
" not == initial pages " << pages[0]);
2765 CHECK2(pages[3] > pages[0],
"pages after load " << pages[3]
2766 <<
" not > initial pages " << pages[0]);
2767 CHECK2(pages[4] == pages[0],
"pages after delete " << pages[4]
2768 <<
" not == initial pages " << pages[0]);
2769 CHECK2(pages[5] == pages[0],
"pages after drop index " << pages[5]
2770 <<
" not == initial pages " << pages[0]);
2771 CHECK2(pages[6] == pages[0],
"pages after drop table " << pages[6]
2772 <<
" not == initial pages " << pages[0]);
2781 g_info <<
"mgm: disconnected" << endl;
2789 #define CHK_RET_FAILED(x) if (!(x)) { ndbout_c("Failed on line: %u", __LINE__); return NDBT_FAILED; }
2795 Ndb* pNdb = GETNDB(step);
2799 CHK_RET_FAILED(pIdx != 0);
2802 CHK_RET_FAILED(pRowRecord != 0);
2804 CHK_RET_FAILED(pIdxRecord != 0);
2806 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
2807 Uint8 * pRow =
new Uint8[len];
2811 calc.equalForRow(pRow, pRowRecord, 0);
2814 CHK_RET_FAILED(pTrans != 0);
2817 for (Uint32 i = 0; i<2; i++)
2821 code.interpret_exit_ok();
2823 code.interpret_exit_nok();
2828 bzero(&opts,
sizeof(opts));
2829 opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
2830 opts.interpretedCode = &code;
2832 pOp[
i] = pTrans->readTuple(pIdxRecord, (
char*)pRow,
2833 pRowRecord, (
char*)pRow,
2838 CHK_RET_FAILED(pOp[i]);
2841 int res = pTrans->
execute(Commit, AO_IgnoreError);
2843 CHK_RET_FAILED(res == 0);
2844 CHK_RET_FAILED(pOp[0]->getNdbError().code == 0);
2845 CHK_RET_FAILED(pOp[1]->getNdbError().code != 0);
2856 Ndb* pNdb = GETNDB(step);
2860 CHK_RET_FAILED(pIdx != 0);
2863 CHK_RET_FAILED(pRowRecord != 0);
2865 CHK_RET_FAILED(pIdxRecord != 0);
2867 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
2868 Uint8 * pRow =
new Uint8[len];
2871 CHK_RET_FAILED(pTrans != 0);
2874 for (Uint32 i = 0; i<3; i++)
2878 code.interpret_exit_nok();
2880 code.interpret_exit_ok();
2886 calc.equalForRow(pRow, pRowRecord, i);
2889 bzero(&opts,
sizeof(opts));
2890 opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
2891 opts.interpretedCode = &code;
2893 pOp[
i] = pTrans->deleteTuple(pIdxRecord, (
char*)pRow,
2894 pRowRecord, (
char*)pRow,
2898 CHK_RET_FAILED(pOp[i]);
2901 int res = pTrans->
execute(Commit, AO_IgnoreError);
2903 CHK_RET_FAILED(res == 0);
2904 CHK_RET_FAILED(pOp[0]->getNdbError().code == 0);
2905 CHK_RET_FAILED(pOp[1]->getNdbError().code != 0);
2906 CHK_RET_FAILED(pOp[2]->getNdbError().code == 0);
2915 deferred_errors[] = {
2935 Ndb* pNdb = GETNDB(step);
2938 const int rows = ctx->getNumRecords();
2941 CHK_RET_FAILED(pRowRecord != 0);
2943 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
2944 Uint8 * pRow =
new Uint8[len];
2946 for (
int i = 0; deferred_errors[
i] != 0; i += 2)
2948 const int errorno = deferred_errors[
i];
2949 const int nodefail = deferred_errors[i+1];
2951 for (
int j = 0; j<3; j++)
2954 CHK_RET_FAILED(pTrans != 0);
2958 nodefail == 1 ? res.getNode(NdbRestarter::NS_RANDOM) :
2962 ndbout_c(
"errorno: %u(nf: %u - %u) j: %u : %s", errorno,
2963 nodefail, nodeId, j,
2964 j == 0 ?
"test before error insert" :
2965 j == 1 ?
"test with error insert" :
2966 j == 2 ?
"test after error insert" :
2968 if (j == 0 || j == 2)
2973 else if (nodefail == 0)
2975 CHK_RET_FAILED(res.insertErrorInAllNodes(errorno) == 0);
2979 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2980 CHK_RET_FAILED(res.dumpStateOneNode(nodeId, val2, 2) == 0);
2981 CHK_RET_FAILED(res.insertErrorInNode(nodeId, errorno) == 0);
2984 for (
int rowNo = 0; rowNo < 100; rowNo++)
2986 int rowId = rand() % rows;
2990 calc.setValues(pRow, pRowRecord, rowId, rand());
2993 bzero(&opts,
sizeof(opts));
2994 opts.optionsPresent =
2995 NdbOperation::OperationOptions::OO_DEFERRED_CONSTAINTS;
2997 const NdbOperation * pOp = pTrans->updateTuple(pRowRecord, (
char*)pRow,
2998 pRowRecord, (
char*)pRow,
3002 CHK_RET_FAILED(pOp != 0);
3005 int result = pTrans->
execute(Commit, AO_IgnoreError);
3006 if (j == 0 || j == 2)
3008 CHK_RET_FAILED(result == 0);
3012 CHK_RET_FAILED(result != 0);
3017 if (j == 0 || j == 2)
3024 ndbout_c(
" waiting for %u to enter not-started", nodeId);
3026 CHK_RET_FAILED(res.waitNodesNoStart(&nodeId, 1) == 0);
3028 ndbout_c(
" starting all");
3029 CHK_RET_FAILED(res.startAll() == 0);
3030 ndbout_c(
" wait cluster started");
3031 CHK_RET_FAILED(res.waitClusterStarted() == 0);
3032 ndbout_c(
" cluster started");
3034 CHK_RET_FAILED(res.insertErrorInAllNodes(0) == 0);
3047 Ndb* pNdb = GETNDB(step);
3050 unsigned seed = (unsigned)NdbTick_CurrentMillisecond();
3052 const int rows = ctx->getNumRecords();
3053 const int loops = 10 * ctx->getNumLoops();
3054 const int until_stopped = ctx->getProperty(
"UntilStopped");
3055 const int deferred = ctx->getProperty(
"Deferred");
3056 const int batch = ctx->getProperty(
"Batch", Uint32(50));
3059 CHK_RET_FAILED(pRowRecord != 0);
3061 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
3062 Uint8 * pRow =
new Uint8[len];
3065 int count_failed = 0;
3066 for (
int i = 0; i < loops || (until_stopped && !ctx->isTestStopped()); i++)
3069 CHK_RET_FAILED(pTrans != 0);
3073 for (
int rowNo = 0; rowNo < batch; rowNo++)
3075 int left = rows - lastrow;
3076 int rowId = lastrow;
3079 rowId += ndb_rand_r(&seed) % (left / 10 + 1);
3090 calc.setValues(pRow, pRowRecord, rowId, rand());
3093 bzero(&opts,
sizeof(opts));
3096 opts.optionsPresent =
3097 NdbOperation::OperationOptions::OO_DEFERRED_CONSTAINTS;
3101 switch(ndb_rand_r(&seed) % 3){
3103 pOp = pTrans->writeTuple(pRowRecord, (
char*)pRow,
3104 pRowRecord, (
char*)pRow,
3110 pOp = pTrans->deleteTuple(pRowRecord, (
char*)pRow,
3111 pRowRecord, (
char*)pRow,
3117 pOp = pTrans->updateTuple(pRowRecord, (
char*)pRow,
3118 pRowRecord, (
char*)pRow,
3124 CHK_RET_FAILED(pOp != 0);
3125 result = pTrans->
execute(NoCommit, AO_IgnoreError);
3132 result = pTrans->
execute(Commit, AO_IgnoreError);
3138 ndbout << err << endl;
3139 CHK_RET_FAILED(err.
code == 1235 ||
3153 ndbout_c(
"count_ok: %d count_failed: %d",
3154 count_ok, count_failed);
3165 for (
int l = 0; l<ctx->getNumLoops() && !ctx->isTestStopped(); l++)
3167 for (
int i = 0; deferred_errors[
i] != 0 && !ctx->isTestStopped(); i += 2)
3169 const int errorno = deferred_errors[
i];
3170 const int nodefail = deferred_errors[i+1];
3172 int nodeId = res.getNode(NdbRestarter::NS_RANDOM);
3174 ndbout_c(
"errorno: %u (nf: %u - %u)",
3180 CHK_RET_FAILED(res.insertErrorInNode(nodeId, errorno) == 0);
3181 NdbSleep_MilliSleep(300);
3182 CHK_RET_FAILED(res.insertErrorInNode(nodeId, errorno) == 0);
3186 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
3187 CHK_RET_FAILED(res.dumpStateOneNode(nodeId, val2, 2) == 0);
3188 CHK_RET_FAILED(res.insertErrorInNode(nodeId, errorno) == 0);
3189 ndbout_c(
" waiting for %u to enter not-started", nodeId);
3191 CHK_RET_FAILED(res.waitNodesNoStart(&nodeId, 1) == 0);
3193 ndbout_c(
" starting all");
3194 CHK_RET_FAILED(res.startAll() == 0);
3195 ndbout_c(
" wait cluster started");
3196 CHK_RET_FAILED(res.waitClusterStarted() == 0);
3197 ndbout_c(
" cluster started");
3206 NDBT_TESTSUITE(testIndex);
3207 TESTCASE(
"CreateAll",
3208 "Test that we can create all various indexes on each table\n"
3209 "Then drop the indexes\n"){
3210 INITIALIZER(runCreateIndexes);
3212 TESTCASE(
"CreateAll_O",
3213 "Test that we can create all various indexes on each table\n"
3214 "Then drop the indexes\n"){
3215 TC_PROPERTY(
"OrderedIndex", 1);
3216 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3217 INITIALIZER(runCreateIndexes);
3219 TESTCASE(
"InsertDeleteGentle",
3220 "Create one index, then perform insert and delete in the table\n"
3221 "loop number of times. Use batch size 1."){
3222 TC_PROPERTY(
"BatchSize", 1);
3223 INITIALIZER(runInsertDelete);
3224 FINALIZER(runClearTable);
3226 TESTCASE(
"InsertDeleteGentle_O",
3227 "Create one index, then perform insert and delete in the table\n"
3228 "loop number of times. Use batch size 1."){
3229 TC_PROPERTY(
"OrderedIndex", 1);
3230 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3231 TC_PROPERTY(
"BatchSize", 1);
3232 INITIALIZER(runInsertDelete);
3233 FINALIZER(runClearTable);
3235 TESTCASE(
"InsertDelete",
3236 "Create one index, then perform insert and delete in the table\n"
3237 "loop number of times. Use batchsize 512 to stress db more"){
3238 TC_PROPERTY(
"BatchSize", 512);
3239 INITIALIZER(runInsertDelete);
3240 FINALIZER(runClearTable);
3243 TESTCASE(
"InsertDelete_O",
3244 "Create one index, then perform insert and delete in the table\n"
3245 "loop number of times. Use batchsize 512 to stress db more"){
3246 TC_PROPERTY(
"OrderedIndex", 1);
3247 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3248 TC_PROPERTY(
"BatchSize", 512);
3249 INITIALIZER(runInsertDelete);
3250 FINALIZER(runClearTable);
3253 TESTCASE(
"CreateLoadDropGentle",
3254 "Try to create, drop and load various indexes \n"
3255 "on table loop number of times.Usa batch size 1.\n"){
3256 TC_PROPERTY(
"BatchSize", 1);
3257 INITIALIZER(runCreateLoadDropIndex);
3259 TESTCASE(
"CreateLoadDropGentle_O",
3260 "Try to create, drop and load various indexes \n"
3261 "on table loop number of times.Usa batch size 1.\n"){
3262 TC_PROPERTY(
"OrderedIndex", 1);
3263 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3264 TC_PROPERTY(
"BatchSize", 1);
3265 INITIALIZER(runCreateLoadDropIndex);
3267 TESTCASE(
"CreateLoadDrop",
3268 "Try to create, drop and load various indexes \n"
3269 "on table loop number of times. Use batchsize 512 to stress db more\n"){
3270 TC_PROPERTY(
"BatchSize", 512);
3271 INITIALIZER(runCreateLoadDropIndex);
3273 TESTCASE(
"CreateLoadDrop_O",
3274 "Try to create, drop and load various indexes \n"
3275 "on table loop number of times. Use batchsize 512 to stress db more\n"){
3276 TC_PROPERTY(
"OrderedIndex", 1);
3277 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3278 TC_PROPERTY(
"BatchSize", 512);
3279 INITIALIZER(runCreateLoadDropIndex);
3282 "Test that indexes are correctly maintained during node fail and node restart"){
3283 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3284 TC_PROPERTY(
"PauseThreads", 2);
3285 INITIALIZER(runClearTable);
3286 INITIALIZER(createRandomIndex);
3287 INITIALIZER(runLoadTable);
3289 STEP(runTransactions1);
3290 STEP(runTransactions1);
3291 FINALIZER(runVerifyIndex);
3292 FINALIZER(createRandomIndex_Drop);
3293 FINALIZER(runClearTable);
3296 "Test that indexes are correctly maintained during node fail and node restart"){
3297 TC_PROPERTY(
"OrderedIndex", 1);
3298 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3299 TC_PROPERTY(
"PauseThreads", 2);
3300 INITIALIZER(runClearTable);
3301 INITIALIZER(createRandomIndex);
3302 INITIALIZER(runLoadTable);
3304 STEP(runTransactions1);
3305 STEP(runTransactions1);
3306 FINALIZER(runVerifyIndex);
3307 FINALIZER(createRandomIndex_Drop);
3308 FINALIZER(runClearTable);
3311 "Test that indexes are correctly maintained during node fail and node restart"){
3312 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3313 TC_PROPERTY(
"PauseThreads", 2);
3314 INITIALIZER(runClearTable);
3315 INITIALIZER(createRandomIndex);
3316 INITIALIZER(createPkIndex);
3317 INITIALIZER(runLoadTable);
3319 STEP(runTransactions2);
3320 STEP(runTransactions2);
3321 FINALIZER(runVerifyIndex);
3322 FINALIZER(createRandomIndex_Drop);
3323 FINALIZER(createPkIndex_Drop);
3324 FINALIZER(runClearTable);
3327 "Test that indexes are correctly maintained during node fail and node restart"){
3328 TC_PROPERTY(
"OrderedIndex", 1);
3329 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3330 TC_PROPERTY(
"PauseThreads", 1);
3331 INITIALIZER(runClearTable);
3332 INITIALIZER(createRandomIndex);
3333 INITIALIZER(createPkIndex);
3334 INITIALIZER(runLoadTable);
3336 STEP(runTransactions2);
3338 FINALIZER(runVerifyIndex);
3339 FINALIZER(createRandomIndex_Drop);
3340 FINALIZER(createPkIndex_Drop);
3341 FINALIZER(runClearTable);
3344 "Test that indexes are correctly maintained during node fail and node restart"){
3345 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3346 TC_PROPERTY(
"PauseThreads", 2);
3347 INITIALIZER(runClearTable);
3348 INITIALIZER(createRandomIndex);
3349 INITIALIZER(createPkIndex);
3351 STEP(runTransactions3);
3352 STEP(runVerifyIndex);
3353 FINALIZER(runVerifyIndex);
3354 FINALIZER(createPkIndex_Drop);
3355 FINALIZER(createRandomIndex_Drop);
3356 FINALIZER(runClearTable);
3359 "Test that indexes are correctly maintained during node fail and node restart"){
3360 TC_PROPERTY(
"OrderedIndex", 1);
3361 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3362 TC_PROPERTY(
"PauseThreads", 2);
3363 INITIALIZER(runClearTable);
3364 INITIALIZER(createRandomIndex);
3365 INITIALIZER(createPkIndex);
3367 STEP(runTransactions3);
3368 STEP(runVerifyIndex);
3369 FINALIZER(runVerifyIndex);
3370 FINALIZER(createPkIndex_Drop);
3371 FINALIZER(createRandomIndex_Drop);
3372 FINALIZER(runClearTable);
3375 "Test that indexes are correctly maintained during node fail and node restart"){
3376 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3377 TC_PROPERTY(
"PauseThreads", 4);
3378 INITIALIZER(runClearTable);
3379 INITIALIZER(createRandomIndex);
3380 INITIALIZER(createPkIndex);
3381 INITIALIZER(runLoadTable);
3383 STEP(runTransactions1);
3384 STEP(runTransactions1);
3385 STEP(runTransactions2);
3386 STEP(runTransactions2);
3387 FINALIZER(runVerifyIndex);
3388 FINALIZER(createRandomIndex_Drop);
3389 FINALIZER(createPkIndex_Drop);
3390 FINALIZER(runClearTable);
3393 "Test that indexes are correctly maintained during node fail and node restart"){
3394 TC_PROPERTY(
"OrderedIndex", 1);
3395 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3396 TC_PROPERTY(
"PauseThreads", 4);
3397 INITIALIZER(runClearTable);
3398 INITIALIZER(createRandomIndex);
3399 INITIALIZER(createPkIndex);
3400 INITIALIZER(runLoadTable);
3402 STEP(runTransactions1);
3403 STEP(runTransactions1);
3404 STEP(runTransactions2);
3405 STEP(runTransactions2);
3406 FINALIZER(runVerifyIndex);
3407 FINALIZER(createRandomIndex_Drop);
3408 FINALIZER(createPkIndex_Drop);
3409 FINALIZER(runClearTable);
3412 "Test that indexes are correctly maintained during node fail and node restart"){
3413 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3414 TC_PROPERTY(
"BatchSize", (
unsigned)1);
3415 INITIALIZER(runClearTable);
3416 INITIALIZER(createRandomIndex);
3417 INITIALIZER(createPkIndex);
3418 INITIALIZER(runLoadTable);
3420 STEP(runTransactions1);
3421 STEP(runTransactions1);
3422 STEP(runTransactions2);
3423 STEP(runTransactions2);
3424 FINALIZER(runVerifyIndex);
3425 FINALIZER(createRandomIndex_Drop);
3426 FINALIZER(createPkIndex_Drop);
3427 FINALIZER(runClearTable);
3430 "Test that indexes are correctly maintained during node fail and node restart"){
3431 TC_PROPERTY(
"OrderedIndex", 1);
3432 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3433 TC_PROPERTY(
"BatchSize", (
unsigned)1);
3434 INITIALIZER(runClearTable);
3435 INITIALIZER(createRandomIndex);
3436 INITIALIZER(createPkIndex);
3437 INITIALIZER(runLoadTable);
3439 STEP(runTransactions1);
3440 STEP(runTransactions1);
3441 STEP(runTransactions2);
3442 STEP(runTransactions2);
3443 FINALIZER(runVerifyIndex);
3444 FINALIZER(createRandomIndex_Drop);
3445 FINALIZER(createPkIndex_Drop);
3446 FINALIZER(runClearTable);
3449 "Test that indexes are correctly maintained during SR"){
3450 INITIALIZER(runClearTable);
3451 INITIALIZER(createRandomIndex);
3452 INITIALIZER(createPkIndex);
3453 STEP(runSystemRestart1);
3454 FINALIZER(runVerifyIndex);
3455 FINALIZER(createPkIndex_Drop);
3456 FINALIZER(createRandomIndex_Drop);
3457 FINALIZER(runClearTable);
3459 TESTCASE(
"MixedTransaction",
3460 "Test mixing of index and normal operations"){
3461 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3462 INITIALIZER(runClearTable);
3463 INITIALIZER(createPkIndex);
3464 INITIALIZER(runLoadTable);
3466 FINALIZER(createPkIndex_Drop);
3467 FINALIZER(runClearTable);
3469 TESTCASE(
"MixedTransaction2",
3470 "Test mixing of index and normal operations with batching"){
3471 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3472 INITIALIZER(runClearTable);
3473 INITIALIZER(createPkIndex);
3474 INITIALIZER(runLoadTable);
3476 FINALIZER(createPkIndex_Drop);
3477 FINALIZER(runClearTable);
3480 "Test that indexes are correctly maintained during SR"){
3481 TC_PROPERTY(
"OrderedIndex", 1);
3482 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3483 INITIALIZER(runClearTable);
3484 INITIALIZER(createRandomIndex);
3485 INITIALIZER(createPkIndex);
3486 STEP(runSystemRestart1);
3487 FINALIZER(runVerifyIndex);
3488 FINALIZER(createPkIndex_Drop);
3489 FINALIZER(createRandomIndex_Drop);
3490 FINALIZER(runClearTable);
3492 TESTCASE(
"BuildDuring",
3493 "Test that index build when running transactions work"){
3494 TC_PROPERTY(
"OrderedIndex", (
unsigned)0);
3495 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3496 TC_PROPERTY(
"Threads", 1);
3497 TC_PROPERTY(
"BatchSize", 1);
3498 INITIALIZER(runClearTable);
3499 STEP(runBuildDuring);
3500 STEP(runTransactions4);
3502 FINALIZER(runClearTable);
3504 TESTCASE(
"BuildDuring_O",
3505 "Test that index build when running transactions work"){
3506 TC_PROPERTY(
"OrderedIndex", (
unsigned)1);
3507 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3508 TC_PROPERTY(
"Threads", 1);
3509 INITIALIZER(runClearTable);
3510 STEP(runBuildDuring);
3511 STEP(runTransactions4);
3513 FINALIZER(runClearTable);
3515 TESTCASE(
"UniqueNull",
3516 "Test that unique indexes and nulls"){
3517 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3518 INITIALIZER(runClearTable);
3519 INITIALIZER(createRandomIndex);
3520 INITIALIZER(createPkIndex);
3521 INITIALIZER(runLoadTable);
3522 STEP(runTransactions1);
3523 STEP(runTransactions2);
3524 STEP(runUniqueNullTransactions);
3525 FINALIZER(runVerifyIndex);
3526 FINALIZER(createRandomIndex_Drop);
3527 FINALIZER(createPkIndex_Drop);
3528 FINALIZER(runClearTable);
3530 TESTCASE(
"Bug21384",
3531 "Test that unique indexes and nulls"){
3532 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3533 INITIALIZER(runClearTable);
3534 INITIALIZER(createPkIndex);
3535 INITIALIZER(runLoadTable);
3537 FINALIZER(createPkIndex_Drop);
3538 FINALIZER(runClearTable);
3540 TESTCASE(
"Bug25059",
3541 "Test that unique indexes and nulls"){
3542 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3543 INITIALIZER(createPkIndex);
3544 INITIALIZER(runLoadTable);
3546 FINALIZER(createPkIndex_Drop);
3548 TESTCASE(
"Bug28804",
3549 "Test behaviour on out of TransactionBufferMemory for index lookup"){
3550 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3551 INITIALIZER(runClearTable);
3552 INITIALIZER(createPkIndex);
3553 INITIALIZER(runLoadTable);
3555 FINALIZER(createPkIndex_Drop);
3556 FINALIZER(runClearTable);
3558 TESTCASE(
"Bug28804_ATTRINFO",
3559 "Test behaviour on out of TransactionBufferMemory for index lookup"
3560 " in saveINDXATTRINFO"){
3561 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3562 INITIALIZER(runClearTable);
3563 INITIALIZER(createPkIndex);
3564 INITIALIZER(runLoadTable);
3565 STEP(runBug28804_ATTRINFO);
3566 FINALIZER(createPkIndex_Drop);
3567 FINALIZER(runClearTable);
3569 TESTCASE(
"Bug46069",
""){
3570 TC_PROPERTY(
"OrderedIndex", 1);
3571 TC_PROPERTY(
"THREADS", 12);
3572 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3573 INITIALIZER(createPkIndex);
3575 STEPS(runBug46069_pkdel, 10);
3576 STEPS(runBug46069_scandel, 2);
3577 FINALIZER(createPkIndex_Drop);
3579 TESTCASE(
"ConstraintDetails",
3580 "Test that the details part of the returned NdbError is as "
3582 INITIALIZER(runConstraintDetails);
3584 TESTCASE(
"Bug50118",
""){
3585 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3586 INITIALIZER(runClearTable);
3587 INITIALIZER(runLoadTable);
3588 INITIALIZER(createPkIndex);
3589 STEP(runReadIndexUntilStopped);
3590 STEP(runReadIndexUntilStopped);
3591 STEP(runReadIndexUntilStopped);
3593 FINALIZER(createPkIndex_Drop);
3594 FINALIZER(runClearTable);
3596 TESTCASE(
"FireTrigOverload",
""){
3597 TC_PROPERTY(
"LoggedIndexes", (
unsigned)0);
3598 TC_PROPERTY(
"NotOnlyPkId", (
unsigned)1);
3599 TC_PROPERTY(NDBT_TestCase::getStepThreadStackSizePropName(), 128*1024);
3600 INITIALIZER(createRandomIndex);
3601 INITIALIZER(runClearTable);
3602 STEP(runTrigOverload);
3603 FINALIZER(runClearError);
3604 FINALIZER(createRandomIndex_Drop);
3606 TESTCASE(
"DeferredError",
3607 "Test with deferred unique index handling and error inserts")
3609 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3610 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3611 INITIALIZER(createPkIndex);
3612 INITIALIZER(runLoadTable);
3613 STEP(runTestDeferredError);
3614 FINALIZER(createPkIndex_Drop);
3616 TESTCASE(
"DeferredMixedLoad",
3617 "Test mixed load of DML with deferred indexes")
3619 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3620 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3621 TC_PROPERTY(
"UntilStopped", Uint32(0));
3622 TC_PROPERTY(
"Deferred", Uint32(1));
3623 INITIALIZER(createPkIndex);
3624 INITIALIZER(runLoadTable);
3625 STEPS(runMixedDML, 10);
3626 FINALIZER(createPkIndex_Drop);
3628 TESTCASE(
"DeferredMixedLoadError",
3629 "Test mixed load of DML with deferred indexes")
3631 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3632 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3633 TC_PROPERTY(
"UntilStopped", Uint32(1));
3634 TC_PROPERTY(
"Deferred", Uint32(1));
3635 INITIALIZER(createPkIndex);
3636 INITIALIZER(runLoadTable);
3637 STEPS(runMixedDML, 4);
3638 STEP(runDeferredError);
3639 FINALIZER(createPkIndex_Drop);
3641 TESTCASE(
"NF_DeferredMixed",
3642 "Test mixed load of DML with deferred indexes")
3644 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3645 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3646 TC_PROPERTY(
"UntilStopped", Uint32(1));
3647 TC_PROPERTY(
"Deferred", Uint32(1));
3648 INITIALIZER(createPkIndex);
3649 INITIALIZER(runLoadTable);
3650 STEPS(runMixedDML, 4);
3652 FINALIZER(createPkIndex_Drop);
3654 TESTCASE(
"NF_Mixed",
3655 "Test mixed load of DML")
3657 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3658 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3659 TC_PROPERTY(
"UntilStopped", Uint32(1));
3660 INITIALIZER(createPkIndex);
3661 INITIALIZER(runLoadTable);
3662 STEPS(runMixedDML, 4);
3664 FINALIZER(createPkIndex_Drop);
3666 TESTCASE(
"Bug56829",
3667 "Return empty ordered index nodes to index fragment "
3668 "so that empty fragment pages can be freed"){
3671 TESTCASE(
"Bug12315582",
"")
3673 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3674 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3675 INITIALIZER(createPkIndex);
3676 INITIALIZER(runLoadTable);
3677 INITIALIZER(runBug12315582);
3678 FINALIZER(createPkIndex_Drop);
3680 TESTCASE(
"Bug60851",
"")
3682 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3683 TC_PROPERTY(
"OrderedIndex", Uint32(0));
3684 INITIALIZER(createPkIndex);
3685 INITIALIZER(runLoadTable);
3686 INITIALIZER(runBug60851);
3687 FINALIZER(createPkIndex_Drop);
3689 TESTCASE(
"RefreshWithOrderedIndex",
3690 "Refresh tuples with ordered index(es)")
3692 TC_PROPERTY(
"OrderedIndex", 1);
3693 TC_PROPERTY(
"LoggedIndexes", Uint32(0));
3694 INITIALIZER(createPkIndex);
3695 INITIALIZER(runRefreshTupleAbort);
3696 FINALIZER(createPkIndex_Drop);
3697 FINALIZER(runClearTable);
3699 NDBT_TESTSUITE_END(testIndex);
3701 int main(
int argc,
const char** argv){
3703 NDBT_TESTSUITE_INSTANCE(testIndex);
3704 return testIndex.execute(argc, argv);