Debian Codegraph @

mysql-test/suite/ndb/t/ndb_fully_replicated_restart2.inc

raw
1 # Include file running tests for a specified
2 # restart type
3 #
4 --echo ndb_fully_replicated_restart2.inc ($restart_type)
5
6 --echo Create FR table
7 use test;
8 create table test.t1 (
9 a int primary key,
10 b int,
11 c int,
12 d int,
13 unique(c), key(d))
14 comment="NDB_TABLE=FULLY_REPLICATED=1" engine=ndb;
15
16 --echo Put some stuff into it
17 --disable_query_log
18 --disable_result_log
19 --let $id=5120
20 while ($id)
21 {
22 --eval insert into test.t1 values ($id,$id+1,$id+2,$id+3)
23 --dec $id
24 }
25 --enable_result_log
26 --enable_query_log
27
28
29 --echo *************************
30 --echo Pre-restart checks
31 --echo *************************
32
33 --echo Check row count
34 select count(1) from test.t1 into @row_count;
35 select @row_count;
36
37 --echo Show physical rows per logical row (NoOfReplicas * NumNodeGroups)
38 select floor(sum(fixed_elem_count) / @row_count) as phys_rows_per_row
39 from ndbinfo.memory_per_fragment
40 where fq_name='test/def/t1' into @prpr;
41 select @prpr;
42
43 # Run checks on behaviour of FR table
44 --source ndb_fully_replicated_restart2_checks.inc
45
46
47 # Now perform a restart as specified by the caller
48
49 if ($restart_type == 'SR')
50 {
51 --echo Now perform a system restart
52
53 --exec $NDB_MGM --execute "all restart" >> $NDB_TOOLS_OUTPUT
54
55 --echo Wait for SR to complete
56 --exec $NDB_WAITER
57 }
58
59 if ($restart_type == 'NR')
60 {
61 --echo Now perform a rolling restart
62 # RR is more interesting than a single NR as it restarts every node, so any
63 # required runtime state must be correctly rebuilt
64
65 --echo Node 1
66 --exec $NDB_MGM --execute "1 restart" >> $NDB_TOOLS_OUTPUT
67 --exec $NDB_WAITER
68
69 --echo Node 2
70 --exec $NDB_MGM --execute "2 restart" >> $NDB_TOOLS_OUTPUT
71 --exec $NDB_WAITER
72
73 --echo Node 3
74 --exec $NDB_MGM --execute "3 restart" >> $NDB_TOOLS_OUTPUT
75 --exec $NDB_WAITER
76
77 --echo Node 4
78 --exec $NDB_MGM --execute "4 restart" >> $NDB_TOOLS_OUTPUT
79 --exec $NDB_WAITER
80 }
81
82 if ($restart_type == 'SRTO')
83 {
84 --echo Now perform SR with takeover
85
86 --echo Node 1 restart -n
87 --exec $NDB_MGM --execute "1 restart -n" >> $NDB_TOOLS_OUTPUT
88 --echo Wait for Node 1 to enter NOSTART state
89 --exec $NDB_WAITER --not-started --wait-nodes=1
90
91 --echo Now make some change and trigger some LCP action
92 # Potentially improve this to ensure LCPs complete
93 --exec $NDB_MGM --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT
94 --sleep 10
95 --exec $NDB_MGM --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT
96 --sleep 10
97 --exec $NDB_MGM --execute "ALL DUMP 7099" >> $NDB_TOOLS_OUTPUT
98 --sleep 10
99
100 --echo Now bring down the other nodes
101 --exec $NDB_MGM --execute "ALL restart -n" >> $NDB_TOOLS_OUTPUT
102
103 --echo Wait for them to come down
104 --exec $NDB_WAITER --not-started
105
106 --echo Now start-em up
107 --exec $NDB_MGM --execute "all start" >> $NDB_TOOLS_OUTPUT
108
109 --echo Wait for SR to complete
110 --exec $NDB_WAITER
111 }
112
113
114 --echo --- Wait to establish connection
115 --source include/ndb_not_readonly.inc
116
117
118 --echo **************************
119 --echo Post-restart checks
120 --echo **************************
121
122
123 # Run checks on behaviour of FR table
124 --source ndb_fully_replicated_restart2_checks.inc
125
126
127 --echo Delete the lot
128 delete from test.t1 limit 1024;
129 delete from test.t1 limit 1024;
130 delete from test.t1 limit 1024;
131 delete from test.t1 limit 1024;
132 delete from test.t1 limit 1024;
133 delete from test.t1 limit 1024;
134
135 select count(1) from test.t1 into @new_row_count;
136 select @new_row_count;
137
138 select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1';
139
140 #--echo Show fragment balance
141 #select avg(fixed_elem_count), std(fixed_elem_count), min(fixed_elem_count), max(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1';
142
143 --echo Check new Physical row count against expected
144
145 select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where fq_name='test/def/t1' into @sum;
146 set @diff = (@new_row_count * @prpr) - @sum;
147 select floor(@new_row_count * @prpr) as expected_phys_rows,
148 @sum as actual_phys_rows,
149 @diff as diff;
150
151 --let $d=query_get_value(select @diff as d, d, 1)
152
153 if ($d)
154 {
155 --echo Show actual fragments
156 select * from ndbinfo.memory_per_fragment
157 where fq_name='test/def/t1'
158 order by
159 node_id, fragment_num;
160 --die Physical vs Logical row count error
161 }
162
163 --echo Check UI physical row count against expected
164
165 select sum(fixed_elem_count) from ndbinfo.memory_per_fragment where parent_fq_name='test/def/t1' and fq_name like '%/c$unique' into @sum;
166 set @diff = (@new_row_count * @prpr) - @sum;
167 select floor(@new_row_count * @prpr) as expected_phys_rows,
168 @sum as actual_phys_rows,
169 @diff as diff;
170
171 drop table test.t1;