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

Proposed by Alexey Kopytov on 2014-10-09
Status: Merged
Approved by: Alexey Kopytov on 2014-10-09
Approved revision: 5034
Merged at revision: 5034
Proposed branch: lp:~akopytov/percona-xtrabackup/bug664128
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 147 lines (+70/-44)
2 files modified
storage/innobase/xtrabackup/src/xtrabackup.cc (+30/-44)
storage/innobase/xtrabackup/test/t/bug664128.sh (+40/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug664128
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve on 2014-10-09
Review via email: mp+237726@code.launchpad.net

Description of the change

    Bug #664128: xtrabackup does not support "--loose-" options

    Added support for all option modifiers supported by upstream MySQL:

    skip, disable, enable, maximum, loose.

    Percona Server supports some additional arguments, but those are
    rarely used especially for InnoDB variables.

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

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/src/xtrabackup.cc'
2--- storage/innobase/xtrabackup/src/xtrabackup.cc 2014-10-06 10:45:17 +0000
3+++ storage/innobase/xtrabackup/src/xtrabackup.cc 2014-10-09 06:28:36 +0000
4@@ -315,6 +315,8 @@
5 parsed from the defaults file */
6 static std::ostringstream print_param_str;
7
8+static ulonglong global_max_value;
9+
10 extern "C" sig_handler handle_fatal_signal(int sig);
11
12 /* Simple datasink creation tracking...add datasinks in the reverse order you
13@@ -6145,61 +6147,45 @@
14 "# This MySQL options file was generated by XtraBackup.\n"
15 "[" << defaults_group << "]\n";
16
17- /* ignore unsupported options */
18- {
19- int i,j,argc_new,find;
20- char *optend, *prev_found = NULL;
21- argc_new = argc;
22-
23- j=1;
24- for (i=1 ; i < argc ; i++) {
25- uint count;
26- struct my_option *opt= (struct my_option *) xb_long_options;
27- optend= strcend((argv)[i], '=');
28- if (!strncmp(argv[i], "--defaults-file", optend - argv[i]))
29- {
30+ /* Throw a descriptive error if --defaults-file is not the first command
31+ line argument */
32+ for (int i = 2 ; i < argc ; i++) {
33+ char *optend = strcend((argv)[i], '=');
34+
35+ if (!strncmp(argv[i], "--defaults-file", optend - argv[i])) {
36+
37 msg("xtrabackup: Error: --defaults-file "
38 "must be specified first on the command "
39 "line\n");
40 exit(EXIT_FAILURE);
41 }
42- for (count= 0; opt->name; opt++) {
43- if (!getopt_compare_strings(opt->name, (argv)[i] + 2,
44- (uint)(optend - (argv)[i] - 2))) /* match found */
45- {
46- if (!opt->name[(uint)(optend - (argv)[i] - 2)]) {
47- find = 1;
48- goto next_opt;
49- }
50- if (!count) {
51- count= 1;
52- prev_found= (char *) opt->name;
53- }
54- else if (strcmp(prev_found, opt->name)) {
55- count++;
56- }
57- }
58- }
59- find = count;
60-next_opt:
61- if(!find){
62- argc_new--;
63- } else {
64- (argv)[j]=(argv)[i];
65- j++;
66- }
67 }
68- argc = argc_new;
69- argv[argc] = NULL;
70+
71+ /* We want xtrabackup to ignore unknown options, because it only
72+ recognizes a small subset of server variables */
73+ my_getopt_skip_unknown = TRUE;
74+
75+ /* Reset u_max_value for all options, as we don't want the
76+ --maximum-... modifier to set the actual option values */
77+ for (my_option *optp= xb_long_options; optp->name; optp++) {
78+ optp->u_max_value = (G_PTR *) &global_max_value;
79 }
80
81 if ((ho_error=handle_options(&argc, &argv, xb_long_options, get_one_option)))
82 exit(ho_error);
83
84- if (argc != 0) {
85- msg("xtrabackup: Error: unknown argument: '%s'\n",
86- argv[0]);
87- exit(EXIT_FAILURE);
88+ /* Reject command line arguments that don't look like options, i.e. are
89+ not of the form '-X' (single-character options) or '--option' (long
90+ options) */
91+ for (int i = 1 ; i < argc ; i++) {
92+ const char * const opt = argv[i];
93+
94+ if (strncmp(opt, "--", 2) &&
95+ !(strlen(opt) == 2 && opt[0] == '-')) {
96+
97+ msg("xtrabackup: Error: unknown argument: '%s'\n", opt);
98+ exit(EXIT_FAILURE);
99+ }
100 }
101
102 if ((!xtrabackup_print_param) && (!xtrabackup_prepare) && (strcmp(mysql_data_home, "./") == 0)) {
103
104=== added file 'storage/innobase/xtrabackup/test/t/bug664128.sh'
105--- storage/innobase/xtrabackup/test/t/bug664128.sh 1970-01-01 00:00:00 +0000
106+++ storage/innobase/xtrabackup/test/t/bug664128.sh 2014-10-09 06:28:36 +0000
107@@ -0,0 +1,40 @@
108+########################################################################
109+# Bug #664128: xtrabackup does not support "--loose-" options
110+########################################################################
111+
112+cat >$topdir/my.cnf <<EOF
113+[mysqld]
114+loose-innodb_log_file_size=5M
115+maximum-innodb_log_file_size=6M
116+skip-innodb_fast_checksum
117+EOF
118+
119+diff -u - <($XB_BIN --defaults-file=$topdir/my.cnf --print-param) <<EOF
120+# This MySQL options file was generated by XtraBackup.
121+[mysqld]
122+innodb_log_file_size=5242880
123+innodb_log_file_size=5242880
124+innodb_fast_checksum=0
125+EOF
126+
127+cat >$topdir/my.cnf <<EOF
128+[mysqld]
129+enable-innodb_fast_checksum
130+EOF
131+
132+diff -u - <($XB_BIN --defaults-file=$topdir/my.cnf --print-param) <<EOF
133+# This MySQL options file was generated by XtraBackup.
134+[mysqld]
135+innodb_fast_checksum=1
136+EOF
137+
138+cat >$topdir/my.cnf <<EOF
139+[mysqld]
140+disable-innodb_fast_checksum
141+EOF
142+
143+diff -u - <($XB_BIN --defaults-file=$topdir/my.cnf --print-param) <<EOF
144+# This MySQL options file was generated by XtraBackup.
145+[mysqld]
146+innodb_fast_checksum=0
147+EOF

Subscribers

People subscribed via source and target branches

to all changes: