Merge lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1391041 into lp:percona-xtrabackup/2.2

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: 5047
Merged at revision: 5049
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1391041
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 191 lines (+95/-12)
6 files modified
storage/innobase/xtrabackup/doc/source/howtos/recipes_ibkx_gtid.rst (+2/-2)
storage/innobase/xtrabackup/innobackupex.pl (+16/-6)
storage/innobase/xtrabackup/test/t/bug1391041.sh (+73/-0)
storage/innobase/xtrabackup/test/t/bug977101.sh (+2/-2)
storage/innobase/xtrabackup/test/t/gtid.sh (+1/-1)
storage/innobase/xtrabackup/test/t/ib_slave_info.sh (+1/-1)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/2.2-xb-bug1391041
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+243264@code.launchpad.net

Description of the change

Bug 1391041: innobackupex should skip GTID output is GTID_MODE is OFF

For MySQL:

1. If GTID_MODE is ON print only GTID of the last change
2. If GTID_MODE is OFF print filename and position

For MariaDB always print filename, position and GTID,
because MariaDB can be easily switched between GTID and
non-GTID and both file/pos and GTID are up to date.

http://jenkins.percona.com/view/PXB%202.2/job/percona-xtrabackup-2.2-param/252/

To post a comment you must log in.
Alexey Kopytov (akopytov) wrote :

Sergei,

What about xtrabackup_binlog_info? As in, why does it still contain both GTID and non-GTID coordinates regardless of gtid_mode?

review: Needs Information

It's a fair question. I modified the code and docs to leave xtrabackup_binlog_info with only GTID or non-GTID, but not both.
http://jenkins.percona.com/view/PXB%202.2/job/percona-xtrabackup-2.2-param/256/

Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage/innobase/xtrabackup/doc/source/howtos/recipes_ibkx_gtid.rst'
2--- storage/innobase/xtrabackup/doc/source/howtos/recipes_ibkx_gtid.rst 2013-05-13 13:29:59 +0000
3+++ storage/innobase/xtrabackup/doc/source/howtos/recipes_ibkx_gtid.rst 2014-12-02 15:12:45 +0000
4@@ -17,11 +17,11 @@
5 In the destination folder there will be a file with the name :file:`xtrabackup_binlog_info`. This file will contain both, binary log coordinates and ``GTID`` information. ::
6
7 $ cat xtrabackup_binlog_info
8- mysql-bin.000002 1232 c777888a-b6df-11e2-a604-080027635ef5:1-4
9+ c777888a-b6df-11e2-a604-080027635ef5:1-4
10
11 That information is also printed by innobackupex after backup is taken: ::
12
13- innobackupex: MySQL binlog position: filename 'mysql-bin.000002', position 1232, gtid_executed c777888a-b6df-11e2-a604-080027635ef5:1-4
14+ innobackupex: MySQL binlog position: GTID of the last change 'c777888a-b6df-11e2-a604-080027635ef5:1-4'
15
16 STEP 2: Prepare the backup
17 --------------------------
18
19=== modified file 'storage/innobase/xtrabackup/innobackupex.pl'
20--- storage/innobase/xtrabackup/innobackupex.pl 2014-11-21 09:07:50 +0000
21+++ storage/innobase/xtrabackup/innobackupex.pl 2014-12-02 15:12:45 +0000
22@@ -3085,13 +3085,21 @@
23 # from the SHOW MASTER STATUS output
24 my $filename = $con->{master_status}->{File};
25 my $position = $con->{master_status}->{Position};
26+ my $mysql_gtid = defined($con->{vars}->{gtid_mode}) &&
27+ $con->{vars}->{gtid_mode}->{Value} eq 'ON';
28+ my $mariadb_gtid = defined($con->{vars}->{gtid_current_pos});
29+ my @binlog_coordinates;
30+ my @binlog_info_content;
31
32 # Do not create xtrabackup_binlog_info if binary log is disabled
33 if (!defined($filename) or !defined($position)) {
34 return;
35 }
36
37- $mysql_binlog_position = "filename '$filename', position $position";
38+ if ($mariadb_gtid || !$mysql_gtid) {
39+ @binlog_coordinates = ("filename '$filename'", "position $position");
40+ @binlog_info_content = ($filename, $position);
41+ }
42
43 $gtid = $con->{master_status}->{Executed_Gtid_Set};
44 if (!defined($gtid)) {
45@@ -3100,14 +3108,16 @@
46 $gtid = $con->{vars}->{gtid_current_pos}->{Value};
47 }
48
49- if (defined($gtid)) {
50- $mysql_binlog_position .= ", GTID of the last change '$gtid'";
51- } else {
52- $gtid = '';
53+ if ($mariadb_gtid || $mysql_gtid) {
54+ push(@binlog_coordinates, "GTID of the last change '$gtid'");
55+ push(@binlog_info_content, $gtid);
56 }
57
58+ $mysql_binlog_position = join(", ", @binlog_coordinates);
59+
60 # write binlog info file
61- write_to_backup_file("$binlog_info", "$filename\t$position\t\t$gtid\n");
62+ write_to_backup_file($binlog_info,
63+ join("\t", @binlog_info_content) . "\n");
64 }
65
66 #
67
68=== added file 'storage/innobase/xtrabackup/test/t/bug1391041.sh'
69--- storage/innobase/xtrabackup/test/t/bug1391041.sh 1970-01-01 00:00:00 +0000
70+++ storage/innobase/xtrabackup/test/t/bug1391041.sh 2014-12-02 15:12:45 +0000
71@@ -0,0 +1,73 @@
72+########################################################################
73+# Bug 1391041: innobackupex should skip GTID output is GTID_MODE is OFF
74+########################################################################
75+
76+. inc/common.sh
77+
78+require_server_version_higher_than 5.6.0
79+
80+MYSQLD_EXTRA_MY_CNF_OPTS="
81+gtid_mode=on
82+log_slave_updates=on
83+enforce_gtid_consistency=on
84+"
85+start_server
86+
87+$MYSQL $MYSQL_ARGS test <<EOF
88+CREATE TABLE t(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c INT);
89+INSERT INTO t(c) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
90+SET AUTOCOMMIT=0;
91+INSERT INTO t(c) SELECT c FROM t;
92+INSERT INTO t(c) SELECT c FROM t;
93+INSERT INTO t(c) SELECT c FROM t;
94+INSERT INTO t(c) SELECT c FROM t;
95+INSERT INTO t(c) SELECT c FROM t;
96+INSERT INTO t(c) SELECT c FROM t;
97+INSERT INTO t(c) SELECT c FROM t;
98+COMMIT;
99+EOF
100+
101+innobackupex --no-timestamp $topdir/backup
102+
103+binlog_info=$topdir/backup/xtrabackup_binlog_info
104+
105+if egrep -q "filename.*position" $OUTFILE ; then
106+ die "Found filename/position with GTID_MODE=ON"
107+fi
108+
109+if ! egrep -q "GTID of the last change" $OUTFILE ; then
110+ die "GTID of the last change not found with GTID_MODE=ON"
111+fi
112+
113+if egrep -q "^mysql-bin.[0-9]+[[:space:]]+[0-9]+$" $binlog_info ; then
114+ die "Found filename/position with GTID_MODE=ON"
115+fi
116+
117+if ! egrep -q "^[a-f0-9:-]+$" $binlog_info ; then
118+ die "GTID not found in xtrabackup_binlog_info with GTID_MODE=ON"
119+fi
120+
121+echo -n >$OUTFILE
122+rm -rf $topdir/backup
123+MYSQLD_EXTRA_MY_CNF_OPTS=
124+
125+stop_server
126+start_server
127+
128+innobackupex --no-timestamp $topdir/backup
129+
130+if egrep -q "GTID of the last change" $OUTFILE ; then
131+ die "Found GTID of the last change with GTID_MODE=OFF"
132+fi
133+
134+if ! grep -q "filename.*position" $OUTFILE ; then
135+ die "filename/position not found with GTID_MODE=OFF"
136+fi
137+
138+if ! egrep -q "^mysql-bin.[0-9]+[[:space:]]+[0-9]+$" $binlog_info ; then
139+ die "Found filename/position in xtrabackup_binlog_info with GTID_MODE=OFF"
140+fi
141+
142+if egrep -q "^[a-f0-9:-]+$" $binlog_info ; then
143+ die "Found GTID of the last change in xtrabackup_binlog_info with GTID_MODE=OFF"
144+fi
145
146=== modified file 'storage/innobase/xtrabackup/test/t/bug977101.sh'
147--- storage/innobase/xtrabackup/test/t/bug977101.sh 2013-04-27 18:48:50 +0000
148+++ storage/innobase/xtrabackup/test/t/bug977101.sh 2014-12-02 15:12:45 +0000
149@@ -17,14 +17,14 @@
150
151 # Check that binlog info is correct with --safe-slave-backup
152 innobackupex --no-timestamp --safe-slave-backup $topdir/backup
153-run_cmd egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+[[:space:]]+$' \
154+run_cmd egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+$' \
155 $topdir/backup/xtrabackup_binlog_info
156
157 # Check that both binlog info and slave info are correct with
158 # --safe-slave-backup
159 rm -rf $topdir/backup
160 innobackupex --no-timestamp --slave-info --safe-slave-backup $topdir/backup
161-run_cmd egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+[[:space:]]+$' \
162+run_cmd egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+$' \
163 $topdir/backup/xtrabackup_binlog_info
164 run_cmd egrep -q '^CHANGE MASTER TO MASTER_LOG_FILE='\''mysql-bin.[0-9]+'\'', MASTER_LOG_POS=[0-9]+$' \
165 $topdir/backup/xtrabackup_slave_info
166
167=== modified file 'storage/innobase/xtrabackup/test/t/gtid.sh'
168--- storage/innobase/xtrabackup/test/t/gtid.sh 2013-07-25 15:04:49 +0000
169+++ storage/innobase/xtrabackup/test/t/gtid.sh 2014-12-02 15:12:45 +0000
170@@ -30,7 +30,7 @@
171 innobackupex --no-timestamp $topdir/backup
172
173 # Check that the value of gtid_executed is in xtrabackup_binlog_info
174-if ! egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+[[:space:]]+[a-f0-9:-]+$' \
175+if ! egrep -q '^[a-f0-9:-]+$' \
176 $topdir/backup/xtrabackup_binlog_info
177 then
178 die "Cannot find GTID coordinates in xtrabackup_binlog_info"
179
180=== modified file 'storage/innobase/xtrabackup/test/t/ib_slave_info.sh'
181--- storage/innobase/xtrabackup/test/t/ib_slave_info.sh 2013-08-18 18:07:09 +0000
182+++ storage/innobase/xtrabackup/test/t/ib_slave_info.sh 2014-12-02 15:12:45 +0000
183@@ -22,7 +22,7 @@
184 $topdir/backup
185
186 innobackupex --no-timestamp --slave-info $topdir/backup
187-egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+[[:space:]]+$' \
188+egrep -q '^mysql-bin.[0-9]+[[:space:]]+[0-9]+$' \
189 $topdir/backup/xtrabackup_binlog_info
190 egrep -q '^CHANGE MASTER TO MASTER_LOG_FILE='\''mysql-bin.[0-9]+'\'', MASTER_LOG_POS=[0-9]+$' \
191 $topdir/backup/xtrabackup_slave_info

Subscribers

People subscribed via source and target branches