Debian Codegraph @

mysql-test/suite/rpl/t/rpl_checksum_cache.test

raw
1 #Want to skip this test from daily Valgrind execution
2 --source include/no_valgrind_without_big.inc
3 --source include/not_group_replication_plugin.inc
4 --source include/not_have_privilege_checks_user.inc
5 -- source include/master-slave.inc
6
7 --disable_warnings
8 call mtr.add_suppression(".* since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the replica. Statement: insert into t2 set data=repeat.*'a', @act_size.*");
9 call mtr.add_suppression(".* since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the replica. Statement: insert into t1 values.* NAME_CONST.*'n',.*, @data .*");
10 call mtr.add_suppression("Replica SQL.*Request to stop replica SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
11 --enable_warnings
12
13 connection master;
14 set @save_binlog_cache_size = @@global.binlog_cache_size;
15 set @save_binlog_checksum = @@global.binlog_checksum;
16 set @save_source_verify_checksum = @@global.source_verify_checksum;
17 set @@global.binlog_cache_size = 4096;
18 set @@global.binlog_checksum = CRC32;
19 set @@global.source_verify_checksum = 1;
20
21 # Sync mtr suppressions before stopping the slave or else we can get "Slave
22 # SQL Thread stopped with incomplete event group having non-transactional
23 # changes" error.
24 --source include/sync_slave_sql_with_master.inc
25 # restart slave to force the dump thread to verify events (on master side)
26 source include/stop_slave.inc;
27 source include/start_slave.inc;
28
29 connection master;
30
31 #
32 # Testing a critical part of checksum handling dealing with transaction cache.
33 # The cache's buffer size is set to be less than the transaction's footprint
34 # in binlog.
35 #
36 # To verify combined buffer-by-buffer read out of the file and fixing crc per event
37 # there are the following parts:
38 #
39 # 1. the event size is much less than the cache's buffer
40 # 2. the event size is bigger than the cache's buffer
41 # 3. the event size if approximately the same as the cache's buffer
42 # 4. all in above
43
44 #
45 # 1. the event size is much less than the cache's buffer
46 #
47
48 flush status;
49 show status like "binlog_cache_use";
50 show status like "binlog_cache_disk_use";
51
52 #
53 # parameter to ensure the test slightly varies binlog content
54 # between different invocations
55 #
56 let $deviation_size=32;
57 eval create table t1 (a int PRIMARY KEY, b CHAR($deviation_size)) engine=innodb;
58
59 # Now we are going to create transaction which is long enough so its
60 # transaction binlog will be flushed to disk...
61
62 delimiter |;
63 create procedure test.p_init (n int, size int)
64 begin
65 while n > 0 do
66 select round(RAND() * size) into @act_size;
67 set @data = repeat('a', @act_size);
68 insert into t1 values(n, @data );
69 set n= n-1;
70 end while;
71 end|
72
73 delimiter ;|
74
75 let $1 = 4000; # PB2 can run it slow to time out on following sync_slave_with_master:s
76
77 begin;
78 --disable_warnings
79 # todo: check if it is really so.
80 #+Note 1592 Unsafe statement binlogged in statement format since BINLOG_FORMAT = STATEMENT. Reason for unsafeness: Statement uses a system function whose value may differ on slave.
81 eval call test.p_init($1, $deviation_size);
82 --enable_warnings
83 commit;
84
85 show status like "binlog_cache_use";
86 --echo *** binlog_cache_disk_use must be non-zero ***
87 show status like "binlog_cache_disk_use";
88
89 --source include/sync_slave_sql_with_master.inc
90
91 let $diff_tables= master:t1, slave:t1;
92 source include/diff_tables.inc;
93
94 # undoing changes with verifying the above once again
95 connection master;
96
97 begin;
98 delete from t1;
99 commit;
100
101 --source include/sync_slave_sql_with_master.inc
102
103 #
104 # 2. the event size is bigger than the cache's buffer
105 #
106 connection master;
107
108 flush status;
109 let $t2_data_size= `select 3 * @@global.binlog_cache_size`;
110 let $t2_aver_size= `select 2 * @@global.binlog_cache_size`;
111 let $t2_max_rand= `select 1 * @@global.binlog_cache_size`;
112
113 eval create table t2(a int auto_increment primary key, data VARCHAR($t2_data_size)) ENGINE=Innodb;
114 let $1=100;
115 --disable_query_log
116 begin;
117 while ($1)
118 {
119 eval select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
120 set @data = repeat('a', @act_size);
121 insert into t2 set data = @data;
122 dec $1;
123 }
124 commit;
125 --enable_query_log
126 show status like "binlog_cache_use";
127 --echo *** binlog_cache_disk_use must be non-zero ***
128 show status like "binlog_cache_disk_use";
129
130 --source include/sync_slave_sql_with_master.inc
131 --let $diff_tables= master:t2, slave:t2
132 source include/diff_tables.inc;
133
134 # undoing changes with verifying the above once again
135 connection master;
136
137 begin;
138 delete from t2;
139 commit;
140
141 --source include/sync_slave_sql_with_master.inc
142 #
143 # 3. the event size if approximately the same as the cache's buffer
144 #
145
146 connection master;
147
148 flush status;
149 let $t3_data_size= `select 2 * @@global.binlog_cache_size`;
150 let $t3_aver_size= `select (9 * @@global.binlog_cache_size) / 10`;
151 let $t3_max_rand= `select (2 * @@global.binlog_cache_size) / 10`;
152
153 eval create table t3(a int auto_increment primary key, data VARCHAR($t3_data_size)) engine=innodb;
154
155 let $1= 300;
156 --disable_query_log
157 begin;
158 while ($1)
159 {
160 eval select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
161 insert into t3 set data= repeat('a', @act_size);
162 dec $1;
163 }
164 commit;
165 --enable_query_log
166 show status like "binlog_cache_use";
167 --echo *** binlog_cache_disk_use must be non-zero ***
168 show status like "binlog_cache_disk_use";
169
170 --source include/sync_slave_sql_with_master.inc
171 --let $diff_tables= master:t3, slave:t3
172 source include/diff_tables.inc;
173
174 # undoing changes with verifying the above once again
175 connection master;
176
177 begin;
178 delete from t3;
179 commit;
180
181 --source include/sync_slave_sql_with_master.inc
182
183 #
184 # 4. all in above
185 #
186
187 connection master;
188 flush status;
189
190 delimiter |;
191 eval create procedure test.p1 (n int)
192 begin
193 while n > 0 do
194 case (select (round(rand()*100) % 3) + 1)
195 when 1 then
196 select round(RAND() * $deviation_size) into @act_size;
197 set @data = repeat('a', @act_size);
198 insert into t1 values(n, @data);
199 when 2 then
200 begin
201 select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size;
202 insert into t2 set data=repeat('a', @act_size);
203 end;
204 when 3 then
205 begin
206 select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size;
207 insert into t3 set data= repeat('a', @act_size);
208 end;
209 end case;
210 set n= n-1;
211 end while;
212 end|
213 delimiter ;|
214
215 let $1= 1000;
216 set autocommit= 0;
217 begin;
218 --disable_warnings
219 eval call test.p1($1);
220 --enable_warnings
221 commit;
222
223 show status like "binlog_cache_use";
224 --echo *** binlog_cache_disk_use must be non-zero ***
225 show status like "binlog_cache_disk_use";
226
227 --source include/sync_slave_sql_with_master.inc
228
229 --let $diff_tables= master:t1, slave:t1
230 source include/diff_tables.inc;
231
232 --let $diff_tables= master:t2, slave:t2
233 source include/diff_tables.inc;
234
235 --let $diff_tables= master:t3, slave:t3
236 source include/diff_tables.inc;
237
238
239 connection master;
240
241 begin;
242 delete from t1;
243 delete from t2;
244 delete from t3;
245 commit;
246
247 drop table t1, t2, t3;
248 set @@global.binlog_cache_size = @save_binlog_cache_size;
249 set @@global.binlog_checksum = @save_binlog_checksum;
250 set @@global.source_verify_checksum = @save_source_verify_checksum;
251 drop procedure test.p_init;
252 drop procedure test.p1;
253
254 --source include/rpl_end.inc