Merge lp:~sergei.glushchenko/percona-xtrabackup/xb_bug483827 into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Superseded
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/xb_bug483827
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 408 lines (+111/-40)
8 files modified
doc/source/how-tos.rst (+1/-0)
doc/source/innobackupex/innobackupex_option_reference.rst (+4/-0)
doc/source/innobackupex/restoring_a_backup_ibk.rst (+1/-1)
doc/source/xtrabackup_bin/xbk_option_reference.rst (+4/-0)
innobackupex (+40/-34)
src/xtrabackup.c (+21/-4)
test/t/bug983685.sh (+1/-1)
test/t/bug996493.sh (+39/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/xb_bug483827
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Needs Fixing
Review via email: mp+99860@code.launchpad.net

This proposal has been superseded by a proposal from 2012-05-18.

Description of the change

Bug #483827. Support for mysqld_multi.
Fix based on work of Daniël van Eeden (lp:~dveeden/percona-xtrabackup/lp483827)
--section option added to innobackupex, specifying which section of my.cnf to handle.
--mysqld-section option added to xtrabackup for the same purpose.
Tescase does not run mysqld_multi, it just tests correctness of --section option.

http://jenkins.percona.com/view/Percona%20Xtrabackup/job/percona-xtrabackup-param/168/

To post a comment you must log in.
409. By Hrvoje Matijakovic

* merged lp:~hrvojem/percona-xtrabackup/release-notes-1.9.2

410. By Hrvoje Matijakovic

* merged lp:~hrvojem/percona-xtrabackup/theme-update-2.0

411. By Stewart Smith

merge 1.9.2 release branch

412. By Hrvoje Matijakovic

* merged lp:~hrvojem/percona-xtrabackup/bug972185

413. By Hrvoje Matijakovic

* merged lp:~hrvojem/percona-xtrabackup/fresh-theme-2.0

414. By Stewart Smith

merge 1.6.6 release notes

415. By Stewart Smith

null merge of update 1.6.6 release date

416. By Stewart Smith

add 2.0.0 release notes

417. By Hrvoje Matijakovic

* merged lp:~hrvojem/percona-xtrabackup/theme-fix-2.0

418. By Stewart Smith

merge spelling fix in error msg

419. By Stewart Smith

Merge 2.0.0 release branch

420. By Alexey Kopytov

Automerge of lp:~akopytov/percona-xtrabackup/bug977995

421. By Alexey Kopytov

Bug #977998: --stream=tar fails (archive_write_header failed)

The problem was in the USTAR format used by XtraBackup which is
incompatible with files larger than 8 GB.

Fixed by changing the libarchive format to 'restricted PAX' which avoids
the limitation. However, the PAX format generates some annoying (and
benign) warnings when the GNU tar format is used due to extended
attributes written to the tar stream by libarchive in the PAX mode. This
problem was fixed by modifying the bundled libarchive code to suppress
the extended attributes.

422. By Stewart Smith

merge XB 2.0 docs update

423. By Stewart Smith

merge Sergei's fix for: Bug #983720: ib_lru_dump and --galera-info fail with --stream=xbstream

424. By Stewart Smith

Merge Sergei's fix for: Bug 983685: innodb_data_file_path is not written to backup-my.cnf
Regression introduced by fix for bug #733651.
Along with innodb_data_file_path, innodb_log_group_home_dir is also missed.

425. By Alexey Kopytov

Null merge of doc theme changes from 1.6.

Revision history for this message
Alexey Kopytov (akopytov) wrote :

Sergei,

   - sections in my.cnf are called groups in MySQL documentation. So
     let's be consistent and call them groups as well, and name the
     options (both the innobackupex and the xtrabackup one)
     --defaults-group, rather than --section and --mysqld-section

   - it looks like get_option is always passed the same value as its
     second argument, so I wonder if it really needs that argument, or
     rather just use $option_mysqld_section (or whatever it will be
     renamed to, i.e. $option_defaults_group) internally.

   - s/laod/load/
   - s/accetps/accepts/
   - s/rstore_args/restore_args/. Though you don't really need that
     function, as tests are executed in a separate shell process, so
     modifications to variables have no effect on other tests anyway.

   - I know that code in main() that scan options for "--mysqld-section"
     was copy-pasted, but please format it according to InnoDB
     style. Because currently it's a terrible mix of all possible
     formatting styles.

   - in the same code, I don't think strstr() is necessary, because you
     already have the pointer to '=' (or terminating zero) in optend.

review: Needs Fixing
426. By Sergei Glushchenko

Bug 996493: innobackupex --apply-log doesn't read config from backup-my.cnf
Following have been done:
1. Remove datadir and innodb_data_home_dir from backup-my.cnf
2. When do --apply-log read settings from backup-my.cnf
3. When do --copy-back read settings from /etc/my.cnf

427. By Sergei Glushchenko

Bug #483827. Support for mysqld_multi.
Based on work of Daniël van Eeden (lp:~dveeden/percona-xtrabackup/lp483827)
--defaults-group option added to both innobackupex and xtrabackup, specifying
which section of my.cnf to handle.

Unmerged revisions

427. By Sergei Glushchenko

Bug #483827. Support for mysqld_multi.
Based on work of Daniël van Eeden (lp:~dveeden/percona-xtrabackup/lp483827)
--defaults-group option added to both innobackupex and xtrabackup, specifying
which section of my.cnf to handle.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/source/how-tos.rst'
2--- doc/source/how-tos.rst 2011-07-07 05:32:50 +0000
3+++ doc/source/how-tos.rst 2012-05-17 09:29:18 +0000
4@@ -13,6 +13,7 @@
5 howtos/recipes_ibkx_local
6 howtos/recipes_ibkx_stream
7 howtos/recipes_ibkx_inc
8+ howtos/recipes_ibkx_multi
9
10
11 .. _recipes-xbk:
12
13=== modified file 'doc/source/innobackupex/innobackupex_option_reference.rst'
14--- doc/source/innobackupex/innobackupex_option_reference.rst 2012-05-15 09:30:50 +0000
15+++ doc/source/innobackupex/innobackupex_option_reference.rst 2012-05-17 09:29:18 +0000
16@@ -70,6 +70,10 @@
17
18 This option accepts a string argument that specifies the port to use when connecting to the database server with TCP/IP. It is passed to the :command:`mysql` child process. It is passed to the :command:`mysql` child process without alteration. See :command:`mysql --help` for details.
19
20+.. option:: --defaults-group
21+
22+ This option accepts a string argument that specifies the group which should be read from the configuration file. This is needed if you use mysqld_multi.
23+
24 .. option:: --socket
25
26 This option accepts a string argument that specifies the socket to use when connecting to the local database server with a UNIX domain socket. It is passed to the mysql child process without alteration. See :command:`mysql --help` for details.
27
28=== modified file 'doc/source/innobackupex/restoring_a_backup_ibk.rst'
29--- doc/source/innobackupex/restoring_a_backup_ibk.rst 2011-07-07 05:32:50 +0000
30+++ doc/source/innobackupex/restoring_a_backup_ibk.rst 2012-05-17 09:29:18 +0000
31@@ -6,7 +6,7 @@
32
33 $ innobackupex --copy-back /path/to/BACKUP-DIR
34
35-It will copy all the data-related files back to the server's :term:`datadir`, determined by the :file:`backup-my.cnf` configuration file in the directory. You should check the last line of the output for a success message::
36+It will copy all the data-related files back to the server's :term:`datadir`, determined by the server's :file:`my.cnf` configuration file. You should check the last line of the output for a success message::
37
38 innobackupex: Finished copying back files.
39
40
41=== modified file 'doc/source/xtrabackup_bin/xbk_option_reference.rst'
42--- doc/source/xtrabackup_bin/xbk_option_reference.rst 2012-04-21 07:12:28 +0000
43+++ doc/source/xtrabackup_bin/xbk_option_reference.rst 2012-05-17 09:29:18 +0000
44@@ -101,6 +101,10 @@
45 --innodb-read-io-threads
46 --innodb-write-io-threads
47
48+.. option:: --defaults-group
49+
50+ This option is to set the group which should be read from the configuration file. This is used by innobackupex if you use the `--defaults-group` option. It is needed for mysqld_multi deployments. It must be the first option.
51+
52 .. option:: --log-stream
53
54 Makes xtrabackup not copy data files, and output the contents of the InnoDB log files to STDOUT until the :option:`--suspend-at-end` file is deleted. This option enables :option:`--suspend-at-end` automatically.
55
56=== modified file 'innobackupex'
57--- innobackupex 2012-05-15 09:30:50 +0000
58+++ innobackupex 2012-05-17 09:29:18 +0000
59@@ -84,6 +84,7 @@
60 my $option_mysql_port = '';
61 my $option_mysql_socket = '';
62 my $option_mysql_host = '';
63+my $option_defaults_group = 'mysqld';
64 my $option_no_timestamp = '';
65 my $option_slave_info = '';
66 my $option_galera_info = '';
67@@ -377,7 +378,7 @@
68 # process.
69 #
70 sub backup {
71- my $orig_datadir = get_option(\%config, 'mysqld', 'datadir');
72+ my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
73
74 # check that we can connect to the database. This done by
75 # connecting, issuing a query, and closing the connection.
76@@ -626,13 +627,13 @@
77 # back to their original locations.
78 #
79 sub copy_back {
80- my $orig_datadir = get_option(\%config, 'mysqld', 'datadir');
81+ my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
82 my $orig_ibdata_dir =
83- get_option(\%config, 'mysqld', 'innodb_data_home_dir');
84+ get_option(\%config, $option_defaults_group, 'innodb_data_home_dir');
85 my $orig_innodb_data_file_path =
86- get_option(\%config, 'mysqld', 'innodb_data_file_path');
87+ get_option(\%config, $option_defaults_group, 'innodb_data_file_path');
88 my $orig_iblog_dir =
89- get_option(\%config, 'mysqld', 'innodb_log_group_home_dir');
90+ get_option(\%config, $option_defaults_group, 'innodb_log_group_home_dir');
91 my $iblog_files = 'ib_logfile.*';
92 my $excluded_files =
93 '\.\.?|backup-my\.cnf|xtrabackup_logfile|' .
94@@ -736,6 +737,12 @@
95
96 if ($option_defaults_file) {
97 $options = $options . " --defaults-file=\"$option_defaults_file\" ";
98+ } else {
99+ $options = $options . " --defaults-file=\"${backup_dir}/backup-my.cnf\" ";
100+ }
101+
102+ if ($option_defaults_group) {
103+ $options = $options . " --defaults-group=\"$option_defaults_group\" ";
104 }
105
106 $options = $options . "--prepare --target-dir=$backup_dir";
107@@ -861,6 +868,10 @@
108 $options = $options . " --defaults-file=\"$option_defaults_file\" ";
109 }
110
111+ if ($option_defaults_group) {
112+ $options = $options . " --defaults-group=\"$option_defaults_group\" ";
113+ }
114+
115 $options = $options . "--backup --suspend-at-end";
116
117 if (!$option_remote_host && !$option_stream) {
118@@ -923,13 +934,13 @@
119
120 if($option_remote_host) {
121 #direct copy to remote
122- my $orig_datadir = get_option(\%config, 'mysqld', 'datadir');
123+ my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
124 my $orig_ibdata_dir =
125- get_option(\%config, 'mysqld', 'innodb_data_home_dir');
126+ get_option(\%config, $option_defaults_group, 'innodb_data_home_dir');
127 my $orig_innodb_data_file_path =
128- get_option(\%config, 'mysqld', 'innodb_data_file_path');
129+ get_option(\%config, $option_defaults_group, 'innodb_data_file_path');
130 my $innodb_flush_method =
131- get_option(\%config, 'mysqld', 'innodb_flush_method');
132+ get_option(\%config, $option_defaults_group, 'innodb_flush_method');
133 my $innodb_use_odirect;
134 $innodb_use_odirect = 1 if $innodb_flush_method =~ m/^(ALL_)?O_DIRECT$/i;
135
136@@ -1580,7 +1591,7 @@
137 read_config_file(\%config);
138
139 if(!$option_tmpdir) {
140- $option_tmpdir = get_option(\%config, 'mysqld', 'tmpdir');
141+ $option_tmpdir = get_option(\%config, $option_defaults_group, 'tmpdir');
142 }
143
144 # get innodb log home directory from options file
145@@ -1633,22 +1644,10 @@
146 #
147 sub write_backup_config_file {
148 my $filename = shift;
149- my $innodb_data_file_path =
150- get_option(\%config, 'mysqld', 'innodb_data_file_path');
151- my $root;
152-
153- my @array = split(/;/, $innodb_data_file_path);
154- for (my $i = 0; $i <= $#array; $i++) {
155- my @tmp = split(/\/+/, $array[$i]);
156- $array[$i] = $tmp[-1];
157- }
158- $innodb_data_file_path = join(";", @array);
159
160 if (!$option_remote_host) {
161- $root = $backup_dir;
162 open(FILE, "> $filename") || Die "Failed to open file '$filename': $!";
163 } else {
164- $root = `ssh $option_ssh_opt $option_remote_host 'cd $backup_dir; pwd'`;
165 open(FILE, "| ssh $option_ssh_opt $option_remote_host 'cat > $filename'")
166 || Die "Failed to open file '$option_remote_host:$filename': $!";
167 }
168@@ -1664,15 +1663,12 @@
169
170 my $options_dump = "# This MySQL options file was generated by $innobackup_script.\n\n" .
171 "# The MySQL server\n" .
172- "[mysqld]\n" .
173- "datadir=$root\n" .
174- "innodb_data_home_dir=$root\n" .
175- "innodb_log_group_home_dir=$root\n";
176+ "[mysqld]\n";
177
178 my $option_name;
179 foreach $option_name (@option_names) {
180- if (has_option(\%config, 'mysqld', $option_name)) {
181- my $option_value = get_option(\%config, 'mysqld', $option_name);
182+ if (has_option(\%config, $option_defaults_group, $option_name)) {
183+ my $option_value = get_option(\%config, $option_defaults_group, $option_name);
184 $options_dump .= "$option_name=$option_value\n";
185 }
186 }
187@@ -1738,6 +1734,7 @@
188 'user=s' => \$option_mysql_user,
189 'host=s' => \$option_mysql_host,
190 'port=s' => \$option_mysql_port,
191+ 'defaults-group=s' => \$option_defaults_group,
192 'slave-info' => \$option_slave_info,
193 'galera-info' => \$option_galera_info,
194 'socket=s' => \$option_mysql_socket,
195@@ -1853,7 +1850,7 @@
196 sub make_backup_dir {
197 my $dir;
198 my $innodb_data_file_path =
199- get_option(\%config, 'mysqld', 'innodb_data_file_path');
200+ get_option(\%config, $option_defaults_group, 'innodb_data_file_path');
201
202 # create backup directory
203 $dir = $backup_root;
204@@ -1945,7 +1942,7 @@
205 #
206 sub backup_files {
207 my $prep_mode = shift;
208- my $source_dir = get_option(\%config, 'mysqld', 'datadir');
209+ my $source_dir = get_option(\%config, $option_defaults_group, 'datadir');
210 my @list;
211 my $file;
212 my $database;
213@@ -2217,8 +2214,15 @@
214 my $cmdline = '';
215 my $options = '';
216
217+
218 if ($option_defaults_file) {
219 $options = $options . " --defaults-file=\"$option_defaults_file\" ";
220+ } elsif ($option_apply_log) {
221+ $options = $options . " --defaults-file=\"${backup_dir}/backup-my.cnf\" ";
222+ }
223+
224+ if ($option_defaults_group) {
225+ $options = $options . " --defaults-group=\"$option_defaults_group\" ";
226 }
227
228 $options = $options . "--print-param";
229@@ -2304,7 +2308,6 @@
230 if (!exists ${$config_ref}{$group}) {
231 # no group
232 print STDERR "$prefix fatal error: no '$group' group in MySQL options\n";
233- print STDERR "$prefix fatal error: OR no 'datadir' option in group '$group' in MySQL options\n";
234 exit(1);
235 }
236
237@@ -2332,7 +2335,6 @@
238 if (!exists $config{$group}) {
239 # no group
240 print STDERR "$prefix fatal error: no '$group' group in MySQL options\n";
241- print STDERR "$prefix fatal error: OR no 'datadir' option in group '$group' in MySQL options\n";
242 exit(1);
243 }
244
245@@ -2628,7 +2630,7 @@
246 [--no-timestamp] [--ibbackup=IBBACKUP-BINARY]
247 [--slave-info] [--stream=tar|xbstream]
248 [--scpopt=OPTIONS-FOR-SCP] [--sshopt=OPTIONS-FOR-SSH]
249- [--defaults-file=MY.CNF]
250+ [--defaults-file=MY.CNF] [--defaults-group=mysqld]
251 [--databases=LIST] [--remote-host=HOSTNAME] [--no-lock]
252 [--tmpdir=DIRECTORY] [--tables-file=FILE]
253 [--incremental] [--incremental-basedir]
254@@ -2636,7 +2638,7 @@
255 BACKUP-ROOT-DIR
256
257 innobackupex --apply-log [--use-memory=B] [--uncompress]
258- [--defaults-file=MY.CNF]
259+ [--defaults-file=MY.CNF] [--defaults-group=mysqld]
260 [--export] [--redo-only] [--ibbackup=IBBACKUP-BINARY]
261 BACKUP-DIR
262
263@@ -2823,6 +2825,10 @@
264
265 This option specifies the MySQL username used when connecting to the server, if that's not the current user. The option accepts a string argument. It is passed to the mysql child process without alteration. See mysql --help for details.
266
267+=item --defaults-group=GROUP
268+
269+This option specifies the group name in my.cnf which should be used. This is needed for mysqld_multi deployments.
270+
271 =item --version
272
273 This option displays the xtrabackup version and copyright notice and then exits.
274
275=== modified file 'src/xtrabackup.c'
276--- src/xtrabackup.c 2012-05-15 16:53:07 +0000
277+++ src/xtrabackup.c 2012-05-17 09:29:18 +0000
278@@ -769,6 +769,8 @@
279 char *opt_mysql_tmpdir = NULL;
280 MY_TMPDIR mysql_tmpdir_list;
281
282+const char *defaults_group = "mysqld";
283+
284 /* === static parameters in ha_innodb.cc */
285
286 #define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
287@@ -994,7 +996,8 @@
288 OPT_INNODB_SYNC_SPIN_LOOPS,
289 OPT_INNODB_THREAD_CONCURRENCY,
290 OPT_INNODB_THREAD_SLEEP_DELAY,
291- OPT_XTRA_DEBUG_SYNC
292+ OPT_XTRA_DEBUG_SYNC,
293+ OPT_DEFAULTS_GROUP
294 };
295
296 static struct my_option my_long_options[] =
297@@ -1278,6 +1281,9 @@
298 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
299 #endif
300
301+ {"defaults_group", OPT_DEFAULTS_GROUP, "defaults group in config file (default \"mysqld\").",
302+ (G_PTR*) &defaults_group, (G_PTR*) &defaults_group,
303+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
304 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
305 };
306
307@@ -1337,7 +1343,7 @@
308 #endif
309 }
310
311-static const char *load_default_groups[]= { "mysqld","xtrabackup",0 };
312+static const char *load_default_groups[]= { "mysqld","xtrabackup",0,0 };
313
314 static void print_version(void)
315 {
316@@ -6280,6 +6286,17 @@
317 MY_INIT(argv[0]);
318 xb_regex_init();
319
320+ /* scan options for group to load defaults from */
321+ {
322+ int i;
323+ char* optend;
324+ for (i=1; i < argc; i++) {
325+ optend = strcend(argv[i], '=');
326+ if (strncmp(argv[i], "--defaults-group", optend - argv[i]) == 0) {
327+ load_default_groups[2] = defaults_group = optend + 1;
328+ }
329+ }
330+ }
331 load_defaults("my",load_default_groups,&argc,&argv);
332
333 /* ignore unsupported options */
334@@ -6333,7 +6350,7 @@
335 if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
336 exit(ho_error);
337
338- if ((!xtrabackup_prepare) && (strcmp(mysql_data_home, "./") == 0)) {
339+ if ((!xtrabackup_print_param) && (!xtrabackup_prepare) && (strcmp(mysql_data_home, "./") == 0)) {
340 if (!xtrabackup_print_param)
341 usage();
342 msg("\nxtrabackup: Error: Please set parameter 'datadir'\n");
343@@ -6518,7 +6535,7 @@
344 exit(EXIT_FAILURE);
345
346 printf("# This MySQL options file was generated by XtraBackup.\n");
347- printf("[mysqld]\n");
348+ printf("[%s]\n", defaults_group);
349 printf("datadir = \"%s\"\n", mysql_data_home);
350 printf("tmpdir = \"%s\"\n", mysql_tmpdir_list.list[0]);
351 printf("innodb_data_home_dir = \"%s\"\n",
352
353=== modified file 'test/t/bug983685.sh'
354--- test/t/bug983685.sh 2012-04-17 12:55:16 +0000
355+++ test/t/bug983685.sh 2012-05-17 09:29:18 +0000
356@@ -6,7 +6,7 @@
357
358 init
359
360-options="innodb_data_file_path innodb_log_group_home_dir"
361+options="innodb_data_file_path"
362
363 run_mysqld
364
365
366=== added file 'test/t/bug996493.sh'
367--- test/t/bug996493.sh 1970-01-01 00:00:00 +0000
368+++ test/t/bug996493.sh 2012-05-17 09:29:18 +0000
369@@ -0,0 +1,39 @@
370+########################################################################
371+# Bug #996493: innobackupex --apply-log doesn't read config from
372+# backup-my.cnf
373+########################################################################
374+
375+. inc/common.sh
376+
377+init
378+
379+run_mysqld
380+
381+backup_dir=$topdir/backup
382+innobackupex --no-timestamp $backup_dir
383+vlog "Backup created in directory $backup_dir"
384+
385+vlog "Stop mysqld"
386+stop_mysqld
387+
388+vlog "Remove datadir"
389+rm -r $mysql_datadir/*
390+
391+vlog "Remove my.cnf"
392+mv $topdir/my.cnf $topdir/my.cnf.bak
393+
394+trap "vlog restoring $topdir/my.cnf ; \
395+mv $topdir/my.cnf.bak $topdir/my.cnf" INT TERM EXIT
396+
397+vlog "Apply log"
398+# Do not run innobackupex, because it pass option --defaults-file
399+# which we should avoid. Our goal is to test that backup-my.cnf
400+# will be read by default when apply-log is run.
401+run_cmd $IB_BIN --ibbackup=$XB_BIN --apply-log $backup_dir
402+
403+vlog "Get my.cnf back"
404+mv $topdir/my.cnf.bak $topdir/my.cnf
405+trap "vlog test exit" INT TERM EXIT
406+
407+vlog "Copy back"
408+innobackupex --copy-back $backup_dir

Subscribers

People subscribed via source and target branches