-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtestLimits.cpp
More file actions
1072 lines (851 loc) · 37.7 KB
/
Copy pathtestLimits.cpp
File metadata and controls
1072 lines (851 loc) · 37.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
All rights reserved. Use is subject to license terms.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
#include <NDBT.hpp>
#include <NDBT_Test.hpp>
#include <NdbRestarter.hpp>
#define CHECKNOTNULL(p) if ((p) == NULL) { \
ndbout << "Error at line " << __LINE__ << endl; \
ERR(trans->getNdbError()); \
trans->close(); \
return NDBT_FAILED; }
#define CHECKEQUAL(v, e) if ((e) != (v)) { \
ndbout << "Error at line " << __LINE__ << \
" expected " << v << endl; \
ERR(trans->getNdbError()); \
trans->close(); \
return NDBT_FAILED; }
/* Setup memory as a long Varchar with 2 bytes of
* length information
*/
Uint32 setLongVarchar(char* where, const char* what, Uint32 sz)
{
where[0]=sz & 0xff;
where[1]=(sz >> 8) & 0xff;
memcpy(&where[2], what, sz);
return (sz + 2);
}
/* Activate the given error insert in TC block
* This is used for error insertion where a TCKEYREQ
* is required to activate the error
*/
int activateErrorInsert(NdbTransaction* trans,
const NdbRecord* record,
const NdbDictionary::Table* tab,
const char* buf,
NdbRestarter* restarter,
Uint32 val)
{
/* We insert the error twice to avoid what appear to be
* races between the error insert and the subsequent
* tests
* Alternatively we could sleep here.
*/
if (restarter->insertErrorInAllNodes(val) != 0){
g_err << "error insert 1 (" << val << ") failed" << endl;
return NDBT_FAILED;
}
if (restarter->insertErrorInAllNodes(val) != 0){
g_err << "error insert 2 (" << val << ") failed" << endl;
return NDBT_FAILED;
}
NdbOperation* insert= trans->getNdbOperation(tab);
CHECKNOTNULL(insert);
CHECKEQUAL(0, insert->insertTuple());
CHECKEQUAL(0, insert->equal((Uint32) 0,
NdbDictionary::getValuePtr
(record,
buf,
0)));
CHECKEQUAL(0, insert->setValue(1,
NdbDictionary::getValuePtr
(record,
buf,
1)));
CHECKEQUAL(0, trans->execute(NdbTransaction::NoCommit));
CHECKEQUAL(0, trans->getNdbError().code);
return NDBT_OK;
}
/* Test for correct behaviour using primary key operations
* when an NDBD node's SegmentedSection pool is exhausted.
*/
int testSegmentedSectionPk(NDBT_Context* ctx, NDBT_Step* step){
/*
* Signal type Exhausted @ How
* -----------------------------------------------------
* Long TCKEYREQ Initial import Consume + send
* Long TCKEYREQ Initial import, not first
* TCKEYREQ in batch Consume + send
* Long TCKEYREQ Initial import, not last
* TCKEYREQ in batch Consume + send
* No testing of short TCKEYREQ variants as they cannot be
* generated in mysql-5.1-telco-6.4+
* TODO : Add short variant testing to testUpgrade.
*/
/* We just run on one table */
if (strcmp(ctx->getTab()->getName(), "WIDE_2COL") != 0)
return NDBT_OK;
const Uint32 maxRowBytes= NDB_MAX_TUPLE_SIZE_IN_WORDS * sizeof(Uint32);
const Uint32 srcBuffBytes= NDBT_Tables::MaxVarTypeKeyBytes;
const Uint32 maxAttrBytes= NDBT_Tables::MaxKeyMaxVarTypeAttrBytes;
char smallKey[50];
char srcBuff[srcBuffBytes];
char smallRowBuf[maxRowBytes];
char bigKeyRowBuf[maxRowBytes];
char bigAttrRowBuf[maxRowBytes];
/* Small key for hinting to same TC */
Uint32 smallKeySize= setLongVarchar(&smallKey[0],
"ShortKey",
8);
/* Large value source */
memset(srcBuff, 'B', srcBuffBytes);
const NdbRecord* record= ctx->getTab()->getDefaultRecord();
/* Setup buffers
* Small row buffer with small key and small data
*/
setLongVarchar(NdbDictionary::getValuePtr(record,
smallRowBuf,
0),
"ShortKey",
8);
NdbDictionary::setNull(record, smallRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(record,
smallRowBuf,
1),
"ShortData",
9);
NdbDictionary::setNull(record, smallRowBuf, 1, false);
/* Big key buffer with big key and small data*/
setLongVarchar(NdbDictionary::getValuePtr(record,
bigKeyRowBuf,
0),
&srcBuff[0],
srcBuffBytes);
NdbDictionary::setNull(record, bigKeyRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(record,
bigKeyRowBuf,
1),
"ShortData",
9);
NdbDictionary::setNull(record, bigKeyRowBuf, 1, false);
/* Big AttrInfo buffer with small key and big data */
setLongVarchar(NdbDictionary::getValuePtr(record,
bigAttrRowBuf,
0),
"ShortKey",
8);
NdbDictionary::setNull(record, bigAttrRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(record,
bigAttrRowBuf,
1),
&srcBuff[0],
maxAttrBytes);
NdbDictionary::setNull(record, bigAttrRowBuf, 1, false);
NdbRestarter restarter;
Ndb* pNdb= GETNDB(step);
/* Start a transaction on a specific node */
NdbTransaction* trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize);
CHECKNOTNULL(trans);
/* Activate error insert 8065 in this transaction, limits
* any single import/append to 1 section
*/
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
record,
ctx->getTab(),
smallRowBuf,
&restarter,
8065));
/* Ok, let's try an insert with a key bigger than 1 section.
* Since it's part of the same transaction, it'll go via
* the same TC.
*/
const NdbOperation* bigInsert = trans->insertTuple(record, bigKeyRowBuf);
CHECKNOTNULL(bigInsert);
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Ok, now a long TCKEYREQ to the same TC - this
* has slightly different abort handling since no other
* operations exist in this new transaction.
* We also change it so that import overflow occurs
* on the AttrInfo section
*/
/* Start transaction on the same node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigInsert = trans->insertTuple(record, bigAttrRowBuf));
CHECKEQUAL(-1,trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code);
trans->close();
/* Ok, now a long TCKEYREQ where we run out of SegmentedSections
* on the first TCKEYREQ, but there are other TCKEYREQs following
* in the same batch. Check that abort handling is correct
*/
/* Start transaction on the same node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
/* First op in batch, will cause overflow */
CHECKNOTNULL(bigInsert = trans->insertTuple(record, bigAttrRowBuf));
/* Second op in batch, what happens to it? */
const NdbOperation* secondOp;
CHECKNOTNULL(secondOp = trans->insertTuple(record, bigAttrRowBuf));
CHECKEQUAL(-1,trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code);
trans->close();
/* Now try with a 'short' TCKEYREQ, generated using the old Api
* with a big key value
*/
/* Start transaction on the same node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
NdbOperation* bigInsertOldApi;
CHECKNOTNULL(bigInsertOldApi= trans->getNdbOperation(ctx->getTab()));
CHECKEQUAL(0, bigInsertOldApi->insertTuple());
CHECKEQUAL(0, bigInsertOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(record,
bigKeyRowBuf,
0)));
CHECKEQUAL(0, bigInsertOldApi->setValue(1,
NdbDictionary::getValuePtr
(record,
bigKeyRowBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Now try with a 'short' TCKEYREQ, generated using the old Api
* with a big data value
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigInsertOldApi= trans->getNdbOperation(ctx->getTab()));
CHECKEQUAL(0, bigInsertOldApi->insertTuple());
CHECKEQUAL(0, bigInsertOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(record,
bigAttrRowBuf,
0)));
CHECKEQUAL(0, bigInsertOldApi->setValue(1,
NdbDictionary::getValuePtr
(record,
bigAttrRowBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
// TODO : Add code to testUpgrade
#if 0
/*
* Short TCKEYREQ KeyInfo accumulate Consume + send long
* (TCKEYREQ + KEYINFO)
* Short TCKEYREQ AttrInfo accumulate Consume + send short key
* + long AI
* (TCKEYREQ + ATTRINFO)
*/
/* Change error insert so that next TCKEYREQ will grab
* all but one SegmentedSection so that we can then test SegmentedSection
* exhaustion when importing the Key/AttrInfo words from the
* TCKEYREQ signal itself.
*/
restarter.insertErrorInAllNodes(8066);
/* Now a 'short' TCKEYREQ, there will be space to import the
* short key, but not the AttrInfo
*/
/* Start transaction on same node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigInsertOldApi= trans->getNdbOperation(ctx->getTab()));
CHECKEQUAL(0, bigInsertOldApi->insertTuple());
CHECKEQUAL(0, bigInsertOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(record,
smallRowBuf,
0)));
CHECKEQUAL(0, bigInsertOldApi->setValue(1, NdbDictionary::getValuePtr
(record,
smallRowBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Change error insert so that there are no SectionSegments
* This will cause failure when attempting to import the
* KeyInfo from the TCKEYREQ
*/
restarter.insertErrorInAllNodes(8067);
/* Now a 'short' TCKEYREQ - there will be no space to import the key */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigInsertOldApi= trans->getNdbOperation(ctx->getTab()));
CHECKEQUAL(0, bigInsertOldApi->insertTuple());
CHECKEQUAL(0, bigInsertOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(record,
smallRowBuf,
0)));
CHECKEQUAL(0, bigInsertOldApi->setValue(1,
NdbDictionary::getValuePtr
(record,
smallRowBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
#endif
/* Finished with error insert, cleanup the error insertion
* Error insert 8068 will free the hoarded segments
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
record,
ctx->getTab(),
smallRowBuf,
&restarter,
8068));
trans->execute(NdbTransaction::Rollback);
CHECKEQUAL(0, trans->getNdbError().code);
trans->close();
return NDBT_OK;
}
/* Test for correct behaviour using unique key operations
* when an NDBD node's SegmentedSection pool is exhausted.
*/
int testSegmentedSectionIx(NDBT_Context* ctx, NDBT_Step* step){
/*
* Signal type Exhausted @ How
* -----------------------------------------------------
* Long TCINDXREQ Initial import Consume + send
* Long TCINDXREQ Build second TCKEYREQ Consume + send short
* w. long base key
*/
/* We will generate :
* 10 SS left :
* Long IndexReq with too long Key/AttrInfo
* 1 SS left :
* Long IndexReq read with short Key + Attrinfo to long
* base table Key
*/
/* We just run on one table */
if (strcmp(ctx->getTab()->getName(), "WIDE_2COL_IX") != 0)
return NDBT_OK;
const char* indexName= "WIDE_2COL_IX$NDBT_IDX0";
const Uint32 maxRowBytes= NDB_MAX_TUPLE_SIZE_IN_WORDS * sizeof(Uint32);
const Uint32 srcBuffBytes= NDBT_Tables::MaxVarTypeKeyBytes;
const Uint32 maxIndexKeyBytes= NDBT_Tables::MaxKeyMaxVarTypeAttrBytesIndex;
/* We want to use 6 Segmented Sections, each of 60 32-bit words, including
* a 2 byte length overhead
* (We don't want to use 10 Segmented Sections as in some scenarios TUP
* uses Segmented Sections when sending results, and if we use TUP on
* the same node, the exhaustion will occur in TUP, which is not what
* we're testing)
*/
const Uint32 mediumPrimaryKeyBytes= (6* 60 * 4) - 2;
char smallKey[50];
char srcBuff[srcBuffBytes];
char smallRowBuf[maxRowBytes];
char bigKeyIxBuf[maxRowBytes];
char bigAttrIxBuf[maxRowBytes];
char bigKeyRowBuf[maxRowBytes];
char resultSpace[maxRowBytes];
/* Small key for hinting to same TC */
Uint32 smallKeySize= setLongVarchar(&smallKey[0],
"ShortKey",
8);
/* Large value source */
memset(srcBuff, 'B', srcBuffBytes);
Ndb* pNdb= GETNDB(step);
const NdbRecord* baseRecord= ctx->getTab()->getDefaultRecord();
const NdbRecord* ixRecord= pNdb->
getDictionary()->getIndex(indexName,
ctx->getTab()->getName())->getDefaultRecord();
/* Setup buffers
* Small row buffer with short key and data in base table record format
*/
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
smallRowBuf,
0),
"ShortKey",
8);
NdbDictionary::setNull(baseRecord, smallRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
smallRowBuf,
1),
"ShortData",
9);
NdbDictionary::setNull(baseRecord, smallRowBuf, 1, false);
/* Big index key buffer
* Big index key (normal row attribute) in index record format
* Index's key is attrid 1 from the base table
* This could get confusing !
*/
setLongVarchar(NdbDictionary::getValuePtr(ixRecord,
bigKeyIxBuf,
1),
&srcBuff[0],
maxIndexKeyBytes);
NdbDictionary::setNull(ixRecord, bigKeyIxBuf, 1, false);
/* Big AttrInfo buffer
* Small key and large attrinfo in base table record format */
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
bigAttrIxBuf,
0),
"ShortIXKey",
10);
NdbDictionary::setNull(baseRecord, bigAttrIxBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
bigAttrIxBuf,
1),
&srcBuff[0],
maxIndexKeyBytes);
NdbDictionary::setNull(baseRecord, bigAttrIxBuf, 1, false);
/* Big key row buffer
* Medium sized key and small attrinfo (index key) in
* base table record format
*/
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
bigKeyRowBuf,
0),
&srcBuff[0],
mediumPrimaryKeyBytes);
NdbDictionary::setNull(baseRecord, bigKeyRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(baseRecord,
bigKeyRowBuf,
1),
"ShortIXKey",
10);
NdbDictionary::setNull(baseRecord, bigKeyRowBuf, 1, false);
/* Start a transaction on a specific node */
NdbTransaction* trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize);
/* Insert a row in the base table with a big PK, and
* small data (Unique IX key). This is used later to lookup
* a big PK and cause overflow when reading TRANSID_AI in TC.
*/
CHECKNOTNULL(trans->insertTuple(baseRecord,
bigKeyRowBuf));
CHECKEQUAL(0, trans->execute(NdbTransaction::Commit));
NdbRestarter restarter;
/* Start a transaction on a specific node */
trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize);
CHECKNOTNULL(trans);
/* Activate error insert 8065 in this transaction, limits any
* single append/import to 10 sections.
*/
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
baseRecord,
ctx->getTab(),
smallRowBuf,
&restarter,
8065));
/* Ok, let's try an index read with a big index key.
* Since it's part of the same transaction, it'll go via
* the same TC.
*/
const NdbOperation* bigRead= trans->readTuple(ixRecord,
bigKeyIxBuf,
baseRecord,
resultSpace);
CHECKNOTNULL(bigRead);
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Ok, now a long TCINDXREQ to the same TC - this
* has slightly different abort handling since no other
* operations exist in this new transaction.
*/
/* Start a transaction on a specific node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(trans->readTuple(ixRecord,
bigKeyIxBuf,
baseRecord,
resultSpace));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code);
trans->close();
/* Now a TCINDXREQ that overflows, but is not the last in the
* batch, what happens to the other TCINDXREQ in the batch?
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(trans->readTuple(ixRecord,
bigKeyIxBuf,
baseRecord,
resultSpace));
/* Another read */
CHECKNOTNULL(trans->readTuple(ixRecord,
bigKeyIxBuf,
baseRecord,
resultSpace));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code);
trans->close();
/* Next we read a tuple with a large primary key via the unique
* index. The index read itself should be fine, but
* pulling in the base table PK will cause abort due to overflow
* handling TRANSID_AI
*/
/* Start a transaction on a specific node */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
/* Activate error insert 8066 in this transaction, limits a
* single import/append to 1 section.
* Note that the TRANSID_AI is received by TC as a short-signal
* train, so no single append is large, but when the first
* segment is used and append starts on the second, it will
* fail.
*/
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
baseRecord,
ctx->getTab(),
smallRowBuf,
&restarter,
8066));
CHECKEQUAL(0, trans->execute(NdbTransaction::NoCommit));
CHECKNOTNULL(bigRead= trans->readTuple(ixRecord,
bigAttrIxBuf,
baseRecord,
resultSpace));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
// TODO Move short signal testing to testUpgrade
#if 0
/*
* Short TCINDXREQ KeyInfo accumulate Consume + send long
* (TCINDXREQ + KEYINFO)
* Short TCINDXREQ AttrInfo accumulate Consume + send short key
* + long AI
* (TCINDXREQ + ATTRINFO)
*/
/* Now try with a 'short' TCINDXREQ, generated using the old Api
* with a big index key value
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
const NdbDictionary::Index* index;
CHECKNOTNULL(index= pNdb->getDictionary()->
getIndex(indexName,
ctx->getTab()->getName()));
NdbIndexOperation* bigReadOldApi;
CHECKNOTNULL(bigReadOldApi= trans->getNdbIndexOperation(index));
CHECKEQUAL(0, bigReadOldApi->readTuple());
/* We use the attribute id of the index, not the base table here */
CHECKEQUAL(0, bigReadOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(ixRecord,
bigKeyIxBuf,
1)));
CHECKNOTNULL(bigReadOldApi->getValue((Uint32)1));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Now try with a 'short' TCINDXREQ, generated using the old Api
* with a big attrinfo value
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
NdbIndexOperation* bigUpdateOldApi;
CHECKNOTNULL(bigUpdateOldApi= trans->getNdbIndexOperation(index));
CHECKEQUAL(0, bigUpdateOldApi->updateTuple());
/* We use the attribute id of the index, not the base table here */
CHECKEQUAL(0, bigUpdateOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(baseRecord,
smallRowBuf,
1)));
CHECKEQUAL(0, bigUpdateOldApi->setValue((Uint32)1,
NdbDictionary::getValuePtr
(baseRecord,
bigAttrIxBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Change error insert so that next TCINDXREQ will grab
* all but one SegmentedSection
*/
restarter.insertErrorInAllNodes(8066);
/* Now a short TCINDXREQ where the KeyInfo from the TCINDXREQ
* can be imported, but the ATTRINFO can't
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigUpdateOldApi= trans->getNdbIndexOperation(index));
CHECKEQUAL(0, bigUpdateOldApi->updateTuple());
/* We use the attribute id of the index, not the base table here */
CHECKEQUAL(0, bigUpdateOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(baseRecord,
smallRowBuf,
1)));
CHECKEQUAL(0, bigUpdateOldApi->setValue((Uint32)1,
NdbDictionary::getValuePtr
(baseRecord,
bigAttrIxBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
/* Change error insert so that there are no SectionSegments */
restarter.insertErrorInAllNodes(8067);
/* Now a short TCINDXREQ where the KeyInfo from the TCINDXREQ
* can't be imported
*/
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKNOTNULL(bigUpdateOldApi= trans->getNdbIndexOperation(index));
CHECKEQUAL(0, bigUpdateOldApi->updateTuple());
/* We use the attribute id of the index, not the base table here */
CHECKEQUAL(0, bigUpdateOldApi->equal((Uint32)0,
NdbDictionary::getValuePtr
(baseRecord,
smallRowBuf,
1)));
CHECKEQUAL(0, bigUpdateOldApi->setValue((Uint32)1,
NdbDictionary::getValuePtr
(baseRecord,
bigAttrIxBuf,
1)));
CHECKEQUAL(-1, trans->execute(NdbTransaction::NoCommit));
/* ZGET_DATABUF_ERR expected */
CHECKEQUAL(218, trans->getNdbError().code)
trans->close();
#endif
/* Finished with error insert, cleanup the error insertion */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
baseRecord,
ctx->getTab(),
smallRowBuf,
&restarter,
8068));
trans->execute(NdbTransaction::Rollback);
CHECKEQUAL(0, trans->getNdbError().code);
trans->close();
return NDBT_OK;
}
int testSegmentedSectionScan(NDBT_Context* ctx, NDBT_Step* step){
/* Test that TC handling of segmented section exhaustion is
* correct
* Since NDBAPI always send long requests, that is all that
* we test
*/
/* We just run on one table */
if (strcmp(ctx->getTab()->getName(), "WIDE_2COL") != 0)
return NDBT_OK;
const Uint32 maxRowBytes= NDB_MAX_TUPLE_SIZE_IN_WORDS * sizeof(Uint32);
char smallKey[50];
char smallRowBuf[maxRowBytes];
Uint32 smallKeySize= setLongVarchar(&smallKey[0],
"ShortKey",
8);
const NdbRecord* record= ctx->getTab()->getDefaultRecord();
/* Setup buffers
* Small row buffer with small key and small data
*/
setLongVarchar(NdbDictionary::getValuePtr(record,
smallRowBuf,
0),
"ShortKey",
8);
NdbDictionary::setNull(record, smallRowBuf, 0, false);
setLongVarchar(NdbDictionary::getValuePtr(record,
smallRowBuf,
1),
"ShortData",
9);
NdbDictionary::setNull(record, smallRowBuf, 1, false);
NdbRestarter restarter;
Ndb* pNdb= GETNDB(step);
/* Start a transaction on a specific node */
NdbTransaction* trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize);
CHECKNOTNULL(trans);
/* Activate error insert 8066 in this transaction, limits a
* single import/append to 1 section.
*/
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
record,
ctx->getTab(),
smallRowBuf,
&restarter,
8066));
/* A scan will always send 2 long sections (Receiver Ids,
* AttrInfo)
* Let's start a scan with > 2400 bytes of
* ATTRINFO and see what happens
*/
NdbScanOperation* scan= trans->getNdbScanOperation(ctx->getTab());
CHECKNOTNULL(scan);
CHECKEQUAL(0, scan->readTuples());
/* Create a particularly useless program */
NdbInterpretedCode prog;
for (Uint32 w=0; w < 2500; w++)
CHECKEQUAL(0, prog.load_const_null(1));
CHECKEQUAL(0, prog.interpret_exit_ok());
CHECKEQUAL(0, prog.finalise());
CHECKEQUAL(0, scan->setInterpretedCode(&prog));
/* Api doesn't seem to wait for result of scan request */
CHECKEQUAL(0, trans->execute(NdbTransaction::NoCommit));
CHECKEQUAL(0, trans->getNdbError().code);
CHECKEQUAL(-1, scan->nextResult());
CHECKEQUAL(217, scan->getNdbError().code);
trans->close();
/* Finished with error insert, cleanup the error insertion */
CHECKNOTNULL(trans= pNdb->startTransaction(ctx->getTab(),
&smallKey[0],
smallKeySize));
CHECKEQUAL(NDBT_OK, activateErrorInsert(trans,
record,
ctx->getTab(),
smallRowBuf,
&restarter,
8068));
CHECKEQUAL(0, trans->execute(NdbTransaction::Rollback));
CHECKEQUAL(0, trans->getNdbError().code);
trans->close();
return NDBT_OK;
}
int testDropSignalFragments(NDBT_Context* ctx, NDBT_Step* step){
/* Segmented section exhaustion results in dropped signals
* Fragmented signals split one logical signal over multiple
* physical signals (to cope with the MAX_SIGNAL_LENGTH=32kB
* limitation).
* This testcase checks that when individual signals comprising
* a fragmented signal (in this case SCANTABREQ) are dropped, the
* system behaves correctly.
* Correct behaviour is to behave in the same way as if the signal
* was not fragmented, and for SCANTABREQ, to return a temporary
* resource error.
*/
NdbRestarter restarter;
Ndb* pNdb= GETNDB(step);
/* SEND > ((2 * MAX_SEND_MESSAGE_BYTESIZE) + SOME EXTRA)
* This way we get at least 3 fragments
* However, as this is generally > 64kB, it's too much AttrInfo for
* a ScanTabReq, so the 'success' case returns error 874
*/
const Uint32 PROG_WORDS= 16500;
struct SubCase
{
Uint32 errorInsertCode;
int expectedRc;
};
const Uint32 numSubCases= 5;
const SubCase cases[numSubCases]=
/* Error insert Scanrc */
{{ 0, 874}, // Normal, success which gives too much AI error
{ 8074, 217}, // Drop first fragment -> error 217
{ 8075, 217}, // Drop middle fragment(s) -> error 217
{ 8076, 217}, // Drop last fragment -> error 217
{ 8077, 217}}; // Drop all fragments -> error 217
const Uint32 numIterations= 50;
Uint32 buff[ PROG_WORDS + 10 ]; // 10 extra for final 'return' etc.
for (Uint32 iteration=0; iteration < (numIterations * numSubCases); iteration++)
{
/* Start a transaction */
NdbTransaction* trans= pNdb->startTransaction();
CHECKNOTNULL(trans);
SubCase subcase= cases[iteration % numSubCases];
Uint32 errorInsertVal= subcase.errorInsertCode;
// printf("Inserting error : %u\n", errorInsertVal);
/* We insert the error twice, to bias races between
* error-insert propagation and the succeeding scan