Debian Codegraph @

mysql-test/suite/ndb_binlog/t/ndb_binlog_index_test_schema_independent.inc

raw
1
2 let have_next_pos=query_get_value(select count(1) as have_next_file from information_schema.COLUMNS where table_schema='mysql' and table_name='ndb_binlog_index' and column_name='next_file', have_next_file, 1);
3 let next_file_col=next_file;
4 let next_pos_col=next_position;
5
6 if (!$have_next_pos)
7 {
8 let next_file_col="------"; # Just used in right($next_file_col, 6)
9 let next_pos_col=1; # Just used in ($next_pos_col = 0)
10 }
11
12 --echo mysql.ndb_binlog_index has next_file column? $have_next_pos
13
14 create table t1 (a int, b varchar(400)) engine=ndb;
15
16 #
17 # Test that entries in the mysql.ndb_binlog_index file correctly align
18 # with the offsets in the binlog
19 # Most testing is done with the next_position, as the position is
20 # subject to concurrency issues.
21 #
22
23 --echo Test pure epochs
24 --echo ----------------
25
26 insert into t1 values(1, repeat('B', 400));
27
28 --disable_query_log
29 --disable_result_log
30 show binlog events; # wait for binlog-sync and therefore epoch end
31 --enable_result_log
32 --enable_query_log
33
34 insert into t1 values(1, repeat('F', 400));
35
36 --disable_query_log
37 --disable_result_log
38 show binlog events; # wait for binlog-sync and therefore epoch end
39 --enable_result_log
40 --enable_query_log
41
42 insert into t1 values(1, repeat('E', 400));
43
44 --disable_query_log
45 --disable_result_log
46 show binlog events; # wait for binlog-sync and therefore epoch end
47 --enable_result_log
48 --enable_query_log
49
50 flush logs;
51 --source suite/ndb_binlog/t/ndb_binlog_check_binlog_index.inc
52
53 reset master;
54
55 --echo Test interleaved epochs and DDL
56 --echo ------------------------------
57
58 insert into t1 values(1, repeat('R', 400));
59
60 create table t2 (a int) engine=ndb;
61
62 insert into t1 values(1, repeat('A', 400));
63
64 create table t3 (a int) engine=ndb;
65
66 insert into t1 value(1, repeat('A', 400));
67
68
69 flush logs;
70 --source suite/ndb_binlog/t/ndb_binlog_check_binlog_index.inc
71
72
73 --echo Test multithreaded interleaved epochs and DDL
74 --echo ---------------------------------------------
75 --echo Issue DDL and DML concurrently on server1
76 --echo They will interleave in the Binlog according to Binlog mutex
77 --echo interactions between DDL executing server thread and binlog injector
78 --echo
79 --echo Check Binlog on DDL-source MySQLD to ensure that binlog index positions
80 --echo 'cover' the Binlog
81 --echo Check Binlog on other MySQLD to ensure that binlog index positions
82 --echo 'cover' the Binlog (DDL here is 'fabricated' by Binlog injector thread
83 --echo
84
85 --connect (server1con1, 127.0.0.1,root,,test,$MASTER_MYPORT,)
86 --connect (server1con2, 127.0.0.1,root,,test,$MASTER_MYPORT,)
87 --connect (server2con1, 127.0.0.1,root,,test,$MASTER_MYPORT1,)
88
89 --connection server1con1
90 reset master;
91
92 --connection server2con1
93 reset master;
94
95 --connection server1con1
96
97 set sql_log_bin=0;
98
99 # Table to tell dmlload to stop
100 create table dmlload_stop (
101 value int primary key
102 );
103
104 delimiter %;
105 create procedure dmlload ()
106 begin
107 declare stop int default 0;
108 repeat
109 start transaction;
110 insert into t1 values (2, repeat('I', 400));
111 commit;
112 start transaction;
113 update t1 set b=repeat('Z', 400) where a=2;
114 commit;
115 start transaction;
116 delete from t1 where a=2;
117 commit;
118 select value from dmlload_stop where value = 1 into stop;
119 until stop
120 end repeat;
121 end%
122
123
124 delimiter ;%
125
126 set sql_log_bin=1;
127
128 # Set DML running in 'background'
129 --connection server1con2
130 send call dmlload();
131
132 # Do DDL in 'foreground' until binlog size reach 2Mb.
133 # more sensible
134 --connection server1con1
135 let $i = 1;
136 let $continue = 1;
137 let $start_time= `select time_to_sec(current_time())`;
138 while ($continue)
139 {
140 --disable_query_log
141 create table fmc (a int) engine=myisam;
142 create table bah(a int) engine=ndb;
143 drop table bah;
144 drop table fmc;
145 --enable_query_log
146
147 # Stop generating binlog when:
148 # - at least 4 loops AND binlog size exceeds 2M (fast machine)
149 # OR
150 # - 25 seconds has passed (slow machine, like with valgrind)
151 # These limit are choosen to avoid that too much binlog is generated
152 # which then take very long to analyze (using `mysqlbinlog --verbose` + load
153 # into table and select).
154 # For example fast machine generates 20M binlog during 25 seconds which
155 # yields 600000 lines to analyze, while slow only generates 136k binlog
156 # during those 25 seconds which are possible to analyze even on slow machine
157 if ($i >= 4)
158 {
159 let $log_pos = query_get_value("SHOW BINARY LOGS", File_size, 1);
160 if ($log_pos > 2000000)
161 {
162 #echo [$i]: Size of binlog, log_pos: $log_pos;
163 let $continue = 0;
164 }
165 }
166 if (`select time_to_sec(current_time()) >= $start_time + 25`)
167 {
168 #echo [$i]: time exceeded;
169 #eval select $start_time, time_to_sec(current_time());
170 let $continue = 0;
171 }
172 inc $i;
173 }
174 # Stop the DML load
175 insert into dmlload_stop values(1);
176
177 # Retrieve DML result
178 --connection server1con2
179 reap;
180
181 --connection server1con1
182
183 --echo Now check binlog index vs binlog itself on Server1
184 flush logs;
185 --source suite/ndb_binlog/t/ndb_binlog_check_binlog_index.inc
186
187 --connection server2con1
188 --echo Now check binlog index vs binlog itself on Server2
189 flush logs;
190 --source suite/ndb_binlog/t/ndb_binlog_check_binlog_index.inc
191
192 --connection server1con1
193
194 drop procedure dmlload;
195 drop table dmlload_stop;
196
197 --echo Cleanup
198 drop table t1;
199 drop table t2;
200 drop table t3;
201
202 --connection default
203 --disconnect server1con1
204 --disconnect server1con2
205 --disconnect server2con1