Merge lp:~vlad-lesin/percona-server/5.6-gtid-deployment-step into lp:percona-server/5.6
- 5.6-gtid-deployment-step
- Merge into 5.6
Status: | Merged |
---|---|
Approved by: | Laurynas Biveinis |
Approved revision: | no longer in the source branch. |
Merged at revision: | 729 |
Proposed branch: | lp:~vlad-lesin/percona-server/5.6-gtid-deployment-step |
Merge into: | lp:percona-server/5.6 |
Diff against target: |
717 lines (+570/-4) 11 files modified
mysql-test/r/mysqld--help-notwin.result (+9/-0) mysql-test/suite/rpl/r/rpl_gtid_deployment_step.result (+188/-0) mysql-test/suite/rpl/t/rpl_gtid_deployment_step.test (+193/-0) mysql-test/suite/sys_vars/r/gtid_deployment_step_basic.result (+28/-0) mysql-test/suite/sys_vars/t/gtid_deployment_step_basic.test (+25/-0) sql/binlog.cc (+30/-2) sql/mysqld.cc (+2/-0) sql/mysqld.h (+2/-0) sql/rpl_master.cc (+24/-0) sql/rpl_slave.cc (+3/-2) sql/sys_vars.cc (+66/-0) |
To merge this branch: | bzr merge lp:~vlad-lesin/percona-server/5.6-gtid-deployment-step |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Approve | ||
Review via email: mp+245423@code.launchpad.net |
Commit message
Description of the change
This is the port of Facebook patch for gtid deployment. The new system variable is used to disable GTID generating on slaves.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Vlad Lesin (vlad-lesin) wrote : | # |
> Please see diff comments. The review is conditional on the associated
> blueprint questions as discussed on IRC.
Fixed.
gtid_deployment
Vlad Lesin (vlad-lesin) wrote : | # |
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
- The testcase needs a test for scenario: slave: gtid_mode=on
step=either setting, master gtid_mode=on, and step goes from on
to off dynamically. One question here is whether we need to
perform a binlog rotation on the change of this variable? I
guess we don't, since we don't change the gtid_mode setting
itself, but I'm not too sure here.
- Do we support step going from off to on dynamically? The use
case does not seem to require it, so might be safe to document
this as unsupported (the deployment procedure would change this
variable offline, at the same time gtid_mode is set to ON)
- The blueprint needs description of dynamic step variable
behavior, i.e. what it blocks.
- Four minor diff comments
Vlad Lesin (vlad-lesin) wrote : | # |
> - The testcase needs a test for scenario: slave: gtid_mode=on
> step=either setting, master gtid_mode=on, and step goes from on
> to off dynamically. One question here is whether we need to
> perform a binlog rotation on the change of this variable? I
> guess we don't, since we don't change the gtid_mode setting
> itself, but I'm not too sure here.
> - Do we support step going from off to on dynamically? The use
> case does not seem to require it, so might be safe to document
> this as unsupported (the deployment procedure would change this
> variable offline, at the same time gtid_mode is set to ON)
> - The blueprint needs description of dynamic step variable
> behavior, i.e. what it blocks.
> - Four minor diff comments
Done.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
- I am unable to find the test for dynamic step change on master
as asked for in the last review? Have you looked into whether
binlog rotation is needed?
Vlad Lesin (vlad-lesin) wrote : | # |
> - I am unable to find the test for dynamic step change on master
> as asked for in the last review?
See rpl_gtid_
-- echo ** Dynamically set gtid_deployment
-- connection master
set global gtid_deployment
call master_procedure();
-- replace_regex /[a-f0-
select @@global.
sync_slave_
call slave_procedure();
-- replace_regex /[a-f0-
select @@global.
> Have you looked into whether binlog rotation is needed?
No, binlog rotation is not needed.
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
I see, thanks. Approving but not merging yet until we decide what further testing this receives.
Preview Diff
1 | === modified file 'mysql-test/r/mysqld--help-notwin.result' |
2 | --- mysql-test/r/mysqld--help-notwin.result 2014-12-16 06:00:17 +0000 |
3 | +++ mysql-test/r/mysqld--help-notwin.result 2015-01-09 04:21:04 +0000 |
4 | @@ -259,6 +259,14 @@ |
5 | --group-concat-max-len=# |
6 | The maximum length of the result of function |
7 | GROUP_CONCAT() |
8 | + --gtid-deployment-step |
9 | + Whether gtid_deployment_step is enabled: OFF or ON. ON |
10 | + means GTIDs are supported by the server but no GTID is |
11 | + generated. If the server is a slave and |
12 | + gtid_deployment_step is ON, the slave doesn't generate |
13 | + any GTIDs but logs any GTID received from master. OFF |
14 | + means the server supports GTID depending on the option |
15 | + gtid_mode. |
16 | --gtid-mode=name Whether Global Transaction Identifiers (GTIDs) are |
17 | enabled. Can be ON or OFF. |
18 | -?, --help Display this help and exit. |
19 | @@ -1185,6 +1193,7 @@ |
20 | gdb FALSE |
21 | general-log FALSE |
22 | group-concat-max-len 1024 |
23 | +gtid-deployment-step FALSE |
24 | gtid-mode OFF |
25 | help TRUE |
26 | host-cache-size 279 |
27 | |
28 | === added file 'mysql-test/suite/rpl/r/rpl_gtid_deployment_step.result' |
29 | --- mysql-test/suite/rpl/r/rpl_gtid_deployment_step.result 1970-01-01 00:00:00 +0000 |
30 | +++ mysql-test/suite/rpl/r/rpl_gtid_deployment_step.result 2015-01-09 04:21:04 +0000 |
31 | @@ -0,0 +1,188 @@ |
32 | +include/master-slave.inc |
33 | +Warnings: |
34 | +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. |
35 | +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. |
36 | +[connection master] |
37 | +drop procedure if exists master_procedure; |
38 | +create procedure master_procedure() |
39 | +begin |
40 | +drop table if exists t1; |
41 | +create table t1(id1 int); |
42 | +insert into t1 values(1); |
43 | +insert into t1 values(2); |
44 | +select @@global.gtid_mode; |
45 | +select @@global.gtid_deployment_step; |
46 | +end; |
47 | +// |
48 | +drop procedure if exists slave_procedure; |
49 | +create procedure slave_procedure() |
50 | +begin |
51 | +select @@global.gtid_mode; |
52 | +select @@global.gtid_deployment_step; |
53 | +select * from t1; |
54 | +end; |
55 | +// |
56 | +** Both Master and slave with gtid_deployment_step=0 and gtid_mode=OFF ** |
57 | +call master_procedure(); |
58 | +@@global.gtid_mode |
59 | +OFF |
60 | +@@global.gtid_deployment_step |
61 | +0 |
62 | +call slave_procedure(); |
63 | +@@global.gtid_mode |
64 | +OFF |
65 | +@@global.gtid_deployment_step |
66 | +0 |
67 | +id1 |
68 | +1 |
69 | +2 |
70 | +include/rpl_restart_server.inc [server_number=2 gtids=on parameters: --gtid_deployment_step=1] |
71 | +** Slave with gtid_deployment_step=1 and gtid_mode=ON ** |
72 | +call master_procedure(); |
73 | +@@global.gtid_mode |
74 | +OFF |
75 | +@@global.gtid_deployment_step |
76 | +0 |
77 | +select @@global.gtid_executed; |
78 | +@@global.gtid_executed |
79 | + |
80 | +include/start_slave.inc |
81 | +include/sync_slave_sql_with_master.inc |
82 | +call slave_procedure(); |
83 | +@@global.gtid_mode |
84 | +ON |
85 | +@@global.gtid_deployment_step |
86 | +1 |
87 | +id1 |
88 | +1 |
89 | +2 |
90 | +select @@global.gtid_executed; |
91 | +@@global.gtid_executed |
92 | + |
93 | +include/rpl_restart_server.inc [server_number=1 gtids=on parameters: --gtid_deployment_step=1] |
94 | +** Both master and slave with gtid_deployment_step=1 and gtid_mode=ON ** |
95 | +call master_procedure(); |
96 | +@@global.gtid_mode |
97 | +ON |
98 | +@@global.gtid_deployment_step |
99 | +1 |
100 | +select @@global.gtid_executed; |
101 | +@@global.gtid_executed |
102 | + |
103 | +include/start_slave.inc |
104 | +include/sync_slave_sql_with_master.inc |
105 | +call slave_procedure(); |
106 | +@@global.gtid_mode |
107 | +ON |
108 | +@@global.gtid_deployment_step |
109 | +1 |
110 | +id1 |
111 | +1 |
112 | +2 |
113 | +select @@global.gtid_executed; |
114 | +@@global.gtid_executed |
115 | + |
116 | +** Dynamically set gtid_deployment_step to 0 on master ** |
117 | +set global gtid_deployment_step= 0; |
118 | +call master_procedure(); |
119 | +@@global.gtid_mode |
120 | +ON |
121 | +@@global.gtid_deployment_step |
122 | +0 |
123 | +select @@global.gtid_executed; |
124 | +@@global.gtid_executed |
125 | +UUID:1-4 |
126 | +call slave_procedure(); |
127 | +@@global.gtid_mode |
128 | +ON |
129 | +@@global.gtid_deployment_step |
130 | +1 |
131 | +id1 |
132 | +1 |
133 | +2 |
134 | +select @@global.gtid_executed; |
135 | +@@global.gtid_executed |
136 | +UUID:1-4 |
137 | +include/rpl_restart_server.inc [server_number=1 gtids=on parameters: --gtid_deployment_step=0] |
138 | +** Master with gtid_deployment_step=0 and gtid_mode=ON, slave with gtid_deployment_step=1 and gtid_mode=ON ** |
139 | +call master_procedure(); |
140 | +@@global.gtid_mode |
141 | +ON |
142 | +@@global.gtid_deployment_step |
143 | +0 |
144 | +select @@global.gtid_executed; |
145 | +@@global.gtid_executed |
146 | +UUID:1-8 |
147 | +include/start_slave.inc |
148 | +include/sync_slave_sql_with_master.inc |
149 | +call slave_procedure(); |
150 | +@@global.gtid_mode |
151 | +ON |
152 | +@@global.gtid_deployment_step |
153 | +1 |
154 | +id1 |
155 | +1 |
156 | +2 |
157 | +select @@global.gtid_executed; |
158 | +@@global.gtid_executed |
159 | +UUID:1-8 |
160 | +include/rpl_restart_server.inc [server_number=2 gtids=on parameters: --gtid_deployment_step=0] |
161 | +** Both master and slave with gtid_deployment_step=0 and gtid_mode=ON ** |
162 | +call master_procedure(); |
163 | +@@global.gtid_mode |
164 | +ON |
165 | +@@global.gtid_deployment_step |
166 | +0 |
167 | +select @@global.gtid_executed; |
168 | +@@global.gtid_executed |
169 | +UUID:1-12 |
170 | +include/start_slave.inc |
171 | +include/sync_slave_sql_with_master.inc |
172 | +call slave_procedure(); |
173 | +@@global.gtid_mode |
174 | +ON |
175 | +@@global.gtid_deployment_step |
176 | +0 |
177 | +id1 |
178 | +1 |
179 | +2 |
180 | +select @@global.gtid_executed; |
181 | +@@global.gtid_executed |
182 | +UUID:1-12 |
183 | +drop table t1; |
184 | +drop procedure master_procedure; |
185 | +drop procedure slave_procedure; |
186 | +** Testing scenario where gtid_deployment_step is turned OFF in master causing it to |
187 | +generate gtid_events from the middle of active binlog ** |
188 | +include/rpl_reset.inc |
189 | +include/rpl_restart_server.inc [server_number=2 gtids=on parameters: --gtid_deployment_step=0] |
190 | +include/rpl_restart_server.inc [server_number=1 gtids=on parameters: --gtid_deployment_step=1] |
191 | +create table t1(id1 int); |
192 | +insert into t1 values(100); |
193 | +insert into t1 values(200); |
194 | +include/start_slave.inc |
195 | +include/sync_slave_sql_with_master.inc |
196 | +select * from t1; |
197 | +id1 |
198 | +100 |
199 | +200 |
200 | +include/rpl_restart_server.inc [server_number=1 gtids=on parameters: --gtid_deployment_step=0] |
201 | +insert into t1 values(300); |
202 | +insert into t1 values(400); |
203 | +select @@global.gtid_executed; |
204 | +@@global.gtid_executed |
205 | +UUID:1-2 |
206 | +include/stop_slave.inc |
207 | +change master to master_auto_position=1; |
208 | +include/start_slave.inc |
209 | +select * from t1; |
210 | +id1 |
211 | +100 |
212 | +200 |
213 | +300 |
214 | +400 |
215 | +select @@global.gtid_executed; |
216 | +@@global.gtid_executed |
217 | +UUID:1-2 |
218 | +drop table t1; |
219 | +include/rpl_end.inc |
220 | |
221 | === added file 'mysql-test/suite/rpl/t/rpl_gtid_deployment_step.test' |
222 | --- mysql-test/suite/rpl/t/rpl_gtid_deployment_step.test 1970-01-01 00:00:00 +0000 |
223 | +++ mysql-test/suite/rpl/t/rpl_gtid_deployment_step.test 2015-01-09 04:21:04 +0000 |
224 | @@ -0,0 +1,193 @@ |
225 | +# This test verifies the functionality of the config option |
226 | +# 'gtid_deployment_step'. The scenarios that are tested are |
227 | +# 1) Both Master and slave with gtid_deployment_step=0 and gtid_mode=OFF. |
228 | +# 2) Master with gtid_deployment_step=0 and gtid_mode=OFF, |
229 | +# slave with gtid_deployment_step=1 and gtid_mode=ON. |
230 | +# 3) Both master and slave with gtid_deployment_step=1 and gtid_mode=ON. |
231 | +# 4) Master with gtid_deployment_step=0 and gtid_mode=ON, slave with |
232 | +# gtid_deployment_step=1 and gtid_mode=ON. |
233 | +# 5) Both master and slave with gtid_deployment_step=0 and gtid_mode=ON. |
234 | +# After each scenario, global variable @@gtid_executed is verified to be same |
235 | +# in both master and slave. |
236 | +# |
237 | +-- source include/master-slave.inc |
238 | + |
239 | +-- disable_warnings ONCE |
240 | +drop procedure if exists master_procedure; |
241 | + |
242 | +DELIMITER //; |
243 | +create procedure master_procedure() |
244 | +begin |
245 | + drop table if exists t1; |
246 | + create table t1(id1 int); |
247 | + insert into t1 values(1); |
248 | + insert into t1 values(2); |
249 | + select @@global.gtid_mode; |
250 | + select @@global.gtid_deployment_step; |
251 | +end; |
252 | +// |
253 | +DELIMITER ;// |
254 | + |
255 | +-- disable_warnings ONCE |
256 | +drop procedure if exists slave_procedure; |
257 | + |
258 | +DELIMITER //; |
259 | +create procedure slave_procedure() |
260 | +begin |
261 | + select @@global.gtid_mode; |
262 | + select @@global.gtid_deployment_step; |
263 | + select * from t1; |
264 | +end; |
265 | +// |
266 | +DELIMITER ;// |
267 | + |
268 | +-- echo ** Both Master and slave with gtid_deployment_step=0 and gtid_mode=OFF ** |
269 | +-- connection master |
270 | +call master_procedure(); |
271 | +sync_slave_with_master; |
272 | +call slave_procedure(); |
273 | + |
274 | +-- let $rpl_server_number= 2 |
275 | +-- let $rpl_start_with_gtids= 1 |
276 | +-- let $rpl_server_parameters= --gtid_deployment_step=1 |
277 | +-- source include/rpl_restart_server.inc |
278 | +-- echo ** Slave with gtid_deployment_step=1 and gtid_mode=ON ** |
279 | +-- connection master |
280 | +call master_procedure(); |
281 | +select @@global.gtid_executed; |
282 | +-- connection slave |
283 | +-- disable_warnings |
284 | +-- source include/start_slave.inc |
285 | +-- enable_warnings |
286 | +-- connection master |
287 | +-- let $use_gtids= 0 |
288 | +-- source include/sync_slave_sql_with_master.inc |
289 | +call slave_procedure(); |
290 | +select @@global.gtid_executed; |
291 | + |
292 | +-- let $rpl_server_number= 1 |
293 | +-- let $rpl_start_with_gtids= 1 |
294 | +-- let $rpl_server_parameters= --gtid_deployment_step=1 |
295 | +-- source include/rpl_restart_server.inc |
296 | +-- echo ** Both master and slave with gtid_deployment_step=1 and gtid_mode=ON ** |
297 | +-- connection master |
298 | +call master_procedure(); |
299 | +select @@global.gtid_executed; |
300 | +-- connection slave |
301 | +-- disable_warnings |
302 | +-- source include/start_slave.inc |
303 | +-- enable_warnings |
304 | +-- connection master |
305 | +-- let $use_gtids= 0 |
306 | +-- source include/sync_slave_sql_with_master.inc |
307 | +call slave_procedure(); |
308 | +select @@global.gtid_executed; |
309 | + |
310 | +-- echo ** Dynamically set gtid_deployment_step to 0 on master ** |
311 | +-- connection master |
312 | +set global gtid_deployment_step= 0; |
313 | +call master_procedure(); |
314 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
315 | +select @@global.gtid_executed; |
316 | +sync_slave_with_master; |
317 | +call slave_procedure(); |
318 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
319 | +select @@global.gtid_executed; |
320 | + |
321 | +-- let $rpl_server_number= 1 |
322 | +-- let $rpl_start_with_gtids= 1 |
323 | +-- let $rpl_server_parameters= --gtid_deployment_step=0 |
324 | +-- source include/rpl_restart_server.inc |
325 | +-- echo ** Master with gtid_deployment_step=0 and gtid_mode=ON, slave with gtid_deployment_step=1 and gtid_mode=ON ** |
326 | +-- connection master |
327 | +call master_procedure(); |
328 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
329 | +select @@global.gtid_executed; |
330 | +-- connection slave |
331 | +-- disable_warnings |
332 | +-- source include/start_slave.inc |
333 | +-- enable_warnings |
334 | +-- connection master |
335 | +-- let $use_gtids= 0 |
336 | +-- source include/sync_slave_sql_with_master.inc |
337 | +call slave_procedure(); |
338 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
339 | +select @@global.gtid_executed; |
340 | + |
341 | +-- let $rpl_server_number= 2 |
342 | +-- let $rpl_start_with_gtids= 1 |
343 | +-- let $rpl_server_parameters= --gtid_deployment_step=0 |
344 | +-- source include/rpl_restart_server.inc |
345 | +-- echo ** Both master and slave with gtid_deployment_step=0 and gtid_mode=ON ** |
346 | +-- connection master |
347 | +call master_procedure(); |
348 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
349 | +select @@global.gtid_executed; |
350 | +-- connection slave |
351 | +-- disable_warnings |
352 | +-- source include/start_slave.inc |
353 | +-- enable_warnings |
354 | +-- connection master |
355 | +-- let $use_gtids= 0 |
356 | +-- source include/sync_slave_sql_with_master.inc |
357 | +call slave_procedure(); |
358 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
359 | +select @@global.gtid_executed; |
360 | + |
361 | +-- connection master |
362 | +drop table t1; |
363 | +drop procedure master_procedure; |
364 | +drop procedure slave_procedure; |
365 | + |
366 | +-- echo ** Testing scenario where gtid_deployment_step is turned OFF in master causing it to |
367 | +-- echo generate gtid_events from the middle of active binlog ** |
368 | + |
369 | +-- source include/rpl_reset.inc |
370 | + |
371 | +-- let $rpl_server_number= 2 |
372 | +-- let $rpl_start_with_gtids= 1 |
373 | +-- let $rpl_server_parameters= --gtid_deployment_step=0 |
374 | +-- source include/rpl_restart_server.inc |
375 | + |
376 | +-- let $rpl_server_number= 1 |
377 | +-- let $rpl_start_with_gtids= 1 |
378 | +-- let $rpl_server_parameters= --gtid_deployment_step=1 |
379 | +-- source include/rpl_restart_server.inc |
380 | + |
381 | +-- connection master |
382 | +create table t1(id1 int); |
383 | +insert into t1 values(100); |
384 | +insert into t1 values(200); |
385 | + |
386 | +-- connection slave |
387 | +-- disable_warnings |
388 | +-- source include/start_slave.inc |
389 | +-- enable_warnings |
390 | +-- connection master |
391 | +-- let $use_gtids= 0 |
392 | +-- source include/sync_slave_sql_with_master.inc |
393 | +select * from t1; |
394 | + |
395 | +-- let $rpl_server_number= 1 |
396 | +-- let $rpl_start_with_gtids= 1 |
397 | +-- let $rpl_server_parameters= --gtid_deployment_step=0 |
398 | +-- source include/rpl_restart_server.inc |
399 | +-- connection master |
400 | +insert into t1 values(300); |
401 | +insert into t1 values(400); |
402 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
403 | +select @@global.gtid_executed; |
404 | + |
405 | +-- connection slave |
406 | +-- source include/stop_slave.inc |
407 | +change master to master_auto_position=1; |
408 | +-- source include/start_slave.inc |
409 | +-- connection master |
410 | +sync_slave_with_master; |
411 | +select * from t1; |
412 | +-- replace_regex /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/UUID/ |
413 | +select @@global.gtid_executed; |
414 | + |
415 | +-- connection master |
416 | +drop table t1; |
417 | +-- source include/rpl_end.inc |
418 | |
419 | === added file 'mysql-test/suite/sys_vars/r/gtid_deployment_step_basic.result' |
420 | --- mysql-test/suite/sys_vars/r/gtid_deployment_step_basic.result 1970-01-01 00:00:00 +0000 |
421 | +++ mysql-test/suite/sys_vars/r/gtid_deployment_step_basic.result 2015-01-09 04:21:04 +0000 |
422 | @@ -0,0 +1,28 @@ |
423 | +SET @start_global_value = @@global.gtid_deployment_step; |
424 | +SELECT @start_global_value; |
425 | +@start_global_value |
426 | +0 |
427 | +select @@global.gtid_deployment_step; |
428 | +@@global.gtid_deployment_step |
429 | +0 |
430 | +select @@session.gtid_deployment_step; |
431 | +ERROR HY000: Variable 'gtid_deployment_step' is a GLOBAL variable |
432 | +show global variables like 'gtid_deployment_step'; |
433 | +Variable_name Value |
434 | +gtid_deployment_step OFF |
435 | +show session variables like 'gtid_deployment_step'; |
436 | +Variable_name Value |
437 | +gtid_deployment_step OFF |
438 | +select * from information_schema.global_variables where variable_name='gtid_deployment_step'; |
439 | +VARIABLE_NAME VARIABLE_VALUE |
440 | +GTID_DEPLOYMENT_STEP OFF |
441 | +select * from information_schema.session_variables where variable_name='gtid_deployment_step'; |
442 | +VARIABLE_NAME VARIABLE_VALUE |
443 | +GTID_DEPLOYMENT_STEP OFF |
444 | +set global gtid_deployment_step = "ON"; |
445 | +select @@global.gtid_deployment_step; |
446 | +@@global.gtid_deployment_step |
447 | +1 |
448 | +set session gtid_deployment_step = 1; |
449 | +ERROR HY000: Variable 'gtid_deployment_step' is a GLOBAL variable and should be set with SET GLOBAL |
450 | +set global gtid_deployment_step = default; |
451 | |
452 | === added file 'mysql-test/suite/sys_vars/t/gtid_deployment_step_basic.test' |
453 | --- mysql-test/suite/sys_vars/t/gtid_deployment_step_basic.test 1970-01-01 00:00:00 +0000 |
454 | +++ mysql-test/suite/sys_vars/t/gtid_deployment_step_basic.test 2015-01-09 04:21:04 +0000 |
455 | @@ -0,0 +1,25 @@ |
456 | +-- source include/not_embedded.inc |
457 | + |
458 | +SET @start_global_value = @@global.gtid_deployment_step; |
459 | +SELECT @start_global_value; |
460 | + |
461 | +# |
462 | +# exists as global only |
463 | +# |
464 | +select @@global.gtid_deployment_step; |
465 | +--error ER_INCORRECT_GLOBAL_LOCAL_VAR |
466 | +select @@session.gtid_deployment_step; |
467 | +show global variables like 'gtid_deployment_step'; |
468 | +show session variables like 'gtid_deployment_step'; |
469 | +select * from information_schema.global_variables where variable_name='gtid_deployment_step'; |
470 | +select * from information_schema.session_variables where variable_name='gtid_deployment_step'; |
471 | + |
472 | +set global gtid_deployment_step = "ON"; |
473 | +select @@global.gtid_deployment_step; |
474 | +--error ER_GLOBAL_VARIABLE |
475 | +set session gtid_deployment_step = 1; |
476 | +set global gtid_deployment_step = default; |
477 | + |
478 | +# |
479 | +# See rpl.rpl_gtid_deployment_step.test for a comprehensive test case. |
480 | +# |
481 | |
482 | === modified file 'sql/binlog.cc' |
483 | --- sql/binlog.cc 2014-12-16 06:00:17 +0000 |
484 | +++ sql/binlog.cc 2015-01-09 04:21:04 +0000 |
485 | @@ -945,11 +945,37 @@ |
486 | DBUG_RETURN(0); |
487 | } |
488 | |
489 | +static bool should_write_gtids(const THD *thd) { |
490 | + /* |
491 | + Return false in the situation where slave sql_thread is |
492 | + trying to generate gtid's for binlog events received from master. |
493 | + |
494 | + Note that the check thd->variables.gtid_next.type == AUTOMATIC_GROUP |
495 | + is used to ensure that a new gtid is generated for the transaction group, |
496 | + instead of using SESSION.gtid_next value. |
497 | + */ |
498 | + if (thd->rli_slave && |
499 | + thd->variables.gtid_next.type == AUTOMATIC_GROUP) |
500 | + return false; |
501 | + /* |
502 | + Return true (allow gtids to be generated) in the scenario where |
503 | + gtid_deployment_step is false (Normal run after deployment procedure |
504 | + is done). |
505 | + |
506 | + Return true in the scenario where slave sql_thread uses gtid received from |
507 | + master. This is necessary in the situation where deployment is done on |
508 | + master, but slave still in deployment mode (gtid_deployment_step is true). |
509 | + */ |
510 | + return (!gtid_deployment_step || (thd->rli_slave && |
511 | + thd->variables.gtid_next.type != AUTOMATIC_GROUP)); |
512 | + |
513 | +} |
514 | + |
515 | int binlog_cache_data::write_event(THD *thd, Log_event *ev) |
516 | { |
517 | DBUG_ENTER("binlog_cache_data::write_event"); |
518 | |
519 | - if (gtid_mode > 0) |
520 | + if (gtid_mode > 0 && should_write_gtids(thd)) |
521 | { |
522 | Group_cache::enum_add_group_status status= |
523 | group_cache.add_logged_group(thd, get_byte_position()); |
524 | @@ -1081,8 +1107,10 @@ |
525 | |
526 | DBUG_ASSERT(thd->variables.gtid_next.type != UNDEFINED_GROUP); |
527 | |
528 | - if (gtid_mode == 0) |
529 | + if (gtid_mode == 0 || !should_write_gtids(thd)) |
530 | + { |
531 | DBUG_RETURN(0); |
532 | + } |
533 | |
534 | Group_cache* group_cache= &cache_data->group_cache; |
535 | |
536 | |
537 | === modified file 'sql/mysqld.cc' |
538 | --- sql/mysqld.cc 2014-12-16 07:47:59 +0000 |
539 | +++ sql/mysqld.cc 2015-01-09 04:21:04 +0000 |
540 | @@ -499,6 +499,8 @@ |
541 | my_bool simplified_binlog_gtid_recovery; |
542 | ulong binlog_error_action; |
543 | const char *binlog_error_action_list[]= {"IGNORE_ERROR", "ABORT_SERVER", NullS}; |
544 | +bool gtid_deployment_step= false; |
545 | +bool opt_gtid_deployment_step= false; |
546 | ulong gtid_mode; |
547 | const char *gtid_mode_names[]= |
548 | {"OFF", "UPGRADE_STEP_1", "UPGRADE_STEP_2", "ON", NullS}; |
549 | |
550 | === modified file 'sql/mysqld.h' |
551 | --- sql/mysqld.h 2014-12-16 07:47:59 +0000 |
552 | +++ sql/mysqld.h 2015-01-09 04:21:04 +0000 |
553 | @@ -254,6 +254,8 @@ |
554 | GTID_MODE_ON= 3 |
555 | }; |
556 | extern ulong gtid_mode; |
557 | +extern bool gtid_deployment_step; |
558 | +extern bool opt_gtid_deployment_step; |
559 | extern const char *gtid_mode_names[]; |
560 | extern TYPELIB gtid_mode_typelib; |
561 | |
562 | |
563 | === modified file 'sql/rpl_master.cc' |
564 | --- sql/rpl_master.cc 2014-12-16 06:00:17 +0000 |
565 | +++ sql/rpl_master.cc 2015-01-09 04:21:04 +0000 |
566 | @@ -854,6 +854,7 @@ |
567 | bool searching_first_gtid= using_gtid_protocol; |
568 | bool skip_group= false; |
569 | bool binlog_has_previous_gtids_log_event= false; |
570 | + bool gtid_event_logged= false; |
571 | bool has_transmit_started= false; |
572 | Sid_map *sid_map= slave_gtid_executed ? slave_gtid_executed->get_sid_map() : NULL; |
573 | |
574 | @@ -1345,6 +1346,7 @@ |
575 | "searching gtid(%d).", |
576 | gtid_ev.get_sidno(sid_map), gtid_ev.get_gno(), |
577 | skip_group, searching_first_gtid)); |
578 | + gtid_event_logged= true; |
579 | } |
580 | break; |
581 | |
582 | @@ -1378,6 +1380,19 @@ |
583 | */ |
584 | goto_next_binlog= true; |
585 | |
586 | + if (!gtid_event_logged && using_gtid_protocol) |
587 | + { |
588 | + /* |
589 | + Skip groups in the binlogs which don't have any gtid event |
590 | + logged before them. When gtid_deployment_step is ON, the server |
591 | + doesn't generate GTID and so no gtid_event is logged before binlog |
592 | + events. But when gtid_deployment_step is OFF, the server starts |
593 | + writing gtid_events in the middle of active binlog. When slave |
594 | + connects with gtid_protocol, master needs to skip binlog events |
595 | + which don't have corresponding gtid_event. |
596 | + */ |
597 | + skip_group= true; |
598 | + } |
599 | break; |
600 | } |
601 | |
602 | @@ -1733,6 +1748,7 @@ |
603 | "skip group(%d) searching gtid(%d).", |
604 | gtid_ev.get_sidno(sid_map), gtid_ev.get_gno(), |
605 | skip_group, searching_first_gtid)); |
606 | + gtid_event_logged= true; |
607 | } |
608 | break; |
609 | |
610 | @@ -1764,6 +1780,14 @@ |
611 | and jump to the next one. |
612 | */ |
613 | goto_next_binlog= true; |
614 | + if (!gtid_event_logged && using_gtid_protocol) |
615 | + { |
616 | + /* |
617 | + Skip groups in the binlogs which don't have any gtid event |
618 | + logged before them. |
619 | + */ |
620 | + skip_group= true; |
621 | + } |
622 | |
623 | break; |
624 | } |
625 | |
626 | === modified file 'sql/rpl_slave.cc' |
627 | --- sql/rpl_slave.cc 2014-12-16 06:00:17 +0000 |
628 | +++ sql/rpl_slave.cc 2015-01-09 04:21:04 +0000 |
629 | @@ -2523,8 +2523,9 @@ |
630 | mi->master_gtid_mode= typelib_index - 1; |
631 | break; |
632 | } |
633 | - if (mi->master_gtid_mode > gtid_mode + 1 || |
634 | - gtid_mode > mi->master_gtid_mode + 1) |
635 | + if ((mi->master_gtid_mode > gtid_mode + 1 || |
636 | + gtid_mode > mi->master_gtid_mode + 1) && |
637 | + !gtid_deployment_step) |
638 | { |
639 | mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, |
640 | "The slave IO thread stops because the master has " |
641 | |
642 | === modified file 'sql/sys_vars.cc' |
643 | --- sql/sys_vars.cc 2014-12-16 07:47:59 +0000 |
644 | +++ sql/sys_vars.cc 2015-01-09 04:21:04 +0000 |
645 | @@ -5049,6 +5049,72 @@ |
646 | } |
647 | #endif |
648 | |
649 | +/* This function is based on check_read_only() */ |
650 | +static bool check_gtid_deployment_step(sys_var *self, THD *thd, set_var *var) |
651 | +{ |
652 | + if (thd->locked_tables_mode || thd->in_active_multi_stmt_transaction()) |
653 | + { |
654 | + my_error(ER_LOCK_OR_ACTIVE_TRANSACTION, MYF(0)); |
655 | + return true; |
656 | + } |
657 | + return false; |
658 | +} |
659 | + |
660 | +/* This function is based on fix_read_only() */ |
661 | +static bool fix_gtid_deployment_step(sys_var *self, THD *thd, enum_var_type type) |
662 | +{ |
663 | + DBUG_ENTER("fix_gtid_deployment_step"); |
664 | + bool new_gtid_deployment_step= gtid_deployment_step; |
665 | + bool result= true; |
666 | + |
667 | + if (gtid_deployment_step == FALSE || |
668 | + gtid_deployment_step == opt_gtid_deployment_step) |
669 | + { |
670 | + opt_gtid_deployment_step= gtid_deployment_step; |
671 | + DBUG_RETURN(false); |
672 | + } |
673 | + |
674 | + if (check_gtid_deployment_step(self, thd, 0)) // just in case |
675 | + goto end; |
676 | + |
677 | + gtid_deployment_step= opt_gtid_deployment_step; |
678 | + mysql_mutex_unlock(&LOCK_global_system_variables); |
679 | + |
680 | + if (thd->global_read_lock.lock_global_read_lock(thd)) |
681 | + goto end_with_mutex_unlock; |
682 | + |
683 | + if ((result= thd->global_read_lock.make_global_read_lock_block_commit(thd))) |
684 | + goto end_with_read_lock; |
685 | + |
686 | + /* |
687 | + Change the opt_deployment_step system variable, |
688 | + safe because the lock is held |
689 | + */ |
690 | + opt_gtid_deployment_step= new_gtid_deployment_step; |
691 | + result= false; |
692 | + |
693 | + end_with_read_lock: |
694 | + /* Release the lock */ |
695 | + thd->global_read_lock.unlock_global_read_lock(thd); |
696 | + end_with_mutex_unlock: |
697 | + mysql_mutex_lock(&LOCK_global_system_variables); |
698 | + end: |
699 | + gtid_deployment_step= opt_gtid_deployment_step; |
700 | + DBUG_RETURN(result); |
701 | +} |
702 | + |
703 | +static Sys_var_mybool Sys_gtid_deployment_step( |
704 | + "gtid_deployment_step", |
705 | + "Whether gtid_deployment_step is enabled: OFF or ON. ON means " |
706 | + "GTIDs are supported by the server but no GTID is generated. If the " |
707 | + "server is a slave and gtid_deployment_step is ON, the slave doesn't " |
708 | + "generate any GTIDs but logs any GTID received from master. OFF means " |
709 | + "the server supports GTID depending on the option gtid_mode.", |
710 | + GLOBAL_VAR(gtid_deployment_step), CMD_LINE(OPT_ARG), DEFAULT(FALSE), |
711 | + NO_MUTEX_GUARD, NOT_IN_BINLOG, |
712 | + ON_CHECK(check_gtid_deployment_step), |
713 | + ON_UPDATE(fix_gtid_deployment_step)); |
714 | + |
715 | static Sys_var_enum Sys_gtid_mode( |
716 | "gtid_mode", |
717 | /* |
Please see diff comments. The review is conditional on the associated blueprint questions as discussed on IRC.