Merge lp:~akopytov/percona-xtrabackup/bug408803-1.7 into lp:percona-xtrabackup/2.0

Proposed by Alexey Kopytov
Status: Merged
Merged at revision: 330
Proposed branch: lp:~akopytov/percona-xtrabackup/bug408803-1.7
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 282 lines (+81/-60)
5 files modified
doc/source/innobackupex/how_innobackupex_works.rst (+1/-1)
doc/source/innobackupex/privileges.rst (+1/-1)
innobackupex (+61/-54)
test/t/bug884737.sh (+14/-0)
xtrabackup.c (+4/-4)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug408803-1.7
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Review via email: mp+82103@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 'doc/source/innobackupex/how_innobackupex_works.rst'
2--- doc/source/innobackupex/how_innobackupex_works.rst 2011-10-21 17:47:31 +0000
3+++ doc/source/innobackupex/how_innobackupex_works.rst 2011-11-14 07:14:52 +0000
4@@ -59,7 +59,7 @@
5
6 Finally, the binary log position will be printed to ``STDERR`` and |innobackupex| will exit returning 0 if all went OK.
7
8-Note that the ``STDERR`` of |innobackupex| is not written in any file. You will have to redirect it to a file, e.g., ``innobackupex OPTIONS > backupout.log``.
9+Note that the ``STDERR`` of |innobackupex| is not written in any file. You will have to redirect it to a file, e.g., ``innobackupex OPTIONS 2> backupout.log``.
10
11 .. _copy-back-ibk:
12
13
14=== modified file 'doc/source/innobackupex/privileges.rst'
15--- doc/source/innobackupex/privileges.rst 2011-07-28 05:29:04 +0000
16+++ doc/source/innobackupex/privileges.rst 2011-11-14 07:14:52 +0000
17@@ -8,7 +8,7 @@
18
19 Permissions are those which permits a user to perform operations on the system, like reading, writing or executing on a certain directory or start/stop a system service. **They are set at a system level and only apply to system users**.
20
21-Whether |xtrabackup| or |innobackupex| is used, there are two actors involved: the user invoking the program - *a system user* - and the user performing action in the database server - *a database server*. Note that these are different users on different places, despite they may have the same username.
22+Whether |xtrabackup| or |innobackupex| is used, there are two actors involved: the user invoking the program - *a system user* - and the user performing action in the database server - *a database user*. Note that these are different users on different places, despite they may have the same username.
23
24 All the invocations of |innobackupex| and |xtrabackup| in this documentation assumes that the system user has the appropriate permissions and you are providing the relevant options for connecting the database server - besides the options for the action to be performed - and the database user has adequate privileges.
25
26
27=== modified file 'innobackupex'
28--- innobackupex 2011-10-21 17:47:31 +0000
29+++ innobackupex 2011-11-14 07:14:52 +0000
30@@ -54,7 +54,7 @@
31
32 # time in seconds after which a dummy query is sent to mysql server
33 # in order to keep the database connection alive
34-my $mysql_keep_alive_timeout = 1800;
35+my $mysql_keep_alive = 5;
36
37 ######################################################################
38 # end of modifiable parameters
39@@ -169,9 +169,6 @@
40 # run on a slave server
41 my $mysql_slave_position = '';
42
43-# time of the most recent mysql_check call. (value returned by time() function)
44-my $mysql_last_access_time = 0;
45-
46 # process id of ibbackup program (runs as a child process of this script)
47 my $ibbackup_pid = '';
48
49@@ -366,7 +363,6 @@
50 # check that we can connect to the database. This done by
51 # connecting, issuing a query, and closing the connection.
52 mysql_open();
53- mysql_check();
54 mysql_close();
55
56 # start ibbackup as a child process
57@@ -379,19 +375,15 @@
58
59 # connect to database
60 mysql_open();
61- mysql_check();
62
63 if ($option_safe_slave_backup) {
64- mysql_check();
65 wait_for_safe_slave();
66 }
67
68 # flush tables with read lock
69- mysql_check();
70 mysql_lockall() if !$option_no_lock;
71
72 if ($option_slave_info) {
73- mysql_check();
74 write_slave_info();
75 }
76
77@@ -406,7 +398,6 @@
78 mysql_unlockall() if !$option_no_lock;
79
80 if ( $option_safe_slave_backup && $host_is_slave ) {
81- mysql_check();
82 print STDERR "$prefix: Starting slave SQL thread\n";
83 mysql_send('START SLAVE SQL_THREAD;');
84 }
85@@ -991,35 +982,15 @@
86
87
88 #
89-# mysql_open subroutine starts mysql as a child process with
90-# a pipe connection.
91-#
92-sub mysql_open {
93- my $options = get_mysql_options();
94- # run mysql as a child process with a pipe connection
95- $now = current_time();
96- (my $prt_options = $options) =~ s/--password=[^ ]+ /--password=xxxxxxxx /g;
97- print STDERR "$now $prefix Starting mysql with options: $prt_options\n";
98- $mysql_pid = open(*MYSQL_WRITER, "| mysql $options >$mysql_stdout 2>$mysql_stderr ") or Die "Failed to spawn mysql child process: $!";
99- MYSQL_WRITER->autoflush(1);
100- $now = current_time();
101- print STDERR "$now $prefix Connected to database with mysql child process (pid=$mysql_pid)\n";
102- print MYSQL_WRITER "SET SESSION wait_timeout = 2147000;\n" or die "Connection to mysql child process failed: $!";
103-
104- mysql_check();
105-}
106-
107-
108-#
109-# mysql_check subroutine checks that the connection to mysql child process
110-# is ok.
111-#
112-sub mysql_check {
113+# Check that the server is responding to queries
114+#
115+sub mysql_ping {
116 my $mysql_pid_copy = $mysql_pid;
117
118 # send a dummy query to mysql child process
119 $hello_id++;
120- my $hello_message = "innobackup hello $hello_id";
121+
122+ my $hello_message = "xtrabackup ping $hello_id";
123 print MYSQL_WRITER "select '$hello_message';\n"
124 or Die "Connection to mysql child process failed: $!";
125
126@@ -1051,21 +1022,54 @@
127 . " You may adjust time limit by editing the value of parameter"
128 . " \"\$mysql_response_timeout\" in this script.)";
129 } elsif ($@) { Die $@; }
130-
131- $mysql_last_access_time = time();
132-}
133-
134-
135-#
136-# mysql_keep_alive subroutine tries to keep connection to the mysqld database
137-# server alive by sending a dummy query when the connection has been idle
138-# for the specified time.
139-#
140-sub mysql_keep_alive {
141- if ((time() - $mysql_last_access_time) > $mysql_keep_alive_timeout) {
142- # too long idle, send a dummy query
143- mysql_check();
144- }
145+}
146+
147+
148+#
149+# SIGALRM handler which sends a keepalive query to the server
150+#
151+sub catch_sigalrm {
152+ mysql_ping();
153+ # Reschedule SIGALRM
154+ alarm $mysql_keep_alive;
155+}
156+
157+
158+#
159+# Schedule periodic server pings
160+#
161+sub start_keepalives {
162+ $SIG{ALRM} = \&catch_sigalrm;
163+ alarm $mysql_keep_alive;
164+}
165+
166+#
167+# Cancel periodic server pings
168+#
169+sub stop_keepalives {
170+ alarm 0;
171+ $SIG{ALRM} = "DEFAULT";
172+}
173+
174+#
175+# mysql_open subroutine starts mysql as a child process with
176+# a pipe connection.
177+#
178+sub mysql_open {
179+ my $options = get_mysql_options();
180+ # run mysql as a child process with a pipe connection
181+ $now = current_time();
182+ (my $prt_options = $options) =~ s/--password=[^ ]+ /--password=xxxxxxxx /g;
183+ print STDERR "$now $prefix Starting mysql with options: $prt_options\n";
184+ $mysql_pid = open(*MYSQL_WRITER, "| mysql $options >$mysql_stdout 2>$mysql_stderr ") or Die "Failed to spawn mysql child process: $!";
185+ MYSQL_WRITER->autoflush(1);
186+ $now = current_time();
187+ print STDERR "$now $prefix Connected to database with mysql child process (pid=$mysql_pid)\n";
188+ print MYSQL_WRITER "SET SESSION wait_timeout = 2147000;\n" or die "Connection to mysql child process failed: $!";
189+
190+ mysql_ping();
191+
192+ start_keepalives();
193 }
194
195
196@@ -1079,10 +1083,14 @@
197 sub mysql_send {
198 my $request = shift;
199
200+ stop_keepalives();
201+
202 $current_mysql_request = $request;
203 print MYSQL_WRITER "$request\n";
204- mysql_check();
205+ mysql_ping();
206 $current_mysql_request = '';
207+
208+ start_keepalives();
209 }
210
211
212@@ -1090,6 +1098,8 @@
213 # mysql_close subroutine terminates mysql child process gracefully.
214 #
215 sub mysql_close {
216+ stop_keepalives();
217+
218 print MYSQL_WRITER "quit\n";
219 $now = current_time();
220 print STDERR "$now $prefix Connection to database server closed\n";
221@@ -1852,9 +1862,6 @@
222 "'$source_dir/$database/$wildcard' ($file_c files)\n";
223 }
224 foreach $file (@list) {
225- # copying may take a long time, so we have to prevent
226- # mysql connection from timing out
227- mysql_keep_alive();
228 next unless check_if_required($database, $file);
229
230 if($option_include) {
231
232=== added file 'test/t/bug884737.sh'
233--- test/t/bug884737.sh 1970-01-01 00:00:00 +0000
234+++ test/t/bug884737.sh 2011-11-14 07:14:52 +0000
235@@ -0,0 +1,14 @@
236+########################################################################
237+# Bug #884737: xtrabackup's --parallel option asserts / crashes with a
238+# value of -1
239+########################################################################
240+
241+. inc/common.sh
242+
243+init
244+run_mysqld
245+
246+# Check that --parallel=<negative value> doesn't blow up
247+vlog "Creating the backup directory: $topdir/backup"
248+mkdir -p $topdir/backup
249+innobackupex $topdir/backup --parallel=-1
250
251=== modified file 'xtrabackup.c'
252--- xtrabackup.c 2011-10-05 02:31:10 +0000
253+++ xtrabackup.c 2011-11-14 07:14:52 +0000
254@@ -708,7 +708,7 @@
255
256 ibool xtrabackup_logfile_is_renamed = FALSE;
257
258-uint parallel;
259+int parallel;
260
261 /* === metadata of backup === */
262 #define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
263@@ -1043,8 +1043,8 @@
264 {"parallel", OPT_XTRA_PARALLEL,
265 "Number of threads to use for parallel datafiles transfer. Does not have "
266 "any effect in the stream mode. The default value is 1.",
267- (G_PTR*) &parallel, (G_PTR*) &parallel, 0, GET_UINT, REQUIRED_ARG,
268- 1, 1, UINT_MAX, 0, 0, 0},
269+ (G_PTR*) &parallel, (G_PTR*) &parallel, 0, GET_INT, REQUIRED_ARG,
270+ 1, 1, INT_MAX, 0, 0, 0},
271
272 {"innodb_adaptive_hash_index", OPT_INNODB_ADAPTIVE_HASH_INDEX,
273 "Enable InnoDB adaptive hash index (enabled by default). "
274@@ -4107,7 +4107,7 @@
275 count = parallel;
276 count_mutex = OS_MUTEX_CREATE();
277
278- for (i = 0; i < parallel; i++) {
279+ for (i = 0; i < (uint) parallel; i++) {
280 data_threads[i].it = it;
281 data_threads[i].num = i+1;
282 data_threads[i].count = &count;

Subscribers

People subscribed via source and target branches