Merge lp:~akopytov/percona-xtrabackup/bug977101-2.0 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 437
Proposed branch: lp:~akopytov/percona-xtrabackup/bug977101-2.0
Merge into: lp:percona-xtrabackup/2.0
Prerequisite: lp:~akopytov/percona-xtrabackup/replication-support-in-test-suite-2.0
Diff against target: 108 lines (+40/-23)
2 files modified
innobackupex (+9/-23)
test/t/bug977101.sh (+31/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug977101-2.0
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+108821@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Stewart Smith (stewart) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex'
2--- innobackupex 2012-05-23 17:06:52 +0000
3+++ innobackupex 2012-06-08 18:50:29 +0000
4@@ -1207,28 +1207,21 @@
5 #
6 sub write_binlog_info {
7 my @lines;
8- my @info_lines = ();
9 my $position = '';
10 my $filename = '';
11
12 # get binlog position
13- mysql_send "SHOW MASTER STATUS;";
14+ mysql_send 'SHOW MASTER STATUS\G';
15
16- # get "show master status" output lines (2) from mysql output
17+ # get the name of the last binlog file and position in it
18+ # from the SHOW MASTER STATUS output
19 file_to_array($mysql_stdout, \@lines);
20- foreach my $line (@lines) {
21- if ($line =~ m/xtrabackup ping/) {
22- # this is a hello message, ignore it
23- } else {
24- # this is output line from "show master status"
25- push(@info_lines, $line);
26- }
27+ foreach (@lines) {
28+ $filename = $1 if /^\s+File:\s(\S+)\s*$/;
29+ $position = $1 if /^\s+Position:\s(\d+)\s*$/;
30 }
31
32 # write binlog info file
33- if (!defined $info_lines[1]) {
34- $info_lines[1] = "";
35- }
36 if (!$option_remote_host) {
37 open(FILE, ">$binlog_info") ||
38 Die "Failed to open file '$binlog_info': $!";
39@@ -1236,7 +1229,7 @@
40 open(FILE, "| ssh $option_ssh_opt $option_remote_host 'cat > $binlog_info'") ||
41 Die "Failed to open file '$option_remote_host:$binlog_info': $!";
42 }
43- print FILE "$info_lines[1]\n";
44+ print FILE "$filename\t$position\t\t\n";
45 close(FILE);
46
47 if ($option_stream) {
48@@ -1245,14 +1238,7 @@
49 unlink $binlog_info || Die "Failed to delete '$binlog_info': $!";
50 }
51
52- # get the name of the last binlog file and position in it
53- ($filename, $position) = $info_lines[1] =~ /^\s*([^\s]+)\s+(.*)$/;
54-
55- if (defined $filename && defined $position) {
56- $mysql_binlog_position = "filename '$filename', position $position";
57- } else {
58- $mysql_binlog_position = "filename '', position ";
59- }
60+ $mysql_binlog_position = "filename '$filename', position $position";
61 }
62
63 #
64@@ -1314,7 +1300,7 @@
65
66 # get slave status. Use single quotes here, otherwise
67 # \G is evaluated as a control character.
68- mysql_send 'SHOW SLAVE STATUS\G;';
69+ mysql_send 'SHOW SLAVE STATUS\G';
70
71 # get output of the "show slave status" command from mysql output
72 # and extract binlog position of the master server
73
74=== added file 'test/t/bug977101.sh'
75--- test/t/bug977101.sh 1970-01-01 00:00:00 +0000
76+++ test/t/bug977101.sh 2012-06-08 18:50:29 +0000
77@@ -0,0 +1,31 @@
78+########################################################################
79+# Bug #977101: --safe-slave-backup results in incorrect binlog info
80+########################################################################
81+
82+. inc/common.sh
83+
84+master_id=1
85+slave_id=2
86+
87+start_server_with_id $master_id
88+start_server_with_id $slave_id
89+
90+setup_slave $slave_id $master_id
91+
92+# Full backup of the slave server
93+switch_server $slave_id
94+
95+# Check that binlog info is correct with --safe-slave-backup
96+innobackupex --no-timestamp --safe-slave-backup $topdir/backup
97+egrep -q '^mysql-bin.000001[[:space:]]+[0-9]+[[:space:]]+$' \
98+ $topdir/backup/xtrabackup_binlog_info
99+
100+# Check that both binlog info and slave info are correct with
101+# --safe-slave-backup
102+rm -rf $topdir/backup
103+innobackupex --no-timestamp --slave-info --safe-slave-backup $topdir/backup
104+egrep -q '^mysql-bin.000001[[:space:]]+[0-9]+[[:space:]]+$' \
105+ $topdir/backup/xtrabackup_binlog_info
106+egrep -q '^CHANGE MASTER TO MASTER_LOG_FILE='\''mysql-bin.000001'\'', MASTER_LOG_POS=[0-9]+$' \
107+ $topdir/backup/xtrabackup_slave_info
108+

Subscribers

People subscribed via source and target branches