Debian Codegraph @

mysql-test/suite/ndb/t/ndb_tctakeover2.test

raw
1 --source include/have_ndb.inc
2
3 --echo Create table with non standard partitioning
4 --echo allowing colocation of operations in a single LDM
5 create table t1 (a int, b int, c int, primary key(a,b)) engine=ndb partition by key(a);
6
7 --echo Insert some rows
8 --echo All will be on the same partition, LDM instance, nodes
9 insert into t1 values (1,1,1);
10 insert into t1 select 1, b+1, 1 from t1;
11 insert into t1 select 1, b+2, 1 from t1;
12 insert into t1 select 1, b+4, 1 from t1;
13 insert into t1 select 1, b+8, 1 from t1;
14 insert into t1 select 1, b+16, 1 from t1;
15 insert into t1 select 1, b+32, 1 from t1;
16 insert into t1 select 1, b+64, 1 from t1;
17 insert into t1 select 1, b+128, 1 from t1;
18 insert into t1 select 1, b+256, 1 from t1;
19
20 --echo Check LQH operation entry size and records per page.
21 --echo Usable words on page are 32768 - 128
22 let $rpp = query_get_value("select floor((32768-128)/entry_size) as recs_per_page from ndbinfo.ndb\\\$pools where pool_name='LQH Operation Record' LIMIT 1", recs_per_page, 1);
23 #--echo rpp is $rpp
24
25 let $extra_pages=0;
26
27 while ($extra_pages < 2)
28 {
29 --echo Extra pages is $extra_pages
30
31 --echo Start a transaction with a number of operations
32 --echo 100 ops makes it easier to identify in case of noise
33 begin;
34 update t1 set c=c+1 limit 100;
35
36 --echo Determine TC
37 let $tcnode= query_get_value('select node_id from ndbinfo.cluster_transactions where count_operations=100', node_id, 1);
38 #--echo tcnode is $tcnode
39
40 --echo Determine other node
41 let $survnode= query_get_value('select distinct(node_id) from ndbinfo.cluster_operations where node_id!=$tcnode', node_id, 1);
42 #--echo Non TC node with operations is $survnode
43
44 --echo Determine target number of ops
45 --echo as multiple of records per page
46 --echo With optional extra pages to test dynamic sub pool limit
47 let $targetops= query_get_value("select max(total), $extra_pages * $rpp, $rpp * ($extra_pages + floor((max(total) + $rpp - 1) / $rpp)) as target from ndbinfo.ndb\\\$pools where pool_name='LQH Operation Record' and node_id=$survnode", target, 1);
48 #--echo Target operations $targetops
49
50 --echo Check targetops not too small
51 --disable_query_log
52 --eval select $targetops > 200 as enoughTargetOps;
53 --enable_query_log
54
55 --echo Subtract 200 ops
56 --echo 100 for those already created
57 --echo 100 reserved for DBUTIL usage
58 let $extraops = query_get_value("select $targetops - 200 as extraops", extraops, 1);
59
60 #--echo ExtraOps is $extraops
61
62 --echo Consume ops up to target
63
64 --disable_query_log
65 while ($extraops > 0)
66 {
67 update t1 set c=c+1 limit 1;
68 dec $extraops;
69 }
70 --enable_query_log
71
72 #select node_id, block_instance, count(1) from ndbinfo.cluster_operations group by node_id, block_instance;
73 #select * from ndbinfo.ndb$pools where pool_name like "LQH Operation Records";
74 #select node_id, block_instance, min(user_ptr), max(user_ptr) from ndbinfo.ndb$acc_operations group by node_id, block_instance;
75
76 --echo Restart TC node
77 exec $NDB_MGM -e "$tcnode restart -a -n" >> $NDB_TOOLS_OUTPUT;
78
79 --echo Wait for not started state
80 exec $NDB_WAITER --not-started -w $tcnode >> $NDB_TOOLS_OUTPUT;
81
82 --echo Check no operations from failed TC remain (must be none)
83 --disable_query_log
84 --eval select * from ndbinfo.cluster_operations where tc_node_id=$tcnode;
85 --enable_query_log
86
87 --echo Start TC node
88 exec $NDB_MGM -e "$tcnode start" >> $NDB_TOOLS_OUTPUT;
89
90 --echo Wait for all started
91 exec $NDB_WAITER >> $NDB_TOOLS_OUTPUT;
92
93 --echo OK
94
95 --error 1297
96 rollback;
97
98 --inc $extra_pages
99 }
100
101 drop table t1;
102
103 remove_file $NDB_TOOLS_OUTPUT;
104
105
106