18 #include <NDBT_Test.hpp>
19 #include <NDBT_ReturnCodes.h>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <TestNdbEventOperation.hpp>
23 #include <NdbAutoPtr.hpp>
24 #include <NdbRestarter.hpp>
25 #include <NdbRestarts.hpp>
26 #include <signaldata/DumpStateOrd.hpp>
28 #include <Bitmask.hpp>
30 static int createEvent(
Ndb *pNdb,
36 sprintf(eventName,
"%s_EVENT",tab.
getName());
41 g_err <<
"Dictionary not found "
47 myDict->dropEvent(eventName);
50 myEvent.setTable(tab.
getName());
53 myEvent.addEventColumn(a);
55 myEvent.mergeEvents(merge_events);
58 myEvent.setReport(NdbDictionary::Event::ER_SUBSCRIBE);
60 int res = myDict->createEvent(myEvent);
64 else if (myDict->getNdbError().classification ==
67 g_info <<
"Event creation failed event exists\n";
68 res = myDict->dropEvent(eventName);
70 g_err <<
"Failed to drop event: "
71 << myDict->getNdbError().code <<
" : "
72 << myDict->getNdbError().message << endl;
76 res = myDict->createEvent(myEvent);
78 g_err <<
"Failed to create event (1): "
79 << myDict->getNdbError().code <<
" : "
80 << myDict->getNdbError().message << endl;
86 g_err <<
"Failed to create event (2): "
87 << myDict->getNdbError().code <<
" : "
88 << myDict->getNdbError().message << endl;
95 static int createEvent(
Ndb *pNdb,
99 bool merge_events = ctx->getProperty(
"MergeEvents");
100 bool report = ctx->getProperty(
"ReportSubscribe");
102 return createEvent(pNdb, tab, merge_events, report);
107 char eventName[1024];
108 sprintf(eventName,
"%s_EVENT",tab.
getName());
111 g_err <<
"Dictionary not found "
116 if (myDict->dropEvent(eventName)) {
117 g_err <<
"Failed to drop event: "
118 << myDict->getNdbError().code <<
" : "
119 << myDict->getNdbError().message << endl;
128 int do_report_error = 1)
131 sprintf(buf,
"%s_EVENT", tab.
getName());
136 g_err <<
"createEventOperation: "
142 for (
int j = 0; j < n_columns; j++)
147 if ( pOp->execute() )
150 g_err <<
"pOp->execute(): "
151 << pOp->getNdbError().code <<
" "
152 << pOp->getNdbError().message << endl;
161 if (createEvent(GETNDB(step),* ctx->getTab(), ctx) != 0){
171 return transId ^ (transId >> 32);
174 bool checkAnyValueTransId(Uint64 transId, Uint32 anyValue)
176 return transId && (anyValue == Uint32(transId ^ (transId >> 32)));
188 const char function[] =
"HugoTransactions::eventOperation: ";
192 struct receivedEvent* recUpdateEvent = &recInsertEvent[records];
193 struct receivedEvent* recDeleteEvent = &recInsertEvent[2*records];
200 stats.n_consecutive = 0;
201 stats.n_duplicates = 0;
202 stats.n_inconsistent_gcis = 0;
204 for (
int i = 0;
i < records;
i++) {
205 recInsertEvent[
i].pk = 0xFFFFFFFF;
206 recInsertEvent[
i].count = 0;
207 recInsertEvent[
i].event = 0xFFFFFFFF;
209 recUpdateEvent[
i].pk = 0xFFFFFFFF;
210 recUpdateEvent[
i].count = 0;
211 recUpdateEvent[
i].event = 0xFFFFFFFF;
213 recDeleteEvent[
i].pk = 0xFFFFFFFF;
214 recDeleteEvent[
i].count = 0;
215 recDeleteEvent[
i].event = 0xFFFFFFFF;
221 g_err <<
function <<
"Event Creation failedDictionary not found\n";
228 char eventName[1024];
229 sprintf(eventName,
"%s_EVENT",tab.
getName());
232 g_info <<
function <<
"create EventOperation\n";
235 g_err <<
function <<
"Event operation creation failed\n";
239 g_info <<
function <<
"get values\n";
245 for (
int a = 0; a < (int)noEventColumnName; a++) {
251 g_info <<
function <<
"execute\n";
253 g_err <<
function <<
"operation execution failed: \n";
259 g_info <<
function <<
"ok\n";
262 Uint64 last_inconsitant_gci = (Uint64)-1;
277 Uint64 gci = pOp->
getGCI();
281 if (last_inconsitant_gci != gci) {
282 last_inconsitant_gci = gci;
283 stats.n_inconsistent_gcis++;
285 g_warning <<
"A node failure has occured and events might be missing\n";
287 g_info <<
function <<
"GCI " << gci <<
": " << count;
292 g_info <<
" INSERT: ";
293 recEvent = recInsertEvent;
297 g_info <<
" DELETE: ";
298 recEvent = recDeleteEvent;
302 g_info <<
" UPDATE: ";
303 recEvent = recUpdateEvent;
315 if (!checkAnyValueTransId(transId, anyValue))
317 g_err <<
"ERROR : TransId and AnyValue mismatch. "
318 <<
"Transid : " << transId
319 <<
", AnyValue : " << anyValue
320 <<
", Expected AnyValue : "
321 << (Uint32) ((transId >> 32) ^ transId)
328 if ((
int)pk < records) {
329 recEvent[pk].pk = pk;
330 recEvent[pk].count++;
333 for (
int i = 1;
i < (int)noEventColumnName;
i++) {
334 if (recAttr[
i]->isNULL() >= 0) {
335 g_info <<
" post[" <<
i <<
"]=";
336 if (recAttr[i]->isNULL() == 0)
337 g_info << recAttr[i]->u_32_value();
341 if (recAttrPre[i]->isNULL() >= 0) {
342 g_info <<
" pre[" << i <<
"]=";
343 if (recAttrPre[i]->isNULL() == 0)
344 g_info << recAttrPre[i]->u_32_value();
358 g_info <<
"dropping event operation" << endl;
362 g_err <<
"operation execution failed\n";
366 g_info <<
" ok" << endl;
368 if (stats.n_inserts > 0) {
369 stats.n_consecutive++;
371 if (stats.n_deletes > 0) {
372 stats.n_consecutive++;
374 if (stats.n_updates > 0) {
375 stats.n_consecutive++;
377 for (
int i = 0; i < (int)records/3; i++) {
378 if (recInsertEvent[i].pk != Uint32(i)) {
379 stats.n_consecutive ++;
380 ndbout <<
"missing insert pk " << i << endl;
381 }
else if (recInsertEvent[i].count > 1) {
382 ndbout <<
"duplicates insert pk " << i
383 <<
" count " << recInsertEvent[
i].count << endl;
384 stats.n_duplicates += recInsertEvent[
i].count-1;
386 if (recUpdateEvent[i].pk != Uint32(i)) {
387 stats.n_consecutive ++;
388 ndbout <<
"missing update pk " << i << endl;
389 }
else if (recUpdateEvent[i].count > 1) {
390 ndbout <<
"duplicates update pk " << i
391 <<
" count " << recUpdateEvent[
i].count << endl;
392 stats.n_duplicates += recUpdateEvent[
i].count-1;
394 if (recDeleteEvent[i].pk != Uint32(i)) {
395 stats.n_consecutive ++;
396 ndbout <<
"missing delete pk " << i << endl;
397 }
else if (recDeleteEvent[i].count > 1) {
398 ndbout <<
"duplicates delete pk " << i
399 <<
" count " << recDeleteEvent[
i].count << endl;
400 stats.n_duplicates += recDeleteEvent[
i].count-1;
411 sprintf(buf,
"%s_SHADOW", table->
getName());
413 GETNDB(step)->getDictionary()->dropTable(buf);
414 if (GETNDB(step)->getDictionary()->getTable(buf))
416 g_err <<
"unsucessful drop of " << buf << endl;
421 table_shadow.setName(buf);
425 GETNDB(step)->getDictionary()->createTable(table_shadow);
426 if (GETNDB(step)->getDictionary()->getTable(buf))
429 g_err <<
"unsucessful create of " << buf << endl;
437 sprintf(buf,
"%s_SHADOW", table->
getName());
439 GETNDB(step)->getDictionary()->dropTable(buf);
445 int loops = ctx->getNumLoops();
453 char eventName[1024];
454 sprintf(eventName,
"%s_EVENT",tab.
getName());
457 for (
int i= 0; i < loops; i++)
460 if (eventOperation(GETNDB(step), tab, (
void*)&stats, 0) != 0){
464 g_info <<
"create EventOperation\n";
467 g_err <<
"Event operation creation failed\n";
471 g_info <<
"dropping event operation" << endl;
474 g_err <<
"operation execution failed\n";
483 int theThreadIdCounter = 0;
487 int tId = theThreadIdCounter++;
489 int records = ctx->getNumRecords();
494 g_info <<
"***** start Id " << tId << endl;
498 if (eventOperation(GETNDB(step), *ctx->getTab(), (
void*)&stats, 3*records) != 0){
503 if (stats.n_inserts == records &&
504 stats.n_deletes == records &&
505 stats.n_updates == records &&
506 stats.n_consecutive == 3 &&
507 stats.n_duplicates == 0)
512 if (ret == NDBT_FAILED) {
513 g_info <<
"***** end Id " << tId << endl;
514 ndbout_c(
"n_inserts = %d (%d)", stats.n_inserts, records);
515 ndbout_c(
"n_deletes = %d (%d)", stats.n_deletes, records);
516 ndbout_c(
"n_updates = %d (%d)", stats.n_updates, records);
517 ndbout_c(
"n_consecutive = %d (%d)", stats.n_consecutive, 3);
518 ndbout_c(
"n_duplicates = %d (%d)", stats.n_duplicates, 0);
519 ndbout_c(
"n_inconsistent_gcis = %d (%d)", stats.n_inconsistent_gcis, 0);
527 int loops = ctx->getNumLoops();
528 int records = ctx->getNumRecords();
531 hugoTrans.setAnyValueCallback(setAnyValue);
536 sleep(theThreadIdCounter);
538 if (hugoTrans.loadTable(GETNDB(step), records, 1,
true, loops) != 0){
541 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, loops) != 0){
544 if (hugoTrans.pkDelRecords(GETNDB(step), records, 1,
true, loops) != 0){
552 int loops = ctx->getNumLoops();
553 int records = ctx->getNumRecords();
555 hugoTrans.setAnyValueCallback(setAnyValue);
557 if(ctx->getPropertyWait(
"LastGCI_hi", ~(Uint32)0))
559 g_err <<
"FAIL " << __LINE__ << endl;
563 while(loops -- && !ctx->isTestStopped())
565 hugoTrans.clearTable(GETNDB(step), 0);
567 if (hugoTrans.loadTable(GETNDB(step), 3*records, 1,
true, 1) != 0){
568 g_err <<
"FAIL " << __LINE__ << endl;
572 if (hugoTrans.pkDelRecords(GETNDB(step), 3*records, 1,
true, 1) != 0){
573 g_err <<
"FAIL " << __LINE__ << endl;
576 if (hugoTrans.loadTable(GETNDB(step), records, 1,
true, 1) != 0){
577 g_err <<
"FAIL " << __LINE__ << endl;
580 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
581 g_err <<
"FAIL " << __LINE__ << endl;
584 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
585 g_err <<
"FAIL " << __LINE__ << endl;
588 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
589 g_err <<
"FAIL " << __LINE__ << endl;
593 ndbout_c(
"set(LastGCI_hi): %u/%u",
594 Uint32(hugoTrans.m_latest_gci >> 32),
595 Uint32(hugoTrans.m_latest_gci));
596 ctx->setProperty(
"LastGCI_lo", Uint32(hugoTrans.m_latest_gci));
597 ctx->setProperty(
"LastGCI_hi", Uint32(hugoTrans.m_latest_gci >> 32));
598 if(ctx->getPropertyWait(
"LastGCI_hi", ~(Uint32)0))
600 g_err <<
"FAIL " << __LINE__ << endl;
610 return dropEvent(GETNDB(step), * ctx->getTab());
618 sprintf(buf,
"%s_SHADOW", table->
getName());
621 if (hugoTrans.compare(GETNDB(step), buf, 0))
631 DBUG_ENTER(
"runEventApplier");
633 int result = NDBT_OK;
637 char shadow[1024], buf[1024];
638 sprintf(shadow,
"%s_SHADOW", table->
getName());
640 if ((table_shadow = GETNDB(step)->getDictionary()->getTable(shadow)) == 0)
642 g_err <<
"Unable to get table " << shadow << endl;
643 DBUG_RETURN(NDBT_FAILED);
646 sprintf(buf,
"%s_EVENT", table->
getName());
648 pCreate = pOp = GETNDB(step)->createEventOperation(buf);
650 g_err <<
"Event operation creation failed on %s" << buf << endl;
651 DBUG_RETURN(NDBT_FAILED);
653 bool merge_events = ctx->getProperty(
"MergeEvents");
654 pOp->mergeEvents(merge_events);
660 for (i = 0; i < n_columns; i++) {
665 if (pOp->execute()) {
666 g_err <<
"execute operation execution failed: \n";
667 g_err << pOp->getNdbError().code <<
" "
668 << pOp->getNdbError().message << endl;
669 result = NDBT_FAILED;
673 ctx->setProperty(
"LastGCI_hi", ~(Uint32)0);
676 while(!ctx->isTestStopped())
679 Uint64 stop_gci= ~(Uint64)0;
681 Ndb* ndb= GETNDB(step);
683 while(!ctx->isTestStopped() && curr_gci <= stop_gci)
688 assert(pOp == pCreate);
690 if (pOp->getEventType() >=
691 NdbDictionary::Event::TE_FIRST_NON_DATA_EVENT)
700 g_err <<
"startTransaction failed "
701 << GETNDB(step)->getNdbError().code <<
" "
702 << GETNDB(step)->getNdbError().message << endl;
703 result = NDBT_FAILED;
711 g_err <<
"getNdbOperation failed "
714 result = NDBT_FAILED;
719 switch (pOp->getEventType()) {
723 g_err <<
"insertTuple "
726 result = NDBT_FAILED;
734 g_err <<
"deleteTuple "
737 result = NDBT_FAILED;
745 g_err <<
"updateTuple "
748 result = NDBT_FAILED;
758 Uint32 anyValue = pOp->getAnyValue();
759 Uint64 transId = pOp->getTransId();
762 if (!checkAnyValueTransId(transId, anyValue))
764 g_err <<
"ERROR : TransId and AnyValue mismatch. "
765 <<
"Transid : " << transId
766 <<
", AnyValue : " << anyValue
767 <<
", Expected AnyValue : "
768 << (Uint32) ((transId >> 32) ^ transId)
775 for (i= 0; i < n_columns; i++)
777 if (recAttr[i]->isNULL())
781 g_err <<
"internal error: primary key isNull()="
782 << recAttr[
i]->
isNULL() << endl;
783 result = NDBT_FAILED;
787 switch (pOp->getEventType()) {
789 if (recAttr[i]->isNULL() < 0)
791 g_err <<
"internal error: missing value for insert\n";
792 result = NDBT_FAILED;
806 op->
equal(i,recAttr[i]->aRef()))
808 g_err <<
"equal " << i <<
" "
811 result = NDBT_FAILED;
817 switch (pOp->getEventType()) {
819 for (i= 0; i < n_columns; i++)
822 op->
setValue(i,recAttr[i]->isNULL() ? 0:recAttr[i]->aRef()))
824 g_err <<
"setValue(insert) " << i <<
" "
827 result = NDBT_FAILED;
836 for (i= 0; i < n_columns; i++)
840 op->
setValue(i,recAttr[i]->isNULL() ? 0:recAttr[i]->aRef()))
842 g_err <<
"setValue(update) " << i <<
" "
845 result = NDBT_FAILED;
855 if (trans->
execute(Commit) == 0)
865 g_err <<
"Ignoring execute failed "
873 else if (noRetries++ == 10)
875 g_err <<
"execute failed "
879 result = NDBT_FAILED;
884 NdbSleep_MilliSleep(100);
887 Uint32 stop_gci_hi = ctx->getProperty(
"LastGCI_hi", ~(Uint32)0);
888 Uint32 stop_gci_lo = ctx->getProperty(
"LastGCI_lo", ~(Uint32)0);
889 stop_gci = Uint64(stop_gci_lo) | (Uint64(stop_gci_hi) << 32);
892 ndbout_c(
"Applied gci: %u/%u, %d events",
893 Uint32(stop_gci >> 32), Uint32(stop_gci), count);
894 if (hugoTrans.compare(GETNDB(step), shadow, 0))
896 g_err <<
"compare failed" << endl;
897 result = NDBT_FAILED;
900 ctx->setProperty(
"LastGCI_hi", ~(Uint32)0);
907 if (GETNDB(step)->dropEventOperation(pCreate)) {
908 g_err <<
"dropEventOperation execution failed "
909 << GETNDB(step)->getNdbError().code <<
" "
910 << GETNDB(step)->getNdbError().message << endl;
911 result = NDBT_FAILED;
920 DBUG_ENTER(
"runEventConsumer");
921 int result = NDBT_OK;
926 sprintf(buf,
"%s_EVENT", table->
getName());
928 pCreate = pOp = GETNDB(step)->createEventOperation(buf);
930 g_err <<
"Event operation creation failed on %s" << buf << endl;
931 DBUG_RETURN(NDBT_FAILED);
933 bool merge_events = ctx->getProperty(
"MergeEvents");
934 pOp->mergeEvents(merge_events);
940 for (i = 0; i < n_columns; i++) {
945 if (pOp->execute()) {
946 g_err <<
"execute operation execution failed: \n";
947 g_err << pOp->getNdbError().code <<
" "
948 << pOp->getNdbError().message << endl;
949 result = NDBT_FAILED;
953 ctx->setProperty(
"LastGCI_hi", ~(Uint32)0);
956 while(!ctx->isTestStopped())
959 Ndb* ndb= GETNDB(step);
962 while(!ctx->isTestStopped())
967 if (curr_gci != last_gci)
975 ndbout_c(
"Consumed gci: %u/%u, %d events",
976 Uint32(last_gci >> 32), Uint32(last_gci), count);
983 if (GETNDB(step)->dropEventOperation(pCreate)) {
984 g_err <<
"dropEventOperation execution failed "
985 << GETNDB(step)->getNdbError().code <<
" "
986 << GETNDB(step)->getNdbError().message << endl;
987 result = NDBT_FAILED;
997 int result = NDBT_OK;
1000 Ndb* ndb= GETNDB(step);
1003 sprintf(buf,
"%s_EVENT", table->
getName());
1006 if ( pOp == NULL ) {
1007 g_err <<
"Event operation creation failed on %s" << buf << endl;
1015 for (i = 0; i < n_columns; i++) {
1022 g_err <<
"execute operation execution failed: \n";
1023 g_err << pOp->getNdbError().code <<
" "
1024 << pOp->getNdbError().message << endl;
1025 result = NDBT_FAILED;
1029 while(!ctx->isTestStopped())
1031 Uint64 curr_gci = 0;
1032 while(!ctx->isTestStopped())
1037 assert(pOp == pCreate);
1046 g_err <<
"dropEventOperation execution failed "
1049 result = NDBT_FAILED;
1056 int result = NDBT_OK;
1061 bool abort = ctx->getProperty(
"Graceful", Uint32(0)) == 0;
1063 if (restarter.getNumDbNodes() < 2){
1068 if(restarter.waitClusterStarted(60) != 0){
1069 g_err <<
"Cluster failed to start" << endl;
1073 while(result != NDBT_FAILED && !ctx->isTestStopped()){
1075 int id = lastId % restarter.getNumDbNodes();
1076 int nodeId = restarter.getDbNodeId(
id);
1077 ndbout <<
"Restart node " << nodeId << endl;
1078 if (abort ==
false && ((i % 3) == 0))
1080 restarter.insertErrorInNode(nodeId, 13043);
1083 if(restarter.restartOneDbNode(nodeId,
false,
false, abort) != 0){
1084 g_err <<
"Failed to restartNextDbNode" << endl;
1085 result = NDBT_FAILED;
1089 if(restarter.waitClusterStarted(60) != 0){
1090 g_err <<
"Cluster failed to start" << endl;
1091 result = NDBT_FAILED;
1104 int result = NDBT_OK;
1105 int loops = ctx->getNumLoops();
1110 if (restarter.getNumDbNodes() < 2){
1115 if(restarter.waitClusterStarted(60) != 0){
1116 g_err <<
"Cluster failed to start" << endl;
1120 while(result != NDBT_FAILED
1121 && !ctx->isTestStopped()
1124 int id = lastId % restarter.getNumDbNodes();
1125 int nodeId = restarter.getDbNodeId(
id);
1126 ndbout <<
"Restart node " << nodeId << endl;
1127 if(restarter.restartOneDbNode(nodeId,
false,
false,
true) != 0){
1128 g_err <<
"Failed to restartNextDbNode" << endl;
1129 result = NDBT_FAILED;
1133 if(restarter.waitClusterStarted(60) != 0){
1134 g_err <<
"Cluster failed to start" << endl;
1135 result = NDBT_FAILED;
1152 DBUG_ENTER(
"getAllTables");
1153 Ndb * ndb= GETNDB(step);
1157 for (
int i= 0; i < ctx->getNumTables(); i++)
1162 ndbout <<
"Failed to get table" << endl;
1164 DBUG_RETURN(NDBT_FAILED);
1166 pTabs.push_back(pTab);
1167 ndbout <<
" " << ctx->getTableName(i);
1169 pTabs.push_back(NULL);
1172 DBUG_RETURN(NDBT_OK);
1177 DBUG_ENTER(
"createAllEvents");
1178 Ndb * ndb= GETNDB(step);
1179 for (
int i= 0; pTabs[
i]; i++)
1181 if (createEvent(ndb,*pTabs[i], ctx))
1183 DBUG_RETURN(NDBT_FAILED);
1186 DBUG_RETURN(NDBT_OK);
1191 DBUG_ENTER(
"dropAllEvents");
1192 Ndb * ndb= GETNDB(step);
1195 for (i= 0; pTabs[
i]; i++)
1197 if (dropEvent(ndb,*pTabs[i]))
1199 DBUG_RETURN(NDBT_FAILED);
1202 DBUG_RETURN(NDBT_OK);
1207 DBUG_ENTER(
"createAllShadows");
1208 Ndb * ndb= GETNDB(step);
1211 for (
int i= 0; pTabs[
i]; i++)
1214 sprintf(buf,
"%s_SHADOW", pTabs[i]->getName());
1219 DBUG_RETURN(NDBT_FAILED);
1223 table_shadow.setName(buf);
1226 g_err <<
"createTable(" << buf <<
") "
1229 DBUG_RETURN(NDBT_FAILED);
1231 pShadowTabs.push_back(dict->
getTable(buf));
1232 if (!pShadowTabs[i])
1234 g_err <<
"getTable(" << buf <<
") "
1237 DBUG_RETURN(NDBT_FAILED);
1240 DBUG_RETURN(NDBT_OK);
1245 DBUG_ENTER(
"dropAllShadows");
1246 Ndb * ndb= GETNDB(step);
1249 for (
int i= 0; pTabs[
i]; i++)
1252 sprintf(buf,
"%s_SHADOW", pTabs[i]->getName());
1255 DBUG_RETURN(NDBT_FAILED);
1258 DBUG_RETURN(NDBT_OK);
1263 if (ops[0]->startTransaction(ndb) != NDBT_OK)
1266 for (
int i= ops.size()-1; i > 0; i--)
1268 ops[
i]->setTransaction(t,
true);
1275 if (ops[0]->closeTransaction(ndb) != NDBT_OK)
1277 for (
int i= ops.size()-1; i > 0; i--)
1279 ops[
i]->setTransaction(NULL,
true);
1286 if (ops[0]->execute_Commit(ndb) != NDBT_OK)
1291 static int copy_events(
Ndb *ndb)
1293 DBUG_ENTER(
"copy_events");
1302 DBUG_PRINT(
"info", (
"pollEvents res=%d", res));
1316 g_err <<
"unable to find table " << buf << endl;
1320 if (pOp->isOverrun())
1322 g_err <<
"buffer overrun\n";
1328 g_err <<
"A node failure has occured and events might be missing\n";
1338 g_err <<
"startTransaction failed "
1347 g_err <<
"getNdbOperation failed "
1357 g_err <<
"insertTuple "
1370 g_err <<
"deleteTuple "
1383 g_err <<
"updateTuple "
1398 for (
const NdbRecAttr *pk= pOp->getFirstPkAttr();
1404 g_err <<
"internal error: primary key isNull()="
1405 << pk->isNULL() << endl;
1406 DBUG_RETURN(NDBT_FAILED);
1408 if (op->
equal(pk->getColumn()->getColumnNo(),pk->aRef()))
1410 g_err <<
"equal " << pk->getColumn()->getColumnNo() <<
" "
1413 DBUG_RETURN(NDBT_FAILED);
1421 for (
const NdbRecAttr *data= pOp->getFirstDataAttr();
1425 if (data->isNULL() < 0 ||
1426 op->
setValue(data->getColumn()->getColumnNo(),
1427 data->isNULL() ? 0:data->aRef()))
1429 g_err <<
"setValue(insert) " << data->getColumn()->getColumnNo()
1441 for (
const NdbRecAttr *data= pOp->getFirstDataAttr();
1445 if (data->isNULL() >= 0 &&
1446 op->
setValue(data->getColumn()->getColumnNo(),
1447 data->isNULL() ? 0:data->aRef()))
1449 g_err <<
"setValue(update) " << data->getColumn()->getColumnNo()
1452 DBUG_RETURN(NDBT_FAILED);
1461 if (trans->
execute(Commit) == 0)
1467 if (noRetries++ == 10 ||
1470 g_err <<
"execute " << r <<
" failed "
1477 NdbSleep_MilliSleep(100);
1481 g_info <<
"n_updates: " << n_updates <<
" "
1482 <<
"n_inserts: " << n_inserts <<
" "
1483 <<
"n_deletes: " << n_deletes << endl;
1487 static int verify_copy(
Ndb *ndb,
1491 for (
unsigned i= 0; i < tabs1.size(); i++)
1495 if (hugoTrans.compare(ndb, tabs2[i]->getName(), 0))
1501 static int createEventOperations(
Ndb * ndb)
1503 DBUG_ENTER(
"createEventOperations");
1507 for (i= 0; pTabs[
i]; i++)
1510 sprintf(buf,
"%s_EVENT", pTabs[i]->getName());
1514 DBUG_RETURN(NDBT_FAILED);
1517 int n_columns= pTabs[
i]->getNoOfColumns();
1518 for (
int j = 0; j < n_columns; j++)
1520 pOp->
getValue(pTabs[i]->getColumn(j)->getName());
1521 pOp->
getPreValue(pTabs[i]->getColumn(j)->getName());
1526 DBUG_RETURN(NDBT_FAILED);
1530 DBUG_RETURN(NDBT_OK);
1536 DBUG_ENTER(
"createAllEventOperations");
1537 Ndb * ndb= GETNDB(step);
1538 int r= createEventOperations(ndb);
1541 DBUG_RETURN(NDBT_FAILED);
1543 DBUG_RETURN(NDBT_OK);
1547 static int dropEventOperations(
Ndb * ndb)
1549 DBUG_ENTER(
"dropEventOperations");
1552 while ( (pOp= ndb->getEventOperation()) )
1556 DBUG_RETURN(NDBT_FAILED);
1560 DBUG_RETURN(NDBT_OK);
1566 DBUG_ENTER(
"dropAllEventOperations");
1567 Ndb * ndb= GETNDB(step);
1568 int r= dropEventOperations(ndb);
1571 DBUG_RETURN(NDBT_FAILED);
1573 DBUG_RETURN(NDBT_OK);
1579 DBUG_ENTER(
"runMulti");
1581 Ndb * ndb= GETNDB(step);
1586 if (createEventOperations(ndb))
1588 DBUG_RETURN(NDBT_FAILED);
1593 for (i= 0; no_error && pTabs[
i]; i++)
1601 if (start_transaction(ndb, hugo_ops))
1604 DBUG_RETURN(NDBT_FAILED);
1606 for (i= 0; no_error && pTabs[
i]; i++)
1608 hugo_ops[
i]->pkInsertRecord(ndb, 0, n_records);
1610 if (execute_commit(ndb, hugo_ops))
1613 DBUG_RETURN(NDBT_FAILED);
1615 if(close_transaction(ndb, hugo_ops))
1618 DBUG_RETURN(NDBT_FAILED);
1624 if (copy_events(ndb) < 0)
1627 DBUG_RETURN(NDBT_FAILED);
1629 if (verify_copy(ndb, pTabs, pShadowTabs))
1632 DBUG_RETURN(NDBT_FAILED);
1638 if (start_transaction(ndb, hugo_ops))
1641 DBUG_RETURN(NDBT_FAILED);
1644 hugo_ops[0]->pkUpdateRecord(ndb, n_records-1);
1646 if (execute_commit(ndb, hugo_ops))
1649 DBUG_RETURN(NDBT_FAILED);
1651 if(close_transaction(ndb, hugo_ops))
1654 DBUG_RETURN(NDBT_FAILED);
1660 if (copy_events(ndb) < 0)
1663 DBUG_RETURN(NDBT_FAILED);
1665 if (verify_copy(ndb, pTabs, pShadowTabs))
1668 DBUG_RETURN(NDBT_FAILED);
1672 if (dropEventOperations(ndb))
1674 DBUG_RETURN(NDBT_FAILED);
1678 DBUG_RETURN(NDBT_OK);
1679 DBUG_RETURN(NDBT_FAILED);
1684 DBUG_ENTER(
"runMulti");
1686 int records = ctx->getNumRecords();
1687 int loops = ctx->getNumLoops();
1688 Ndb * ndb= GETNDB(step);
1692 if (createEventOperations(ndb))
1694 DBUG_RETURN(NDBT_FAILED);
1697 for (i= 0; pTabs[
i]; i++)
1700 if (hugo.loadTable(ndb, records, 1,
true, 1))
1702 DBUG_RETURN(NDBT_FAILED);
1705 if (copy_events(ndb) < 0)
1707 DBUG_RETURN(NDBT_FAILED);
1711 if (verify_copy(ndb, pTabs, pShadowTabs))
1713 DBUG_RETURN(NDBT_FAILED);
1718 for (
int j= 0; j < loops; j++)
1722 if (restarts.executeRestart(ctx,
"RestartRandomNodeAbort", timeout))
1724 DBUG_RETURN(NDBT_FAILED);
1729 for (i= 0; pTabs[
i]; i++)
1732 if (hugo.pkUpdateRecords(ndb, records, 1, 1))
1734 DBUG_RETURN(NDBT_FAILED);
1736 if (copy_events(ndb) < 0)
1738 DBUG_RETURN(NDBT_FAILED);
1743 if (verify_copy(ndb, pTabs, pShadowTabs))
1745 DBUG_RETURN(NDBT_FAILED);
1750 if (dropEventOperations(ndb))
1752 DBUG_RETURN(NDBT_FAILED);
1755 DBUG_RETURN(NDBT_OK);
1765 int nodes[MAX_NDB_NODES];
1767 for (Uint32 i = 0; i<MAX_NDB_NODES; i++)
1772 res.restartOneDbNode(i,
false,
true,
true);
1779 if (res.waitNodesNoStart(nodes, cnt) != 0)
1782 res.startNodes(nodes, cnt);
1784 return res.waitClusterStarted();
1787 static int restartAllNodes()
1798 for (Uint32 i = 0; i<(Uint32)restarter.getNumDbNodes(); i++)
1800 int nodeId = restarter.getDbNodeId(i);
1801 if (ng.
get(restarter.getNodeGroup(nodeId)) ==
false)
1804 ng.
set(restarter.getNodeGroup(nodeId));
1813 if ((res = restartNodes(nodes0)) != NDBT_OK)
1819 res = restartNodes(nodes1);
1825 DBUG_ENTER(
"runCreateDropNR");
1826 Ndb * ndb= GETNDB(step);
1827 int result = NDBT_OK;
1829 int loops = ctx->getNumLoops();
1831 if (restarter.getNumDbNodes() < 2)
1841 result = NDBT_FAILED;
1842 if (createEvent(ndb, *pTab, ctx))
1844 g_err <<
"createEvent failed" << endl;
1850 g_err <<
"Failed to createEventOperation" << endl;
1853 if (dropEvent(ndb, *pTab))
1855 g_err <<
"Failed to dropEvent()" << endl;
1858 ndbout <<
"Restarting with dropped events with subscribers" << endl;
1859 if (restartAllNodes())
1862 g_err <<
"Failed to drop " << pTab->
getName() <<
" in db" << endl;
1865 ndbout <<
"Restarting with dropped events and dropped "
1866 <<
"table with subscribers" << endl;
1867 if (restartAllNodes())
1871 g_err <<
"Failed dropEventOperation" << endl;
1876 g_err <<
"createTable failed: "
1881 }
while (--loops > 0);
1883 DBUG_RETURN(result);
1892 sprintf(buf,
"%s_EVENT", tab.
getName());
1893 Ndb* ndb = GETNDB(step);
1894 int loops = 5 * ctx->getNumLoops();
1895 int untilStopped = ctx->getProperty(
"SubscribeUntilStopped", (Uint32)0);
1897 while ((untilStopped || --loops) && !ctx->isTestStopped())
1902 g_err <<
"createEventOperation: "
1903 << ndb->getNdbError().code <<
" "
1904 << ndb->getNdbError().message << endl;
1909 for (
int j = 0; j < n_columns; j++)
1916 g_err <<
"pOp->execute(): "
1920 ndb->dropEventOperation(pOp);
1926 if (ndb->pollEvents(0))
1928 while (ndb->nextEvent())
1932 if (ndb->dropEventOperation(pOp))
1934 g_err <<
"pOp->execute(): "
1935 << ndb->getNdbError().code <<
" "
1936 << ndb->getNdbError().message << endl;
1947 int records = ctx->getNumRecords();
1949 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
1958 int parallelism = ctx->getProperty(
"Parallelism", (Uint32)0);
1959 int abort = ctx->getProperty(
"AbortProb", (Uint32)0);
1961 while (ctx->isTestStopped() ==
false)
1963 if (hugoTrans.scanUpdateRecords(GETNDB(step), 0, abort,
1964 parallelism) == NDBT_FAILED){
1975 int records = ctx->getNumRecords();
1978 while (ctx->isTestStopped() ==
false)
1980 if (hugoTrans.loadTable(GETNDB(step), records, 1) != 0){
1983 if (utilTrans.clearTable(GETNDB(step), records) != 0){
1998 if (restarter.getNumDbNodes() < 2){
2003 NdbSleep_SecSleep(10);
2005 int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
2007 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2008 if (restarter.dumpStateOneNode(nodeId, val2, 2))
2011 restarter.insertErrorInNode(nodeId, 13033);
2012 if (restarter.waitNodesNoStart(&nodeId, 1))
2015 if (restarter.startNodes(&nodeId, 1))
2018 if (restarter.waitClusterStarted())
2022 int records = ctx->getNumRecords();
2025 if(ctx->getPropertyWait(
"LastGCI_hi", ~(Uint32)0))
2027 g_err <<
"FAIL " << __LINE__ << endl;
2031 hugoTrans.clearTable(GETNDB(step), 0);
2033 if (hugoTrans.loadTable(GETNDB(step), 3*records, 1,
true, 1) != 0){
2034 g_err <<
"FAIL " << __LINE__ << endl;
2038 if (hugoTrans.pkDelRecords(GETNDB(step), 3*records, 1,
true, 1) != 0){
2039 g_err <<
"FAIL " << __LINE__ << endl;
2042 if (hugoTrans.loadTable(GETNDB(step), records, 1,
true, 1) != 0){
2043 g_err <<
"FAIL " << __LINE__ << endl;
2046 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
2047 g_err <<
"FAIL " << __LINE__ << endl;
2050 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
2051 g_err <<
"FAIL " << __LINE__ << endl;
2054 if (hugoTrans.pkUpdateRecords(GETNDB(step), records, 1, 1) != 0){
2055 g_err <<
"FAIL " << __LINE__ << endl;
2059 ctx->setProperty(
"LastGCI_lo", Uint32(hugoTrans.m_latest_gci));
2060 ctx->setProperty(
"LastGCI_hi", Uint32(hugoTrans.m_latest_gci >> 32));
2061 if(ctx->getPropertyWait(
"LastGCI_hi", ~(Uint32)0))
2063 g_err <<
"FAIL " << __LINE__ << endl;
2074 Ndb * ndb= GETNDB(step);
2077 int result= NDBT_OK;
2079 bool found_gap =
false;
2085 g_err <<
"Failed to createEventOperation" << endl;
2089 if (restarter.insertErrorInAllNodes(13036) != 0)
2091 result = NDBT_FAILED;
2099 g_err <<
"pollEvents failed: \n";
2107 while (!found_gap && (tmp= ndb->
nextEvent()))
2117 g_err <<
"buffer overflow not detected\n";
2118 result = NDBT_FAILED;
2125 g_err <<
"dropping event operation failed\n";
2126 result = NDBT_FAILED;
2135 Ndb * ndb= GETNDB(step);
2139 int result = NDBT_OK;
2141 bool connected =
true;
2145 g_err <<
"Failed to createEventOperation" << endl;
2149 if (restarter.insertErrorInAllNodes(13037) != 0)
2151 result = NDBT_FAILED;
2159 g_err <<
"pollEvents failed: \n";
2162 result = NDBT_FAILED;
2169 while (connected && (tmp= ndb->
nextEvent()))
2173 printf(
"Found stray NdbEventOperation\n");
2174 result = NDBT_FAILED;
2188 g_err <<
"failed to detect cluster disconnect\n";
2189 result = NDBT_FAILED;
2197 g_err <<
"dropping event operation failed\n";
2198 result = NDBT_FAILED;
2203 while (!connected && retries--)
2206 if (hugoTrans.loadTable(ndb, 100) == 0)
2213 NdbSleep_MilliSleep(300);
2214 result = NDBT_FAILED;
2219 g_err <<
"Failed to reconnect\n";
2222 if (restarter.restartAll(
false,
false,
true) != 0){
2230 if (restarter.waitClusterStarted(300) != 0){
2244 int loops = ctx->getNumLoops();
2248 if (restarter.getNumDbNodes() < 2){
2253 NdbSleep_SecSleep(10);
2255 while (loops-- && ctx->isTestStopped() ==
false)
2257 int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
2260 printf(
"nodeid: %u : victims: ", nodeId);
2261 for (
int i = 0; i<restarter.getNumDbNodes(); i++)
2263 int id = restarter.getDbNodeId(i);
2267 if (restarter.getNodeGroup(
id) == restarter.getNodeGroup(nodeId))
2269 nodes[nodecount++] =
id;
2271 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2272 if (restarter.dumpStateOneNode(
id, val2, 2))
2276 printf(
"\n"); fflush(stdout);
2278 restarter.insertErrorInNode(nodeId, 13034);
2279 if (restarter.waitNodesNoStart(nodes, nodecount))
2282 if (restarter.startNodes(nodes, nodecount))
2285 if (restarter.waitClusterStarted())
2299 if ((ret = xncc->
connect(30, 1, 0)) != 0)
2311 Ndb* xndb =
new Ndb(xncc,
"TEST_DB");
2312 if (xndb->
init() != 0)
2336 sprintf(buf,
"%s_EVENT", table->
getName());
2341 g_err <<
"Event operation creation failed on %s" << buf << endl;
2348 for (
int i = 0; i < n_columns; i++) {
2365 if (res.getNumDbNodes() < 2)
2373 if (cc(&xncc, &xndb))
2386 int api = xncc->node_id();
2387 int nodeId = res.getDbNodeId(rand() % res.getNumDbNodes());
2388 ndbout_c(
"stopping %u", nodeId);
2389 res.restartOneDbNode(nodeId,
false,
true,
true);
2394 ndbout_c(
"waiting for %u", nodeId);
2395 res.waitNodesNoStart(&nodeId, 1);
2400 res.dumpStateOneNode(nodeId, dump, 2);
2401 res.startNodes(&nodeId, 1);
2402 ndbout_c(
"waiting cluster");
2403 res.waitClusterStarted();
2407 g_err <<
"execute operation execution failed: \n";
2417 ndbout_c(
"stopping %u", nodeId);
2418 res.restartOneDbNode(nodeId,
false,
true,
true);
2423 ndbout_c(
"waiting for %u", nodeId);
2424 res.waitNodesNoStart(&nodeId, 1);
2428 res.dumpStateOneNode(nodeId, dump, 2);
2429 res.startNodes(&nodeId, 1);
2430 ndbout_c(
"waiting node sp 7");
2431 res.waitNodesStartPhase(&nodeId, 1, 6);
2436 NdbSleep_SecSleep(5);
2439 res.dumpStateOneNode(nodeId, dump, 1);
2441 res.waitClusterStarted();
2443 if (cc(&xncc, &xndb))
2448 pOp = op(xndb, ctx->getTab());
2458 g_err <<
"execute operation execution failed: \n";
2479 if (restarter.getNumDbNodes() < 2)
2486 6023, (int)NdbRestarter::NS_NON_MASTER,
2487 13013, (
int)NdbRestarter::NS_RANDOM,
2488 13019, (int)NdbRestarter::NS_RANDOM,
2501 int loops = ctx->getNumLoops();
2502 while (loops-- && !ctx->isTestStopped())
2505 while (codes[i] != 0)
2507 int code = codes[i++];
2508 int nodeId = restarter.getNode((NdbRestarter::NodeSelector)codes[i++]);
2509 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2510 if (restarter.dumpStateOneNode(nodeId, val2, 2))
2513 ndbout_c(
"Node %u error: %u", nodeId, code);
2514 if (restarter.insertErrorInNode(nodeId, code))
2517 if (restarter.waitNodesNoStart(&nodeId, 1))
2520 if (restarter.startNodes(&nodeId, 1))
2523 if (restarter.waitClusterStarted())
2527 int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
2528 if (restarter.restartOneDbNode(nodeId,
false,
true,
true) != 0)
2531 if (restarter.waitNodesNoStart(&nodeId, 1))
2535 while (nr_codes[i] != 0)
2537 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2538 if (restarter.dumpStateOneNode(nodeId, val2, 2))
2541 ndbout_c(
"Node %u error: %u", nodeId, nr_codes[i]);
2542 if (restarter.insertErrorInNode(nodeId, nr_codes[i]))
2545 if (restarter.startNodes(&nodeId, 1))
2548 NdbSleep_SecSleep(3);
2550 if (restarter.waitNodesNoStart(&nodeId, 1))
2556 ndbout_c(
"Done..now starting %u", nodeId);
2557 if (restarter.startNodes(&nodeId, 1))
2560 if (restarter.waitClusterStarted())
2596 #define UPDATE_COL 66
2601 Ndb* ndb= GETNDB(step);
2605 sprintf(buf,
"%s_EVENT", table->
getName());
2607 if ( pOp == NULL ) {
2608 g_err <<
"Event operation creation failed on %s" << buf << endl;
2612 int result = NDBT_OK;
2622 for (i = 0; i < n_columns; i++) {
2629 g_err <<
"execute operation execution failed: \n";
2630 g_err << pOp->getNdbError().code <<
" "
2631 << pOp->getNdbError().message << endl;
2635 hugoTrans.loadTable(GETNDB(step), ctx->getNumRecords());
2637 for (
int i = 0; i<ctx->getNumLoops(); i++)
2639 ndbout_c(
"testing %u updates", (i + 1));
2641 for (
int m = 0; m<(i+1); m++)
2643 for (
int r = 0; r<ctx->getNumRecords(); r++)
2648 hop.equalForRow(pOp, r);
2651 if (pTrans->
execute(NoCommit) != 0)
2657 if (pTrans->
execute(Commit) != 0)
2665 ndbout_c(
"set(LastGCI_hi): %u/%u",
2668 ctx->setProperty(
"LastGCI_lo", Uint32(gci));
2669 ctx->setProperty(
"LastGCI_hi", Uint32(gci >> 32));
2670 if(ctx->getPropertyWait(
"LastGCI_hi", ~(Uint32)0))
2672 g_err <<
"FAIL " << __LINE__ << endl;
2678 Uint64 curr_gci = 0;
2679 while(curr_gci <= gci)
2691 if (recAttr[c]->isNULL() >= 0)
2696 if (c != UPDATE_COL &&
2703 printf(
"Detect (incorrect) update value for: ");
2706 result = NDBT_FAILED;
2715 ndbout_c(
"found %u updates bugs: %u", cnt, bug);
2737 if (res.getNumDbNodes() < 2)
2743 if (runCreateEvent(ctx, step))
2748 Ndb* pNdb = GETNDB(step);
2761 Ndb* ndb =
new Ndb(&ctx->m_cluster_connection,
"TEST_DB");
2762 if (ndb->
init() != 0)
2765 ndbout_c(
"here: %u", __LINE__);
2772 ndbout_c(
"here: %u", __LINE__);
2780 int nodeId = res.getDbNodeId(rand() % res.getNumDbNodes());
2781 ndbout_c(
"stopping %u", nodeId);
2782 res.restartOneDbNode(nodeId,
false,
false,
true);
2786 if (res.waitClusterStarted())
2792 runDropEvent(ctx, step);
2801 if (res.getNumDbNodes() < 2)
2807 int nodeId = res.getDbNodeId(rand() % res.getNumDbNodes());
2809 Ndb* pNdb = GETNDB(step);
2813 const char * name =
"BugXXX";
2818 for (
int i = 0; i<ctx->getNumLoops(); i++)
2838 createEvent(ndb0, *copyptr, ctx);
2839 pOp0 = createEventOperation(ndb0, *copyptr);
2842 res.restartOneDbNode(nodeId,
false,
true,
true);
2847 res.waitNodesNoStart(&nodeId, 1);
2848 res.startNodes(&nodeId, 1);
2849 if (res.waitClusterStarted())
2867 if (res.getNumDbNodes() < 2)
2873 int nodeId = res.getDbNodeId(rand() % res.getNumDbNodes());
2875 Ndb* pNdb = GETNDB(step);
2879 if (runCreateEvent(ctx, step))
2884 for (
int i = 0; i<ctx->getNumLoops(); i++)
2888 res.restartOneDbNode(nodeId,
false,
true,
true);
2893 res.waitNodesNoStart(&nodeId, 1);
2895 GETNDB(step)->dropEventOperation(pOp);
2897 res.startNodes(&nodeId, 1);
2898 if (res.waitClusterStarted())
2904 runDropEvent(ctx, step);
2938 ndbout <<
"Table create failed, err : " <<
2945 enum OpTypes {Insert, Update, Write, Delete, EndOfOpTypes};
2954 executeOps(
Ndb* pNdb,
2959 Uint32 anyValueOffset,
2966 Uint32* keyPtr= (Uint32*) NdbDictionary::getValuePtr(record,
2969 Uint32* attrPtr= (Uint32*) NdbDictionary::getValuePtr(record,
2973 for (Uint32 i=keyOffset; i < (keyOffset + rowCount); i++)
2975 memcpy(keyPtr, &i,
sizeof(i));
2976 memcpy(attrPtr, &i,
sizeof(i));
2977 opts.optionsPresent |= NdbOperation::OperationOptions::OO_ANYVALUE;
2978 opts.anyValue= anyValueOffset +
i;
2979 bool allowInterpreted=
2983 if (!allowInterpreted)
2984 opts.optionsPresent &=
2985 ~ (Uint64) NdbOperation::OperationOptions::OO_INTERPRETED;
2989 if (trans->insertTuple(record,
2993 sizeof(opts)) == NULL)
2995 g_err <<
"Can't create operation : " <<
3001 if (trans->updateTuple(record,
3007 sizeof(opts)) == NULL)
3009 g_err <<
"Can't create operation : " <<
3015 if (trans->writeTuple(record,
3021 sizeof(opts)) == NULL)
3023 g_err <<
"Can't create operation : " <<
3029 if (trans->deleteTuple(record,
3035 sizeof(opts)) == NULL)
3037 g_err <<
"Can't create operation : " <<
3043 g_err <<
"Bad operation type : " << op << endl;
3052 g_err <<
"Error executing operations :" <<
3063 checkAnyValueInEvent(
Ndb* pNdb,
3069 Uint32 anyValueOffset,
3074 while (received < num)
3080 g_err <<
"Error while polling for events : " <<
3087 printf(
"No event, waiting...\n");
3092 while((event= pNdb->
nextEvent()) != NULL)
3105 Uint32 keyVal= (checkPre?
3110 (anyValueOffset + keyVal))
3112 g_err <<
"Error : Got event, key is " <<
3113 keyVal <<
" anyValue is " <<
3114 event->getAnyValue() <<
3115 " expected " << (anyValueOffset + keyVal)
3135 name.
assfmt(
"TAB_TESTEVENT%d", rand() & 65535);
3136 Ndb* pNdb= GETNDB(step);
3144 char eventName[1024];
3145 sprintf(eventName,
"%s_EVENT", tab->
getName());
3147 if (createEvent(pNdb, *tab,
false,
true) != 0)
3154 if (eventOp == NULL)
3156 g_err <<
"Failed to create event operation :" <<
3166 if ((eventKeyData == NULL) || (eventAttrData == NULL))
3168 g_err <<
"Failed to get NdbRecAttrs for events" << endl;
3174 g_err <<
"Failed to execute event operation :" <<
3184 opts.optionsPresent= 0;
3188 nonsenseProgram.load_const_u32(0, 0);
3189 nonsenseProgram.interpret_exit_ok();
3193 const Uint32 rowCount= 1500;
3194 Uint32 keyOffset= 0;
3195 Uint32 anyValueOffset= 100;
3197 printf (
"Testing AnyValue with no interpreted program\n");
3198 for (
int variants= 0; variants < 2; variants ++)
3200 for (
int op= Insert; op < EndOfOpTypes; op++)
3202 printf(
" Testing opType %d (ko=%d, ao=%d)...",
3203 op, keyOffset, anyValueOffset);
3205 if (executeOps(pNdb,
3214 if (checkAnyValueInEvent(pNdb,
3215 eventOldKeyData, eventKeyData,
3216 eventOldAttrData, eventAttrData,
3225 printf(
"Testing AnyValue with interpreted program\n");
3226 opts.optionsPresent|= NdbOperation::OperationOptions::OO_INTERPRETED;
3227 opts.interpretedCode= &nonsenseProgram;
3230 if (dropEventOperations(pNdb) != 0)
3232 g_err <<
"Dropping event operations failed : " <<
3237 if (dropEvent(pNdb, tab->
getName()) != 0)
3239 g_err <<
"Dropping event failed : " <<
3257 if (res.getNumDbNodes() < 2)
3263 const int cases = 4;
3264 int loops = ctx->getNumLoops();
3267 for (
int i = 0; i<loops; i++)
3269 int master = res.getMasterNodeId();
3270 int next = res.getNextMasterNodeId(master);
3272 res.insertErrorInNode(next, 8064);
3273 int val1[] = { 7213, 0 };
3274 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
3275 if (res.dumpStateOneNode(master, val2, 2))
3281 const char * off = NdbEnv_GetEnv(
"NDB_ERR", buf,
sizeof(buf));
3289 ndbout_c(
"stopping %u", master);
3290 res.restartOneDbNode(master,
false,
true,
true);
3296 ndbout_c(
"stopping %u, err 7213", master);
3299 res.dumpStateOneNode(next, val1, 2);
3302 ndbout_c(
"stopping %u, err 7214", master);
3305 res.dumpStateOneNode(next, val1, 2);
3308 ndbout_c(
"stopping %u, err 7007", master);
3309 res.insertErrorInNode(master, 7007);
3312 ndbout_c(
"waiting for %u", master);
3313 res.waitNodesNoStart(&master, 1);
3314 ndbout_c(
"starting %u", master);
3315 res.startNodes(&master, 1);
3316 ndbout_c(
"waiting for cluster started");
3317 if (res.waitClusterStarted())
3330 int result = NDBT_OK;
3333 int error[] = { 13031, 13044, 13045, 0 };
3334 for (
int i = 0; error[
i] && result == NDBT_OK; i++)
3336 ndbout_c(
"error: %d", error[i]);
3337 res.insertErrorInNode(res.getDbNodeId(rand() % res.getNumDbNodes()),
3340 result = runCreateEvent(ctx, step);
3341 result = runCreateEvent(ctx, step);
3342 result = runDropEvent(ctx, step);
3350 int result = NDBT_OK;
3353 Ndb* pNdb = GETNDB(step);
3355 int error_all[] = { 13046, 0 };
3356 for (
int i = 0; error_all[
i] && result == NDBT_OK; i++)
3358 ndbout_c(
"error: %d", error_all[i]);
3359 res.insertErrorInAllNodes(error_all[i]);
3361 if (createEventOperation(pNdb, *ctx->getTab()) != 0)
3373 int loops = ctx->getNumLoops();
3374 Ndb* pNdb = GETNDB(step);
3408 if (cc(&pCC, &pNdb))
3414 while (!ctx->isTestStopped())
3416 createEvent(pNdb, tab,
false,
false);
3423 dropEvent(pNdb, tab);
3431 NDBT_TESTSUITE(test_event);
3432 TESTCASE(
"BasicEventOperation",
3433 "Verify that we can listen to Events"
3434 "NOTE! No errors are allowed!" )
3443 INITIALIZER(runCreateEvent);
3444 STEP(runEventOperation);
3446 FINALIZER(runDropEvent);
3448 TESTCASE(
"CreateDropEventOperation",
3449 "Verify that we can Create and Drop many times"
3450 "NOTE! No errors are allowed!" ){
3451 INITIALIZER(runCreateEvent);
3452 STEP(runCreateDropEventOperation);
3453 FINALIZER(runDropEvent);
3455 TESTCASE(
"ParallellEventOperation",
3456 "Verify that we can listen to Events in parallell"
3457 "NOTE! No errors are allowed!" ){
3458 INITIALIZER(runCreateEvent);
3459 STEP(runEventOperation);
3460 STEP(runEventOperation);
3462 FINALIZER(runDropEvent);
3464 TESTCASE(
"EventOperationApplier",
3465 "Verify that if we apply the data we get from event "
3466 "operation is the same as the original table"
3467 "NOTE! No errors are allowed!" ){
3468 INITIALIZER(runCreateEvent);
3469 INITIALIZER(runCreateShadowTable);
3470 STEP(runEventApplier);
3471 STEP(runEventMixedLoad);
3472 FINALIZER(runDropEvent);
3473 FINALIZER(runVerify);
3474 FINALIZER(runDropShadowTable);
3476 TESTCASE(
"EventOperationApplier_NR",
3477 "Verify that if we apply the data we get from event "
3478 "operation is the same as the original table"
3479 "NOTE! No errors are allowed!" ){
3480 INITIALIZER(runCreateEvent);
3481 INITIALIZER(runCreateShadowTable);
3482 STEP(runEventApplier);
3483 STEP(runEventMixedLoad);
3485 FINALIZER(runDropEvent);
3486 FINALIZER(runVerify);
3487 FINALIZER(runDropShadowTable);
3489 TESTCASE(
"EventOperationApplier_NS",
3490 "Verify that if we apply the data we get from event "
3491 "operation is the same as the original table"
3492 "NOTE! No errors are allowed!" ){
3493 TC_PROPERTY(
"Graceful", 1);
3494 INITIALIZER(runCreateEvent);
3495 INITIALIZER(runCreateShadowTable);
3496 STEP(runEventApplier);
3497 STEP(runEventMixedLoad);
3499 FINALIZER(runDropEvent);
3500 FINALIZER(runVerify);
3501 FINALIZER(runDropShadowTable);
3503 TESTCASE(
"MergeEventOperationApplier",
3504 "Verify that if we apply the data we get from merged event "
3505 "operation is the same as the original table"
3506 "NOTE! No errors are allowed!" ){
3507 TC_PROPERTY(
"MergeEvents", 1);
3508 INITIALIZER(runCreateEvent);
3509 INITIALIZER(runCreateShadowTable);
3510 STEP(runEventApplier);
3511 STEP(runEventMixedLoad);
3512 FINALIZER(runDropEvent);
3513 FINALIZER(runVerify);
3514 FINALIZER(runDropShadowTable);
3516 TESTCASE(
"MergeEventOperationApplier_NR",
3517 "Verify that if we apply the data we get from merged event "
3518 "operation is the same as the original table"
3519 "NOTE! No errors are allowed!" ){
3520 TC_PROPERTY(
"MergeEvents", 1);
3521 INITIALIZER(runCreateEvent);
3522 INITIALIZER(runCreateShadowTable);
3523 STEP(runEventApplier);
3524 STEP(runEventMixedLoad);
3526 FINALIZER(runDropEvent);
3527 FINALIZER(runVerify);
3528 FINALIZER(runDropShadowTable);
3531 "Verify that we can work with all tables in parallell"
3532 "NOTE! HugoOperations::startTransaction, pTrans != NULL errors, "
3535 INITIALIZER(getAllTables);
3536 INITIALIZER(createAllEvents);
3537 INITIALIZER(createAllShadows);
3539 FINALIZER(dropAllShadows);
3540 FINALIZER(dropAllEvents);
3542 TESTCASE(
"Multi_NR",
3543 "Verify that we can work with all tables in parallell"
3544 "NOTE! HugoOperations::startTransaction, pTrans != NULL errors, "
3547 INITIALIZER(getAllTables);
3548 INITIALIZER(createAllEvents);
3549 INITIALIZER(createAllShadows);
3551 FINALIZER(dropAllShadows);
3552 FINALIZER(dropAllEvents);
3554 TESTCASE(
"CreateDropNR",
3555 "Verify that we can Create and Drop in any order"
3556 "NOTE! No errors are allowed!" ){
3557 FINALIZER(runCreateDropNR);
3559 TESTCASE(
"SubscribeUnsubscribe",
3560 "A bunch of threads doing subscribe/unsubscribe in loop"
3561 "NOTE! No errors are allowed!" ){
3562 INITIALIZER(runCreateEvent);
3563 STEPS(runSubscribeUnsubscribe, 16);
3564 FINALIZER(runDropEvent);
3566 TESTCASE(
"Bug27169",
""){
3567 INITIALIZER(runCreateEvent);
3568 STEP(runEventListenerUntilStopped);
3569 STEP(runInsertDeleteUntilStopped);
3570 STEP(runScanUpdateUntilStopped);
3571 STEP(runRestarterLoop);
3572 FINALIZER(runDropEvent);
3574 TESTCASE(
"Bug31701",
""){
3575 INITIALIZER(runCreateEvent);
3576 INITIALIZER(runCreateShadowTable);
3577 STEP(runEventApplier);
3579 FINALIZER(runDropEvent);
3580 FINALIZER(runDropShadowTable);
3582 TESTCASE(
"SubscribeNR",
""){
3583 TC_PROPERTY(
"ReportSubscribe", 1);
3584 TC_PROPERTY(
"SubscribeUntilStopped", 1);
3585 INITIALIZER(runCreateEvent);
3586 STEPS(runSubscribeUnsubscribe, 5);
3587 STEP(runNFSubscribe);
3588 FINALIZER(runDropEvent);
3590 TESTCASE(
"EventBufferOverflow",
3591 "Simulating EventBuffer overflow while node restart"
3592 "NOTE! No errors are allowed!" ){
3593 INITIALIZER(runCreateEvent);
3594 STEP(errorInjectBufferOverflow);
3595 FINALIZER(runDropEvent);
3597 TESTCASE(
"StallingSubscriber",
3598 "Simulating slow subscriber that will become disconnected"
3599 "NOTE! No errors are allowed!" ){
3600 INITIALIZER(runCreateEvent);
3601 STEP(errorInjectStalling);
3603 TESTCASE(
"Bug33793",
""){
3604 INITIALIZER(runCreateEvent);
3605 STEP(runEventListenerUntilStopped);
3607 FINALIZER(runDropEvent);
3609 TESTCASE(
"Bug34853",
""){
3610 INITIALIZER(runCreateEvent);
3611 INITIALIZER(runBug34853);
3612 FINALIZER(runDropEvent);
3614 TESTCASE(
"Bug35208",
""){
3615 INITIALIZER(runBug35208_createTable);
3616 INITIALIZER(runCreateEvent);
3617 INITIALIZER(runCreateShadowTable);
3619 STEP(runEventApplier);
3620 FINALIZER(runDropEvent);
3621 FINALIZER(runVerify);
3622 FINALIZER(runDropShadowTable);
3624 TESTCASE(
"Bug37279",
"")
3626 INITIALIZER(runBug37279);
3628 TESTCASE(
"Bug37338",
"")
3630 INITIALIZER(runBug37338);
3632 TESTCASE(
"Bug37442",
"")
3634 INITIALIZER(runBug37442);
3636 TESTCASE(
"Bug37672",
"NdbRecord option OO_ANYVALUE causes interpreted delete to abort.")
3638 INITIALIZER(runBug37672);
3640 TESTCASE(
"Bug30780",
"")
3642 INITIALIZER(runCreateEvent);
3643 INITIALIZER(runLoadTable);
3644 STEP(runEventConsumer);
3645 STEPS(runScanUpdateUntilStopped, 3);
3647 FINALIZER(runDropEvent);
3649 TESTCASE(
"Bug44915",
"")
3651 INITIALIZER(runBug44915);
3653 TESTCASE(
"Bug56579",
"")
3655 INITIALIZER(runCreateEvent);
3657 FINALIZER(runDropEvent);
3659 TESTCASE(
"Bug57886",
"")
3661 STEP(runBug57886_create_drop);
3662 STEPS(runBug57886_subscribe_unsunscribe, 5);
3664 NDBT_TESTSUITE_END(test_event);
3666 int main(
int argc,
const char** argv){
3668 NDBT_TESTSUITE_INSTANCE(test_event);
3669 test_event.setCreateAllTables(
true);
3670 return test_event.execute(argc, argv);