Merge lp:~akopytov/percona-xtrabackup/bug1239670-2.2 into lp:percona-xtrabackup/2.2

Proposed by Alexey Kopytov
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: no longer in the source branch.
Merged at revision: 4880
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1239670-2.2
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 112 lines (+73/-11)
2 files modified
xtrabackup/innobackupex (+23/-11)
xtrabackup/test/t/bug1239670.sh (+50/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1239670-2.2
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Review via email: mp+192788@code.launchpad.net

Description of the change

    Bug #1239670: xtrabackup_slave_info does not contain GTID purge lists

    Modified innobackupex to detect when the slave server is in the GTID
    mode, and produce the correct (pseudo-)SQL to setup a new slave in this
    case. I.e. xtrabackup_slave_info instead of:

    CHANGE MASTER TO MASTER_LOG_FILE=..., MASTER_LOG_POS=...

    will contain:

    SET GLOBAL gtid_purged=...;
    CHANGE MASTER TO MASTER_AUTO_POSITION=1

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'xtrabackup/innobackupex'
2--- xtrabackup/innobackupex 2013-09-26 06:26:18 +0000
3+++ xtrabackup/innobackupex 2013-10-26 16:08:42 +0000
4@@ -3143,18 +3143,16 @@
5
6 my @lines;
7 my @info_lines;
8- my $position = '';
9- my $filename = '';
10- my $master= '';
11
12 # get slave status
13 get_mysql_slave_status($con);
14
15 # get output of the "show slave status" command from mysql output
16 # and extract binlog position of the master server
17- $master = $con->{slave_status}->{Master_Host};
18- $filename = $con->{slave_status}->{Relay_Master_Log_File};
19- $position = $con->{slave_status}->{Exec_Master_Log_Pos};
20+ my $master = $con->{slave_status}->{Master_Host};
21+ my $filename = $con->{slave_status}->{Relay_Master_Log_File};
22+ my $position = $con->{slave_status}->{Exec_Master_Log_Pos};
23+ my $gtid_executed = $con->{slave_status}->{Executed_Gtid_Set};
24
25 if (!defined($master) || !defined($filename) || !defined($position)) {
26 my $now = current_time();
27@@ -3167,11 +3165,25 @@
28 return;
29 }
30
31- # print slave status to a file
32- write_to_backup_file("$slave_info",
33- "CHANGE MASTER TO MASTER_LOG_FILE='$filename', MASTER_LOG_POS=$position\n");
34-
35- $mysql_slave_position = "master host '$master', filename '$filename', position $position";
36+ # Print slave status to a file.
37+ # If GTID mode is used, construct a CHANGE MASTER statement with
38+ # MASTER_AUTO_POSITION and correct a gtid_purged value.
39+ if (defined($gtid_executed) && $gtid_executed) {
40+ $gtid_executed =~ s/\n/ /;
41+ write_to_backup_file("$slave_info",
42+ "SET GLOBAL gtid_purged='$gtid_executed';\n" .
43+ "CHANGE MASTER TO MASTER_AUTO_POSITION=1\n");
44+ $mysql_slave_position = "master host '$master', ".
45+ "purge list '$gtid_executed'";
46+ } else {
47+ write_to_backup_file("$slave_info",
48+ "CHANGE MASTER TO MASTER_LOG_FILE='$filename', " .
49+ "MASTER_LOG_POS=$position\n");
50+
51+ $mysql_slave_position = "master host '$master', " .
52+ "filename '$filename', " .
53+ "position $position";
54+ }
55 }
56
57 sub eat_sql_whitespace {
58
59=== added file 'xtrabackup/test/t/bug1239670.sh'
60--- xtrabackup/test/t/bug1239670.sh 1970-01-01 00:00:00 +0000
61+++ xtrabackup/test/t/bug1239670.sh 2013-10-26 16:08:42 +0000
62@@ -0,0 +1,50 @@
63+#########################################################################
64+# Bug #1239670: xtrabackup_slave_info does not contain GTID purge lists
65+#########################################################################
66+
67+require_server_version_higher_than 5.6.0
68+
69+MYSQLD_EXTRA_MY_CNF_OPTS="
70+gtid_mode=on
71+log_slave_updates=on
72+enforce_gtid_consistency=on
73+"
74+master_id=1
75+slave_id=2
76+
77+start_server_with_id $master_id
78+start_server_with_id $slave_id
79+
80+setup_slave $slave_id $master_id
81+
82+switch_server $master_id
83+
84+$MYSQL $MYSQL_ARGS test <<EOF
85+CREATE TABLE t(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, c INT);
86+INSERT INTO t(c) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
87+SET AUTOCOMMIT=0;
88+INSERT INTO t(c) SELECT c FROM t;
89+INSERT INTO t(c) SELECT c FROM t;
90+INSERT INTO t(c) SELECT c FROM t;
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+COMMIT;
96+EOF
97+
98+sync_slave_with_master $slave_id $master_id
99+
100+switch_server $slave_id
101+
102+$MYSQL $MYSQL_ARGS -e "SHOW SLAVE STATUS\G"
103+
104+innobackupex --no-timestamp --slave-info $topdir/backup
105+
106+vlog "Verifying format of xtrabackup_slave_info:"
107+f=$topdir/backup/xtrabackup_slave_info
108+echo "---"
109+cat $f
110+echo "---"
111+run_cmd egrep -q '^SET GLOBAL gtid_purged='\''[0-9a-f:, -]+'\' $f
112+run_cmd egrep -q '^CHANGE MASTER TO MASTER_AUTO_POSITION=1' $f

Subscribers

People subscribed via source and target branches

to all changes: