1
/* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#include <NDBT_Test.hpp>
18
#include <HugoTransactions.hpp>
19
#include <UtilTransactions.hpp>
20
#include <NdbRestarter.hpp>
22
#include <signaldata/DumpStateOrd.hpp>
23
#include <NdbBackup.hpp>
25
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
27
int records = ctx->getNumRecords();
28
HugoTransactions hugoTrans(*ctx->getTab());
29
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
35
#define CHECK(b) if (!(b)) { \
36
g_err << "ERR: "<< step->getName() \
37
<< " failed on line " << __LINE__ << endl; \
38
result = NDBT_FAILED; \
41
int runSystemRestart1(NDBT_Context* ctx, NDBT_Step* step){
42
Ndb* pNdb = GETNDB(step);
45
Uint32 loops = ctx->getNumLoops();
46
int records = ctx->getNumRecords();
48
NdbRestarter restarter;
51
UtilTransactions utilTrans(*ctx->getTab());
52
HugoTransactions hugoTrans(*ctx->getTab());
53
while(i<=loops && result != NDBT_FAILED){
55
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
58
2. Restart cluster and verify records
60
4. Restart cluster and verify records
61
5. Delete half of the records
62
6. Restart cluster and verify records
64
8. Restart cluster and verify records
65
9. Insert, update, delete records
66
10. Restart cluster and verify records
67
11. Insert, update, delete records
68
12. Restart cluster with error insert 5020 and verify records
70
ndbout << "Loading records..." << endl;
71
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
73
ndbout << "Restarting cluster" << endl;
74
CHECK(restarter.restartAll() == 0);
75
CHECK(restarter.waitClusterStarted(timeout) == 0);
76
CHECK(pNdb->waitUntilReady(timeout) == 0);
78
ndbout << "Verifying records..." << endl;
79
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
80
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
81
CHECK(count == records);
83
ndbout << "Updating records..." << endl;
84
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
86
ndbout << "Restarting cluster..." << endl;
87
CHECK(restarter.restartAll() == 0);
88
CHECK(restarter.waitClusterStarted(timeout) == 0);
89
CHECK(pNdb->waitUntilReady(timeout) == 0);
91
ndbout << "Verifying records..." << endl;
92
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
93
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
94
CHECK(count == records);
96
ndbout << "Deleting 50% of records..." << endl;
97
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
99
ndbout << "Restarting cluster..." << endl;
100
CHECK(restarter.restartAll() == 0);
101
CHECK(restarter.waitClusterStarted(timeout) == 0);
102
CHECK(pNdb->waitUntilReady(timeout) == 0);
104
ndbout << "Verifying records..." << endl;
105
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
106
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
107
CHECK(count == (records/2));
109
ndbout << "Deleting all records..." << endl;
110
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
112
ndbout << "Restarting cluster..." << endl;
113
CHECK(restarter.restartAll() == 0);
114
CHECK(restarter.waitClusterStarted(timeout) == 0);
115
CHECK(pNdb->waitUntilReady(timeout) == 0);
117
ndbout << "Verifying records..." << endl;
118
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
121
ndbout << "Doing it all..." << endl;
122
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
123
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
124
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
125
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
126
CHECK(utilTrans.clearTable(pNdb, records) == 0);
127
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
128
CHECK(utilTrans.clearTable(pNdb, records) == 0);
129
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
130
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
131
CHECK(utilTrans.clearTable(pNdb, records) == 0);
133
ndbout << "Restarting cluster..." << endl;
134
CHECK(restarter.restartAll() == 0);
135
CHECK(restarter.waitClusterStarted(timeout) == 0);
136
CHECK(pNdb->waitUntilReady(timeout) == 0);
138
ndbout << "Verifying records..." << endl;
139
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
142
ndbout << "Doing it all..." << endl;
143
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
144
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
145
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
146
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
147
CHECK(utilTrans.clearTable(pNdb, records) == 0);
148
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
149
CHECK(utilTrans.clearTable(pNdb, records) == 0);
151
ndbout << "Restarting cluster with error insert 5020..." << endl;
152
CHECK(restarter.restartAll(false, true) == 0);
153
CHECK(restarter.waitClusterNoStart(timeout) == 0);
154
CHECK(restarter.insertErrorInAllNodes(5020) == 0);
155
CHECK(restarter.startAll() == 0);
156
CHECK(restarter.waitClusterStarted(timeout) == 0);
157
CHECK(pNdb->waitUntilReady(timeout) == 0);
162
ndbout << "runSystemRestart1 finished" << endl;
167
int runSystemRestart2(NDBT_Context* ctx, NDBT_Step* step){
168
Ndb* pNdb = GETNDB(step);
169
int result = NDBT_OK;
170
/// int timeout = 300;
172
Uint32 loops = ctx->getNumLoops();
173
int records = ctx->getNumRecords();
175
NdbRestarter restarter;
178
UtilTransactions utilTrans(*ctx->getTab());
179
HugoTransactions hugoTrans(*ctx->getTab());
180
while(i<=loops && result != NDBT_FAILED && !ctx->isTestStopped()){
182
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
183
/* Use error 7070 to set time between LCP to it's min value
185
2. Restart cluster and verify records
187
4. Restart cluster and verify records
188
5. Delete half of the records
189
6. Restart cluster and verify records
190
7. Delete all records
191
8. Restart cluster and verify records
192
9. Insert, update, delete records
193
10. Restart cluster and verify records
195
int val = DumpStateOrd::DihMinTimeBetweenLCP;
196
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
198
ndbout << "Loading records..." << endl;
199
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
201
ndbout << "Restarting cluster" << endl;
202
CHECK(restarter.restartAll() == 0);
203
CHECK(restarter.waitClusterStarted(timeout) == 0);
205
int val = DumpStateOrd::DihMinTimeBetweenLCP;
206
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
208
CHECK(pNdb->waitUntilReady(timeout) == 0);
210
ndbout << "Verifying records..." << endl;
211
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
212
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
213
CHECK(count == records);
215
ndbout << "Updating records..." << endl;
216
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
218
ndbout << "Restarting cluster..." << endl;
219
CHECK(restarter.restartAll() == 0);
220
CHECK(restarter.waitClusterStarted(timeout) == 0);
222
int val = DumpStateOrd::DihMinTimeBetweenLCP;
223
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
225
CHECK(pNdb->waitUntilReady(timeout) == 0);
227
ndbout << "Verifying records..." << endl;
228
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
229
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
230
CHECK(count == records);
232
ndbout << "Deleting 50% of records..." << endl;
233
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
235
ndbout << "Restarting cluster..." << endl;
236
CHECK(restarter.restartAll() == 0);
237
CHECK(restarter.waitClusterStarted(timeout) == 0);
239
int val = DumpStateOrd::DihMinTimeBetweenLCP;
240
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
242
CHECK(pNdb->waitUntilReady(timeout) == 0);
244
ndbout << "Verifying records..." << endl;
245
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
246
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
247
CHECK(count == (records/2));
249
ndbout << "Deleting all records..." << endl;
250
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
252
ndbout << "Restarting cluster..." << endl;
253
CHECK(restarter.restartAll() == 0);
254
CHECK(restarter.waitClusterStarted(timeout) == 0);
256
int val = DumpStateOrd::DihMinTimeBetweenLCP;
257
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
259
CHECK(pNdb->waitUntilReady(timeout) == 0);
261
ndbout << "Verifying records..." << endl;
262
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
265
ndbout << "Doing it all..." << endl;
266
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
267
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
268
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
269
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
270
CHECK(utilTrans.clearTable(pNdb, records) == 0);
271
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
272
CHECK(utilTrans.clearTable(pNdb, records) == 0);
273
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
274
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
275
CHECK(utilTrans.clearTable(pNdb, records) == 0);
277
ndbout << "Restarting cluster..." << endl;
278
CHECK(restarter.restartAll() == 0);
279
CHECK(restarter.waitClusterStarted(timeout) == 0);
281
int val = DumpStateOrd::DihMinTimeBetweenLCP;
282
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
284
CHECK(pNdb->waitUntilReady(timeout) == 0);
286
ndbout << "Verifying records..." << endl;
287
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
293
ndbout << "runSystemRestart2 finished" << endl;
298
int runSystemRestartTestUndoLog(NDBT_Context* ctx, NDBT_Step* step){
299
Ndb* pNdb = GETNDB(step);
300
int result = NDBT_OK;
302
Uint32 loops = ctx->getNumLoops();
303
int records = ctx->getNumRecords();
305
NdbRestarter restarter;
310
dump7080[1] = ctx->getTab()->getTableId();
312
UtilTransactions utilTrans(*ctx->getTab());
313
HugoTransactions hugoTrans(*ctx->getTab());
314
while(i<=loops && result != NDBT_FAILED){
316
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
318
1. Start LCP, turn on undologging but delay write of datapages.
319
2. Insert, update, delete records
320
3. Complete writing of data pages and finish LCP.
321
4. Restart cluster and verify records
323
// Use dump state 7080 to delay writing of datapages
324
// for the current table
325
ndbout << "Dump state: "<<dump7080[0]<<", "<<dump7080[1]<<endl;
326
CHECK(restarter.dumpStateAllNodes(dump7080, 2) == 0);
327
NdbSleep_SecSleep(10);
329
ndbout << "Doing it all..." << endl;
330
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
331
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
332
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
333
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
334
CHECK(utilTrans.clearTable(pNdb, records) == 0);
335
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
336
CHECK(utilTrans.clearTable(pNdb, records) == 0);
338
// Reset error and let LCP continue
339
CHECK(restarter.insertErrorInAllNodes(0) == 0);
340
NdbSleep_SecSleep(60);
342
ndbout << "Restarting cluster..." << endl;
343
CHECK(restarter.restartAll() == 0);
344
CHECK(restarter.waitClusterStarted(timeout) == 0);
345
CHECK(pNdb->waitUntilReady(timeout) == 0);
347
ndbout << "Verifying records..." << endl;
348
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
351
// Use dump state 7080 to delay writing of datapages
352
// for the current table
353
ndbout << "Dump state: "<<dump7080[0]<<", "<<dump7080[1]<<endl;
354
CHECK(restarter.dumpStateAllNodes(dump7080, 2) == 0);
355
NdbSleep_SecSleep(10);
357
ndbout << "Doing it all, delete 50%..." << endl;
358
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
359
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
360
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
362
// Reset error and let LCP continue
363
CHECK(restarter.insertErrorInAllNodes(0) == 0);
364
NdbSleep_SecSleep(20);
366
ndbout << "Restarting cluster..." << endl;
367
CHECK(restarter.restartAll() == 0);
368
CHECK(restarter.waitClusterStarted(timeout) == 0);
369
CHECK(pNdb->waitUntilReady(timeout) == 0);
371
ndbout << "Verifying records..." << endl;
372
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
373
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
374
CHECK(count == (records/2));
375
CHECK(utilTrans.clearTable(pNdb, records) == 0);
380
ndbout << "runSystemRestartTestUndoLog finished" << endl;
385
int runSystemRestartTestFullDb(NDBT_Context* ctx, NDBT_Step* step){
386
Ndb* pNdb = GETNDB(step);
387
int result = NDBT_OK;
389
Uint32 loops = ctx->getNumLoops();
391
NdbRestarter restarter;
394
UtilTransactions utilTrans(*ctx->getTab());
395
HugoTransactions hugoTrans(*ctx->getTab());
396
while(i<=loops && result != NDBT_FAILED){
398
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
400
1. Load data until db reports it's full
401
2. Restart cluster and verify records
403
ndbout << "Filling up table..." << endl;
404
CHECK(hugoTrans.fillTable(pNdb) == 0);
405
CHECK(utilTrans.selectCount(pNdb, 64, &count1) == 0);
406
ndbout << "Db is full. Table has "<<count1 <<" records."<< endl;
408
ndbout << "Restarting cluster" << endl;
409
CHECK(restarter.restartAll() == 0);
410
CHECK(restarter.waitClusterStarted(timeout) == 0);
411
CHECK(pNdb->waitUntilReady(timeout) == 0);
413
ndbout << "Verifying records..." << endl;
414
CHECK(hugoTrans.scanReadRecords(pNdb, count1) == 0);
415
CHECK(utilTrans.selectCount(pNdb, 64, &count2) == 0);
416
CHECK(count1 == count2);
418
ndbout << "Deleting all records..." << endl;
419
CHECK(utilTrans.clearTable2(pNdb, count1) == 0);
421
ndbout << "Restarting cluster..." << endl;
422
CHECK(restarter.restartAll() == 0);
423
CHECK(restarter.waitClusterStarted(timeout) == 0);
424
CHECK(pNdb->waitUntilReady(timeout) == 0);
426
ndbout << "Verifying records..." << endl;
427
CHECK(utilTrans.selectCount(pNdb, 64, &count1) == 0);
433
ndbout << "runSystemRestartTestFullDb finished" << endl;
438
int runSystemRestart3(NDBT_Context* ctx, NDBT_Step* step){
439
Ndb* pNdb = GETNDB(step);
440
int result = NDBT_OK;
442
Uint32 loops = ctx->getNumLoops();
443
int records = ctx->getNumRecords();
445
NdbRestarter restarter;
448
const Uint32 nodeCount = restarter.getNumDbNodes();
450
g_info << "SR3 - Needs atleast 2 nodes to test" << endl;
455
for(i = 0; i<nodeCount; i++)
456
nodeIds.push_back(restarter.getDbNodeId(i));
458
Uint32 currentRestartNodeIndex = 0;
459
UtilTransactions utilTrans(*ctx->getTab());
460
HugoTransactions hugoTrans(*ctx->getTab());
462
while(i<=loops && result != NDBT_FAILED){
464
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
467
* 2. Restart 1 node -nostart
469
* 4. Restart cluster and verify records
470
* 5. Restart 1 node -nostart
471
* 6. Delete half of the records
472
* 7. Restart cluster and verify records
473
* 8. Restart 1 node -nostart
474
* 9. Delete all records
475
* 10. Restart cluster and verify records
477
g_info << "Loading records..." << endl;
478
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
481
g_info << "1 - Stopping one node" << endl;
482
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
486
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
488
g_info << "Updating records..." << endl;
489
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
491
g_info << "Restarting cluster..." << endl;
492
CHECK(restarter.restartAll() == 0);
493
CHECK(restarter.waitClusterStarted(timeout) == 0);
494
CHECK(pNdb->waitUntilReady(timeout) == 0);
496
g_info << "Verifying records..." << endl;
497
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
498
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
499
CHECK(count == records);
501
g_info << "2 - Stopping one node" << endl;
502
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
506
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
508
g_info << "Deleting 50% of records..." << endl;
509
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
511
g_info << "Restarting cluster..." << endl;
512
CHECK(restarter.restartAll() == 0);
513
CHECK(restarter.waitClusterStarted(timeout) == 0);
514
CHECK(pNdb->waitUntilReady(timeout) == 0);
516
g_info << "Verifying records..." << endl;
517
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
518
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
519
CHECK(count == (records/2));
521
g_info << "3 - Stopping one node" << endl;
522
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
526
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
527
g_info << "Deleting all records..." << endl;
528
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
530
g_info << "Restarting cluster..." << endl;
531
CHECK(restarter.restartAll() == 0);
532
CHECK(restarter.waitClusterStarted(timeout) == 0);
533
CHECK(pNdb->waitUntilReady(timeout) == 0);
535
ndbout << "Verifying records..." << endl;
536
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
542
g_info << "runSystemRestart3 finished" << endl;
547
int runSystemRestart4(NDBT_Context* ctx, NDBT_Step* step){
548
Ndb* pNdb = GETNDB(step);
549
int result = NDBT_OK;
551
Uint32 loops = ctx->getNumLoops();
552
int records = ctx->getNumRecords();
554
NdbRestarter restarter;
557
const Uint32 nodeCount = restarter.getNumDbNodes();
559
g_info << "SR4 - Needs atleast 2 nodes to test" << endl;
564
for(i = 0; i<nodeCount; i++)
565
nodeIds.push_back(restarter.getDbNodeId(i));
567
Uint32 currentRestartNodeIndex = 0;
568
UtilTransactions utilTrans(*ctx->getTab());
569
HugoTransactions hugoTrans(*ctx->getTab());
572
int val = DumpStateOrd::DihMinTimeBetweenLCP;
573
if(restarter.dumpStateAllNodes(&val, 1) != 0){
574
g_err << "ERR: "<< step->getName()
575
<< " failed on line " << __LINE__ << endl;
580
while(i<=loops && result != NDBT_FAILED){
582
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
585
* 2. Restart 1 node -nostart
587
* 4. Restart cluster and verify records
588
* 5. Restart 1 node -nostart
589
* 6. Delete half of the records
590
* 7. Restart cluster and verify records
591
* 8. Restart 1 node -nostart
592
* 9. Delete all records
593
* 10. Restart cluster and verify records
595
g_info << "Loading records..." << endl;
596
CHECK(hugoTrans.loadTable(pNdb, records) == 0);
599
g_info << "1 - Stopping one node" << endl;
600
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
604
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
606
g_info << "Updating records..." << endl;
607
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
609
g_info << "Restarting cluster..." << endl;
610
CHECK(restarter.restartAll() == 0);
611
CHECK(restarter.waitClusterStarted(timeout) == 0);
613
int val = DumpStateOrd::DihMinTimeBetweenLCP;
614
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
616
CHECK(pNdb->waitUntilReady(timeout) == 0);
618
g_info << "Verifying records..." << endl;
619
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
620
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
621
CHECK(count == records);
623
g_info << "2 - Stopping one node" << endl;
624
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
628
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
630
g_info << "Deleting 50% of records..." << endl;
631
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
633
g_info << "Restarting cluster..." << endl;
634
CHECK(restarter.restartAll() == 0);
635
CHECK(restarter.waitClusterStarted(timeout) == 0);
637
int val = DumpStateOrd::DihMinTimeBetweenLCP;
638
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
640
CHECK(pNdb->waitUntilReady(timeout) == 0);
642
g_info << "Verifying records..." << endl;
643
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
644
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
645
CHECK(count == (records/2));
647
g_info << "3 - Stopping one node" << endl;
648
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
652
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
653
g_info << "Deleting all records..." << endl;
654
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
656
g_info << "Restarting cluster..." << endl;
657
CHECK(restarter.restartAll() == 0);
658
CHECK(restarter.waitClusterStarted(timeout) == 0);
660
int val = DumpStateOrd::DihMinTimeBetweenLCP;
661
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
663
CHECK(pNdb->waitUntilReady(timeout) == 0);
665
ndbout << "Verifying records..." << endl;
666
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
672
g_info << "runSystemRestart4 finished" << endl;
677
int runSystemRestart5(NDBT_Context* ctx, NDBT_Step* step){
678
Ndb* pNdb = GETNDB(step);
679
int result = NDBT_OK;
681
Uint32 loops = ctx->getNumLoops();
682
int records = ctx->getNumRecords();
684
NdbRestarter restarter;
687
const Uint32 nodeCount = restarter.getNumDbNodes();
689
g_info << "SR5 - Needs atleast 2 nodes to test" << endl;
694
for(i = 0; i<nodeCount; i++)
695
nodeIds.push_back(restarter.getDbNodeId(i));
697
Uint32 currentRestartNodeIndex = 0;
698
UtilTransactions utilTrans(*ctx->getTab());
699
HugoTransactions hugoTrans(*ctx->getTab());
702
int val = DumpStateOrd::DihMinTimeBetweenLCP;
703
if(restarter.dumpStateAllNodes(&val, 1) != 0){
704
g_err << "ERR: "<< step->getName()
705
<< " failed on line " << __LINE__ << endl;
710
while(i<=loops && result != NDBT_FAILED){
712
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
715
* 2. Restart 1 node -nostart
717
* 4. Restart cluster and verify records
718
* 5. Restart 1 node -nostart
719
* 6. Delete half of the records
720
* 7. Restart cluster and verify records
721
* 8. Restart 1 node -nostart
722
* 9. Delete all records
723
* 10. Restart cluster and verify records
725
g_info << "Loading records..." << endl;
726
hugoTrans.loadTable(pNdb, records);
729
g_info << "1 - Stopping one node" << endl;
730
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
734
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
736
g_info << "Updating records..." << endl;
737
hugoTrans.pkUpdateRecords(pNdb, records);
739
g_info << "Restarting cluster..." << endl;
740
CHECK(restarter.restartAll(false, false, true) == 0);
741
CHECK(restarter.waitClusterStarted(timeout) == 0);
743
int val = DumpStateOrd::DihMinTimeBetweenLCP;
744
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
746
CHECK(pNdb->waitUntilReady(timeout) == 0);
748
g_info << "Verifying records..." << endl;
749
hugoTrans.pkReadRecords(pNdb, records);
750
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
751
//CHECK(count == records);
753
g_info << "2 - Stopping one node" << endl;
754
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
758
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
760
g_info << "Deleting 50% of records..." << endl;
761
hugoTrans.pkDelRecords(pNdb, records/2);
763
g_info << "Restarting cluster..." << endl;
764
CHECK(restarter.restartAll(false, false, true) == 0);
765
CHECK(restarter.waitClusterStarted(timeout) == 0);
767
int val = DumpStateOrd::DihMinTimeBetweenLCP;
768
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
770
CHECK(pNdb->waitUntilReady(timeout) == 0);
772
g_info << "Verifying records..." << endl;
773
hugoTrans.scanReadRecords(pNdb, records/2, 0, 64);
774
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
775
//CHECK(count == (records/2));
777
g_info << "3 - Stopping one node" << endl;
778
CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
782
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
783
g_info << "Deleting all records..." << endl;
784
utilTrans.clearTable(pNdb, records/2);
786
g_info << "Restarting cluster..." << endl;
787
CHECK(restarter.restartAll(false, false, true) == 0);
788
CHECK(restarter.waitClusterStarted(timeout) == 0);
790
int val = DumpStateOrd::DihMinTimeBetweenLCP;
791
CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
793
CHECK(pNdb->waitUntilReady(timeout) == 0);
795
ndbout << "Verifying records..." << endl;
796
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
799
CHECK(utilTrans.clearTable(pNdb) == 0);
803
g_info << "runSystemRestart5 finished" << endl;
808
int runSystemRestart6(NDBT_Context* ctx, NDBT_Step* step){
809
Ndb* pNdb = GETNDB(step);
810
int result = NDBT_OK;
812
Uint32 loops = ctx->getNumLoops();
813
int records = ctx->getNumRecords();
814
NdbRestarter restarter;
817
const Uint32 nodeCount = restarter.getNumDbNodes();
819
g_info << "SR6 - Needs atleast 2 nodes to test" << endl;
824
for(i = 0; i<nodeCount; i++)
825
nodeIds.push_back(restarter.getDbNodeId(i));
827
Uint32 currentRestartNodeIndex = 0;
828
UtilTransactions utilTrans(*ctx->getTab());
829
HugoTransactions hugoTrans(*ctx->getTab());
831
while(i<=loops && result != NDBT_FAILED){
833
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
836
* 2. Restart all node -nostart
837
* 3. Restart some nodes -i -nostart
838
* 4. Start all nodes verify records
840
g_info << "Loading records..." << endl;
841
hugoTrans.loadTable(pNdb, records);
843
CHECK(restarter.restartAll(false, true, false) == 0);
845
Uint32 nodeId = nodeIds[currentRestartNodeIndex];
846
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
848
CHECK(restarter.restartOneDbNode(nodeId, true, true,false) == 0);
849
CHECK(restarter.waitClusterNoStart(timeout) == 0);
850
CHECK(restarter.startAll() == 0);
851
CHECK(restarter.waitClusterStarted(timeout) == 0);
852
CHECK(pNdb->waitUntilReady(timeout) == 0);
853
int count = records - 1;
854
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
855
CHECK(count == records);
856
CHECK(utilTrans.clearTable(pNdb) == 0);
860
g_info << "runSystemRestart6 finished" << endl;
865
int runSystemRestart7(NDBT_Context* ctx, NDBT_Step* step){
866
Ndb* pNdb = GETNDB(step);
867
int result = NDBT_OK;
868
Uint32 loops = ctx->getNumLoops();
869
int records = ctx->getNumRecords();
870
NdbRestarter restarter;
873
const Uint32 nodeCount = restarter.getNumDbNodes();
875
g_info << "SR7 - Needs atleast 2 nodes to test" << endl;
880
for(i = 0; i<nodeCount; i++)
881
nodeIds.push_back(restarter.getDbNodeId(i));
887
Uint32 currentRestartNodeIndex = 1;
888
UtilTransactions utilTrans(*ctx->getTab());
889
HugoTransactions hugoTrans(*ctx->getTab());
891
while(i<=loops && result != NDBT_FAILED){
893
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
896
* 2. Restart all node -nostart
897
* 3. Start all but one node
898
* 4. Wait for startphase >= 2
902
g_info << "Loading records..." << endl;
903
hugoTrans.loadTable(pNdb, records);
905
CHECK(restarter.restartAll(false, true, false) == 0);
907
int nodeId = nodeIds[currentRestartNodeIndex];
908
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
911
for(Uint32 k = 0; k<nodeCount; k++){
912
if(nodeIds[k] != nodeId){
913
a_nodeIds[j++] = nodeIds[k];
917
CHECK(restarter.startNodes(a_nodeIds, nodeCount - 1) == 0);
918
CHECK(restarter.waitNodesStarted(a_nodeIds, nodeCount - 1, 120) == 0);
919
CHECK(pNdb->waitUntilReady(5) == 0);
920
int count = records - 1;
921
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
922
CHECK(count == records);
924
CHECK(restarter.startNodes(&nodeId, 1) == 0);
925
CHECK(restarter.waitNodesStarted(&nodeId, 1, 120) == 0);
927
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
928
CHECK(count == records);
929
CHECK(utilTrans.clearTable(pNdb) == 0);
934
g_info << "runSystemRestart7 finished" << endl;
939
int runSystemRestart8(NDBT_Context* ctx, NDBT_Step* step){
940
Ndb* pNdb = GETNDB(step);
941
int result = NDBT_OK;
943
Uint32 loops = ctx->getNumLoops();
944
int records = ctx->getNumRecords();
945
NdbRestarter restarter;
948
const Uint32 nodeCount = restarter.getNumDbNodes();
950
g_info << "SR8 - Needs atleast 2 nodes to test" << endl;
955
for(i = 0; i<nodeCount; i++)
956
nodeIds.push_back(restarter.getDbNodeId(i));
962
Uint32 currentRestartNodeIndex = 1;
963
UtilTransactions utilTrans(*ctx->getTab());
964
HugoTransactions hugoTrans(*ctx->getTab());
966
while(i<=loops && result != NDBT_FAILED){
968
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
971
* 2. Restart all node -nostart
972
* 3. Start all but one node
977
g_info << "Loading records..." << endl;
978
hugoTrans.loadTable(pNdb, records);
980
CHECK(restarter.restartAll(false, true, false) == 0);
982
int nodeId = nodeIds[currentRestartNodeIndex];
983
currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
986
for(Uint32 k = 0; k<nodeCount; k++){
987
if(nodeIds[k] != nodeId){
988
a_nodeIds[j++] = nodeIds[k];
992
CHECK(restarter.startNodes(a_nodeIds, nodeCount-1) == 0);
993
CHECK(restarter.waitNodesStartPhase(a_nodeIds, nodeCount-1, 3, 120) == 0);
994
CHECK(restarter.startNodes(&nodeId, 1) == 0);
995
CHECK(restarter.waitClusterStarted(timeout) == 0);
997
int count = records - 1;
998
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
999
CHECK(count == records);
1000
CHECK(utilTrans.clearTable(pNdb) == 0);
1004
g_info << "runSystemRestart8 finished" << endl;
1009
int runSystemRestart9(NDBT_Context* ctx, NDBT_Step* step){
1010
Ndb* pNdb = GETNDB(step);
1011
int result = NDBT_OK;
1013
Uint32 loops = ctx->getNumLoops();
1014
int records = ctx->getNumRecords();
1015
NdbRestarter restarter;
1018
Uint32 currentRestartNodeIndex = 1;
1019
UtilTransactions utilTrans(*ctx->getTab());
1020
HugoTransactions hugoTrans(*ctx->getTab());
1022
int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
1023
int dump[] = { DumpStateOrd::DihStartLcpImmediately };
1026
CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
1028
HugoOperations ops(* ctx->getTab());
1029
CHECK(ops.startTransaction(pNdb) == 0);
1030
for(i = 0; i<10; i++){
1031
CHECK(ops.pkInsertRecord(pNdb, i, 1, 1) == 0);
1032
CHECK(ops.execute_NoCommit(pNdb) == 0);
1034
for(i = 0; i<10; i++){
1035
CHECK(ops.pkUpdateRecord(pNdb, i, 1) == 0);
1036
CHECK(ops.execute_NoCommit(pNdb) == 0);
1038
NdbSleep_SecSleep(10);
1039
CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
1040
NdbSleep_SecSleep(10);
1041
CHECK(ops.execute_Commit(pNdb) == 0);
1043
CHECK(restarter.restartAll() == 0);
1044
CHECK(restarter.waitClusterStarted(timeout) == 0);
1045
CHECK(pNdb->waitUntilReady(timeout) == 0);
1046
ops.closeTransaction(pNdb);
1049
g_info << "runSystemRestart9 finished" << endl;
1054
int runBug18385(NDBT_Context* ctx, NDBT_Step* step){
1055
NdbRestarter restarter;
1056
const Uint32 nodeCount = restarter.getNumDbNodes();
1058
g_info << "Bug18385 - Needs atleast 2 nodes to test" << endl;
1062
int node1 = restarter.getDbNodeId(rand() % nodeCount);
1063
int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
1065
if (node1 == -1 || node2 == -1)
1068
int dump[] = { DumpStateOrd::DihSetTimeBetweenGcp, 300 };
1070
int result = NDBT_OK;
1072
CHECK(restarter.dumpStateAllNodes(dump, 2) == 0);
1073
CHECK(restarter.restartOneDbNode(node1, false, true, false) == 0);
1074
NdbSleep_SecSleep(3);
1075
CHECK(restarter.restartAll(false, true, false) == 0);
1079
for(Uint32 i = 0; i<nodeCount; i++)
1080
if ((nodes[cnt] = restarter.getDbNodeId(i)) != node2)
1083
assert(cnt == nodeCount - 1);
1085
CHECK(restarter.startNodes(nodes, cnt) == 0);
1086
CHECK(restarter.waitNodesStarted(nodes, cnt, 300) == 0);
1088
CHECK(restarter.insertErrorInNode(node2, 7170) == 0);
1089
CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);
1090
CHECK(restarter.restartOneDbNode(node2, true, false, true) == 0);
1091
CHECK(restarter.waitNodesStarted(&node2, 1) == 0);
1095
g_info << "Bug18385 finished" << endl;
1100
int runWaitStarted(NDBT_Context* ctx, NDBT_Step* step){
1102
NdbRestarter restarter;
1103
restarter.waitClusterStarted(300);
1105
NdbSleep_SecSleep(3);
1109
int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
1110
int records = ctx->getNumRecords();
1112
Ndb* pNdb = GETNDB(step);
1113
if(pNdb->waitUntilReady(5) != 0){
1117
UtilTransactions utilTrans(*ctx->getTab());
1118
if (utilTrans.clearTable2(pNdb, records) != 0){
1125
runBug21536(NDBT_Context* ctx, NDBT_Step* step)
1127
NdbRestarter restarter;
1128
const Uint32 nodeCount = restarter.getNumDbNodes();
1130
g_info << "Bug21536 - 2 nodes to test" << endl;
1134
int node1 = restarter.getDbNodeId(rand() % nodeCount);
1135
int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
1137
if (node1 == -1 || node2 == -1)
1140
int result = NDBT_OK;
1142
CHECK(restarter.restartOneDbNode(node1, false, true, true) == 0);
1143
CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
1144
CHECK(restarter.insertErrorInNode(node1, 1000) == 0);
1145
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1146
CHECK(restarter.dumpStateOneNode(node1, val2, 2) == 0);
1147
CHECK(restarter.startNodes(&node1, 1) == 0);
1148
restarter.waitNodesStartPhase(&node1, 1, 3, 120);
1149
CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
1151
CHECK(restarter.restartOneDbNode(node2, true, true, true) == 0);
1152
CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);
1153
CHECK(restarter.startNodes(&node1, 1) == 0);
1154
CHECK(restarter.waitNodesStarted(&node1, 1) == 0);
1155
CHECK(restarter.startNodes(&node2, 1) == 0);
1156
CHECK(restarter.waitClusterStarted() == 0);
1160
g_info << "Bug21536 finished" << endl;
1166
runBug24664(NDBT_Context* ctx, NDBT_Step* step)
1168
int result = NDBT_OK;
1169
NdbRestarter restarter;
1170
Ndb* pNdb = GETNDB(step);
1171
const Uint32 nodeCount = restarter.getNumDbNodes();
1173
int records = ctx->getNumRecords();
1174
UtilTransactions utilTrans(*ctx->getTab());
1175
HugoTransactions hugoTrans(*ctx->getTab());
1177
int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
1178
int dump[] = { DumpStateOrd::DihStartLcpImmediately };
1180
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
1181
NdbLogEventHandle handle =
1182
ndb_mgm_create_logevent_handle(restarter.handle, filter);
1184
struct ndb_logevent event;
1187
CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
1188
CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
1189
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1190
event.type != NDB_LE_LocalCheckpointStarted);
1191
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1192
event.type != NDB_LE_LocalCheckpointCompleted);
1194
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
1198
restarter.insertErrorInAllNodes(10036); // Hang LCP
1199
CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
1200
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1201
event.type != NDB_LE_LocalCheckpointStarted);
1202
NdbSleep_SecSleep(3);
1203
CHECK(utilTrans.clearTable(pNdb, records) == 0);
1204
if (hugoTrans.loadTable(GETNDB(step), records) != 0){
1208
restarter.insertErrorInAllNodes(10037); // Resume LCP
1209
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1210
event.type != NDB_LE_LocalCheckpointCompleted);
1212
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1213
event.type != NDB_LE_GlobalCheckpointCompleted);
1214
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1215
event.type != NDB_LE_GlobalCheckpointCompleted);
1216
restarter.restartAll(false, false, true);
1217
CHECK(restarter.waitClusterStarted() == 0);
1224
runBug29167(NDBT_Context* ctx, NDBT_Step* step)
1226
int result = NDBT_OK;
1227
NdbRestarter restarter;
1228
Ndb* pNdb = GETNDB(step);
1229
const Uint32 nodeCount = restarter.getNumDbNodes();
1234
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
1235
NdbLogEventHandle handle =
1236
ndb_mgm_create_logevent_handle(restarter.handle, filter);
1238
struct ndb_logevent event;
1239
int master = restarter.getMasterNodeId();
1241
int node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());
1242
int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
1244
int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1245
restarter.dumpStateAllNodes(val2, 2);
1246
int dump[] = { DumpStateOrd::DihSetTimeBetweenGcp, 30000 };
1247
restarter.dumpStateAllNodes(dump, 2);
1249
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1250
event.type != NDB_LE_GlobalCheckpointCompleted);
1252
CHECK(restarter.insertErrorInAllNodes(932) == 0);
1254
CHECK(restarter.insertErrorInNode(node1, 7183) == 0);
1255
CHECK(restarter.insertErrorInNode(node2, 7183) == 0);
1257
CHECK(restarter.waitClusterNoStart() == 0);
1258
restarter.startAll();
1259
CHECK(restarter.waitClusterStarted() == 0);
1266
runBug28770(NDBT_Context* ctx, NDBT_Step* step) {
1267
Ndb* pNdb = GETNDB(step);
1268
NdbRestarter restarter;
1269
int result = NDBT_OK;
1272
Uint32 loops = ctx->getNumLoops();
1273
int records = ctx->getNumRecords();
1274
UtilTransactions utilTrans(*ctx->getTab());
1275
HugoTransactions hugoTrans(*ctx->getTab());
1277
g_info << "Loading records..." << endl; hugoTrans.loadTable(pNdb,
1281
while(i<=loops && result != NDBT_FAILED){
1282
g_info << "Loop " << i << "/"<< loops <<" started" << endl;
1283
CHECK(restarter.restartAll(false, true, false) == 0);
1284
NdbSleep_SecSleep(3);
1285
CHECK(restarter.waitClusterNoStart() == 0);
1286
restarter.insertErrorInAllNodes(6007);
1287
CHECK(restarter.startAll()== 0);
1288
CHECK(restarter.waitClusterStarted() == 0);
1289
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1290
CHECK(count == records);
1293
ndbout << " runBug28770 finished" << endl;
1298
runStopper(NDBT_Context* ctx, NDBT_Step* step)
1300
NdbRestarter restarter;
1303
while (!ctx->isTestStopped() &&
1304
((stop = ctx->getProperty("StopAbort", Uint32(0))) == 0))
1306
NdbSleep_MilliSleep(30);
1309
if (ctx->isTestStopped())
1314
ndbout << "Killing in " << stop << "ms..." << flush;
1315
NdbSleep_MilliSleep(stop);
1316
restarter.restartAll(false, true, true);
1317
ctx->setProperty("StopAbort", Uint32(0));
1321
int runSR_DD_1(NDBT_Context* ctx, NDBT_Step* step)
1323
Ndb* pNdb = GETNDB(step);
1324
int result = NDBT_OK;
1325
Uint32 loops = ctx->getNumLoops();
1327
NdbRestarter restarter;
1328
NdbBackup backup(GETNDB(step)->getNodeId()+1);
1329
bool lcploop = ctx->getProperty("LCP", (unsigned)0);
1330
bool all = ctx->getProperty("ALL", (unsigned)0);
1335
int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1336
int lcp = DumpStateOrd::DihMinTimeBetweenLCP;
1340
HugoTransactions hugoTrans(*ctx->getTab());
1341
while(i<=loops && result != NDBT_FAILED)
1346
CHECK(restarter.dumpStateAllNodes(&lcp, 1) == 0);
1349
int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
1350
//CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
1352
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
1353
ndbout << "Loading records..." << startFrom << endl;
1354
CHECK(hugoTrans.loadTable(pNdb, startFrom) == 0);
1358
ndbout << "Making " << nodeId << " crash" << endl;
1359
int kill[] = { 9999, 1000, 3000 };
1360
CHECK(restarter.dumpStateOneNode(nodeId, val, 2) == 0);
1361
CHECK(restarter.dumpStateOneNode(nodeId, kill, 3) == 0);
1365
ndbout << "Crashing cluster" << endl;
1366
ctx->setProperty("StopAbort", 1000 + rand() % (3000 - 1000));
1368
Uint64 end = NdbTick_CurrentMillisecond() + 4000;
1369
Uint32 row = startFrom;
1371
ndbout << "Loading from " << row << " to " << row + 1000 << endl;
1372
if (hugoTrans.loadTableStartFrom(pNdb, row, 1000) != 0)
1375
} while (NdbTick_CurrentMillisecond() < end);
1379
ndbout << "Waiting for " << nodeId << " to restart" << endl;
1380
CHECK(restarter.waitNodesNoStart(&nodeId, 1) == 0);
1381
ndbout << "Restarting cluster" << endl;
1382
CHECK(restarter.restartAll(false, true, true) == 0);
1386
ndbout << "Waiting for cluster to restart" << endl;
1388
CHECK(restarter.waitClusterNoStart() == 0);
1389
CHECK(restarter.startAll() == 0);
1390
CHECK(restarter.waitClusterStarted() == 0);
1392
ndbout << "Starting backup..." << flush;
1393
CHECK(backup.start(backupId) == 0);
1394
ndbout << "done" << endl;
1397
CHECK(hugoTrans.selectCount(pNdb, 0, &cnt) == 0);
1398
ndbout << "Found " << cnt << " records..." << endl;
1399
ndbout << "Clearing..." << endl;
1400
CHECK(hugoTrans.clearTable(pNdb,
1401
NdbScanOperation::SF_TupScan, cnt) == 0);
1403
if (cnt > startFrom)
1411
ndbout << "runSR_DD_1 finished" << endl;
1416
int runSR_DD_2(NDBT_Context* ctx, NDBT_Step* step)
1418
Ndb* pNdb = GETNDB(step);
1419
int result = NDBT_OK;
1420
Uint32 loops = ctx->getNumLoops();
1421
Uint32 rows = ctx->getNumRecords();
1423
NdbRestarter restarter;
1424
NdbBackup backup(GETNDB(step)->getNodeId()+1);
1425
bool lcploop = ctx->getProperty("LCP", (unsigned)0);
1426
bool all = ctx->getProperty("ALL", (unsigned)0);
1431
int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1432
int lcp = DumpStateOrd::DihMinTimeBetweenLCP;
1436
HugoTransactions hugoTrans(*ctx->getTab());
1437
while(i<=loops && result != NDBT_FAILED)
1442
CHECK(restarter.dumpStateAllNodes(&lcp, 1) == 0);
1445
int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
1449
ndbout << "Making " << nodeId << " crash" << endl;
1450
int kill[] = { 9999, 3000, 10000 };
1451
CHECK(restarter.dumpStateOneNode(nodeId, val, 2) == 0);
1452
CHECK(restarter.dumpStateOneNode(nodeId, kill, 3) == 0);
1456
ndbout << "Crashing cluster" << endl;
1457
ctx->setProperty("StopAbort", 1000 + rand() % (3000 - 1000));
1460
Uint64 end = NdbTick_CurrentMillisecond() + 11000;
1461
Uint32 row = startFrom;
1463
if (hugoTrans.loadTable(pNdb, rows) != 0)
1466
if (hugoTrans.clearTable(pNdb, NdbScanOperation::SF_TupScan, rows) != 0)
1468
} while (NdbTick_CurrentMillisecond() < end);
1472
ndbout << "Waiting for " << nodeId << " to restart" << endl;
1473
CHECK(restarter.waitNodesNoStart(&nodeId, 1) == 0);
1474
ndbout << "Restarting cluster" << endl;
1475
CHECK(restarter.restartAll(false, true, true) == 0);
1479
ndbout << "Waiting for cluster to restart" << endl;
1482
CHECK(restarter.waitClusterNoStart() == 0);
1483
CHECK(restarter.startAll() == 0);
1484
CHECK(restarter.waitClusterStarted() == 0);
1486
ndbout << "Starting backup..." << flush;
1487
CHECK(backup.start(backupId) == 0);
1488
ndbout << "done" << endl;
1491
CHECK(hugoTrans.selectCount(pNdb, 0, &cnt) == 0);
1492
ndbout << "Found " << cnt << " records..." << endl;
1493
ndbout << "Clearing..." << endl;
1494
CHECK(hugoTrans.clearTable(pNdb,
1495
NdbScanOperation::SF_TupScan, cnt) == 0);
1499
ndbout << "runSR_DD_2 finished" << endl;
1504
int runBug22696(NDBT_Context* ctx, NDBT_Step* step)
1506
Ndb* pNdb = GETNDB(step);
1507
int result = NDBT_OK;
1508
Uint32 loops = ctx->getNumLoops();
1509
Uint32 rows = ctx->getNumRecords();
1510
NdbRestarter restarter;
1511
HugoTransactions hugoTrans(*ctx->getTab());
1514
while(i<=loops && result != NDBT_FAILED)
1516
for (Uint32 j = 0; j<10 && result != NDBT_FAILED; j++)
1517
CHECK(hugoTrans.scanUpdateRecords(pNdb, rows) == 0);
1519
CHECK(restarter.restartAll(false, true, i > 0 ? true : false) == 0);
1520
CHECK(restarter.waitClusterNoStart() == 0);
1521
CHECK(restarter.insertErrorInAllNodes(7072) == 0);
1522
CHECK(restarter.startAll() == 0);
1523
CHECK(restarter.waitClusterStarted() == 0);
1528
NdbSleep_SecSleep(5); // Wait for a few gcp
1537
runBug27434(NDBT_Context* ctx, NDBT_Step* step)
1539
int result = NDBT_OK;
1540
NdbRestarter restarter;
1541
Ndb* pNdb = GETNDB(step);
1542
const Uint32 nodeCount = restarter.getNumDbNodes();
1547
int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
1548
int dump[] = { DumpStateOrd::DihStartLcpImmediately };
1550
int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
1551
NdbLogEventHandle handle =
1552
ndb_mgm_create_logevent_handle(restarter.handle, filter);
1554
struct ndb_logevent event;
1557
int node1 = restarter.getDbNodeId(rand() % nodeCount);
1558
CHECK(restarter.restartOneDbNode(node1, false, true, true) == 0);
1559
NdbSleep_SecSleep(3);
1560
CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
1562
CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
1564
for (Uint32 i = 0; i<3; i++)
1566
CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
1567
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1568
event.type != NDB_LE_LocalCheckpointStarted);
1569
while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1570
event.type != NDB_LE_LocalCheckpointCompleted);
1573
restarter.restartAll(false, true, true);
1574
NdbSleep_SecSleep(3);
1575
CHECK(restarter.waitClusterNoStart() == 0);
1576
restarter.insertErrorInNode(node1, 5046);
1577
restarter.startAll();
1578
CHECK(restarter.waitClusterStarted() == 0);
1584
NDBT_TESTSUITE(testSystemRestart);
1586
"Basic system restart test. Focus on testing restart from REDO log.\n"
1587
"NOTE! Time between lcp's and gcp's should be left at default, \n"
1588
"so that Ndb uses the Redo log when restarting\n"
1590
"2. Restart cluster and verify records \n"
1591
"3. Update records\n"
1592
"4. Restart cluster and verify records \n"
1593
"5. Delete half of the records \n"
1594
"6. Restart cluster and verify records \n"
1595
"7. Delete all records \n"
1596
"8. Restart cluster and verify records \n"
1597
"9. Insert, update, delete records \n"
1598
"10. Restart cluster and verify records\n"
1599
"11. Insert, update, delete records \n"
1600
"12. Restart cluster with error insert 5020 and verify records\n"){
1601
INITIALIZER(runWaitStarted);
1602
STEP(runSystemRestart1);
1603
FINALIZER(runClearTable);
1606
"Basic system restart test. Focus on testing restart from LCP\n"
1607
"NOTE! Time between lcp's is automatically set to it's min value\n"
1608
"so that Ndb uses LCP's when restarting.\n"
1610
"2. Restart cluster and verify records \n"
1611
"3. Update records\n"
1612
"4. Restart cluster and verify records \n"
1613
"5. Delete half of the records \n"
1614
"6. Restart cluster and verify records \n"
1615
"7. Delete all records \n"
1616
"8. Restart cluster and verify records \n"
1617
"9. Insert, update, delete records \n"
1618
"10. Restart cluster and verify records\n"){
1619
INITIALIZER(runWaitStarted);
1620
STEP(runSystemRestart2);
1621
FINALIZER(runClearTable);
1624
"System restart test. Focus on testing of undologging\n"
1625
"in DBACC and DBTUP.\n"
1626
"This is done by starting a LCP, turn on undologging \n"
1627
"but don't start writing the datapages. This will force all\n"
1628
"operations to be written into the undolog.\n"
1629
"Then write datapages and complete LCP.\n"
1630
"Restart the system\n"){
1631
INITIALIZER(runWaitStarted);
1632
STEP(runSystemRestartTestUndoLog);
1633
FINALIZER(runClearTable);
1635
TESTCASE("SR_FULLDB",
1636
"System restart test. Test to restart when DB is full.\n"){
1637
INITIALIZER(runWaitStarted);
1638
STEP(runSystemRestartTestFullDb);
1639
FINALIZER(runClearTable);
1642
"System restart test. Focus on testing restart from with\n"
1643
"not all nodes alive when system went down\n"
1645
"* 2. Restart 1 node -nostart\n"
1646
"* 3. Update records\n"
1647
"* 4. Restart cluster and verify records\n"
1648
"* 5. Restart 1 node -nostart\n"
1649
"* 6. Delete half of the records\n"
1650
"* 7. Restart cluster and verify records\n"
1651
"* 8. Restart 1 node -nostart\n"
1652
"* 9. Delete all records\n"
1653
"* 10. Restart cluster and verify records\n"){
1654
INITIALIZER(runWaitStarted);
1655
STEP(runSystemRestart3);
1656
FINALIZER(runClearTable);
1659
"System restart test. Focus on testing restart from with\n"
1660
"not all nodes alive when system went down but running LCP at\n"
1661
"high speed so that sometimes a TO is required to start cluster\n"
1663
"* 2. Restart 1 node -nostart\n"
1664
"* 3. Update records\n"
1665
"* 4. Restart cluster and verify records\n"
1666
"* 5. Restart 1 node -nostart\n"
1667
"* 6. Delete half of the records\n"
1668
"* 7. Restart cluster and verify records\n"
1669
"* 8. Restart 1 node -nostart\n"
1670
"* 9. Delete all records\n"
1671
"* 10. Restart cluster and verify records\n"){
1672
INITIALIZER(runWaitStarted);
1673
STEP(runSystemRestart4);
1674
FINALIZER(runClearTable);
1677
"As SR4 but making restart aborts\n"
1679
"* 2. Restart 1 node -nostart\n"
1680
"* 3. Update records\n"
1681
"* 4. Restart cluster and verify records\n"
1682
"* 5. Restart 1 node -nostart\n"
1683
"* 6. Delete half of the records\n"
1684
"* 7. Restart cluster and verify records\n"
1685
"* 8. Restart 1 node -nostart\n"
1686
"* 9. Delete all records\n"
1687
"* 10. Restart cluster and verify records\n"){
1688
INITIALIZER(runWaitStarted);
1689
STEP(runSystemRestart5);
1690
FINALIZER(runClearTable);
1693
"Perform system restart with some nodes having FS others wo/\n"
1695
"* 2. Restart all node -nostart\n"
1696
"* 3. Restart some nodes -i -nostart\n"
1697
"* 4. Start all nodes verify records\n"){
1698
INITIALIZER(runWaitStarted);
1699
INITIALIZER(runClearTable);
1700
STEP(runSystemRestart6);
1701
FINALIZER(runClearTable);
1704
"Perform partition win system restart\n"
1706
"* 2. Restart all node -nostart\n"
1707
"* 3. Start all but one node\n"
1708
"* 4. Verify records\n"
1709
"* 5. Start last node\n"
1710
"* 6. Verify records\n"){
1711
INITIALIZER(runWaitStarted);
1712
INITIALIZER(runClearTable);
1713
STEP(runSystemRestart7);
1714
FINALIZER(runClearTable);
1717
"Perform partition win system restart with other nodes delayed\n"
1719
"* 2. Restart all node -nostart\n"
1720
"* 3. Start all but one node\n"
1721
"* 4. Wait for startphase >= 2\n"
1722
"* 5. Start last node\n"
1723
"* 6. Verify records\n"){
1724
INITIALIZER(runWaitStarted);
1725
INITIALIZER(runClearTable);
1726
STEP(runSystemRestart8);
1727
FINALIZER(runClearTable);
1730
"Perform partition win system restart with other nodes delayed\n"
1731
"* 1. Start transaction\n"
1732
"* 2. insert (1,1)\n"
1733
"* 3. update (1,2)\n"
1737
INITIALIZER(runWaitStarted);
1738
INITIALIZER(runClearTable);
1739
STEP(runSystemRestart9);
1740
FINALIZER(runClearTable);
1742
TESTCASE("Bug18385",
1743
"Perform partition system restart with other nodes with higher GCI"){
1744
INITIALIZER(runWaitStarted);
1745
INITIALIZER(runClearTable);
1747
FINALIZER(runClearTable);
1749
TESTCASE("Bug21536",
1750
"Perform partition system restart with other nodes with higher GCI"){
1751
INITIALIZER(runWaitStarted);
1752
INITIALIZER(runClearTable);
1754
FINALIZER(runClearTable);
1756
TESTCASE("Bug24664",
1757
"Check handling of LCP skip/keep")
1759
INITIALIZER(runWaitStarted);
1760
INITIALIZER(runClearTable);
1762
FINALIZER(runClearTable);
1764
TESTCASE("Bug27434",
1767
INITIALIZER(runWaitStarted);
1770
TESTCASE("SR_DD_1", "")
1772
TC_PROPERTY("ALL", 1);
1773
INITIALIZER(runWaitStarted);
1776
FINALIZER(runClearTable);
1778
TESTCASE("SR_DD_1b", "")
1780
INITIALIZER(runWaitStarted);
1782
FINALIZER(runClearTable);
1784
TESTCASE("SR_DD_1_LCP", "")
1786
TC_PROPERTY("ALL", 1);
1787
TC_PROPERTY("LCP", 1);
1788
INITIALIZER(runWaitStarted);
1791
FINALIZER(runClearTable);
1793
TESTCASE("SR_DD_1b_LCP", "")
1795
TC_PROPERTY("LCP", 1);
1796
INITIALIZER(runWaitStarted);
1798
FINALIZER(runClearTable);
1800
TESTCASE("SR_DD_2", "")
1802
TC_PROPERTY("ALL", 1);
1803
INITIALIZER(runWaitStarted);
1806
FINALIZER(runClearTable);
1808
TESTCASE("SR_DD_2b", "")
1810
INITIALIZER(runWaitStarted);
1812
FINALIZER(runClearTable);
1814
TESTCASE("SR_DD_2_LCP", "")
1816
TC_PROPERTY("ALL", 1);
1817
TC_PROPERTY("LCP", 1);
1818
INITIALIZER(runWaitStarted);
1821
FINALIZER(runClearTable);
1823
TESTCASE("SR_DD_2b_LCP", "")
1825
TC_PROPERTY("LCP", 1);
1826
INITIALIZER(runWaitStarted);
1828
FINALIZER(runClearTable);
1830
TESTCASE("Bug29167", "")
1832
INITIALIZER(runWaitStarted);
1835
TESTCASE("Bug28770",
1836
"Check readTableFile1 fails, readTableFile2 succeeds\n"
1837
"1. Restart all node -nostart\n"
1838
"2. Insert error 6100 into all nodes\n"
1839
"3. Start all nodes\n"
1840
"4. Ensure cluster start\n"
1841
"5. Read and verify reocrds\n"
1842
"6. Repeat until looping is completed\n"){
1843
INITIALIZER(runWaitStarted);
1844
INITIALIZER(runClearTable);
1846
FINALIZER(runClearTable);
1848
TESTCASE("Bug22696", "")
1850
INITIALIZER(runWaitStarted);
1851
INITIALIZER(runLoadTable);
1852
INITIALIZER(runBug22696);
1853
FINALIZER(runClearTable);
1855
NDBT_TESTSUITE_END(testSystemRestart);
1857
int main(int argc, const char** argv){
1859
return testSystemRestart.execute(argc, argv);