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

Proposed by Alexey Kopytov on 2014-10-27
Status: Merged
Approved by: Alexey Kopytov on 2014-10-27
Approved revision: 5041
Merged at revision: 5041
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1372679
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 151 lines (+93/-9)
2 files modified
storage/innobase/xtrabackup/innobackupex.pl (+39/-9)
storage/innobase/xtrabackup/test/t/bug1372679.sh (+54/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1372679
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve on 2014-10-27
Review via email: mp+239732@code.launchpad.net

Description of the change

    Bug #1372679: innobackupex --slave-info doesn't handle
    slave_parallel_workers>0

    Changed innobackupex to fail with an error when --slave-info is used on
    a multi-threaded non-GTID slave, because Exec_Master_Log_Pos cannot be
    trusted for a multi-threaded slave.

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

To post a comment you must log in.
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/innobackupex.pl'
2--- storage/innobase/xtrabackup/innobackupex.pl 2014-10-27 10:31:20 +0000
3+++ storage/innobase/xtrabackup/innobackupex.pl 2014-10-27 14:49:12 +0000
4@@ -77,6 +77,8 @@
5 my $have_backup_locks = 0;
6 my $have_galera_enabled = 0;
7 my $have_flush_engine_logs = 0;
8+my $have_multi_threaded_slave = 0;
9+my $have_gtid_slave = 0;
10
11 # command line options
12 my $option_help = '';
13@@ -1904,6 +1906,15 @@
14
15 detect_mysql_capabilities_for_backup(\%mysql);
16
17+
18+ # Do not allow --slave-info with a multi-threded non-GTID slave,
19+ # see https://bugs.launchpad.net/percona-xtrabackup/+bug/1372679
20+ if ($option_slave_info and $have_multi_threaded_slave
21+ and !$have_gtid_slave) {
22+ die "The --slave-info option requires GTID enabled for a " .
23+ "multi-threaded slave."
24+ }
25+
26 #
27 # if one of the history incrementals is being used, try to grab the
28 # innodb_to_lsn from the history table and set the option_incremental_lsn
29@@ -4927,20 +4938,26 @@
30 # Query the server to find out what backup capabilities it supports.
31 #
32 sub detect_mysql_capabilities_for_backup {
33+ my $con = shift;
34+
35 if ($option_incremental) {
36 $have_changed_page_bitmaps =
37- mysql_query($_[0], "SELECT COUNT(*) FROM " .
38+ mysql_query($con, "SELECT COUNT(*) FROM " .
39 "INFORMATION_SCHEMA.PLUGINS " .
40 "WHERE PLUGIN_NAME LIKE 'INNODB_CHANGED_PAGES'");
41 }
42
43- if (!defined($_[0]->{vars})) {
44- get_mysql_vars($_[0]);
45- }
46-
47- $have_backup_locks = defined($_[0]->{vars}->{have_backup_locks});
48-
49- $have_galera_enabled = defined($_[0]->{vars}->{wsrep_on});
50+ if (!defined($con->{vars})) {
51+ get_mysql_vars($con);
52+ }
53+
54+ if (!defined($con->{slave_status})) {
55+ get_mysql_slave_status($con);
56+ }
57+
58+ $have_backup_locks = defined($con->{vars}->{have_backup_locks});
59+
60+ $have_galera_enabled = defined($con->{vars}->{wsrep_on});
61
62 if ($option_galera_info && !$have_galera_enabled) {
63 my $now = current_time();
64@@ -4952,7 +4969,7 @@
65 $option_galera_info = 0;
66 }
67
68- if ($mysql{vars}->{version}->{Value} =~ m/5\.[123]\.\d/) {
69+ if ($con->{vars}->{version}->{Value} =~ m/5\.[123]\.\d/) {
70 my $now = current_time();
71
72 print STDERR "\n$now $prefix Warning: FLUSH ENGINE LOGS " .
73@@ -4964,6 +4981,19 @@
74 } else {
75 $have_flush_engine_logs = 1;
76 }
77+
78+ if (defined($con->{vars}->{slave_parallel_workers}) and
79+ ($con->{vars}->{slave_parallel_workers}->{Value} > 0)) {
80+ $have_multi_threaded_slave = 1;
81+ }
82+
83+ my $gtid_executed = $con->{slave_status}->{Executed_Gtid_Set};
84+ my $gtid_slave_pos = $con->{vars}->{gtid_slave_pos};
85+
86+ if ((defined($gtid_executed) and $gtid_executed ne '') or
87+ (defined($gtid_slave_pos) and $gtid_slave_pos ne '')) {
88+ $have_gtid_slave = 1;
89+ }
90 }
91
92 #
93
94=== added file 'storage/innobase/xtrabackup/test/t/bug1372679.sh'
95--- storage/innobase/xtrabackup/test/t/bug1372679.sh 1970-01-01 00:00:00 +0000
96+++ storage/innobase/xtrabackup/test/t/bug1372679.sh 2014-10-27 14:49:12 +0000
97@@ -0,0 +1,54 @@
98+########################################################################
99+# Bug #1372679: innobackupex --slave-info doesn't handle
100+# slave_parallel_workers>0
101+########################################################################
102+
103+require_server_version_higher_than 5.6.0
104+
105+# Test that --slave-info with MTS enabled + GTID disabled fails
106+
107+MYSQLD_EXTRA_MY_CNF_OPTS="
108+slave_parallel_workers=2
109+"
110+master_id=1
111+slave_id=2
112+
113+start_server_with_id $master_id
114+
115+start_server_with_id $slave_id
116+
117+setup_slave $slave_id $master_id
118+
119+switch_server $slave_id
120+
121+innobackupex --no-timestamp --slave-info $topdir/backup 2>&1 |
122+ grep 'The --slave-info option requires GTID enabled for a multi-threaded slave' ||
123+ die "could not find the error message"
124+
125+if [[ ${PIPESTATUS[0]} == 0 ]]
126+then
127+ die "innobackupex did not fail as expected"
128+fi
129+
130+stop_server_with_id $master_id
131+stop_server_with_id $slave_id
132+
133+remove_var_dirs
134+
135+# Test that --slave-info with MTS enabled + GTID enabled works
136+
137+MYSQLD_EXTRA_MY_CNF_OPTS="
138+gtid_mode=on
139+log_slave_updates=on
140+enforce_gtid_consistency=on
141+slave_parallel_workers=2
142+"
143+
144+start_server_with_id $master_id
145+start_server_with_id $slave_id
146+
147+setup_slave $slave_id $master_id
148+
149+switch_server $slave_id
150+
151+innobackupex --no-timestamp --slave-info $topdir/backup

Subscribers

People subscribed via source and target branches

to all changes: