MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testScan.cpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include <NDBT.hpp>
19 #include <NDBT_Test.hpp>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <NdbRestarter.hpp>
23 #include <Vector.hpp>
24 #include "ScanFunctions.hpp"
25 #include <random.h>
26 #include <signaldata/DumpStateOrd.hpp>
27 
29 getTable(Ndb* pNdb, int i){
30  const NdbDictionary::Table* t = NDBT_Tables::getTable(i);
31  if (t == NULL){
32  return 0;
33  }
34  return pNdb->getDictionary()->getTable(t->getName());
35 }
36 
37 
38 int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
39 
40  int records = ctx->getProperty("Rows", ctx->getNumRecords());
41 
42  HugoTransactions hugoTrans(*ctx->getTab());
43  if (hugoTrans.loadTable(GETNDB(step), records) != 0){
44  return NDBT_FAILED;
45  }
46  return NDBT_OK;
47 }
48 
49 
50 int runCreateAllTables(NDBT_Context* ctx, NDBT_Step* step){
51 
52  int a = NDBT_Tables::createAllTables(GETNDB(step), false, true);
53  return a;
54 }
55 
56 int runDropAllTablesExceptTestTable(NDBT_Context* ctx, NDBT_Step* step){
57 
58  for (int i=0; i < NDBT_Tables::getNumTables(); i++){
59 
60  const NdbDictionary::Table* tab = NDBT_Tables::getTable(i);
61  if (tab == NULL){
62  return NDBT_ProgramExit(NDBT_FAILED);
63  }
64 
65  GETNDB(step)->getDictionary()->dropTable(tab->getName());
66  }
67  return NDBT_OK;
68 }
69 
70 int runLoadAllTables(NDBT_Context* ctx, NDBT_Step* step){
71 
72  int records = ctx->getNumRecords();
73  for (int i=0; i < NDBT_Tables::getNumTables(); i++){
74 
75  const NdbDictionary::Table* tab = getTable(GETNDB(step), i);
76  if (tab == NULL){
77  return NDBT_FAILED;
78  }
79 
80  HugoTransactions hugoTrans(*tab);
81  if (hugoTrans.loadTable(GETNDB(step), records) != 0){
82  return NDBT_FAILED;
83  }
84  }
85  return NDBT_OK;
86 }
87 
88 char orderedPkIdxName[255];
89 
90 int createOrderedPkIndex(NDBT_Context* ctx, NDBT_Step* step){
91 
92  const NdbDictionary::Table* pTab = ctx->getTab();
93  Ndb* pNdb = GETNDB(step);
94 
95  // Create index
96  BaseString::snprintf(orderedPkIdxName, sizeof(orderedPkIdxName),
97  "IDC_O_PK_%s", pTab->getName());
98  NdbDictionary::Index pIdx(orderedPkIdxName);
99  pIdx.setTable(pTab->getName());
101  pIdx.setLogging(false);
102 
103  for (int c = 0; c< pTab->getNoOfColumns(); c++){
104  const NdbDictionary::Column * col = pTab->getColumn(c);
105  if(col->getPrimaryKey()){
106  pIdx.addIndexColumn(col->getName());
107  }
108  }
109 
110  if (pNdb->getDictionary()->createIndex(pIdx) != 0){
111  ndbout << "FAILED! to create index" << endl;
112  const NdbError err = pNdb->getDictionary()->getNdbError();
113  ERR(err);
114  return NDBT_FAILED;
115  }
116 
117  return NDBT_OK;
118 }
119 
120 int createOrderedPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
121  const NdbDictionary::Table* pTab = ctx->getTab();
122  Ndb* pNdb = GETNDB(step);
123 
124  // Drop index
125  if (pNdb->getDictionary()->dropIndex(orderedPkIdxName,
126  pTab->getName()) != 0){
127  ndbout << "FAILED! to drop index" << endl;
128  ERR(pNdb->getDictionary()->getNdbError());
129  return NDBT_FAILED;
130  }
131 
132  return NDBT_OK;
133 }
134 
135 
136 int runScanReadRandomTable(NDBT_Context* ctx, NDBT_Step* step){
137  int loops = ctx->getNumLoops();
138  int records = ctx->getNumRecords();
139  int parallelism = ctx->getProperty("Parallelism", 240);
140  int abort = ctx->getProperty("AbortProb", 5);
141 
142  int i = 0;
143  while (i<loops) {
144 
145  int tabNum = myRandom48(NDBT_Tables::getNumTables());
146  const NdbDictionary::Table* tab = getTable(GETNDB(step), tabNum);
147  if (tab == NULL){
148  g_info << "tab == NULL" << endl;
149  return NDBT_FAILED;
150  }
151 
152  g_info << "Scan reading from table " << tab->getName() << endl;
153  HugoTransactions hugoTrans(*tab);
154 
155  g_info << i << ": ";
156  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism) != 0){
157  return NDBT_FAILED;
158  }
159  i++;
160  }
161  return NDBT_OK;
162 }
163 
164 int runScanReadRandomTableExceptTestTable(NDBT_Context* ctx, NDBT_Step* step){
165  int loops = ctx->getNumLoops();
166  int records = ctx->getNumRecords();
167  int parallelism = ctx->getProperty("Parallelism", 240);
168  int abort = ctx->getProperty("AbortProb", 5);
169 
170  int i = 0;
171  while (i<loops) {
172  const NdbDictionary::Table* tab= NULL;
173  bool chosenTable=false;
174  while (!chosenTable)
175  {
176  int tabNum = myRandom48(NDBT_Tables::getNumTables());
177  tab = getTable(GETNDB(step), tabNum);
178  if (tab == NULL){
179  g_info << "tab == NULL" << endl;
180  return NDBT_FAILED;
181  }
182  // Skip test table
183  chosenTable= (strcmp(tab->getName(), ctx->getTab()->getName()));
184  }
185 
186  g_info << "Scan reading from table " << tab->getName() << endl;
187  HugoTransactions hugoTrans(*tab);
188 
189  g_info << i << ": ";
190  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism) != 0){
191  return NDBT_FAILED;
192  }
193  i++;
194  }
195  return NDBT_OK;
196 }
197 
198 int runInsertUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
199  int records = ctx->getNumRecords();
200  int i = 0;
201  HugoTransactions hugoTrans(*ctx->getTab());
202  while (ctx->isTestStopped() == false) {
203  g_info << i << ": ";
204  if (hugoTrans.loadTable(GETNDB(step), records, 1) != 0){
205  return NDBT_FAILED;
206  }
207  i++;
208  }
209  return NDBT_OK;
210 }
211 
212 int runInsertDelete(NDBT_Context* ctx, NDBT_Step* step){
213  int result = NDBT_OK;
214  int records = ctx->getNumRecords();
215  int loops = ctx->getNumLoops();
216  int i = 0;
217  HugoTransactions hugoTrans(*ctx->getTab());
218  UtilTransactions utilTrans(*ctx->getTab());
219  while (i<loops) {
220  g_info << i << ": ";
221  if (hugoTrans.loadTable(GETNDB(step), records, 1) != 0){
222  result = NDBT_FAILED;
223  break;
224  }
225  if (utilTrans.clearTable(GETNDB(step), records) != 0){
226  result = NDBT_FAILED;
227  break;
228  }
229  i++;
230  }
231 
232  ctx->stopTest();
233 
234  return result;
235 }
236 
237 int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
238  int records = ctx->getNumRecords();
239 
240  UtilTransactions utilTrans(*ctx->getTab());
241  if (utilTrans.clearTable2(GETNDB(step), records) != 0){
242  return NDBT_FAILED;
243  }
244  return NDBT_OK;
245 }
246 
247 int runScanDelete(NDBT_Context* ctx, NDBT_Step* step){
248  int loops = ctx->getNumLoops();
249  int records = ctx->getNumRecords();
250 
251  int i = 0;
252  UtilTransactions utilTrans(*ctx->getTab());
253  HugoTransactions hugoTrans(*ctx->getTab());
254  while (i<loops) {
255  g_info << i << ": ";
256  if (utilTrans.clearTable(GETNDB(step), records) != 0){
257  return NDBT_FAILED;
258  }
259  // Load table, don't allow any primary key violations
260  if (hugoTrans.loadTable(GETNDB(step), records, 512, false) != 0){
261  return NDBT_FAILED;
262  }
263  i++;
264  }
265  return NDBT_OK;
266 }
267 
268 int runScanDelete2(NDBT_Context* ctx, NDBT_Step* step){
269  int loops = ctx->getNumLoops();
270  int records = ctx->getNumRecords();
271 
272  int i = 0;
273  UtilTransactions utilTrans(*ctx->getTab());
274  HugoTransactions hugoTrans(*ctx->getTab());
275 
276  while (i<loops) {
277  g_info << i << ": ";
278  if (utilTrans.clearTable2(GETNDB(step), records) != 0){
279  return NDBT_FAILED;
280  }
281  // Load table, don't allow any primary key violations
282  if (hugoTrans.loadTable(GETNDB(step), records, 512, false) != 0){
283  return NDBT_FAILED;
284  }
285  i++;
286  }
287  return NDBT_OK;
288 }
289 
290 int runVerifyTable(NDBT_Context* ctx, NDBT_Step* step){
291  return NDBT_OK;
292 }
293 
294 int runScanRead(NDBT_Context* ctx, NDBT_Step* step){
295  int loops = ctx->getNumLoops();
296  int records = ctx->getProperty("Rows", ctx->getNumRecords());
297  int parallelism = ctx->getProperty("Parallelism", 240);
298  int abort = ctx->getProperty("AbortProb", 5);
299  int tupscan = ctx->getProperty("TupScan", (Uint32)0);
300  int lockmode = ctx->getProperty("LockMode", NdbOperation::LM_CommittedRead);
301 
302  int i = 0;
303  HugoTransactions hugoTrans(*ctx->getTab());
304  while (i<loops && !ctx->isTestStopped()) {
305  g_info << i << ": ";
306 
307  int scan_flags = 0;
308  if (tupscan == 1)
309  {
310  scan_flags |= NdbScanOperation::SF_TupScan;
311  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
312  NdbOperation::LockMode(lockmode),
313  scan_flags) != 0)
314  return NDBT_FAILED;
315  }
316  else if (hugoTrans.scanReadRecords(GETNDB(step), records, abort,
317  parallelism,
318  NdbOperation::LockMode(lockmode)) != 0)
319  {
320  return NDBT_FAILED;
321  }
322  i++;
323  }
324  return NDBT_OK;
325 }
326 
327 int runRandScanRead(NDBT_Context* ctx, NDBT_Step* step){
328  int loops = ctx->getNumLoops();
329  int records = ctx->getNumRecords();
330  int parallelism = ctx->getProperty("Parallelism", 240);
331  int abort = ctx->getProperty("AbortProb", 5);
332  int tupscan = ctx->getProperty("TupScan", (Uint32)0);
333  int lmarg = ctx->getProperty("LockMode", ~Uint32(0));
334  int nocount = ctx->getProperty("NoCount", Uint32(0));
335 
336  if (nocount)
337  records = 0;
338 
339  int i = 0;
340  HugoTransactions hugoTrans(*ctx->getTab());
341  while (i<loops && !ctx->isTestStopped()) {
342  g_info << i << ": ";
344  if (lmarg != ~0)
345  lm = (NdbOperation::LockMode)lmarg;
346  int scan_flags = 0;
347 
348  if (tupscan == 1)
349  scan_flags |= NdbScanOperation::SF_TupScan;
350  else if (tupscan == 2 && ((rand() & 0x800)))
351  {
352  scan_flags |= NdbScanOperation::SF_TupScan;
353  }
354 
355  if (hugoTrans.scanReadRecords(GETNDB(step),
356  records, abort, parallelism,
357  lm,
358  scan_flags) != 0){
359  return NDBT_FAILED;
360  }
361  i++;
362  }
363  return NDBT_OK;
364 }
365 
366 int runScanReadIndex(NDBT_Context* ctx, NDBT_Step* step){
367  int loops = ctx->getNumLoops();
368  int records = ctx->getProperty("Rows", ctx->getNumRecords());
369  int parallelism = ctx->getProperty("Parallelism", 240);
370  int abort = ctx->getProperty("AbortProb", 5);
371  int lockmode = ctx->getProperty("LockMode", NdbOperation::LM_CommittedRead);
372  int rand_mode = ctx->getProperty("RandScanOptions", Uint32(1));
373  const NdbDictionary::Index * pIdx =
374  GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName,
375  ctx->getTab()->getName());
376 
377  int i = 0;
378  HugoTransactions hugoTrans(*ctx->getTab());
379  while (pIdx && i<loops && !ctx->isTestStopped()) {
380  g_info << i << ": ";
381  bool sort = (rand() % 100) > 50 ? true : false;
382  bool desc = (rand() % 100) > 50 ? true : false;
384  desc = false; // random causes too many deadlocks
385  if (rand_mode == 0)
386  {
387  sort = false;
388  desc = false;
389  lm = (NdbOperation::LockMode)lockmode;
390  }
391  int scan_flags =
392  (NdbScanOperation::SF_OrderBy & -(int)sort) |
393  (NdbScanOperation::SF_Descending & -(int)desc);
394  if (hugoTrans.scanReadRecords(GETNDB(step), pIdx,
395  records, abort, parallelism,
396  lm,
397  scan_flags) != 0){
398  return NDBT_FAILED;
399  }
400  i++;
401  }
402  return NDBT_OK;
403 }
404 
405 int runScanReadCommitted(NDBT_Context* ctx, NDBT_Step* step){
406  int loops = ctx->getNumLoops();
407  int records = ctx->getNumRecords();
408  int parallelism = ctx->getProperty("Parallelism", 240);
409  int abort = ctx->getProperty("AbortProb", 5);
410  bool tupScan = ctx->getProperty("TupScan");
411  int scan_flags = (NdbScanOperation::SF_TupScan & -(int)tupScan);
412 
413  int i = 0;
414  HugoTransactions hugoTrans(*ctx->getTab());
415  while (i<loops && !ctx->isTestStopped()) {
416  g_info << i << ": ";
417  if (hugoTrans.scanReadRecords(GETNDB(step), records,
418  abort, parallelism,
420  scan_flags) != 0){
421  return NDBT_FAILED;
422  }
423  i++;
424  }
425  return NDBT_OK;
426 }
427 
428 int runScanReadError(NDBT_Context* ctx, NDBT_Step* step){
429  int result = NDBT_OK;
430  int loops = ctx->getNumLoops();
431  int records = ctx->getNumRecords();
432  int parallelism = 240; // Max parallelism
433  int error = ctx->getProperty("ErrorCode");
434  NdbRestarter restarter;
435 
436  int i = 0;
437  HugoTransactions hugoTrans(*ctx->getTab());
438  while (i<loops && !ctx->isTestStopped()) {
439  g_info << i << ": ";
440 
441  ndbout << "insertErrorInAllNodes("<<error<<")"<<endl;
442  if (restarter.insertErrorInAllNodes(error) != 0){
443  ndbout << "Could not insert error in all nodes "<<endl;
444  return NDBT_FAILED;
445  }
446 
447  if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, parallelism) != 0){
448  result = NDBT_FAILED;
449  }
450  i++;
451  }
452 
453  restarter.insertErrorInAllNodes(0);
454  return result;
455 }
456 
457 int
458 runInsertError(NDBT_Context* ctx, NDBT_Step* step){
459  int error = ctx->getProperty("ErrorCode");
460  NdbRestarter restarter;
461 
462  ctx->setProperty("ErrorCode", (Uint32)0);
463  if (restarter.insertErrorInAllNodes(error) != 0){
464  ndbout << "Could not insert error in all nodes "<<endl;
465  return NDBT_FAILED;
466  }
467  return NDBT_OK;
468 }
469 
470 int runScanReadErrorOneNode(NDBT_Context* ctx, NDBT_Step* step){
471  int result = NDBT_OK;
472  int loops = ctx->getNumLoops();
473  int records = ctx->getNumRecords();
474  int parallelism = 240; // Max parallelism
475  int error = ctx->getProperty("ErrorCode");
476  NdbRestarter restarter;
477  int lastId = 0;
478 
479  if (restarter.getNumDbNodes() < 2){
480  ctx->stopTest();
481  return NDBT_OK;
482  }
483 
484  int i = 0;
485  HugoTransactions hugoTrans(*ctx->getTab());
486  while (i<loops && result == NDBT_OK) {
487  g_info << i << ": ";
488 
489  int nodeId = restarter.getDbNodeId(lastId);
490  lastId = (lastId + 1) % restarter.getNumDbNodes();
491  ndbout << "insertErrorInNode("<<nodeId<<", "<<error<<")"<<endl;
492  if (restarter.insertErrorInNode(nodeId, error) != 0){
493  ndbout << "Could not insert error in node="<<nodeId<<endl;
494  return NDBT_FAILED;
495  }
496 
497  for (int j=0; j<10; j++){
498  if (hugoTrans.scanReadRecords(GETNDB(step),
499  records, 0, parallelism) != 0)
500  result = NDBT_FAILED;
501  }
502 
503 
504  if(restarter.waitClusterStarted(120) != 0){
505  g_err << "Cluster failed to restart" << endl;
506  result = NDBT_FAILED;
507  }
508  restarter.insertErrorInAllNodes(0);
509 
510  i++;
511  }
512  restarter.insertErrorInAllNodes(0);
513  return result;
514 }
515 
516 int runRestartAll(NDBT_Context* ctx, NDBT_Step* step){
517 
518  NdbRestarter restarter;
519 
520  if (restarter.restartAll() != 0){
521  ndbout << "Could not restart all nodes"<<endl;
522  return NDBT_FAILED;
523  }
524 
525  if (restarter.waitClusterStarted(120) != 0){
526  ndbout << "Could not restarted" << endl;
527  return NDBT_FAILED;
528  }
529 
530  return NDBT_OK;
531 }
532 
533 static int RANDOM_PARALLELISM = 9999;
534 
535 int runScanReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
536  int records = ctx->getNumRecords();
537  int i = 0;
538 
539  int parallelism = ctx->getProperty("Parallelism", 240);
540  int para = parallelism;
541 
542  HugoTransactions hugoTrans(*ctx->getTab());
543  while (ctx->isTestStopped() == false) {
544  if (parallelism == RANDOM_PARALLELISM)
545  para = myRandom48(239)+1;
546 
547  g_info << i << ": ";
548  if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, para) != 0){
549  return NDBT_FAILED;
550  }
551  i++;
552  }
553  return NDBT_OK;
554 }
555 
556 int runScanReadUntilStoppedNoCount(NDBT_Context* ctx, NDBT_Step* step){
557  int i = 0;
558  HugoTransactions hugoTrans(*ctx->getTab());
559  while (ctx->isTestStopped() == false) {
560  g_info << i << ": ";
561  if (hugoTrans.scanReadRecords(GETNDB(step), 0) != 0){
562  return NDBT_FAILED;
563  }
564  i++;
565  }
566  return NDBT_OK;
567 }
568 
569 int runScanReadUntilStoppedPrintTime(NDBT_Context* ctx, NDBT_Step* step){
570  int records = ctx->getNumRecords();
571  int i = 0;
572  int parallelism = ctx->getProperty("Parallelism", 240);
573  NdbTimer timer;
574  Ndb* ndb = GETNDB(step);
575 
576 
577  HugoTransactions hugoTrans(*ctx->getTab());
578  while (ctx->isTestStopped() == false) {
579  timer.doReset();
580  timer.doStart();
581  g_info << i << ": ";
582  if (ndb->waitUntilReady() != 0)
583  return NDBT_FAILED;
584  if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, parallelism) != 0)
585  return NDBT_FAILED;
586  timer.doStop();
587  if ((timer.elapsedTime()/1000) > 1)
588  timer.printTotalTime();
589  i++;
590  }
591  return NDBT_OK;
592 }
593 
594 
595 int runPkRead(NDBT_Context* ctx, NDBT_Step* step){
596  int loops = ctx->getNumLoops();
597  int records = ctx->getNumRecords();
598  int i = 0;
599  HugoTransactions hugoTrans(*ctx->getTab());
600  while (i<loops) {
601  g_info << i << ": ";
602  if (hugoTrans.pkReadRecords(GETNDB(step), records) != 0){
603  return NDBT_FAILED;
604  }
605  i++;
606  }
607  return NDBT_OK;
608 }
609 
610 int runScanUpdate(NDBT_Context* ctx, NDBT_Step* step){
611  int loops = ctx->getNumLoops();
612  int records = ctx->getNumRecords();
613  int parallelism = ctx->getProperty("Parallelism", 1);
614  int abort = ctx->getProperty("AbortProb", 5);
615  int i = 0;
616  HugoTransactions hugoTrans(*ctx->getTab());
617  while (i<loops) {
618  g_info << i << ": ";
619 
620  if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism) != 0){
621  return NDBT_FAILED;
622  }
623  i++;
624  }
625  return NDBT_OK;
626 }
627 
628 int runScanUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
629  //int records = ctx->getNumRecords();
630  int i = 0;
631 
632  int parallelism = ctx->getProperty("Parallelism", 240);
633  int para = parallelism;
634 
635  HugoTransactions hugoTrans(*ctx->getTab());
636  while (ctx->isTestStopped() == false) {
637  if (parallelism == RANDOM_PARALLELISM)
638  para = myRandom48(239)+1;
639 
640  g_info << i << ": ";
641  if (hugoTrans.scanUpdateRecords(GETNDB(step), 0, 0, para) == NDBT_FAILED){
642  return NDBT_FAILED;
643  }
644  i++;
645  }
646  return NDBT_OK;
647 }
648 
649 
650 int runScanUpdate2(NDBT_Context* ctx, NDBT_Step* step){
651  int loops = ctx->getNumLoops();
652  int records = ctx->getNumRecords();
653  int parallelism = ctx->getProperty("Parallelism", 240);
654  int abort = ctx->getProperty("AbortProb", 5);
655  int i = 0;
656  HugoTransactions hugoTrans(*ctx->getTab());
657  while (i<loops) {
658  g_info << i << ": ";
659  if (hugoTrans.scanUpdateRecords2(GETNDB(step), records, abort, parallelism) != 0){
660  return NDBT_FAILED;
661  }
662  i++;
663  }
664  return NDBT_OK;
665 }
666 
667 int runLocker(NDBT_Context* ctx, NDBT_Step* step){
668  int result = NDBT_OK;
669  int records = ctx->getNumRecords();
670  HugoTransactions hugoTrans(*ctx->getTab());
671 
672  if (hugoTrans.lockRecords(GETNDB(step), records, 5, 500) != 0){
673  result = NDBT_FAILED;
674  }
675  ctx->stopTest();
676 
677  return result;
678 }
679 
680 int runRestarter(NDBT_Context* ctx, NDBT_Step* step){
681  int result = NDBT_OK;
682  int loops = ctx->getNumLoops();
683  NdbRestarter restarter;
684  int i = 0;
685  int lastId = 0;
686  int timeout = 240;
687 
688  if (restarter.getNumDbNodes() < 2){
689  ctx->stopTest();
690  return NDBT_OK;
691  }
692  while(i<loops && result != NDBT_FAILED){
693  if(restarter.waitClusterStarted(timeout) != 0){
694  g_err << "Cluster failed to start 1" << endl;
695  result = NDBT_FAILED;
696  break;
697  }
698  NdbSleep_SecSleep(10);
699 
700  int nodeId = restarter.getDbNodeId(lastId);
701  lastId = (lastId + 1) % restarter.getNumDbNodes();
702  if(restarter.restartOneDbNode(nodeId, false, false, true) != 0){
703  g_err << "Failed to restartNextDbNode" << endl;
704  result = NDBT_FAILED;
705  break;
706  }
707  i++;
708  }
709  if(restarter.waitClusterStarted(timeout) != 0){
710  g_err << "Cluster failed to start 2" << endl;
711  result = NDBT_FAILED;
712  }
713 
714  ctx->stopTest();
715 
716  return result;
717 }
718 
719 
720 int runStopAndStartNode(NDBT_Context* ctx, NDBT_Step* step){
721  int result = NDBT_OK;
722  int loops = ctx->getNumLoops();
723  NdbRestarter restarter;
724  int i = 0;
725  int lastId = 0;
726  int timeout = 240;
727 
728  if (restarter.getNumDbNodes() < 2){
729  ctx->stopTest();
730  return NDBT_OK;
731  }
732  while(i<loops && result != NDBT_FAILED){
733  if(restarter.waitClusterStarted(timeout) != 0){
734  g_err << "Cluster failed to start 1" << endl;
735  result = NDBT_FAILED;
736  break;
737  }
738  NdbSleep_SecSleep(1);
739  int nodeId = restarter.getDbNodeId(lastId);
740  lastId = (lastId + 1) % restarter.getNumDbNodes();
741  g_err << "Stopping node " << nodeId << endl;
742 
743  if(restarter.restartOneDbNode(nodeId, false, true) != 0){
744  g_err << "Failed to restartOneDbNode" << endl;
745  result = NDBT_FAILED;
746  break;
747  }
748 
749  if(restarter.waitNodesNoStart(&nodeId, 1, timeout) != 0){
750  g_err << "Node failed to reach NoStart" << endl;
751  result = NDBT_FAILED;
752  break;
753  }
754 
755  g_info << "Sleeping for 10 secs" << endl;
756  NdbSleep_SecSleep(10);
757 
758  g_err << "Starting node " << nodeId << endl;
759  if(restarter.startNodes(&nodeId, 1) != 0){
760  g_err << "Failed to start the node" << endl;
761  result = NDBT_FAILED;
762  break;
763  }
764 
765  i++;
766  }
767  if(restarter.waitClusterStarted(timeout) != 0){
768  g_err << "Cluster failed to start 2" << endl;
769  result = NDBT_FAILED;
770  }
771 
772  ctx->stopTest();
773 
774  return result;
775 }
776 
777 int runRestarter9999(NDBT_Context* ctx, NDBT_Step* step){
778  int result = NDBT_OK;
779  int loops = ctx->getNumLoops();
780  NdbRestarter restarter;
781  int i = 0;
782  int lastId = 0;
783 
784  if (restarter.getNumDbNodes() < 2){
785  ctx->stopTest();
786  return NDBT_OK;
787  }
788  while(i<loops && result != NDBT_FAILED){
789  if(restarter.waitClusterStarted(120) != 0){
790  g_err << "Cluster failed to start" << endl;
791  result = NDBT_FAILED;
792  break;
793  }
794  NdbSleep_SecSleep(10);
795 
796  int nodeId = restarter.getDbNodeId(lastId);
797  lastId = (lastId + 1) % restarter.getNumDbNodes();
798  if(restarter.insertErrorInNode(nodeId, 9999) != 0){
799  g_err << "Failed to insertErrorInNode="<<nodeId << endl;
800  result = NDBT_FAILED;
801  break;
802  }
803  NdbSleep_SecSleep(10);
804  i++;
805  }
806  if(restarter.waitClusterStarted(120) != 0){
807  g_err << "Cluster failed to start" << endl;
808  result = NDBT_FAILED;
809  }
810 
811  ctx->stopTest();
812 
813  return result;
814 }
815 
816 
817 int runCheckGetValue(NDBT_Context* ctx, NDBT_Step* step){
818  const NdbDictionary::Table* pTab = ctx->getTab();
819  int parallelism = ctx->getProperty("Parallelism", 1);
820  int records = ctx->getNumRecords();
821  int numFailed = 0;
822  AttribList alist;
823  alist.buildAttribList(pTab);
824  UtilTransactions utilTrans(*pTab);
825  for(size_t i = 0; i < alist.attriblist.size(); i++){
826  g_info << (unsigned)i << endl;
827  if(utilTrans.scanReadRecords(GETNDB(step),
828  parallelism,
830  records,
831  alist.attriblist[i]->numAttribs,
832  alist.attriblist[i]->attribs) != 0){
833  numFailed++;
834  }
835  if(utilTrans.scanReadRecords(GETNDB(step),
836  parallelism,
838  records,
839  alist.attriblist[i]->numAttribs,
840  alist.attriblist[i]->attribs) != 0){
841  numFailed++;
842  }
843  }
844 
845  if(numFailed > 0)
846  return NDBT_FAILED;
847  else
848  return NDBT_OK;
849 }
850 
851 int runCloseWithoutStop(NDBT_Context* ctx, NDBT_Step* step){
852  const NdbDictionary::Table* pTab = ctx->getTab();
853  int records = ctx->getNumRecords();
854  int numFailed = 0;
855  ScanFunctions scanF(*pTab);
856  // Iterate over all possible parallelism valuse
857  for (int p = 1; p<240; p++){
858  g_info << p << " CloseWithoutStop openScan" << endl;
859  if (scanF.scanReadFunctions(GETNDB(step),
860  records,
861  p,
862  ScanFunctions::CloseWithoutStop,
863  false) != 0){
864  numFailed++;
865  }
866  g_info << p << " CloseWithoutStop openScanExclusive" << endl;
867  if (scanF.scanReadFunctions(GETNDB(step),
868  records,
869  p,
870  ScanFunctions::CloseWithoutStop,
871  true) != 0){
872  numFailed++;
873  }
874  }
875 
876  if(numFailed > 0)
877  return NDBT_FAILED;
878  else
879  return NDBT_OK;
880 }
881 
882 int runNextScanWhenNoMore(NDBT_Context* ctx, NDBT_Step* step){
883  const NdbDictionary::Table* pTab = ctx->getTab();
884  int records = ctx->getNumRecords();
885  int numFailed = 0;
886  ScanFunctions scanF(*pTab);
887  if (scanF.scanReadFunctions(GETNDB(step),
888  records,
889  6,
890  ScanFunctions::NextScanWhenNoMore,
891  false) != 0){
892  numFailed++;
893  }
894  if (scanF.scanReadFunctions(GETNDB(step),
895  records,
896  6,
897  ScanFunctions::NextScanWhenNoMore,
898  true) != 0){
899  numFailed++;
900  }
901 
902 
903  if(numFailed > 0)
904  return NDBT_FAILED;
905  else
906  return NDBT_OK;
907 }
908 
909 int runEqualAfterOpenScan(NDBT_Context* ctx, NDBT_Step* step){
910  const NdbDictionary::Table* pTab = ctx->getTab();
911  int records = ctx->getNumRecords();
912  int numFailed = 0;
913  ScanFunctions scanF(*pTab);
914  if (scanF.scanReadFunctions(GETNDB(step),
915  records,
916  6,
917  ScanFunctions::EqualAfterOpenScan,
918  false) == NDBT_OK){
919  numFailed++;
920  }
921  if (scanF.scanReadFunctions(GETNDB(step),
922  records,
923  6,
924  ScanFunctions::EqualAfterOpenScan,
925  true) == NDBT_OK){
926  numFailed++;
927  }
928 
929 
930  if(numFailed > 0)
931  return NDBT_FAILED;
932  else
933  return NDBT_OK;
934 }
935 
936 int runOnlyOpenScanOnce(NDBT_Context* ctx, NDBT_Step* step){
937  const NdbDictionary::Table* pTab = ctx->getTab();
938  int records = ctx->getNumRecords();
939  int numFailed = 0;
940  ScanFunctions scanF(*pTab);
941  g_info << "OnlyOpenScanOnce openScanRead" << endl;
942  if (scanF.scanReadFunctions(GETNDB(step),
943  records,
944  6,
945  ScanFunctions::OnlyOpenScanOnce,
946  false) == 0){
947  numFailed++;
948  }
949  g_info << "OnlyOpenScanOnce openScanExclusive" << endl;
950  if (scanF.scanReadFunctions(GETNDB(step),
951  records,
952  6,
953  ScanFunctions::OnlyOpenScanOnce,
954  true) == 0){
955  numFailed++;
956  }
957 
958 
959  if(numFailed > 0)
960  return NDBT_FAILED;
961  else
962  return NDBT_OK;
963 }
964 
965 int runOnlyOneOpInScanTrans(NDBT_Context* ctx, NDBT_Step* step){
966  return NDBT_OK;
967 }
968 
969 int runExecuteScanWithoutOpenScan(NDBT_Context* ctx, NDBT_Step* step){
970  return NDBT_OK;
971 }
972 
973 int runOnlyOneOpBeforeOpenScan(NDBT_Context* ctx, NDBT_Step* step){
974  return NDBT_OK;
975 }
976 
977 int runOnlyOneScanPerTrans(NDBT_Context* ctx, NDBT_Step* step){
978  return NDBT_OK;
979 }
980 
981 int runNoCloseTransaction(NDBT_Context* ctx, NDBT_Step* step){
982  const NdbDictionary::Table* pTab = ctx->getTab();
983  int loops = ctx->getNumLoops();
984  int records = ctx->getNumRecords();
985  int numFailed = 0;
986 
987  ScanFunctions scanF(*pTab);
988  int l = 0;
989  while(l < loops){
990  if (scanF.scanReadFunctions(GETNDB(step),
991  records,
992  6,
993  ScanFunctions::NoCloseTransaction,
994  false) != 0){
995  numFailed++;
996  }
997  if (scanF.scanReadFunctions(GETNDB(step),
998  records,
999  6,
1000  ScanFunctions::NoCloseTransaction,
1001  true) != 0){
1002  numFailed++;
1003  }
1004  l++;
1005  }
1006 
1007 
1008  if(numFailed > 0)
1009  return NDBT_FAILED;
1010  else
1011  return NDBT_OK;
1012 
1013 }
1014 
1015 int runCheckInactivityTimeOut(NDBT_Context* ctx, NDBT_Step* step){
1016  const NdbDictionary::Table* pTab = ctx->getTab();
1017  int records = ctx->getNumRecords();
1018  int numFailed = 0;
1019 
1020  ScanFunctions scanF(*pTab);
1021  if (scanF.scanReadFunctions(GETNDB(step),
1022  records,
1023  1,
1024  ScanFunctions::CheckInactivityTimeOut,
1025  false) != NDBT_OK){
1026  numFailed++;
1027  }
1028  if (scanF.scanReadFunctions(GETNDB(step),
1029  records,
1030  240,
1031  ScanFunctions::CheckInactivityTimeOut,
1032  true) != NDBT_OK){
1033  numFailed++;
1034  }
1035 
1036  if(numFailed > 0)
1037  return NDBT_FAILED;
1038  else
1039  return NDBT_OK;
1040 
1041 }
1042 
1043 int runCheckInactivityBeforeClose(NDBT_Context* ctx, NDBT_Step* step){
1044  const NdbDictionary::Table* pTab = ctx->getTab();
1045  int records = ctx->getNumRecords();
1046  int numFailed = 0;
1047 
1048  ScanFunctions scanF(*pTab);
1049  if (scanF.scanReadFunctions(GETNDB(step),
1050  records,
1051  16,
1052  ScanFunctions::CheckInactivityBeforeClose,
1053  false) != 0){
1054  numFailed++;
1055  }
1056  if (scanF.scanReadFunctions(GETNDB(step),
1057  records,
1058  240,
1059  ScanFunctions::CheckInactivityBeforeClose,
1060  true) != 0){
1061  numFailed++;
1062  }
1063 
1064  if(numFailed > 0)
1065  return NDBT_FAILED;
1066  else
1067  return NDBT_OK;
1068 
1069 }
1070 
1071 int
1072 runScanParallelism(NDBT_Context* ctx, NDBT_Step* step){
1073  int loops = ctx->getNumLoops() + 3;
1074  int records = ctx->getNumRecords();
1075  int abort = ctx->getProperty("AbortProb", 15);
1076 
1077  Uint32 fib[] = { 1, 2 };
1078  Uint32 parallelism = 0; // start with 0
1079  int i = 0;
1080  HugoTransactions hugoTrans(*ctx->getTab());
1081  while (i<loops && !ctx->isTestStopped()) {
1082  g_info << i << ": ";
1083 
1084  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1085  NdbOperation::LM_Read) != 0){
1086  return NDBT_FAILED;
1087  }
1088  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1090  return NDBT_FAILED;
1091  }
1092  if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1094  return NDBT_FAILED;
1095  }
1096  if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism)
1097  != 0){
1098  return NDBT_FAILED;
1099  }
1100  i++;
1101  parallelism = fib[0];
1102  Uint32 next = fib[0] + fib[1];
1103  fib[0] = fib[1];
1104  fib[1] = next;
1105  }
1106  return NDBT_OK;
1107 }
1108 
1109 int
1110 runScanVariants(NDBT_Context* ctx, NDBT_Step* step)
1111 {
1112  //int loops = ctx->getNumLoops();
1113  //int records = ctx->getNumRecords();
1114  Ndb * pNdb = GETNDB(step);
1115  const NdbDictionary::Table* pTab = ctx->getTab();
1116 
1117  HugoCalculator calc(* pTab);
1118  NDBT_ResultRow tmpRow(* pTab);
1119 
1120  for(int lm = 0; lm <= NdbOperation::LM_CommittedRead; lm++)
1121  {
1122  for(int flags = 0; flags < 4; flags++)
1123  {
1124  for (int batch = 0; batch < 100; batch += (1 + batch + (batch >> 3)))
1125  {
1126  for (int par = 0; par < 16; par += 1 + (rand() % 3))
1127  {
1128  bool disk = flags & 1;
1129  bool tups = flags & 2;
1130  g_info << "lm: " << lm
1131  << " disk: " << disk
1132  << " tup scan: " << tups
1133  << " par: " << par
1134  << " batch: " << batch
1135  << endl;
1136 
1137  NdbConnection* pCon = pNdb->startTransaction();
1138  NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());
1139  if (pOp == NULL) {
1140  ERR(pCon->getNdbError());
1141  return NDBT_FAILED;
1142  }
1143 
1144  if( pOp->readTuples((NdbOperation::LockMode)lm,
1145  tups ? NdbScanOperation::SF_TupScan : 0,
1146  par,
1147  batch) != 0)
1148  {
1149  ERR(pCon->getNdbError());
1150  return NDBT_FAILED;
1151  }
1152 
1153  // Define attributes to read
1154  bool found_disk = false;
1155  for(int a = 0; a<pTab->getNoOfColumns(); a++){
1156  if (pTab->getColumn(a)->getStorageType() ==
1157  NdbDictionary::Column::StorageTypeDisk)
1158  {
1159  found_disk = true;
1160  if (!disk)
1161  continue;
1162  }
1163 
1164  if((pOp->getValue(pTab->getColumn(a)->getName())) == 0) {
1165  ERR(pCon->getNdbError());
1166  return NDBT_FAILED;
1167  }
1168  }
1169 
1170  if (! (disk && !found_disk))
1171  {
1172  int check = pCon->execute(NoCommit);
1173  if( check == -1 ) {
1174  ERR(pCon->getNdbError());
1175  return NDBT_FAILED;
1176  }
1177 
1178  int res;
1179  //int row = 0;
1180  while((res = pOp->nextResult()) == 0);
1181  }
1182  pCon->close();
1183  }
1184  }
1185  }
1186  }
1187  return NDBT_OK;
1188 }
1189 
1190 int
1191 runBug36124(NDBT_Context* ctx, NDBT_Step* step){
1192  Ndb * pNdb = GETNDB(step);
1193  const NdbDictionary::Table* pTab = ctx->getTab();
1194 
1195  NdbTransaction* pCon = pNdb->startTransaction();
1196  NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());
1197  if (pOp == NULL) {
1198  ERR(pCon->getNdbError());
1199  return NDBT_FAILED;
1200  }
1201 
1202  if( pOp->readTuples(NdbOperation::LM_Read) != 0)
1203  {
1204  ERR(pCon->getNdbError());
1205  return NDBT_FAILED;
1206  }
1207 
1208  if( pOp->getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1209  {
1210  ERR(pCon->getNdbError());
1211  return NDBT_FAILED;
1212  }
1213 
1214  /* Old style interpreted code api should fail when
1215  * we try to use it
1216  */
1217  if( pOp->interpret_exit_last_row() == 0)
1218  {
1219  return NDBT_FAILED;
1220  }
1221 
1222  pOp->close();
1223 
1224  pCon->close();
1225 
1226  return NDBT_OK;
1227 }
1228 
1229 int
1230 runBug24447(NDBT_Context* ctx, NDBT_Step* step){
1231  int loops = 1; //ctx->getNumLoops();
1232  int records = ctx->getNumRecords();
1233  int abort = ctx->getProperty("AbortProb", 15);
1234  NdbRestarter restarter;
1235  HugoTransactions hugoTrans(*ctx->getTab());
1236  int i = 0;
1237  while (i<loops && !ctx->isTestStopped())
1238  {
1239  g_info << i++ << ": ";
1240 
1241  int nodeId = restarter.getRandomNotMasterNodeId(rand());
1242  if (nodeId == -1)
1243  nodeId = restarter.getMasterNodeId();
1244  if (restarter.insertErrorInNode(nodeId, 8038) != 0)
1245  {
1246  ndbout << "Could not insert error in node="<<nodeId<<endl;
1247  return NDBT_FAILED;
1248  }
1249 
1250  for (Uint32 j = 0; j<10; j++)
1251  {
1252  hugoTrans.scanReadRecords(GETNDB(step), records, abort, 0,
1254  }
1255 
1256  }
1257  restarter.insertErrorInAllNodes(0);
1258 
1259  return NDBT_OK;
1260 }
1261 
1262 int runBug42545(NDBT_Context* ctx, NDBT_Step* step){
1263 
1264  int loops = ctx->getNumLoops();
1265 
1266  Ndb* pNdb = GETNDB(step);
1267  NdbRestarter res;
1268 
1269  if (res.getNumDbNodes() < 2)
1270  {
1271  ctx->stopTest();
1272  return NDBT_OK;
1273  }
1274 
1275  const NdbDictionary::Index * pIdx =
1276  GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName,
1277  ctx->getTab()->getName());
1278 
1279 
1280  int i = 0;
1281  while (pIdx && i++ < loops && !ctx->isTestStopped())
1282  {
1283  g_info << i << ": ";
1284  NdbTransaction* pTrans = pNdb->startTransaction();
1285  int nodeId = pTrans->getConnectedNodeId();
1286 
1287  {
1288  Uint32 cnt = 0;
1289  Vector<NdbTransaction*> translist;
1290  while (cnt < 3)
1291  {
1292  NdbTransaction* p2 = pNdb->startTransaction();
1293  translist.push_back(p2);
1294  if (p2->getConnectedNodeId() == (Uint32)nodeId)
1295  cnt++;
1296  }
1297 
1298  for (size_t t = 0; t < translist.size(); t++)
1299  translist[t]->close();
1300  translist.clear();
1301  }
1302 
1304  pOp = pTrans->getNdbIndexScanOperation(pIdx, ctx->getTab());
1305 
1307  NdbScanOperation::SF_OrderBy);
1308 
1309  ndbout << "Restart node " << nodeId << endl;
1310  res.restartOneDbNode(nodeId, false, true, true);
1314 
1315  res.waitNodesNoStart(&nodeId, 1);
1316  res.startNodes(&nodeId, 1);
1317  res.waitNodesStarted(&nodeId, 1);
1318 
1319  int r1 = pTrans->execute(NdbTransaction::NoCommit);
1320 
1321  int r2;
1322  while ((r2 = pOp->nextResult()) == 0);
1323 
1324  ndbout_c("r0: %d r1: %d r2: %d", r0, r1, r2);
1325 
1326  pTrans->close();
1327  }
1328 
1329  return NDBT_OK;
1330 }
1331 
1332 int
1333 initBug42559(NDBT_Context* ctx, NDBT_Step* step){
1334 
1335  int dump[] = { 7017 }; // Max LCP speed
1336  NdbRestarter res;
1337  res.dumpStateAllNodes(dump, 1);
1338 
1339  return NDBT_OK;
1340 }
1341 int
1342 finalizeBug42559(NDBT_Context* ctx, NDBT_Step* step){
1343 
1344  int dump[] = { 7017, 1 }; // Restore config value
1345  NdbRestarter res;
1346  res.dumpStateAllNodes(dump, 2);
1347 
1348  return NDBT_OK;
1349 }
1350 
1351 
1352 int
1353 runBug54945(NDBT_Context* ctx, NDBT_Step* step)
1354 {
1355 
1356  int loops = ctx->getNumLoops();
1357  const NdbDictionary::Table* pTab = ctx->getTab();
1358 
1359  Ndb* pNdb = GETNDB(step);
1360  NdbRestarter res;
1361 
1362  if (res.getNumDbNodes() < 2)
1363  {
1364  ctx->stopTest();
1365  return NDBT_OK;
1366  }
1367 
1368  while (loops--)
1369  {
1370  int node = res.getNode(NdbRestarter::NS_RANDOM);
1371  int err = 0;
1372  printf("node: %u ", node);
1373  switch(loops % 2){
1374  case 0:
1375  if (res.getNumDbNodes() >= 2)
1376  {
1377  err = 8088;
1378  int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1379  res.dumpStateOneNode(node, val, 2);
1380  res.insertErrorInNode(node, 8088);
1381  ndbout_c("error 8088");
1382  break;
1383  }
1384  // fall through
1385  case 1:
1386  err = 5057;
1387  res.insertErrorInNode(node, 5057);
1388  ndbout_c("error 5057");
1389  break;
1390  }
1391 
1392  for (int i = 0; i< 25; i++)
1393  {
1394  NdbTransaction* pCon = pNdb->startTransaction();
1395  NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());
1396  if (pOp == NULL) {
1397  ERR(pCon->getNdbError());
1398  return NDBT_FAILED;
1399  }
1400 
1401  if( pOp->readTuples(NdbOperation::LM_Read) != 0)
1402  {
1403  ERR(pCon->getNdbError());
1404  return NDBT_FAILED;
1405  }
1406 
1407  if( pOp->getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1408  {
1409  ERR(pCon->getNdbError());
1410  return NDBT_FAILED;
1411  }
1412 
1413  pCon->execute(NoCommit);
1414  pCon->close();
1415  }
1416  if (err == 8088)
1417  {
1418  res.waitNodesNoStart(&node, 1);
1419  res.startAll();
1420  res.waitClusterStarted();
1421  }
1422  }
1423 
1424  return NDBT_OK;
1425 }
1426 
1427 int
1428 runCloseRefresh(NDBT_Context* ctx, NDBT_Step* step)
1429 {
1430  Ndb * pNdb = GETNDB(step);
1431 
1432  const Uint32 codeWords= 1;
1433  Uint32 codeSpace[ codeWords ];
1434  NdbInterpretedCode code(NULL, // Table is irrelevant
1435  &codeSpace[0],
1436  codeWords);
1437  if ((code.interpret_exit_last_row() != 0) ||
1438  (code.finalise() != 0))
1439  {
1440  ERR(code.getNdbError());
1441  return NDBT_FAILED;
1442  }
1443 
1444  const NdbDictionary::Table* pTab = ctx->getTab();
1445  NdbTransaction* pTrans = pNdb->startTransaction();
1446  NdbScanOperation* pOp = pTrans->getNdbScanOperation(pTab->getName());
1447  if (pOp == NULL)
1448  {
1449  ERR(pTrans->getNdbError());
1450  return NDBT_FAILED;
1451  }
1452 
1454  {
1455  ERR(pTrans->getNdbError());
1456  return NDBT_FAILED;
1457  }
1458 
1459  if (pOp->setInterpretedCode(&code) == -1 )
1460  {
1461  ERR(pTrans->getNdbError());
1462  pNdb->closeTransaction(pTrans);
1463  return NDBT_FAILED;
1464  }
1465 
1466  if (pOp->getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1467  {
1468  ERR(pTrans->getNdbError());
1469  return NDBT_FAILED;
1470  }
1471 
1473  pOp->close(); // close this
1474 
1475  pOp = pTrans->getNdbScanOperation(pTab->getName());
1476  if (pOp == NULL)
1477  {
1478  ERR(pTrans->getNdbError());
1479  return NDBT_FAILED;
1480  }
1481 
1483  {
1484  ERR(pTrans->getNdbError());
1485  return NDBT_FAILED;
1486  }
1487 
1488  if (pOp->setInterpretedCode(&code) == -1 )
1489  {
1490  ERR(pTrans->getNdbError());
1491  pNdb->closeTransaction(pTrans);
1492  return NDBT_FAILED;
1493  }
1494 
1495  if (pOp->getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1496  {
1497  ERR(pTrans->getNdbError());
1498  return NDBT_FAILED;
1499  }
1500 
1502  pTrans->refresh();
1503  pTrans->close();
1504  return NDBT_OK;
1505 }
1506 
1507 #define CHK_RET_FAILED(x) if (!(x)) { ndbout_c("Failed on line: %u", __LINE__); return NDBT_FAILED; }
1508 
1509 int
1510 runMixedDML(NDBT_Context* ctx, NDBT_Step* step)
1511 {
1512  Ndb* pNdb = GETNDB(step);
1513  const NdbDictionary::Table* pTab = ctx->getTab();
1514 
1515  unsigned seed = (unsigned)NdbTick_CurrentMillisecond();
1516 
1517  const int rows = ctx->getNumRecords();
1518  const int loops = 10 * ctx->getNumLoops();
1519  const int until_stopped = ctx->getProperty("UntilStopped");
1520  const int batch = ctx->getProperty("Batch", Uint32(50));
1521 
1522  const NdbRecord * pRowRecord = pTab->getDefaultRecord();
1523  CHK_RET_FAILED(pRowRecord != 0);
1524 
1525  const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
1526  Uint8 * pRow = new Uint8[len];
1527 
1528  int count_ok = 0;
1529  int count_failed = 0;
1530  for (int i = 0; i < loops || (until_stopped && !ctx->isTestStopped()); i++)
1531  {
1532  NdbTransaction* pTrans = pNdb->startTransaction();
1533  CHK_RET_FAILED(pTrans != 0);
1534 
1535  int lastrow = 0;
1536  int result = 0;
1537  for (int rowNo = 0; rowNo < batch; rowNo++)
1538  {
1539  int left = rows - lastrow;
1540  int rowId = lastrow;
1541  if (left)
1542  {
1543  rowId += ndb_rand_r(&seed) % (left / 10 + 1);
1544  }
1545  else
1546  {
1547  break;
1548  }
1549  lastrow = rowId;
1550 
1551  bzero(pRow, len);
1552 
1553  HugoCalculator calc(* pTab);
1554  calc.setValues(pRow, pRowRecord, rowId, rand());
1555 
1557  bzero(&opts, sizeof(opts));
1558 
1559  const NdbOperation* pOp = 0;
1560  switch(ndb_rand_r(&seed) % 3){
1561  case 0:
1562  pOp = pTrans->writeTuple(pRowRecord, (char*)pRow,
1563  pRowRecord, (char*)pRow,
1564  0,
1565  &opts,
1566  sizeof(opts));
1567  break;
1568  case 1:
1569  pOp = pTrans->deleteTuple(pRowRecord, (char*)pRow,
1570  pRowRecord, (char*)pRow,
1571  0,
1572  &opts,
1573  sizeof(opts));
1574  break;
1575  case 2:
1576  pOp = pTrans->updateTuple(pRowRecord, (char*)pRow,
1577  pRowRecord, (char*)pRow,
1578  0,
1579  &opts,
1580  sizeof(opts));
1581  break;
1582  }
1583  CHK_RET_FAILED(pOp != 0);
1584  result = pTrans->execute(NoCommit, AO_IgnoreError);
1585  if (result != 0)
1586  {
1587  goto found_error;
1588  }
1589  }
1590 
1591  result = pTrans->execute(Commit, AO_IgnoreError);
1592  if (result != 0)
1593  {
1594  found_error:
1595  count_failed++;
1596  NdbError err = pTrans->getNdbError();
1597  ndbout << err << endl;
1598  CHK_RET_FAILED(err.status == NdbError::TemporaryError ||
1601  }
1602  else
1603  {
1604  count_ok++;
1605  }
1606  pTrans->close();
1607  }
1608 
1609  ndbout_c("count_ok: %d count_failed: %d",
1610  count_ok, count_failed);
1611  delete [] pRow;
1612 
1613  return NDBT_OK;
1614 }
1615 
1616 NDBT_TESTSUITE(testScan);
1617 TESTCASE("ScanRead",
1618  "Verify scan requirement: It should be possible "\
1619  "to read all records in a table without knowing their "\
1620  "primary key."){
1621  INITIALIZER(runLoadTable);
1622  TC_PROPERTY("Parallelism", 1);
1623  STEP(runScanRead);
1624  FINALIZER(runClearTable);
1625 }
1626 TESTCASE("ScanRead16",
1627  "Verify scan requirement: It should be possible to scan read "\
1628  "with parallelism, test with parallelism 16"){
1629  INITIALIZER(runLoadTable);
1630  TC_PROPERTY("Parallelism", 16);
1631  STEP(runScanRead);
1632  FINALIZER(runClearTable);
1633 }
1634 TESTCASE("ScanRead240",
1635  "Verify scan requirement: It should be possible to scan read with "\
1636  "parallelism, test with parallelism 240(240 would automatically be "\
1637  "downgraded to the maximum parallelism value for the current config)"){
1638  INITIALIZER(runLoadTable);
1639  TC_PROPERTY("Parallelism", 240);
1640  STEP(runScanRead);
1641  FINALIZER(runClearTable);
1642 }
1643 TESTCASE("ScanReadCommitted240",
1644  "Verify scan requirement: It should be possible to scan read committed with "\
1645  "parallelism, test with parallelism 240(240 would automatically be "\
1646  "downgraded to the maximum parallelism value for the current config)"){
1647  INITIALIZER(runLoadTable);
1648  TC_PROPERTY("Parallelism", 240);
1649  TC_PROPERTY("TupScan", (Uint32)0);
1650  STEP(runScanReadCommitted);
1651  FINALIZER(runClearTable);
1652 }
1653 TESTCASE("ScanUpdate",
1654  "Verify scan requirement: It should be possible "\
1655  "to update all records in a table without knowing their"\
1656  " primary key."){
1657  INITIALIZER(runLoadTable);
1658  STEP(runScanUpdate);
1659  FINALIZER(runClearTable);
1660 }
1661 TESTCASE("ScanUpdate2",
1662  "Verify scan requirement: It should be possible "\
1663  "to update all records in a table without knowing their"\
1664  " primary key. Do this efficently by calling nextScanResult(false) "\
1665  "in order to update the records already fetched to the api in one batch."){
1666  INITIALIZER(runLoadTable);
1667  TC_PROPERTY("Parallelism", 240);
1668  STEP(runScanUpdate2);
1669  FINALIZER(runClearTable);
1670 }
1671 TESTCASE("ScanDelete",
1672  "Verify scan requirement: It should be possible "\
1673  "to delete all records in a table without knowing their"\
1674  " primary key."){
1675  INITIALIZER(runLoadTable);
1676  STEP(runScanDelete);
1677  FINALIZER(runClearTable);
1678 }
1679 TESTCASE("ScanDelete2",
1680  "Verify scan requirement: It should be possible "\
1681  "to delete all records in a table without knowing their"\
1682  " primary key. Do this efficently by calling nextScanResult(false) "\
1683  "in order to delete the records already fetched to the api in one batch."){
1684  INITIALIZER(runLoadTable);
1685  TC_PROPERTY("Parallelism", 240);
1686  STEP(runScanDelete2);
1687  FINALIZER(runClearTable);
1688 }
1689 TESTCASE("ScanUpdateAndScanRead",
1690  "Verify scan requirement: It should be possible to run "\
1691  "scan read and scan update at the same time"){
1692  INITIALIZER(runLoadTable);
1693  TC_PROPERTY("Parallelism", 16);
1694  STEP(runScanRead);
1695  STEP(runScanUpdate);
1696  FINALIZER(runClearTable);
1697 }
1698 TESTCASE("ScanReadAndLocker",
1699  "Verify scan requirement: The locks are not kept throughout "\
1700  "the entire scan operation. This means that a scan does not "\
1701  "lock the entire table, only the records it's currently "\
1702  "operating on. This will test how scan performs when there are "\
1703  " a number of 1 second locks in the table"){
1704  INITIALIZER(runLoadTable);
1705  STEP(runScanReadUntilStopped);
1706  STEP(runLocker);
1707  FINALIZER(runClearTable);
1708 }
1709 TESTCASE("ScanReadAndPkRead",
1710  "Verify scan requirement: The locks are not kept throughout "\
1711  "the entire scan operation. This means that a scan does not "\
1712  "lock the entire table, only the records it's currently "\
1713  "operating on. This will test how scan performs when there are "\
1714  " a pk reads "){
1715  INITIALIZER(runLoadTable);
1716  STEPS(runScanRead, 2);
1717  STEPS(runPkRead, 2);
1718  FINALIZER(runClearTable);
1719 }
1720 TESTCASE("ScanRead488",
1721  "Verify scan requirement: It's only possible to have 11 concurrent "\
1722  "scans per fragment running in Ndb kernel at the same time. "\
1723  "When this limit is exceeded the scan will be aborted with errorcode "\
1724  "488."){
1725  INITIALIZER(runLoadTable);
1726  STEPS(runRandScanRead, 70);
1727  FINALIZER(runClearTable);
1728 }
1729 TESTCASE("ScanRead488T",
1730  "Verify scan requirement: It's only possible to have 11 concurrent "\
1731  "scans per fragment running in Ndb kernel at the same time. "\
1732  "When this limit is exceeded the scan will be aborted with errorcode "\
1733  "488."){
1734  TC_PROPERTY("TupScan", 1);
1735  INITIALIZER(runLoadTable);
1736  STEPS(runRandScanRead, 70);
1737  FINALIZER(runClearTable);
1738 }
1739 TESTCASE("ScanRead488O",
1740  "Verify scan requirement: It's only possible to have 11 concurrent "\
1741  "scans per fragment running in Ndb kernel at the same time. "\
1742  "When this limit is exceeded the scan will be aborted with errorcode "\
1743  "488."){
1744  INITIALIZER(createOrderedPkIndex);
1745  INITIALIZER(runLoadTable);
1746  STEPS(runScanReadIndex, 70);
1747  FINALIZER(createOrderedPkIndex_Drop);
1748  FINALIZER(runClearTable);
1749 }
1750 TESTCASE("ScanRead488_Mixed",
1751  "Verify scan requirement: It's only possible to have 11 concurrent "\
1752  "scans per fragment running in Ndb kernel at the same time. "\
1753  "When this limit is exceeded the scan will be aborted with errorcode "\
1754  "488."){
1755  TC_PROPERTY("TupScan", 2);
1756  INITIALIZER(createOrderedPkIndex);
1757  INITIALIZER(runLoadTable);
1758  STEPS(runRandScanRead, 50);
1759  STEPS(runScanReadIndex, 50);
1760  FINALIZER(createOrderedPkIndex_Drop);
1761  FINALIZER(runClearTable);
1762 }
1763 TESTCASE("ScanRead488Timeout",
1764  ""){
1765  INITIALIZER(runLoadTable);
1766  TC_PROPERTY("ErrorCode", 5034);
1767  STEPS(runScanRead, 30);
1768  STEP(runScanReadError);
1769  FINALIZER(runClearTable);
1770 }
1771 TESTCASE("ScanRead40",
1772  "Verify scan requirement: Scan with 40 simultaneous threads"){
1773  INITIALIZER(runLoadTable);
1774  STEPS(runScanRead, 40);
1775  FINALIZER(runClearTable);
1776 }
1777 TESTCASE("ScanRead100",
1778  "Verify scan requirement: Scan with 100 simultaneous threads"){
1779  INITIALIZER(runLoadTable);
1780  STEPS(runScanRead, 100);
1781  FINALIZER(runClearTable);
1782 }
1783 TESTCASE("TupScanRead100",
1784  "Verify scan requirement: Scan with 100 simultaneous threads"){
1785  TC_PROPERTY("TupScan", 1);
1786  INITIALIZER(runLoadTable);
1787  STEPS(runScanRead, 100);
1788  FINALIZER(runClearTable);
1789 }
1790 TESTCASE("Scan-bug8262",
1791  ""){
1792  TC_PROPERTY("Rows", 1);
1793  TC_PROPERTY("ErrorCode", 8035);
1794  INITIALIZER(runLoadTable);
1795  INITIALIZER(runInsertError); // Will reset error code
1796  STEPS(runScanRead, 25);
1797  FINALIZER(runInsertError);
1798  FINALIZER(runClearTable);
1799 }
1800 TESTCASE("ScanRead40RandomTable",
1801  "Verify scan requirement: Scan with 40 simultaneous threads. "\
1802  "Use random table for the scan"){
1803  INITIALIZER(runCreateAllTables);
1804  INITIALIZER(runLoadAllTables);
1805  STEPS(runScanReadRandomTable, 40);
1806  FINALIZER(runDropAllTablesExceptTestTable);
1807 }
1808 TESTCASE("ScanRead100RandomTable",
1809  "Verify scan requirement: Scan with 100 simultaneous threads. "\
1810  "Use random table for the scan"){
1811  INITIALIZER(runCreateAllTables);
1812  INITIALIZER(runLoadAllTables);
1813  STEPS(runScanReadRandomTable, 100);
1814  FINALIZER(runDropAllTablesExceptTestTable);
1815 }
1816 TESTCASE("ScanReadRandomPrepare",
1817  "Create and load tables for ScanRead40RandomNoTableCreate."){
1818  INITIALIZER(runCreateAllTables);
1819  INITIALIZER(runLoadAllTables);
1820 }
1821 TESTCASE("ScanRead40RandomNoTableCreate",
1822  "Verify scan requirement: Scan with 40 simultaneous threads. "\
1823  "Use random table for the scan. Dont create or load the tables."){
1824  STEPS(runScanReadRandomTableExceptTestTable, 40);
1825 }
1826 TESTCASE("ScanRead100RandomNoTableCreate",
1827  "Verify scan requirement: Scan with 100 simultaneous threads. "\
1828  "Use random table for the scan. Dont create or load the tables."){
1829  STEPS(runScanReadRandomTableExceptTestTable, 100);
1830 }
1831 TESTCASE("ScanWithLocksAndInserts",
1832  "TR457: This test is added to verify that an insert of a records "\
1833  "that is already in the database does not delete the record"){
1834  INITIALIZER(runLoadTable);
1835  STEPS(runScanReadUntilStopped, 2);
1836  STEP(runLocker);
1837  STEP(runInsertUntilStopped);
1838  FINALIZER(runClearTable);
1839 }
1840 TESTCASE("ScanReadAbort",
1841  "Scan requirement: A scan may be aborted by the application "\
1842  "at any time. This can be performed even if there are more "\
1843  "tuples to scan."){
1844  INITIALIZER(runLoadTable);
1845  TC_PROPERTY("AbortProb", 90);
1846  STEPS(runScanRead, 3);
1847  FINALIZER(runClearTable);
1848 }
1849 TESTCASE("ScanReadAbort15",
1850  "Scan requirement: A scan may be aborted by the application "\
1851  "at any time. This can be performed even if there are more "\
1852  "tuples to scan. Use parallelism 15"){
1853  INITIALIZER(runLoadTable);
1854  TC_PROPERTY("Parallelism", 15);
1855  TC_PROPERTY("AbortProb", 90);
1856  STEPS(runScanRead, 3);
1857  FINALIZER(runClearTable);
1858 }
1859 TESTCASE("ScanReadAbort240",
1860  "Scan requirement: A scan may be aborted by the application "\
1861  "at any time. This can be performed even if there are more "\
1862  "tuples to scan. Use parallelism 240(it will be downgraded to max para for this config)"){
1863  INITIALIZER(runLoadTable);
1864  TC_PROPERTY("Parallelism", 240);
1865  TC_PROPERTY("AbortProb", 90);
1866  STEPS(runScanRead, 3);
1867  FINALIZER(runClearTable);
1868 }
1869 TESTCASE("ScanUpdateAbort16",
1870  "Scan requirement: A scan may be aborted by the application "\
1871  "at any time. This can be performed even if there are more "\
1872  "tuples to scan. Use parallelism 16"){
1873  INITIALIZER(runLoadTable);
1874  TC_PROPERTY("Parallelism", 16);
1875  TC_PROPERTY("AbortProb", 90);
1876  STEPS(runScanUpdate, 3);
1877  FINALIZER(runClearTable);
1878 }
1879 TESTCASE("ScanUpdateAbort240",
1880  "Scan requirement: A scan may be aborted by the application "\
1881  "at any time. This can be performed even if there are more "\
1882  "tuples to scan. Use parallelism 240(it will be downgraded to max para for this config)"){
1883  INITIALIZER(runLoadTable);
1884  TC_PROPERTY("Parallelism", 240);
1885  TC_PROPERTY("AbortProb", 90);
1886  STEPS(runScanUpdate, 3);
1887  FINALIZER(runClearTable);
1888 }
1889 TESTCASE("CheckGetValue",
1890  "Check that we can call getValue to read attributes"\
1891  "Especially interesting to see if we can read only the"\
1892  " first, last or any two attributes from the table"){
1893  INITIALIZER(runLoadTable);
1894  STEP(runCheckGetValue);
1895  VERIFIER(runScanRead);
1896  FINALIZER(runClearTable);
1897 }
1898 TESTCASE("CloseWithoutStop",
1899  "Check that we can close the scanning transaction without calling "\
1900  "stopScan"){
1901  INITIALIZER(runLoadTable);
1902  STEP(runCloseWithoutStop);
1903  VERIFIER(runScanRead);
1904  FINALIZER(runClearTable);
1905 }
1906 TESTCASE("NextScanWhenNoMore",
1907  "Check that we can call nextScanResult when there are no more "\
1908  "records, and that it returns a valid value"){
1909  INITIALIZER(runLoadTable);
1910  STEP(runNextScanWhenNoMore);
1911  VERIFIER(runScanRead);
1912  FINALIZER(runClearTable);
1913 }
1914 TESTCASE("EqualAfterOpenScan",
1915  "Check that we can't call equal after openScan"){
1916  STEP(runEqualAfterOpenScan);
1917 }
1918 TESTCASE("ExecuteScanWithoutOpenScan",
1919  "Check that we can't call executeScan without defining a scan "\
1920  "with openScan"){
1921  INITIALIZER(runLoadTable);
1922  STEP(runExecuteScanWithoutOpenScan);
1923  VERIFIER(runScanRead);
1924  FINALIZER(runClearTable);
1925 }
1926 TESTCASE("OnlyOpenScanOnce",
1927  "Check that we may only call openScan once in the same trans"){
1928  INITIALIZER(runLoadTable);
1929  STEP(runOnlyOpenScanOnce);
1930  VERIFIER(runScanRead);
1931  FINALIZER(runClearTable);
1932 }
1933 TESTCASE("OnlyOneOpInScanTrans",
1934  "Check that we can have only one operation in a scan trans"){
1935  INITIALIZER(runLoadTable);
1936  STEP(runOnlyOneOpInScanTrans);
1937  VERIFIER(runScanRead);
1938  FINALIZER(runClearTable);
1939 }
1940 TESTCASE("OnlyOneOpBeforeOpenScan",
1941  "Check that we can have only one operation in a trans defined "\
1942  "when calling openScan "){
1943  INITIALIZER(runLoadTable);
1944  STEP(runOnlyOneOpBeforeOpenScan);
1945  VERIFIER(runScanRead);
1946  FINALIZER(runClearTable);
1947 }
1948 TESTCASE("OnlyOneScanPerTrans",
1949  "Check that we can have only one scan operation in a trans"){
1950  INITIALIZER(runLoadTable);
1951  STEP(runOnlyOneScanPerTrans);
1952  VERIFIER(runScanRead);
1953  FINALIZER(runClearTable);
1954 }
1955 TESTCASE("NoCloseTransaction",
1956  "Check behaviour when close transaction is not called "){
1957  INITIALIZER(runLoadTable);
1958  STEP(runNoCloseTransaction);
1959  VERIFIER(runScanRead);
1960  FINALIZER(runClearTable);
1961 }
1962 TESTCASE("CheckInactivityTimeOut",
1963  "Check behaviour when the api sleeps for a long time before continuing scan "){
1964  INITIALIZER(runLoadTable);
1965  STEP(runCheckInactivityTimeOut);
1966  VERIFIER(runScanRead);
1967  FINALIZER(runClearTable);
1968 }
1969 TESTCASE("CheckInactivityBeforeClose",
1970  "Check behaviour when the api sleeps for a long time before calling close scan "){
1971  INITIALIZER(runLoadTable);
1972  STEP(runCheckInactivityBeforeClose);
1973  VERIFIER(runScanRead);
1974  FINALIZER(runClearTable);
1975 }
1976 TESTCASE("ScanReadError5021",
1977  "Scan and insert error 5021, one node is expected to crash"){
1978  INITIALIZER(runLoadTable);
1979  TC_PROPERTY("ErrorCode", 5021);
1980  STEP(runScanReadErrorOneNode);
1981  FINALIZER(runClearTable);
1982 }
1983 TESTCASE("ScanReadError5022",
1984  "Scan and insert error 5022, one node is expected to crash"){
1985  INITIALIZER(runLoadTable);
1986  TC_PROPERTY("ErrorCode", 5022);
1987  TC_PROPERTY("NodeNumber", 2);
1988  STEP(runScanReadErrorOneNode);
1989  FINALIZER(runClearTable);
1990 }
1991 TESTCASE("ScanReadError5023",
1992  "Scan and insert error 5023"){
1993  INITIALIZER(runLoadTable);
1994  TC_PROPERTY("ErrorCode", 5023);
1995  STEP(runScanReadError);
1996  FINALIZER(runClearTable);
1997 }
1998 TESTCASE("ScanReadError5024",
1999  "Scan and insert error 5024"){
2000  INITIALIZER(runLoadTable);
2001  TC_PROPERTY("ErrorCode", 5024);
2002  STEP(runScanReadError);
2003  FINALIZER(runClearTable);
2004 }
2005 TESTCASE("ScanReadError5025",
2006  "Scan and insert error 5025"){
2007  INITIALIZER(runLoadTable);
2008  TC_PROPERTY("ErrorCode", 5025);
2009  STEP(runScanReadError);
2010  FINALIZER(runClearTable);
2011 }
2012 TESTCASE("ScanReadError8081",
2013  "Scan and insert error 8081"){
2014  INITIALIZER(runLoadTable);
2015  TC_PROPERTY("ErrorCode", 8081);
2016  STEP(runScanReadError);
2017  FINALIZER(runClearTable);
2018 }
2019 TESTCASE("ScanReadError5030",
2020  "Scan and insert error 5030."\
2021  "Drop all SCAN_NEXTREQ signals in LQH until the node is "\
2022  "shutdown with SYSTEM_ERROR because of scan fragment timeout"){
2023  INITIALIZER(runLoadTable);
2024  TC_PROPERTY("ErrorCode", 5030);
2025  STEP(runScanReadErrorOneNode);
2026  FINALIZER(runClearTable);
2027 }
2028 TESTCASE("ScanReadRestart",
2029  "Scan requirement:A scan should be able to start and "\
2030  "complete during node recovery and when one or more nodes "\
2031  "in the cluster is down.Use random parallelism "){
2032  INITIALIZER(runLoadTable);
2033  TC_PROPERTY("Parallelism", RANDOM_PARALLELISM); // Random
2034  STEP(runScanReadUntilStopped);
2035  STEP(runRestarter);
2036  FINALIZER(runClearTable);
2037 }
2038 TESTCASE("ScanUpdateRestart",
2039  "Scan requirement:A scan should be able to start and "\
2040  "complete during node recovery and when one or more nodes "\
2041  "in the cluster is down. Use random parallelism"){
2042  INITIALIZER(runLoadTable);
2043  TC_PROPERTY("Parallelism", RANDOM_PARALLELISM); // Random
2044  STEP(runScanUpdateUntilStopped);
2045  STEP(runRestarter);
2046  FINALIZER(runClearTable);
2047 }
2048 #if 0
2049 TESTCASE("ScanReadRestart9999",
2050  "Scan requirement:A scan should be able to start and "\
2051  "complete during node recovery and when one or more nodes "\
2052  "in the cluster is down. Use parallelism 240."\
2053  "Restart using error insert 9999"){
2054  INITIALIZER(runLoadTable);
2055  TC_PROPERTY("Parallelism", 240);
2056  STEP(runScanReadUntilStopped);
2057  STEP(runRestarter9999);
2058  FINALIZER(runClearTable);
2059 }
2060 TESTCASE("ScanUpdateRestart9999",
2061  "Scan requirement:A scan should be able to start and "\
2062  "complete during node recovery and when one or more nodes "\
2063  "in the cluster is down. Use parallelism 240."\
2064  "Restart using error insert 9999"){
2065  INITIALIZER(runLoadTable);
2066  TC_PROPERTY("Parallelism", 240);
2067  STEP(runScanReadUntilStopped);
2068  STEP(runScanUpdateUntilStopped);
2069  STEP(runRestarter9999);
2070  FINALIZER(runClearTable);
2071 }
2072 #endif
2073 TESTCASE("InsertDelete",
2074  "Load and delete all while scan updating and scan reading\n"\
2075  "Alexander Lukas special"){
2076  INITIALIZER(runClearTable);
2077  STEP(runScanReadUntilStoppedNoCount);
2078  STEP(runScanUpdateUntilStopped);
2079  STEP(runInsertDelete);
2080  FINALIZER(runClearTable);
2081 }
2082 TESTCASE("Bug48700",
2083  "Load and delete all while scan updating and scan reading\n"\
2084  "Alexander Lukas special"){
2085  TC_PROPERTY("AbortProb", Uint32(0));
2086  TC_PROPERTY("NoCount", 1);
2087  TC_PROPERTY("LockMode", NdbOperation::LM_CommittedRead);
2088  INITIALIZER(runClearTable);
2089  STEPS(runRandScanRead, 10);
2090  STEP(runInsertDelete);
2091  FINALIZER(runClearTable);
2092 }
2093 TESTCASE("CheckAfterTerror",
2094  "Check that we can still scan read after this terror of NdbApi"){
2095  INITIALIZER(runLoadTable);
2096  STEPS(runScanRead, 5);
2097  FINALIZER(runClearTable);
2098 }
2099 TESTCASE("ScanReadWhileNodeIsDown",
2100  "Scan requirement:A scan should be able to run as fast when "\
2101  "one or more nodes in the cluster is down."){
2102  INITIALIZER(runLoadTable);
2103  STEP(runScanReadUntilStoppedPrintTime);
2104  STEP(runStopAndStartNode);
2105  FINALIZER(runClearTable);
2106 }
2107 TESTCASE("ScanParallelism",
2108  "Test scan with different parallelism"){
2109  INITIALIZER(runLoadTable);
2110  STEP(runScanParallelism);
2111  FINALIZER(runClearTable);
2112 }
2113 TESTCASE("ScanVariants",
2114  "Test different scan variants"){
2115  INITIALIZER(runLoadTable);
2116  STEP(runScanVariants);
2117  FINALIZER(runClearTable);
2118 }
2119 TESTCASE("Bug24447",
2120  ""){
2121  INITIALIZER(runLoadTable);
2122  STEP(runBug24447);
2123  FINALIZER(runClearTable);
2124 }
2125 TESTCASE("Bug36124",
2126  "Old interpreted Api usage"){
2127  INITIALIZER(runLoadTable);
2128  STEP(runBug36124);
2129  FINALIZER(runClearTable);
2130 }
2131 TESTCASE("Bug42545", "")
2132 {
2133  INITIALIZER(createOrderedPkIndex);
2134  INITIALIZER(runLoadTable);
2135  STEP(runBug42545);
2136  FINALIZER(createOrderedPkIndex_Drop);
2137  FINALIZER(runClearTable);
2138 }
2139 TESTCASE("Bug42559", "")
2140 {
2141  INITIALIZER(initBug42559);
2142  INITIALIZER(createOrderedPkIndex);
2143  INITIALIZER(runLoadTable);
2144  STEPS(runScanReadIndex, 70);
2145  FINALIZER(createOrderedPkIndex_Drop);
2146  FINALIZER(finalizeBug42559);
2147  FINALIZER(runClearTable);
2148 }
2149 TESTCASE("CloseRefresh", "")
2150 {
2151  INITIALIZER(runCloseRefresh);
2152 }
2153 TESTCASE("Bug54945", "")
2154 {
2155  INITIALIZER(runBug54945);
2156 }
2157 TESTCASE("Bug12324191", "")
2158 {
2159  TC_PROPERTY("LockMode", Uint32(NdbOperation::LM_Read));
2160  TC_PROPERTY("TupScan", Uint32(1));
2161  TC_PROPERTY("Rows", Uint32(0));
2162  INITIALIZER(runLoadTable);
2163  STEP(runScanRead);
2164  STEPS(runMixedDML,10);
2165 }
2166 NDBT_TESTSUITE_END(testScan);
2167 
2168 int main(int argc, const char** argv){
2169  ndb_init();
2170  myRandom48Init((long)NdbTick_CurrentMillisecond());
2171  NDBT_TESTSUITE_INSTANCE(testScan);
2172  return testScan.execute(argc, argv);
2173 }
2174 
2175 template class Vector<Attrib*>;
2176 template class Vector<NdbTransaction*>;