1 /* Copyright (c) 2003-2008 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
17 #include <NDBT_Test.hpp>
18 #include <HugoTransactions.hpp>
19 #include <UtilTransactions.hpp>
20 #include <NdbRestarter.hpp>
21 #include <NdbRestarts.hpp>
23 #include <signaldata/DumpStateOrd.hpp>
24 #include <Bitmask.hpp>
25 #include <RefConvert.hpp>
28 int runLoadTable(NDBT_Context
* ctx
, NDBT_Step
* step
){
30 int records
= ctx
->getNumRecords();
31 HugoTransactions
hugoTrans(*ctx
->getTab());
32 if (hugoTrans
.loadTable(GETNDB(step
), records
) != 0){
38 int runFillTable(NDBT_Context
* ctx
, NDBT_Step
* step
){
40 HugoTransactions
hugoTrans(*ctx
->getTab());
41 if (hugoTrans
.fillTable(GETNDB(step
)) != 0){
47 int runInsertUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
49 int records
= ctx
->getNumRecords();
51 HugoTransactions
hugoTrans(*ctx
->getTab());
52 while (ctx
->isTestStopped() == false) {
54 if (hugoTrans
.loadTable(GETNDB(step
), records
) != 0){
62 int runClearTable(NDBT_Context
* ctx
, NDBT_Step
* step
){
63 int records
= ctx
->getNumRecords();
65 UtilTransactions
utilTrans(*ctx
->getTab());
66 if (utilTrans
.clearTable(GETNDB(step
), records
) != 0){
72 int runClearTableUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
73 int records
= ctx
->getNumRecords();
76 UtilTransactions
utilTrans(*ctx
->getTab());
77 while (ctx
->isTestStopped() == false) {
79 if (utilTrans
.clearTable(GETNDB(step
), records
) != 0){
87 int runScanReadUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
89 int records
= ctx
->getNumRecords();
91 HugoTransactions
hugoTrans(*ctx
->getTab());
92 while (ctx
->isTestStopped() == false) {
94 if (hugoTrans
.scanReadRecords(GETNDB(step
), records
) != 0){
102 int runPkReadUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
103 int result
= NDBT_OK
;
104 int records
= ctx
->getNumRecords();
105 NdbOperation::LockMode lm
=
106 (NdbOperation::LockMode
)ctx
->getProperty("ReadLockMode",
107 (Uint32
)NdbOperation::LM_Read
);
109 HugoTransactions
hugoTrans(*ctx
->getTab());
110 while (ctx
->isTestStopped() == false) {
112 int rows
= (rand()%records
)+1;
113 int batch
= (rand()%rows
)+1;
114 if (hugoTrans
.pkReadRecords(GETNDB(step
), rows
, batch
, lm
) != 0){
122 int runPkUpdateUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
123 int result
= NDBT_OK
;
124 int records
= ctx
->getNumRecords();
125 int multiop
= ctx
->getProperty("MULTI_OP", 1);
126 Ndb
* pNdb
= GETNDB(step
);
129 HugoOperations
hugoOps(*ctx
->getTab());
130 while (ctx
->isTestStopped() == false)
133 int batch
= (rand()%records
)+1;
134 int row
= rand() % records
;
139 if(row
+ batch
> records
)
140 batch
= records
- row
;
142 if(hugoOps
.startTransaction(pNdb
) != 0)
145 if(hugoOps
.pkUpdateRecord(pNdb
, row
, batch
, rand()) != 0)
148 for (int j
= 1; j
<multiop
; j
++)
150 if(hugoOps
.execute_NoCommit(pNdb
) != 0)
153 if(hugoOps
.pkUpdateRecord(pNdb
, row
, batch
, rand()) != 0)
157 if(hugoOps
.execute_Commit(pNdb
) != 0)
160 hugoOps
.closeTransaction(pNdb
);
165 NdbConnection
* pCon
= hugoOps
.getTransaction();
168 NdbError error
= pCon
->getNdbError();
169 hugoOps
.closeTransaction(pNdb
);
170 if (error
.status
== NdbError::TemporaryError
){
171 NdbSleep_MilliSleep(50);
181 int runPkReadPkUpdateUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
182 int result
= NDBT_OK
;
183 int records
= ctx
->getNumRecords();
184 Ndb
* pNdb
= GETNDB(step
);
186 HugoOperations
hugoOps(*ctx
->getTab());
187 while (ctx
->isTestStopped() == false) {
188 g_info
<< i
++ << ": ";
189 int rows
= (rand()%records
)+1;
190 int batch
= (rand()%rows
)+1;
191 int row
= (records
- rows
) ? rand() % (records
- rows
) : 0;
194 for(j
= 0; j
<rows
; j
+= batch
)
200 if(hugoOps
.startTransaction(pNdb
) != 0)
203 if(hugoOps
.pkReadRecord(pNdb
, row
+j
, k
, NdbOperation::LM_Exclusive
) != 0)
206 if(hugoOps
.execute_NoCommit(pNdb
) != 0)
209 if(hugoOps
.pkUpdateRecord(pNdb
, row
+j
, k
, rand()) != 0)
212 if(hugoOps
.execute_Commit(pNdb
) != 0)
215 if(hugoOps
.closeTransaction(pNdb
) != 0)
221 NdbConnection
* pCon
= hugoOps
.getTransaction();
224 NdbError error
= pCon
->getNdbError();
225 hugoOps
.closeTransaction(pNdb
);
226 if (error
.status
== NdbError::TemporaryError
){
227 NdbSleep_MilliSleep(50);
235 int runScanUpdateUntilStopped(NDBT_Context
* ctx
, NDBT_Step
* step
){
236 int result
= NDBT_OK
;
237 int records
= ctx
->getNumRecords();
238 int parallelism
= ctx
->getProperty("Parallelism", 1);
239 int abort
= ctx
->getProperty("AbortProb", (Uint32
)0);
241 HugoTransactions
hugoTrans(*ctx
->getTab());
242 while (ctx
->isTestStopped() == false) {
244 if (hugoTrans
.scanUpdateRecords(GETNDB(step
), records
, abort
,
245 parallelism
) == NDBT_FAILED
){
253 int runScanReadVerify(NDBT_Context
* ctx
, NDBT_Step
* step
){
254 int records
= ctx
->getNumRecords();
255 HugoTransactions
hugoTrans(*ctx
->getTab());
257 if (hugoTrans
.scanReadRecords(GETNDB(step
), records
, 0, 64) != 0){
263 int runRestarter(NDBT_Context
* ctx
, NDBT_Step
* step
){
264 int result
= NDBT_OK
;
265 int loops
= ctx
->getNumLoops();
266 int sync_threads
= ctx
->getProperty("SyncThreads", (unsigned)0);
267 NdbRestarter restarter
;
271 if (restarter
.getNumDbNodes() < 2){
276 if(restarter
.waitClusterStarted() != 0){
277 g_err
<< "Cluster failed to start" << endl
;
281 loops
*= restarter
.getNumDbNodes();
282 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped()){
284 int id
= lastId
% restarter
.getNumDbNodes();
285 int nodeId
= restarter
.getDbNodeId(id
);
286 ndbout
<< "Restart node " << nodeId
<< endl
;
287 if(restarter
.restartOneDbNode(nodeId
, false, true, true) != 0){
288 g_err
<< "Failed to restartNextDbNode" << endl
;
289 result
= NDBT_FAILED
;
293 if (restarter
.waitNodesNoStart(&nodeId
, 1))
295 g_err
<< "Failed to waitNodesNoStart" << endl
;
296 result
= NDBT_FAILED
;
300 if (restarter
.startNodes(&nodeId
, 1))
302 g_err
<< "Failed to start node" << endl
;
303 result
= NDBT_FAILED
;
307 if(restarter
.waitClusterStarted() != 0){
308 g_err
<< "Cluster failed to start" << endl
;
309 result
= NDBT_FAILED
;
313 ctx
->sync_up_and_wait("PauseThreads", sync_threads
);
324 int runCheckAllNodesStarted(NDBT_Context
* ctx
, NDBT_Step
* step
){
325 NdbRestarter restarter
;
327 if(restarter
.waitClusterStarted(1) != 0){
328 g_err
<< "All nodes was not started " << endl
;
337 int runRestarts(NDBT_Context
* ctx
, NDBT_Step
* step
){
338 int result
= NDBT_OK
;
339 int loops
= ctx
->getNumLoops();
340 NDBT_TestCase
* pCase
= ctx
->getCase();
341 NdbRestarts restarts
;
345 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped()){
347 if(restarts
.executeRestart(pCase
->getName(), timeout
) != 0){
348 g_err
<< "Failed to executeRestart(" <<pCase
->getName() <<")" << endl
;
349 result
= NDBT_FAILED
;
358 int runDirtyRead(NDBT_Context
* ctx
, NDBT_Step
* step
){
359 int result
= NDBT_OK
;
360 int loops
= ctx
->getNumLoops();
361 int records
= ctx
->getNumRecords();
362 NdbRestarter restarter
;
363 HugoOperations
hugoOps(*ctx
->getTab());
364 Ndb
* pNdb
= GETNDB(step
);
367 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped()){
370 int id
= i
% restarter
.getNumDbNodes();
371 int nodeId
= restarter
.getDbNodeId(id
);
372 ndbout
<< "Restart node " << nodeId
<< endl
;
373 restarter
.insertErrorInNode(nodeId
, 5041);
374 restarter
.insertErrorInAllNodes(8048 + (i
& 1));
376 for(int j
= 0; j
<records
; j
++){
377 if(hugoOps
.startTransaction(pNdb
) != 0)
380 if(hugoOps
.pkReadRecord(pNdb
, j
, 1, NdbOperation::LM_CommittedRead
) != 0)
384 if((res
= hugoOps
.execute_Commit(pNdb
)) == 4119)
390 if(hugoOps
.closeTransaction(pNdb
) != 0)
394 if(hugoOps
.closeTransaction(pNdb
) != 0)
398 restarter
.waitClusterStarted(60) ;
402 hugoOps
.closeTransaction(pNdb
);
406 int runLateCommit(NDBT_Context
* ctx
, NDBT_Step
* step
){
407 int result
= NDBT_OK
;
408 int loops
= ctx
->getNumLoops();
409 int records
= ctx
->getNumRecords();
410 NdbRestarter restarter
;
411 HugoOperations
hugoOps(*ctx
->getTab());
412 Ndb
* pNdb
= GETNDB(step
);
415 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped()){
418 if(hugoOps
.startTransaction(pNdb
) != 0)
421 if(hugoOps
.pkUpdateRecord(pNdb
, 1, 128) != 0)
424 if(hugoOps
.execute_NoCommit(pNdb
) != 0)
427 Uint32 transNode
= hugoOps
.getTransaction()->getConnectedNodeId();
428 int id
= i
% restarter
.getNumDbNodes();
430 while((nodeId
= restarter
.getDbNodeId(id
)) == transNode
)
431 id
= (id
+ 1) % restarter
.getNumDbNodes();
433 ndbout
<< "Restart node " << nodeId
<< endl
;
435 restarter
.restartOneDbNode(nodeId
,
436 /** initial */ false,
440 restarter
.waitNodesNoStart(&nodeId
, 1);
444 res
= hugoOps
.execute_Commit(pNdb
);
446 res
= hugoOps
.execute_Rollback(pNdb
);
448 ndbout_c("res= %d", res
);
450 hugoOps
.closeTransaction(pNdb
);
452 restarter
.startNodes(&nodeId
, 1);
453 restarter
.waitNodesStarted(&nodeId
, 1);
471 int runBug15587(NDBT_Context
* ctx
, NDBT_Step
* step
){
472 int result
= NDBT_OK
;
473 int loops
= ctx
->getNumLoops();
474 int records
= ctx
->getNumRecords();
475 NdbRestarter restarter
;
477 Uint32 tableId
= ctx
->getTab()->getTableId();
478 int dump
[2] = { DumpStateOrd::LqhErrorInsert5042
, 0 };
481 int nodeId
= restarter
.getDbNodeId(1);
483 ndbout
<< "Restart node " << nodeId
<< endl
;
485 if (restarter
.restartOneDbNode(nodeId
,
486 /** initial */ false,
491 if (restarter
.waitNodesNoStart(&nodeId
, 1))
494 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
496 if (restarter
.dumpStateOneNode(nodeId
, val2
, 2))
499 if (restarter
.dumpStateOneNode(nodeId
, dump
, 2))
502 if (restarter
.startNodes(&nodeId
, 1))
505 restarter
.waitNodesStartPhase(&nodeId
, 1, 3);
507 if (restarter
.waitNodesNoStart(&nodeId
, 1))
510 if (restarter
.dumpStateOneNode(nodeId
, val2
, 1))
513 if (restarter
.startNodes(&nodeId
, 1))
516 if (restarter
.waitNodesStarted(&nodeId
, 1))
523 int runBug15632(NDBT_Context
* ctx
, NDBT_Step
* step
){
524 int result
= NDBT_OK
;
525 int loops
= ctx
->getNumLoops();
526 int records
= ctx
->getNumRecords();
527 NdbRestarter restarter
;
529 int nodeId
= restarter
.getDbNodeId(1);
531 ndbout
<< "Restart node " << nodeId
<< endl
;
533 if (restarter
.restartOneDbNode(nodeId
,
534 /** initial */ false,
539 if (restarter
.waitNodesNoStart(&nodeId
, 1))
542 if (restarter
.insertErrorInNode(nodeId
, 7165))
545 if (restarter
.startNodes(&nodeId
, 1))
548 if (restarter
.waitNodesStarted(&nodeId
, 1))
551 if (restarter
.restartOneDbNode(nodeId
,
552 /** initial */ false,
557 if (restarter
.waitNodesNoStart(&nodeId
, 1))
560 if (restarter
.insertErrorInNode(nodeId
, 7171))
563 if (restarter
.startNodes(&nodeId
, 1))
566 if (restarter
.waitNodesStarted(&nodeId
, 1))
573 int runBug15685(NDBT_Context
* ctx
, NDBT_Step
* step
){
575 Ndb
* pNdb
= GETNDB(step
);
576 HugoOperations
hugoOps(*ctx
->getTab());
577 NdbRestarter restarter
;
579 HugoTransactions
hugoTrans(*ctx
->getTab());
580 if (hugoTrans
.loadTable(GETNDB(step
), 10) != 0){
584 if(hugoOps
.startTransaction(pNdb
) != 0)
587 if(hugoOps
.pkUpdateRecord(pNdb
, 0, 1, rand()) != 0)
590 if(hugoOps
.execute_NoCommit(pNdb
) != 0)
593 if (restarter
.insertErrorInAllNodes(5100))
596 hugoOps
.execute_Rollback(pNdb
);
598 if (restarter
.waitClusterStarted() != 0)
601 if (restarter
.insertErrorInAllNodes(0))
613 runBug16772(NDBT_Context
* ctx
, NDBT_Step
* step
){
615 NdbRestarter restarter
;
616 if (restarter
.getNumDbNodes() < 2)
622 int aliveNodeId
= restarter
.getRandomNotMasterNodeId(rand());
623 int deadNodeId
= aliveNodeId
;
624 while (deadNodeId
== aliveNodeId
)
625 deadNodeId
= restarter
.getDbNodeId(rand() % restarter
.getNumDbNodes());
627 if (restarter
.insertErrorInNode(aliveNodeId
, 930))
630 if (restarter
.restartOneDbNode(deadNodeId
,
631 /** initial */ false,
636 if (restarter
.waitNodesNoStart(&deadNodeId
, 1))
639 if (restarter
.startNodes(&deadNodeId
, 1))
642 // It should now be hanging since we throw away NDB_FAILCONF
643 int ret
= restarter
.waitNodesStartPhase(&deadNodeId
, 1, 3, 10);
644 // So this should fail...i.e it should not reach startphase 3
646 // Now send a NDB_FAILCONF for deadNo
647 int dump
[] = { 7020, 323, 252, 0 };
648 dump
[3] = deadNodeId
;
649 if (restarter
.dumpStateOneNode(aliveNodeId
, dump
, 4))
652 if (restarter
.waitNodesStarted(&deadNodeId
, 1))
655 return ret
? NDBT_OK
: NDBT_FAILED
;
659 runBug18414(NDBT_Context
* ctx
, NDBT_Step
* step
){
661 NdbRestarter restarter
;
662 if (restarter
.getNumDbNodes() < 2)
668 Ndb
* pNdb
= GETNDB(step
);
669 HugoOperations
hugoOps(*ctx
->getTab());
670 HugoTransactions
hugoTrans(*ctx
->getTab());
674 if(hugoOps
.startTransaction(pNdb
) != 0)
677 if(hugoOps
.pkUpdateRecord(pNdb
, 0, 128, rand()) != 0)
680 if(hugoOps
.execute_NoCommit(pNdb
) != 0)
683 int node1
= hugoOps
.getTransaction()->getConnectedNodeId();
684 int node2
= restarter
.getRandomNodeSameNodeGroup(node1
, rand());
686 if (node1
== -1 || node2
== -1)
691 if (restarter
.insertErrorInNode(node1
, 8050))
695 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
696 if (restarter
.dumpStateOneNode(node2
, val2
, 2))
699 if (restarter
.insertErrorInNode(node2
, 5003))
702 int res
= hugoOps
.execute_Rollback(pNdb
);
704 if (restarter
.waitNodesNoStart(&node2
, 1) != 0)
707 if (restarter
.insertErrorInAllNodes(0))
710 if (restarter
.startNodes(&node2
, 1) != 0)
713 if (restarter
.waitClusterStarted() != 0)
716 if (hugoTrans
.scanUpdateRecords(pNdb
, 128) != 0)
719 hugoOps
.closeTransaction(pNdb
);
726 hugoOps
.closeTransaction(pNdb
);
731 runBug18612(NDBT_Context
* ctx
, NDBT_Step
* step
){
733 // Assume two replicas
734 NdbRestarter restarter
;
735 if (restarter
.getNumDbNodes() < 2)
741 Uint32 cnt
= restarter
.getNumDbNodes();
743 for(int loop
= 0; loop
< ctx
->getNumLoops(); loop
++)
747 bzero(partition0
, sizeof(partition0
));
748 bzero(partition1
, sizeof(partition1
));
749 Bitmask
<4> nodesmask
;
751 Uint32 node1
= restarter
.getDbNodeId(rand()%cnt
);
752 for (Uint32 i
= 0; i
<cnt
/2; i
++)
755 int tmp
= restarter
.getRandomNodeOtherNodeGroup(node1
, rand());
762 } while(nodesmask
.get(node1
));
764 partition0
[i
] = node1
;
765 partition1
[i
] = restarter
.getRandomNodeSameNodeGroup(node1
, rand());
767 ndbout_c("nodes %d %d", node1
, partition1
[i
]);
769 assert(!nodesmask
.get(node1
));
770 assert(!nodesmask
.get(partition1
[i
]));
771 nodesmask
.set(node1
);
772 nodesmask
.set(partition1
[i
]);
778 dump
[0] = DumpStateOrd::NdbcntrStopNodes
;
779 memcpy(dump
+ 1, partition0
, sizeof(int)*cnt
/2);
781 Uint32 master
= restarter
.getMasterNodeId();
783 if (restarter
.dumpStateOneNode(master
, dump
, 1+cnt
/2))
786 if (restarter
.waitNodesNoStart(partition0
, cnt
/2))
789 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
791 if (restarter
.dumpStateAllNodes(val2
, 2))
794 if (restarter
.insertErrorInAllNodes(932))
798 memcpy(dump
+ 1, partition0
, sizeof(int)*cnt
/2);
799 for (Uint32 i
= 0; i
<cnt
/2; i
++)
800 if (restarter
.dumpStateOneNode(partition1
[i
], dump
, 1+cnt
/2))
804 memcpy(dump
+ 1, partition1
, sizeof(int)*cnt
/2);
805 for (Uint32 i
= 0; i
<cnt
/2; i
++)
806 if (restarter
.dumpStateOneNode(partition0
[i
], dump
, 1+cnt
/2))
809 if (restarter
.startNodes(partition0
, cnt
/2))
812 if (restarter
.waitNodesStartPhase(partition0
, cnt
/2, 2))
816 for (Uint32 i
= 0; i
<cnt
/2; i
++)
817 if (restarter
.dumpStateAllNodes(dump
, 2))
820 if (restarter
.waitNodesNoStart(partition0
, cnt
/2))
823 for (Uint32 i
= 0; i
<cnt
/2; i
++)
824 if (restarter
.restartOneDbNode(partition0
[i
], true, true, true))
827 if (restarter
.waitNodesNoStart(partition0
, cnt
/2))
830 if (restarter
.startAll())
833 if (restarter
.waitClusterStarted())
840 runBug18612SR(NDBT_Context
* ctx
, NDBT_Step
* step
){
842 // Assume two replicas
843 NdbRestarter restarter
;
844 if (restarter
.getNumDbNodes() < 2)
850 Uint32 cnt
= restarter
.getNumDbNodes();
852 for(int loop
= 0; loop
< ctx
->getNumLoops(); loop
++)
856 bzero(partition0
, sizeof(partition0
));
857 bzero(partition1
, sizeof(partition1
));
858 Bitmask
<4> nodesmask
;
860 Uint32 node1
= restarter
.getDbNodeId(rand()%cnt
);
861 for (Uint32 i
= 0; i
<cnt
/2; i
++)
864 int tmp
= restarter
.getRandomNodeOtherNodeGroup(node1
, rand());
868 } while(nodesmask
.get(node1
));
870 partition0
[i
] = node1
;
871 partition1
[i
] = restarter
.getRandomNodeSameNodeGroup(node1
, rand());
873 ndbout_c("nodes %d %d", node1
, partition1
[i
]);
875 assert(!nodesmask
.get(node1
));
876 assert(!nodesmask
.get(partition1
[i
]));
877 nodesmask
.set(node1
);
878 nodesmask
.set(partition1
[i
]);
883 if (restarter
.restartAll(false, true, false))
888 memcpy(dump
+ 1, partition0
, sizeof(int)*cnt
/2);
889 for (Uint32 i
= 0; i
<cnt
/2; i
++)
890 if (restarter
.dumpStateOneNode(partition1
[i
], dump
, 1+cnt
/2))
894 memcpy(dump
+ 1, partition1
, sizeof(int)*cnt
/2);
895 for (Uint32 i
= 0; i
<cnt
/2; i
++)
896 if (restarter
.dumpStateOneNode(partition0
[i
], dump
, 1+cnt
/2))
899 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
901 if (restarter
.dumpStateAllNodes(val2
, 2))
904 if (restarter
.insertErrorInAllNodes(932))
907 if (restarter
.startAll())
910 if (restarter
.waitClusterStartPhase(2))
914 for (Uint32 i
= 0; i
<cnt
/2; i
++)
915 if (restarter
.dumpStateAllNodes(dump
, 2))
918 if (restarter
.waitClusterNoStart(30))
919 if (restarter
.waitNodesNoStart(partition0
, cnt
/2, 10))
920 if (restarter
.waitNodesNoStart(partition1
, cnt
/2, 10))
923 if (restarter
.startAll())
926 if (restarter
.waitClusterStarted())
932 int runBug20185(NDBT_Context
* ctx
, NDBT_Step
* step
){
933 int result
= NDBT_OK
;
934 int loops
= ctx
->getNumLoops();
935 int records
= ctx
->getNumRecords();
936 NdbRestarter restarter
;
937 HugoOperations
hugoOps(*ctx
->getTab());
938 Ndb
* pNdb
= GETNDB(step
);
940 const int masterNode
= restarter
.getMasterNodeId();
942 int dump
[] = { 7090, 20 } ;
943 if (restarter
.dumpStateAllNodes(dump
, 2))
946 NdbSleep_MilliSleep(3000);
948 for (Uint32 i
= 0; i
<restarter
.getNumDbNodes(); i
++)
949 nodes
.push_back(restarter
.getDbNodeId(i
));
952 if(hugoOps
.startTransaction(pNdb
) != 0)
955 if(hugoOps
.pkUpdateRecord(pNdb
, 1, 1) != 0)
958 if (hugoOps
.execute_NoCommit(pNdb
) != 0)
961 const int node
= hugoOps
.getTransaction()->getConnectedNodeId();
962 if (node
!= masterNode
)
964 hugoOps
.closeTransaction(pNdb
);
970 nodeId
= restarter
.getDbNodeId(rand() % restarter
.getNumDbNodes());
971 } while (nodeId
== node
);
973 ndbout_c("7031 to %d", nodeId
);
974 if (restarter
.insertErrorInNode(nodeId
, 7031))
977 for (Uint32 i
= 0; i
<nodes
.size(); i
++)
979 if (nodes
[i
] != nodeId
)
980 if (restarter
.insertErrorInNode(nodes
[i
], 7030))
984 NdbSleep_MilliSleep(500);
986 if (hugoOps
.execute_Commit(pNdb
) == 0)
989 NdbSleep_MilliSleep(3000);
991 restarter
.waitClusterStarted();
993 if (restarter
.dumpStateAllNodes(dump
, 1))
999 int runBug24717(NDBT_Context
* ctx
, NDBT_Step
* step
){
1000 int result
= NDBT_OK
;
1001 int loops
= ctx
->getNumLoops();
1002 int records
= ctx
->getNumRecords();
1003 NdbRestarter restarter
;
1004 Ndb
* pNdb
= GETNDB(step
);
1006 HugoTransactions
hugoTrans(*ctx
->getTab());
1008 int dump
[] = { 9002, 0 } ;
1009 Uint32 ownNode
= refToNode(pNdb
->getReference());
1012 for (; loops
; loops
--)
1014 int nodeId
= restarter
.getRandomNotMasterNodeId(rand());
1015 restarter
.restartOneDbNode(nodeId
, false, true, true);
1016 restarter
.waitNodesNoStart(&nodeId
, 1);
1018 if (restarter
.dumpStateOneNode(nodeId
, dump
, 2))
1021 restarter
.startNodes(&nodeId
, 1);
1024 for (Uint32 i
= 0; i
< 100; i
++)
1026 hugoTrans
.pkReadRecords(pNdb
, 100, 1, NdbOperation::LM_CommittedRead
);
1028 } while (restarter
.waitClusterStarted(5) != 0);
1035 runBug29364(NDBT_Context
* ctx
, NDBT_Step
* step
){
1036 int result
= NDBT_OK
;
1037 int loops
= ctx
->getNumLoops();
1038 int records
= ctx
->getNumRecords();
1039 NdbRestarter restarter
;
1040 Ndb
* pNdb
= GETNDB(step
);
1042 HugoTransactions
hugoTrans(*ctx
->getTab());
1044 if (restarter
.getNumDbNodes() < 4)
1047 int dump0
[] = { 9000, 0 } ;
1048 int dump1
[] = { 9001, 0 } ;
1049 Uint32 ownNode
= refToNode(pNdb
->getReference());
1052 for (; loops
; loops
--)
1054 int node0
= restarter
.getDbNodeId(rand() % restarter
.getNumDbNodes());
1055 int node1
= restarter
.getRandomNodeOtherNodeGroup(node0
, rand());
1057 restarter
.restartOneDbNode(node0
, false, true, true);
1058 restarter
.waitNodesNoStart(&node0
, 1);
1059 restarter
.startNodes(&node0
, 1);
1060 restarter
.waitClusterStarted();
1062 restarter
.restartOneDbNode(node1
, false, true, true);
1063 restarter
.waitNodesNoStart(&node1
, 1);
1064 if (restarter
.dumpStateOneNode(node1
, dump0
, 2))
1067 restarter
.startNodes(&node1
, 1);
1071 for (Uint32 i
= 0; i
< 100; i
++)
1073 hugoTrans
.pkReadRecords(pNdb
, 100, 1, NdbOperation::LM_CommittedRead
);
1075 } while (restarter
.waitClusterStarted(5) != 0);
1077 if (restarter
.dumpStateOneNode(node1
, dump1
, 1))
1084 int runBug25364(NDBT_Context
* ctx
, NDBT_Step
* step
){
1085 int result
= NDBT_OK
;
1086 NdbRestarter restarter
;
1087 Ndb
* pNdb
= GETNDB(step
);
1088 int loops
= ctx
->getNumLoops();
1090 if (restarter
.getNumDbNodes() < 4)
1093 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1095 for (; loops
; loops
--)
1097 int master
= restarter
.getMasterNodeId();
1098 int victim
= restarter
.getRandomNodeOtherNodeGroup(master
, rand());
1099 int second
= restarter
.getRandomNodeSameNodeGroup(victim
, rand());
1101 int dump
[] = { 935, victim
} ;
1102 if (restarter
.dumpStateOneNode(master
, dump
, 2))
1105 if (restarter
.dumpStateOneNode(master
, val2
, 2))
1108 if (restarter
.restartOneDbNode(second
, false, true, true))
1111 int nodes
[2] = { master
, second
};
1112 if (restarter
.waitNodesNoStart(nodes
, 2))
1115 restarter
.startNodes(nodes
, 2);
1117 if (restarter
.waitNodesStarted(nodes
, 2))
1125 runBug21271(NDBT_Context
* ctx
, NDBT_Step
* step
){
1126 int result
= NDBT_OK
;
1127 int loops
= ctx
->getNumLoops();
1128 int records
= ctx
->getNumRecords();
1129 NdbRestarter restarter
;
1130 HugoOperations
hugoOps(*ctx
->getTab());
1131 Ndb
* pNdb
= GETNDB(step
);
1133 const int masterNode
= restarter
.getMasterNodeId();
1134 const int nodeId
= restarter
.getRandomNodeSameNodeGroup(masterNode
, rand());
1136 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1137 if (restarter
.dumpStateOneNode(nodeId
, val2
, 2))
1140 Uint32 tableId
= ctx
->getTab()->getTableId();
1141 int dump
[] = { DumpStateOrd::LqhErrorInsert5042
, 0, 5044 };
1144 if (restarter
.dumpStateOneNode(nodeId
, dump
, 3))
1147 restarter
.waitNodesNoStart(&nodeId
, 1);
1150 restarter
.startNodes(&nodeId
, 1);
1152 if (restarter
.waitClusterStarted() != 0)
1160 runBug24543(NDBT_Context
* ctx
, NDBT_Step
* step
){
1161 NdbRestarter restarter
;
1163 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1164 if (restarter
.dumpStateAllNodes(val2
, 2))
1168 nodes
[0] = restarter
.getMasterNodeId();
1169 restarter
.insertErrorInNode(nodes
[0], 934);
1171 nodes
[1] = restarter
.getRandomNodeOtherNodeGroup(nodes
[0], rand());
1174 nodes
[1] = restarter
.getRandomNodeSameNodeGroup(nodes
[0], rand());
1177 restarter
.restartOneDbNode(nodes
[1], false, true, true);
1178 if (restarter
.waitNodesNoStart(nodes
, 2))
1181 restarter
.startNodes(nodes
, 2);
1182 if (restarter
.waitNodesStarted(nodes
, 2))
1189 int runBug25468(NDBT_Context
* ctx
, NDBT_Step
* step
){
1191 int result
= NDBT_OK
;
1192 int loops
= ctx
->getNumLoops();
1193 int records
= ctx
->getNumRecords();
1194 NdbRestarter restarter
;
1196 for (int i
= 0; i
<loops
; i
++)
1198 int master
= restarter
.getMasterNodeId();
1203 node2
= restarter
.getRandomNodeSameNodeGroup(master
, rand());
1206 node1
= restarter
.getRandomNodeSameNodeGroup(master
, rand());
1212 node1
= restarter
.getRandomNodeOtherNodeGroup(master
, rand());
1215 node2
= restarter
.getRandomNodeSameNodeGroup(node1
, rand());
1219 ndbout_c("node1: %d node2: %d master: %d", node1
, node2
, master
);
1221 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1223 if (restarter
.dumpStateOneNode(node2
, val2
, 2))
1226 if (restarter
.insertErrorInNode(node1
, 7178))
1230 if (restarter
.dumpStateOneNode(master
, &val1
, 1))
1233 if (restarter
.waitNodesNoStart(&node2
, 1))
1236 if (restarter
.startAll())
1239 if (restarter
.waitClusterStarted())
1246 int runBug25554(NDBT_Context
* ctx
, NDBT_Step
* step
){
1248 int result
= NDBT_OK
;
1249 int loops
= ctx
->getNumLoops();
1250 int records
= ctx
->getNumRecords();
1251 NdbRestarter restarter
;
1253 if (restarter
.getNumDbNodes() < 4)
1256 for (int i
= 0; i
<loops
; i
++)
1258 int master
= restarter
.getMasterNodeId();
1259 int node1
= restarter
.getRandomNodeOtherNodeGroup(master
, rand());
1260 restarter
.restartOneDbNode(node1
, false, true, true);
1262 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1264 if (restarter
.dumpStateOneNode(master
, val2
, 2))
1267 if (restarter
.insertErrorInNode(master
, 7141))
1270 if (restarter
.waitNodesNoStart(&node1
, 1))
1273 if (restarter
.dumpStateOneNode(node1
, val2
, 2))
1276 if (restarter
.insertErrorInNode(node1
, 932))
1279 if (restarter
.startNodes(&node1
, 1))
1282 int nodes
[] = { master
, node1
};
1283 if (restarter
.waitNodesNoStart(nodes
, 2))
1286 if (restarter
.startNodes(nodes
, 2))
1289 if (restarter
.waitClusterStarted())
1296 int runBug25984(NDBT_Context
* ctx
, NDBT_Step
* step
){
1298 int result
= NDBT_OK
;
1299 int loops
= ctx
->getNumLoops();
1300 int records
= ctx
->getNumRecords();
1301 NdbRestarter restarter
;
1303 if (restarter
.getNumDbNodes() < 2)
1306 if (restarter
.restartAll(true, true, true))
1309 if (restarter
.waitClusterNoStart())
1312 if (restarter
.startAll())
1315 if (restarter
.waitClusterStarted())
1318 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1319 int master
= restarter
.getMasterNodeId();
1320 int victim
= restarter
.getRandomNodeOtherNodeGroup(master
, rand());
1322 victim
= restarter
.getRandomNodeSameNodeGroup(master
, rand());
1324 restarter
.restartOneDbNode(victim
, false, true, true);
1326 for (Uint32 i
= 0; i
<6; i
++)
1328 ndbout_c("Loop: %d", i
);
1329 if (restarter
.waitNodesNoStart(&victim
, 1))
1332 if (restarter
.dumpStateOneNode(victim
, val2
, 2))
1335 if (restarter
.insertErrorInNode(victim
, 7016))
1338 if (restarter
.startNodes(&victim
, 1))
1341 NdbSleep_SecSleep(3);
1344 if (restarter
.waitNodesNoStart(&victim
, 1))
1347 if (restarter
.dumpStateOneNode(victim
, val2
, 2))
1350 if (restarter
.insertErrorInNode(victim
, 7170))
1353 if (restarter
.startNodes(&victim
, 1))
1356 if (restarter
.waitNodesNoStart(&victim
, 1))
1359 if (restarter
.restartAll(false, true, true))
1362 if (restarter
.insertErrorInAllNodes(932))
1365 if (restarter
.insertErrorInNode(master
, 7170))
1368 if (restarter
.dumpStateAllNodes(val2
, 2))
1371 restarter
.startNodes(&master
, 1);
1372 NdbSleep_MilliSleep(3000);
1373 restarter
.startAll();
1375 if (restarter
.waitClusterNoStart())
1378 if (restarter
.restartOneDbNode(victim
, true, true, true))
1381 if (restarter
.startAll())
1384 if (restarter
.waitClusterStarted())
1391 runBug26457(NDBT_Context
* ctx
, NDBT_Step
* step
)
1394 if (res
.getNumDbNodes() < 4)
1397 int loops
= ctx
->getNumLoops();
1401 int master
= res
.getMasterNodeId();
1402 int next
= res
.getNextMasterNodeId(master
);
1404 ndbout_c("master: %d next: %d", master
, next
);
1406 if (res
.getNodeGroup(master
) == res
.getNodeGroup(next
))
1408 res
.restartOneDbNode(next
, false, false, true);
1409 if (res
.waitClusterStarted())
1414 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 2 };
1416 if (res
.dumpStateOneNode(next
, val2
, 2))
1419 if (res
.insertErrorInNode(next
, 7180))
1422 res
.restartOneDbNode(master
, false, false, true);
1423 if (res
.waitClusterStarted())
1431 runBug26481(NDBT_Context
* ctx
, NDBT_Step
* step
)
1434 int result
= NDBT_OK
;
1435 int loops
= ctx
->getNumLoops();
1436 int records
= ctx
->getNumRecords();
1439 int node
= res
.getRandomNotMasterNodeId(rand());
1440 ndbout_c("node: %d", node
);
1441 if (res
.restartOneDbNode(node
, true, true, true))
1444 if (res
.waitNodesNoStart(&node
, 1))
1447 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1448 if (res
.dumpStateOneNode(node
, val2
, 2))
1451 if (res
.insertErrorInNode(node
, 7018))
1454 if (res
.startNodes(&node
, 1))
1457 res
.waitNodesStartPhase(&node
, 1, 3);
1459 if (res
.waitNodesNoStart(&node
, 1))
1462 res
.startNodes(&node
, 1);
1464 if (res
.waitClusterStarted())
1471 runBug26450(NDBT_Context
* ctx
, NDBT_Step
* step
)
1474 int result
= NDBT_OK
;
1475 int loops
= ctx
->getNumLoops();
1476 int records
= ctx
->getNumRecords();
1478 Ndb
* pNdb
= GETNDB(step
);
1480 int node
= res
.getRandomNotMasterNodeId(rand());
1482 for (unsigned i
= 0; i
<res
.getNumDbNodes(); i
++)
1484 if (res
.getDbNodeId(i
) != node
)
1485 nodes
.push_back(res
.getDbNodeId(i
));
1488 if (res
.restartAll())
1491 if (res
.waitClusterStarted())
1494 ndbout_c("node: %d", node
);
1495 if (res
.restartOneDbNode(node
, false, true, true))
1498 if (res
.waitNodesNoStart(&node
, 1))
1501 if (runClearTable(ctx
, step
))
1504 for (i
= 0; i
< 2; i
++)
1506 if (res
.restartAll(false, true, i
> 0))
1509 if (res
.waitClusterNoStart())
1512 if (res
.startNodes(nodes
.getBase(), nodes
.size()))
1515 if (res
.waitNodesStarted(nodes
.getBase(), nodes
.size()))
1519 if (res
.startNodes(&node
, 1))
1522 if (res
.waitNodesStarted(&node
, 1))
1525 HugoTransactions
trans (* ctx
->getTab());
1526 if (trans
.selectCount(pNdb
) != 0)
1533 runBug27003(NDBT_Context
* ctx
, NDBT_Step
* step
)
1535 int result
= NDBT_OK
;
1536 int loops
= ctx
->getNumLoops();
1537 int records
= ctx
->getNumRecords();
1540 static const int errnos
[] = { 4025, 4026, 4027, 4028, 0 };
1542 int node
= res
.getRandomNotMasterNodeId(rand());
1543 ndbout_c("node: %d", node
);
1544 if (res
.restartOneDbNode(node
, true, true, true))
1548 for (Uint32 i
= 0; i
<loops
; i
++)
1550 while (errnos
[pos
] != 0)
1552 ndbout_c("Tesing err: %d", errnos
[pos
]);
1554 if (res
.waitNodesNoStart(&node
, 1))
1557 if (res
.insertErrorInNode(node
, 1000))
1560 if (res
.insertErrorInNode(node
, errnos
[pos
]))
1563 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 3 };
1564 if (res
.dumpStateOneNode(node
, val2
, 2))
1567 res
.startNodes(&node
, 1);
1568 NdbSleep_SecSleep(3);
1574 if (res
.waitNodesNoStart(&node
, 1))
1577 res
.startNodes(&node
, 1);
1578 if (res
.waitClusterStarted())
1586 runBug27283(NDBT_Context
* ctx
, NDBT_Step
* step
)
1588 int result
= NDBT_OK
;
1589 int loops
= ctx
->getNumLoops();
1590 int records
= ctx
->getNumRecords();
1593 if (res
.getNumDbNodes() < 2)
1598 static const int errnos
[] = { 7181, 7182, 0 };
1601 for (Uint32 i
= 0; i
<loops
; i
++)
1603 while (errnos
[pos
] != 0)
1605 int master
= res
.getMasterNodeId();
1606 int next
= res
.getNextMasterNodeId(master
);
1607 int next2
= res
.getNextMasterNodeId(next
);
1609 int node
= (i
& 1) ? next
: next2
;
1610 ndbout_c("Tesing err: %d", errnos
[pos
]);
1611 if (res
.insertErrorInNode(next
, errnos
[pos
]))
1614 NdbSleep_SecSleep(3);
1616 if (res
.waitClusterStarted())
1628 runBug27466(NDBT_Context
* ctx
, NDBT_Step
* step
)
1630 int result
= NDBT_OK
;
1631 int loops
= ctx
->getNumLoops();
1632 int records
= ctx
->getNumRecords();
1635 if (res
.getNumDbNodes() < 2)
1641 for (Uint32 i
= 0; i
<loops
; i
++)
1643 int node1
= res
.getDbNodeId(rand() % res
.getNumDbNodes());
1645 while (node1
== node2
)
1647 node2
= res
.getDbNodeId(rand() % res
.getNumDbNodes());
1650 ndbout_c("nodes %u %u", node1
, node2
);
1652 if (res
.restartOneDbNode(node1
, false, true, true))
1655 if (res
.waitNodesNoStart(&node1
, 1))
1658 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1659 if (res
.dumpStateOneNode(node1
, val2
, 2))
1662 if (res
.insertErrorInNode(node2
, 8039))
1665 res
.startNodes(&node1
, 1);
1666 NdbSleep_SecSleep(3);
1667 if (res
.waitNodesNoStart(&node1
, 1))
1669 NdbSleep_SecSleep(5); // Wait for delayed INCL_NODECONF to arrive
1671 res
.startNodes(&node1
, 1);
1672 if (res
.waitClusterStarted())
1680 runBug28023(NDBT_Context
* ctx
, NDBT_Step
* step
)
1682 int result
= NDBT_OK
;
1683 int loops
= ctx
->getNumLoops();
1684 int records
= ctx
->getNumRecords();
1685 Ndb
* pNdb
= GETNDB(step
);
1688 if (res
.getNumDbNodes() < 2)
1694 HugoTransactions
hugoTrans(*ctx
->getTab());
1695 if (hugoTrans
.loadTable(pNdb
, records
) != 0){
1699 if (hugoTrans
.clearTable(pNdb
, records
) != 0)
1704 for (Uint32 i
= 0; i
<loops
; i
++)
1706 int node1
= res
.getDbNodeId(rand() % res
.getNumDbNodes());
1708 if (res
.restartOneDbNode2(node1
,
1709 NdbRestarter::NRRF_ABORT
|
1710 NdbRestarter::NRRF_NOSTART
))
1713 if (res
.waitNodesNoStart(&node1
, 1))
1716 if (hugoTrans
.loadTable(pNdb
, records
) != 0){
1720 if (hugoTrans
.clearTable(pNdb
, records
) != 0)
1725 res
.startNodes(&node1
, 1);
1726 if (res
.waitClusterStarted())
1729 if (hugoTrans
.loadTable(pNdb
, records
) != 0){
1733 if (hugoTrans
.scanUpdateRecords(pNdb
, records
) != 0)
1736 if (hugoTrans
.clearTable(pNdb
, records
) != 0)
1747 runBug28717(NDBT_Context
* ctx
, NDBT_Step
* step
)
1749 int result
= NDBT_OK
;
1750 int loops
= ctx
->getNumLoops();
1751 int records
= ctx
->getNumRecords();
1752 Ndb
* pNdb
= GETNDB(step
);
1755 if (res
.getNumDbNodes() < 4)
1760 int master
= res
.getMasterNodeId();
1761 int node0
= res
.getRandomNodeOtherNodeGroup(master
, rand());
1762 int node1
= res
.getRandomNodeSameNodeGroup(node0
, rand());
1764 ndbout_c("master: %d node0: %d node1: %d", master
, node0
, node1
);
1766 if (res
.restartOneDbNode(node0
, false, true, true))
1772 int filter
[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT
, 0 };
1773 NdbLogEventHandle handle
=
1774 ndb_mgm_create_logevent_handle(res
.handle
, filter
);
1777 int dump
[] = { DumpStateOrd::DihStartLcpImmediately
};
1778 struct ndb_logevent event
;
1780 for (Uint32 i
= 0; i
<3; i
++)
1782 res
.dumpStateOneNode(master
, dump
, 1);
1783 while(ndb_logevent_get_next(handle
, &event
, 0) >= 0 &&
1784 event
.type
!= NDB_LE_LocalCheckpointStarted
);
1785 while(ndb_logevent_get_next(handle
, &event
, 0) >= 0 &&
1786 event
.type
!= NDB_LE_LocalCheckpointCompleted
);
1790 if (res
.waitNodesNoStart(&node0
, 1))
1793 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1795 if (res
.dumpStateOneNode(node0
, val2
, 2))
1798 if (res
.insertErrorInNode(node0
, 5010))
1801 if (res
.insertErrorInNode(node1
, 1001))
1804 if (res
.startNodes(&node0
, 1))
1807 NdbSleep_SecSleep(3);
1809 if (res
.insertErrorInNode(node1
, 0))
1812 if (res
.waitNodesNoStart(&node0
, 1))
1815 if (res
.startNodes(&node0
, 1))
1818 if (res
.waitClusterStarted())
1825 runBug31525(NDBT_Context
* ctx
, NDBT_Step
* step
)
1827 int result
= NDBT_OK
;
1828 int loops
= ctx
->getNumLoops();
1829 int records
= ctx
->getNumRecords();
1830 Ndb
* pNdb
= GETNDB(step
);
1833 if (res
.getNumDbNodes() < 2)
1839 nodes
[0] = res
.getMasterNodeId();
1840 nodes
[1] = res
.getNextMasterNodeId(nodes
[0]);
1842 while (res
.getNodeGroup(nodes
[0]) != res
.getNodeGroup(nodes
[1]))
1844 ndbout_c("Restarting %u as it not in same node group as %u",
1845 nodes
[1], nodes
[0]);
1846 if (res
.restartOneDbNode(nodes
[1], false, true, true))
1849 if (res
.waitNodesNoStart(nodes
+1, 1))
1852 if (res
.startNodes(nodes
+1, 1))
1855 if (res
.waitClusterStarted())
1858 nodes
[1] = res
.getNextMasterNodeId(nodes
[0]);
1861 ndbout_c("nodes[0]: %u nodes[1]: %u", nodes
[0], nodes
[1]);
1863 int val
= DumpStateOrd::DihMinTimeBetweenLCP
;
1864 if (res
.dumpStateAllNodes(&val
, 1))
1867 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1868 if (res
.dumpStateAllNodes(val2
, 2))
1871 if (res
.insertErrorInAllNodes(932))
1874 if (res
.insertErrorInNode(nodes
[1], 7192))
1877 if (res
.insertErrorInNode(nodes
[0], 7191))
1880 if (res
.waitClusterNoStart())
1886 if (res
.waitClusterStarted())
1889 if (res
.restartOneDbNode(nodes
[1], false, false, true))
1892 if (res
.waitClusterStarted())
1899 runBug32160(NDBT_Context
* ctx
, NDBT_Step
* step
)
1901 int result
= NDBT_OK
;
1902 int loops
= ctx
->getNumLoops();
1903 int records
= ctx
->getNumRecords();
1904 Ndb
* pNdb
= GETNDB(step
);
1907 if (res
.getNumDbNodes() < 2)
1912 int master
= res
.getMasterNodeId();
1913 int next
= res
.getNextMasterNodeId(master
);
1915 if (res
.insertErrorInNode(next
, 7194))
1920 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1921 if (res
.dumpStateOneNode(master
, val2
, 2))
1924 if (res
.insertErrorInNode(master
, 7193))
1927 int val3
[] = { 7099 };
1928 if (res
.dumpStateOneNode(master
, val3
, 1))
1931 if (res
.waitNodesNoStart(&master
, 1))
1934 if (res
.startNodes(&master
, 1))
1937 if (res
.waitClusterStarted())
1944 runBug34216(NDBT_Context
* ctx
, NDBT_Step
* step
)
1946 int result
= NDBT_OK
;
1947 int loops
= ctx
->getNumLoops();
1948 NdbRestarter restarter
;
1951 HugoOperations
hugoOps(*ctx
->getTab());
1952 int records
= ctx
->getNumRecords();
1953 Ndb
* pNdb
= GETNDB(step
);
1955 if (restarter
.getNumDbNodes() < 2)
1961 if(restarter
.waitClusterStarted() != 0){
1962 g_err
<< "Cluster failed to start" << endl
;
1967 const char * off
= NdbEnv_GetEnv("NDB_ERR_OFFSET", buf
, sizeof(buf
));
1968 int offset
= off
? atoi(off
) : 0;
1970 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped())
1972 int id
= lastId
% restarter
.getNumDbNodes();
1973 int nodeId
= restarter
.getDbNodeId(id
);
1974 int err
= 5048 + ((i
+offset
) % 2);
1976 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
1978 if(hugoOps
.startTransaction(pNdb
) != 0)
1981 nodeId
= hugoOps
.getTransaction()->getConnectedNodeId();
1982 ndbout
<< "Restart node " << nodeId
<< " " << err
<<endl
;
1984 if (restarter
.dumpStateOneNode(nodeId
, val2
, 2))
1987 if(restarter
.insertErrorInNode(nodeId
, err
) != 0){
1988 g_err
<< "Failed to restartNextDbNode" << endl
;
1989 result
= NDBT_FAILED
;
1993 if (restarter
.insertErrorInNode(nodeId
, 8057) != 0)
1995 g_err
<< "Failed to insert error 8057" << endl
;
1996 result
= NDBT_FAILED
;
2002 int row
= (records
- rows
) ? rand() % (records
- rows
) : 0;
2004 if(hugoOps
.pkUpdateRecord(pNdb
, row
, batch
, rand()) != 0)
2007 for (int l
= 1; l
<5; l
++)
2009 if (hugoOps
.execute_NoCommit(pNdb
) != 0)
2012 if(hugoOps
.pkUpdateRecord(pNdb
, row
, batch
, rand()) != 0)
2016 hugoOps
.execute_Commit(pNdb
);
2017 hugoOps
.closeTransaction(pNdb
);
2019 if (restarter
.waitNodesNoStart(&nodeId
, 1))
2021 g_err
<< "Failed to waitNodesNoStart" << endl
;
2022 result
= NDBT_FAILED
;
2026 if (restarter
.startNodes(&nodeId
, 1))
2028 g_err
<< "Failed to startNodes" << endl
;
2029 result
= NDBT_FAILED
;
2033 if(restarter
.waitClusterStarted() != 0){
2034 g_err
<< "Cluster failed to start" << endl
;
2035 result
= NDBT_FAILED
;
2052 runNF_commit(NDBT_Context
* ctx
, NDBT_Step
* step
)
2054 int result
= NDBT_OK
;
2055 int loops
= ctx
->getNumLoops();
2056 NdbRestarter restarter
;
2057 if (restarter
.getNumDbNodes() < 2)
2063 if(restarter
.waitClusterStarted() != 0){
2064 g_err
<< "Cluster failed to start" << endl
;
2069 while(i
<loops
&& result
!= NDBT_FAILED
&& !ctx
->isTestStopped())
2071 int nodeId
= restarter
.getDbNodeId(rand() % restarter
.getNumDbNodes());
2074 ndbout
<< "Restart node " << nodeId
<< " " << err
<<endl
;
2076 int val2
[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert
, 1 };
2077 if (restarter
.dumpStateOneNode(nodeId
, val2
, 2))
2080 if(restarter
.insertErrorInNode(nodeId
, err
) != 0){
2081 g_err
<< "Failed to restartNextDbNode" << endl
;
2082 result
= NDBT_FAILED
;
2086 if (restarter
.waitNodesNoStart(&nodeId
, 1))
2088 g_err
<< "Failed to waitNodesNoStart" << endl
;
2089 result
= NDBT_FAILED
;
2093 if (restarter
.startNodes(&nodeId
, 1))
2095 g_err
<< "Failed to startNodes" << endl
;
2096 result
= NDBT_FAILED
;
2100 if(restarter
.waitClusterStarted() != 0){
2101 g_err
<< "Cluster failed to start" << endl
;
2102 result
= NDBT_FAILED
;
2115 NDBT_TESTSUITE(testNodeRestart
);
2117 "Test that one node at a time can be stopped and then restarted "\
2118 "when there are no load on the system. Do this loop number of times"){
2119 INITIALIZER(runCheckAllNodesStarted
);
2120 INITIALIZER(runLoadTable
);
2122 FINALIZER(runClearTable
);
2125 "Test that one node at a time can be stopped and then restarted "\
2126 "perform pk read while restarting. Do this loop number of times"){
2127 TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read
);
2128 INITIALIZER(runCheckAllNodesStarted
);
2129 INITIALIZER(runLoadTable
);
2131 STEP(runPkReadUntilStopped
);
2132 FINALIZER(runClearTable
);
2134 TESTCASE("PkReadCommitted",
2135 "Test that one node at a time can be stopped and then restarted "\
2136 "perform pk read while restarting. Do this loop number of times"){
2137 TC_PROPERTY("ReadLockMode", NdbOperation::LM_CommittedRead
);
2138 INITIALIZER(runCheckAllNodesStarted
);
2139 INITIALIZER(runLoadTable
);
2141 STEP(runPkReadUntilStopped
);
2142 FINALIZER(runClearTable
);
2144 TESTCASE("MixedPkRead",
2145 "Test that one node at a time can be stopped and then restarted "\
2146 "perform pk read while restarting. Do this loop number of times"){
2147 TC_PROPERTY("ReadLockMode", -1);
2148 INITIALIZER(runCheckAllNodesStarted
);
2149 INITIALIZER(runLoadTable
);
2151 STEP(runPkReadUntilStopped
);
2152 FINALIZER(runClearTable
);
2154 TESTCASE("PkReadPkUpdate",
2155 "Test that one node at a time can be stopped and then restarted "\
2156 "perform pk read and pk update while restarting. Do this loop number of times"){
2157 TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read
);
2158 INITIALIZER(runCheckAllNodesStarted
);
2159 INITIALIZER(runLoadTable
);
2161 STEP(runPkReadUntilStopped
);
2162 STEP(runPkUpdateUntilStopped
);
2163 STEP(runPkReadPkUpdateUntilStopped
);
2164 STEP(runPkReadUntilStopped
);
2165 STEP(runPkUpdateUntilStopped
);
2166 STEP(runPkReadPkUpdateUntilStopped
);
2167 FINALIZER(runClearTable
);
2169 TESTCASE("MixedPkReadPkUpdate",
2170 "Test that one node at a time can be stopped and then restarted "\
2171 "perform pk read and pk update while restarting. Do this loop number of times"){
2172 TC_PROPERTY("ReadLockMode", -1);
2173 INITIALIZER(runCheckAllNodesStarted
);
2174 INITIALIZER(runLoadTable
);
2176 STEP(runPkReadUntilStopped
);
2177 STEP(runPkUpdateUntilStopped
);
2178 STEP(runPkReadPkUpdateUntilStopped
);
2179 STEP(runPkReadUntilStopped
);
2180 STEP(runPkUpdateUntilStopped
);
2181 STEP(runPkReadPkUpdateUntilStopped
);
2182 FINALIZER(runClearTable
);
2184 TESTCASE("ReadUpdateScan",
2185 "Test that one node at a time can be stopped and then restarted "\
2186 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){
2187 INITIALIZER(runCheckAllNodesStarted
);
2188 INITIALIZER(runLoadTable
);
2190 STEP(runPkReadUntilStopped
);
2191 STEP(runPkUpdateUntilStopped
);
2192 STEP(runPkReadPkUpdateUntilStopped
);
2193 STEP(runScanReadUntilStopped
);
2194 STEP(runScanUpdateUntilStopped
);
2195 FINALIZER(runClearTable
);
2197 TESTCASE("MixedReadUpdateScan",
2198 "Test that one node at a time can be stopped and then restarted "\
2199 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){
2200 TC_PROPERTY("ReadLockMode", -1);
2201 INITIALIZER(runCheckAllNodesStarted
);
2202 INITIALIZER(runLoadTable
);
2204 STEP(runPkReadUntilStopped
);
2205 STEP(runPkUpdateUntilStopped
);
2206 STEP(runPkReadPkUpdateUntilStopped
);
2207 STEP(runScanReadUntilStopped
);
2208 STEP(runScanUpdateUntilStopped
);
2209 FINALIZER(runClearTable
);
2212 "Test that one node at a time can be stopped and then restarted "\
2213 "perform all kind of transactions while restarting. Do this loop number of times"){
2214 INITIALIZER(runCheckAllNodesStarted
);
2215 INITIALIZER(runLoadTable
);
2217 STEP(runPkReadUntilStopped
);
2218 STEP(runPkUpdateUntilStopped
);
2219 STEP(runScanReadUntilStopped
);
2220 STEP(runScanUpdateUntilStopped
);
2221 FINALIZER(runClearTable
);
2224 "Test that one node at a time can be stopped and then restarted "\
2225 "when db is full. Do this loop number of times"){
2226 INITIALIZER(runCheckAllNodesStarted
);
2227 INITIALIZER(runFillTable
);
2229 FINALIZER(runClearTable
);
2231 TESTCASE("RestartRandomNode",
2232 "Test that we can execute the restart RestartRandomNode loop\n"\
2234 INITIALIZER(runCheckAllNodesStarted
);
2235 INITIALIZER(runLoadTable
);
2237 FINALIZER(runScanReadVerify
);
2238 FINALIZER(runClearTable
);
2240 TESTCASE("RestartRandomNodeError",
2241 "Test that we can execute the restart RestartRandomNodeError loop\n"\
2243 INITIALIZER(runCheckAllNodesStarted
);
2244 INITIALIZER(runLoadTable
);
2246 FINALIZER(runScanReadVerify
);
2247 FINALIZER(runClearTable
);
2249 TESTCASE("RestartRandomNodeInitial",
2250 "Test that we can execute the restart RestartRandomNodeInitial loop\n"\
2252 INITIALIZER(runCheckAllNodesStarted
);
2253 INITIALIZER(runLoadTable
);
2255 FINALIZER(runScanReadVerify
);
2256 FINALIZER(runClearTable
);
2258 TESTCASE("RestartNFDuringNR",
2259 "Test that we can execute the restart RestartNFDuringNR loop\n"\
2261 INITIALIZER(runCheckAllNodesStarted
);
2262 INITIALIZER(runLoadTable
);
2264 STEP(runPkUpdateUntilStopped
);
2265 STEP(runScanUpdateUntilStopped
);
2266 FINALIZER(runScanReadVerify
);
2267 FINALIZER(runClearTable
);
2269 TESTCASE("RestartMasterNodeError",
2270 "Test that we can execute the restart RestartMasterNodeError loop\n"\
2272 INITIALIZER(runCheckAllNodesStarted
);
2273 INITIALIZER(runLoadTable
);
2275 FINALIZER(runScanReadVerify
);
2276 FINALIZER(runClearTable
);
2279 TESTCASE("TwoNodeFailure",
2280 "Test that we can execute the restart TwoNodeFailure\n"\
2281 "(which is a multiple node failure restart) loop\n"\
2283 INITIALIZER(runCheckAllNodesStarted
);
2284 INITIALIZER(runLoadTable
);
2286 FINALIZER(runScanReadVerify
);
2287 FINALIZER(runClearTable
);
2289 TESTCASE("TwoMasterNodeFailure",
2290 "Test that we can execute the restart TwoMasterNodeFailure\n"\
2291 "(which is a multiple node failure restart) loop\n"\
2293 INITIALIZER(runCheckAllNodesStarted
);
2294 INITIALIZER(runLoadTable
);
2296 FINALIZER(runScanReadVerify
);
2297 FINALIZER(runClearTable
);
2299 TESTCASE("FiftyPercentFail",
2300 "Test that we can execute the restart FiftyPercentFail\n"\
2301 "(which is a multiple node failure restart) loop\n"\
2303 INITIALIZER(runCheckAllNodesStarted
);
2304 INITIALIZER(runLoadTable
);
2306 FINALIZER(runScanReadVerify
);
2307 FINALIZER(runClearTable
);
2309 TESTCASE("RestartAllNodes",
2310 "Test that we can execute the restart RestartAllNodes\n"\
2311 "(which is a system restart) loop\n"\
2313 INITIALIZER(runCheckAllNodesStarted
);
2314 INITIALIZER(runLoadTable
);
2316 FINALIZER(runScanReadVerify
);
2317 FINALIZER(runClearTable
);
2319 TESTCASE("RestartAllNodesAbort",
2320 "Test that we can execute the restart RestartAllNodesAbort\n"\
2321 "(which is a system restart) loop\n"\
2323 INITIALIZER(runCheckAllNodesStarted
);
2324 INITIALIZER(runLoadTable
);
2326 FINALIZER(runScanReadVerify
);
2327 FINALIZER(runClearTable
);
2329 TESTCASE("RestartAllNodesError9999",
2330 "Test that we can execute the restart RestartAllNodesError9999\n"\
2331 "(which is a system restart) loop\n"\
2333 INITIALIZER(runCheckAllNodesStarted
);
2334 INITIALIZER(runLoadTable
);
2336 FINALIZER(runScanReadVerify
);
2337 FINALIZER(runClearTable
);
2339 TESTCASE("FiftyPercentStopAndWait",
2340 "Test that we can execute the restart FiftyPercentStopAndWait\n"\
2341 "(which is a system restart) loop\n"\
2343 INITIALIZER(runCheckAllNodesStarted
);
2344 INITIALIZER(runLoadTable
);
2346 FINALIZER(runScanReadVerify
);
2347 FINALIZER(runClearTable
);
2349 TESTCASE("RestartNodeDuringLCP",
2350 "Test that we can execute the restart RestartRandomNode loop\n"\
2352 INITIALIZER(runCheckAllNodesStarted
);
2353 INITIALIZER(runLoadTable
);
2355 STEP(runPkUpdateUntilStopped
);
2356 STEP(runScanUpdateUntilStopped
);
2357 FINALIZER(runScanReadVerify
);
2358 FINALIZER(runClearTable
);
2360 TESTCASE("StopOnError",
2361 "Test StopOnError. A node that has StopOnError set to false "\
2362 "should restart automatically when an error occurs"){
2363 INITIALIZER(runCheckAllNodesStarted
);
2364 INITIALIZER(runLoadTable
);
2366 FINALIZER(runScanReadVerify
);
2367 FINALIZER(runClearTable
);
2369 TESTCASE("CommittedRead",
2370 "Test committed read"){
2371 INITIALIZER(runLoadTable
);
2373 FINALIZER(runClearTable
);
2375 TESTCASE("LateCommit",
2376 "Test commit after node failure"){
2377 INITIALIZER(runLoadTable
);
2378 STEP(runLateCommit
);
2379 FINALIZER(runClearTable
);
2381 TESTCASE("Bug15587",
2382 "Test bug with NF during NR"){
2383 INITIALIZER(runLoadTable
);
2384 STEP(runScanUpdateUntilStopped
);
2386 FINALIZER(runClearTable
);
2388 TESTCASE("Bug15632",
2389 "Test bug with NF during NR"){
2390 INITIALIZER(runLoadTable
);
2392 FINALIZER(runClearTable
);
2394 TESTCASE("Bug15685",
2395 "Test bug with NF during abort"){
2397 FINALIZER(runClearTable
);
2399 TESTCASE("Bug16772",
2400 "Test bug with restarting before NF handling is complete"){
2403 TESTCASE("Bug18414",
2404 "Test bug with NF during NR"){
2405 INITIALIZER(runLoadTable
);
2407 FINALIZER(runClearTable
);
2409 TESTCASE("Bug18612",
2410 "Test bug with partitioned clusters"){
2411 INITIALIZER(runLoadTable
);
2413 FINALIZER(runClearTable
);
2415 TESTCASE("Bug18612SR",
2416 "Test bug with partitioned clusters"){
2417 INITIALIZER(runLoadTable
);
2418 STEP(runBug18612SR
);
2419 FINALIZER(runClearTable
);
2421 TESTCASE("Bug20185",
2423 INITIALIZER(runLoadTable
);
2425 FINALIZER(runClearTable
);
2427 TESTCASE("Bug24543", "")
2429 INITIALIZER(runBug24543
);
2431 TESTCASE("Bug21271",
2433 INITIALIZER(runLoadTable
);
2435 STEP(runPkUpdateUntilStopped
);
2436 FINALIZER(runClearTable
);
2438 TESTCASE("Bug31525", ""){
2439 INITIALIZER(runBug31525
);
2441 TESTCASE("Bug24717", ""){
2442 INITIALIZER(runBug24717
);
2444 TESTCASE("Bug25364", ""){
2445 INITIALIZER(runBug25364
);
2447 TESTCASE("Bug25468", ""){
2448 INITIALIZER(runBug25468
);
2450 TESTCASE("Bug25554", ""){
2451 INITIALIZER(runBug25554
);
2453 TESTCASE("Bug25984", ""){
2454 INITIALIZER(runBug25984
);
2456 TESTCASE("Bug26457", ""){
2457 INITIALIZER(runBug26457
);
2459 TESTCASE("Bug26481", ""){
2460 INITIALIZER(runBug26481
);
2462 TESTCASE("Bug26450", ""){
2463 INITIALIZER(runLoadTable
);
2464 INITIALIZER(runBug26450
);
2466 TESTCASE("Bug27003", ""){
2467 INITIALIZER(runBug27003
);
2469 TESTCASE("Bug27283", ""){
2470 INITIALIZER(runBug27283
);
2472 TESTCASE("Bug27466", ""){
2473 INITIALIZER(runBug27466
);
2475 TESTCASE("Bug28023", ""){
2476 INITIALIZER(runBug28023
);
2478 TESTCASE("Bug28717", ""){
2479 INITIALIZER(runBug28717
);
2481 TESTCASE("Bug29364", ""){
2482 INITIALIZER(runBug29364
);
2484 TESTCASE("Bug32160", ""){
2485 INITIALIZER(runBug32160
);
2487 TESTCASE("Bug34216", ""){
2488 INITIALIZER(runCheckAllNodesStarted
);
2489 INITIALIZER(runLoadTable
);
2491 FINALIZER(runClearTable
);
2493 TESTCASE("mixedmultiop", ""){
2494 TC_PROPERTY("MULTI_OP", 5);
2495 INITIALIZER(runCheckAllNodesStarted
);
2496 INITIALIZER(runLoadTable
);
2498 STEP(runPkUpdateUntilStopped
);
2499 STEP(runPkUpdateUntilStopped
);
2500 FINALIZER(runClearTable
);
2502 NDBT_TESTSUITE_END(testNodeRestart
);
2504 int main(int argc
, const char** argv
){
2507 // It might be interesting to have longer defaults for num
2508 // loops in this test
2509 // Just performing 100 node restarts would not be enough?
2510 // We can have initialisers in the NDBT_Testcase class like
2512 testNodeRestart
.setDefaultLoops(1000);
2514 return testNodeRestart
.execute(argc
, argv
);