Merge lp:~akopytov/percona-xtrabackup/bug1135441-2.1 into lp:percona-xtrabackup/2.1

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: 659
Merged at revision: 661
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1135441-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 782 lines (+153/-137)
2 files modified
innobackupex (+140/-137)
src/xtrabackup.cc (+13/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1135441-2.1
Reviewer Review Type Date Requested Status
Stewart Smith (community) Approve
Registry Administrators Pending
Review via email: mp+180050@code.launchpad.net

Description of the change

    Bug #1135441: Make sure all child processes are killed on error

    Modified innobackupex to handle the following cases:

    1. the xtrabackup and the query killer processes are killed on errors
    raised by the script itself (regardless of the way it is done)

    2. the xtrabackup and the query killer processes are killed on
    interceptable signals (such as SIGINT, SIGTERM, etc.) received by
    innobackupex.

    3. (on Linux only) the xtrabackup process is killed even if innobackupex
    is terminated with a non-interceptable signal (such as SIGKILL).

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Heh, bug664986.sh still cowardly fails with the fix. Will investigate and recommit.

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

Looks good. We could start using Autodie and other fancy things in the perl code which will help catch places where we may not die gracefully, but that should be a different patch.

This looks good though.

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 2013-07-31 11:28:11 +0000
3+++ innobackupex 2013-08-15 09:38:11 +0000
4@@ -200,6 +200,9 @@
5 # run on a slave server
6 my $mysql_slave_position = '';
7
8+# process id if the script itself
9+my $innobackupex_pid = $$;
10+
11 # process id of ibbackup program (runs as a child process of this script)
12 my $ibbackup_pid = '';
13
14@@ -400,22 +403,63 @@
15 return strftime("%y%m%d %H:%M:%S", localtime());
16 }
17
18-
19-#
20-# Die subroutine kills all child processes and exits this process.
21-# This subroutine takes the same argument as the built-in die function.
22-# Parameters:
23-# message string which is printed to stdout
24-#
25-sub Die {
26- my $message = shift;
27-
28- # kill all child processes of this process
29- kill_child_processes();
30-
31- die "$prefix Error: $message";
32-}
33-
34+#
35+# Global initialization:
36+# 1. Override the 'die' builtin to customize the format of error messages
37+#
38+# 2. Setup signal handlers to terminate gracefully on fatal signals
39+#
40+BEGIN {
41+ *CORE::GLOBAL::die = sub {
42+
43+ print STDERR "$prefix Error: @_";
44+
45+ # Mimic the default 'die' behavior: append information about the caller
46+ # and the new line, if the argument does not already end with a newline
47+ if ($_[-1] !~ m(\n$)) {
48+ my ($pkg, $file, $line) = caller 0;
49+
50+ print STDERR " at $file line $line.\n";
51+ }
52+
53+ exit(1);
54+ };
55+
56+ foreach ('HUP', 'INT', 'QUIT', 'ABRT', 'PIPE', 'TERM', 'XFSZ') {
57+ $SIG{$_} = \&catch_fatal_signal;
58+ }
59+}
60+
61+#
62+# Make sure all child processes are killed on exit. This doesn't cover cases
63+# when innobackupex is terminated with a signal.
64+#
65+END {
66+ # We only want to execute this in the parent script process, and ignore
67+ # for all child processes it may spawn
68+ if ($$ == $innobackupex_pid) {
69+ kill_child_processes();
70+ }
71+}
72+
73+#
74+# kill child processes spawned by the script
75+#
76+sub kill_child_processes {
77+ if ($ibbackup_pid) {
78+ kill($kill_signal, $ibbackup_pid);
79+ wait_for_ibbackup_finish();
80+ }
81+ stop_query_killer();
82+}
83+
84+sub catch_fatal_signal {
85+ # Don't print anything if a child process is terminated with a signal
86+ if ($$ == $innobackupex_pid) {
87+ die "Terminated with SIG$_[0]"
88+ }
89+}
90+
91 #
92 # Finds all files that match the given pattern recursively beneath
93 # the given directory. Returns a list of files with their paths relative
94@@ -429,7 +473,7 @@
95 my @retlist;
96
97 opendir(FINDDIR, $dir)
98- || Die "Can't open directory '$dir': $!\n";
99+ || die "Can't open directory '$dir': $!";
100
101 while (defined($child = readdir(FINDDIR))) {
102 next if $child eq "." || $child eq "..";
103@@ -464,10 +508,10 @@
104 } elsif ($mode == 2) {
105 $file_cmd = "qpress -do " . $file . " > " . $dest_file;
106 } else {
107- Die("Unknown decrypt_decompress mode : $mode\n");
108+ die "Unknown decrypt_decompress mode : $mode";
109 }
110 print STDERR "$prefix $file_cmd\n";
111- system("$file_cmd") && Die "$file_cmd failed with $!\n";
112+ system("$file_cmd") && die "$file_cmd failed with $!";
113 system("rm -f $file");
114 }
115
116@@ -505,7 +549,7 @@
117 } elsif ($mode == 2) {
118 $file_ext = ".qp";
119 } else {
120- Die("Unknown decrypt_decompress mode : $mode\n");
121+ die "Unknown decrypt_decompress mode : $mode";
122 }
123
124 # recursively find all files of interest in the backup set
125@@ -547,11 +591,11 @@
126 if ($status == $pids[$freepidindex]) {
127 my $childretcode = $? >> 8;
128 if ($childretcode != 0) {
129- Die("Child failed on $workingfiles[$freepidindex] : $childretcode");
130+ die "Child failed on $workingfiles[$freepidindex] : $childretcode";
131 }
132 last;
133 } elsif ($status == -1) {
134- Die("waitpid failed on $workingfiles[$freepidindex] : $status");
135+ die "waitpid failed on $workingfiles[$freepidindex] : $status";
136 }
137 }
138 # couldn't find a free slot yet so sleep for 1/10 th of a second or so.
139@@ -581,10 +625,10 @@
140 my $childretcode = $? >> 8;
141 if ($status == $pids[$freepidindex]) {
142 if ($childretcode != 0) {
143- Die("Child failed on $workingfiles[$freepidindex] : $childretcode");
144+ die "Child failed on $workingfiles[$freepidindex] : $childretcode";
145 }
146 } else {
147- Die("waitpid failed on $workingfiles[$freepidindex] : $status");
148+ die "waitpid failed on $workingfiles[$freepidindex] : $status";
149 }
150 }
151 }
152@@ -795,7 +839,7 @@
153 my $dst_path = shift;
154
155 print STDERR "$prefix Copying '$src_path' to '$dst_path'\n";
156- copy($src_path, $dst_path) or Die "copy failed: $!";
157+ copy($src_path, $dst_path) or die "copy failed: $!";
158 }
159
160 #
161@@ -806,7 +850,7 @@
162 my $dst_path = shift;
163
164 print STDERR "$prefix Moving '$src_path' to '$dst_path'\n";
165- move($src_path, $dst_path) or Die "move failed: $!";
166+ move($src_path, $dst_path) or die "move failed: $!";
167 }
168
169
170@@ -851,14 +895,14 @@
171 # Create the directory in the destination if necessary
172 if (! -e "$dst_path") {
173 print STDERR "$prefix Creating directory '$dst_path'\n";
174- mkdir "$dst_path" or Die "mkdir failed: $!";
175+ mkdir "$dst_path" or die "mkdir failed: $!";
176 } elsif (! -d "$dst_path") {
177- Die "$dst_path exists, but is not a directory";
178+ die "$dst_path exists, but is not a directory";
179 }
180 } else {
181 # Don't overwrite files unless $copy_dir_overwrite is 1
182 if (!$copy_dir_overwrite && -e "$copy_dir_dst/$_") {
183- Die "Failed to process file $File::Find::name: " .
184+ die "Failed to process file $File::Find::name: " .
185 "not overwriting file $copy_dir_dst/$_";
186 }
187
188@@ -898,7 +942,7 @@
189 }
190 if (! exists $processed_files{$rel_path}) {
191 unlink($File::Find::name) or
192- Die("Cannot remove file $File::Find::name");
193+ die "Cannot remove file $File::Find::name";
194 }
195 }
196
197@@ -1043,20 +1087,6 @@
198 "Original undo directory");
199 }
200
201- # check that the original options file and the backup options file have
202- # the same value for "innodb_data_file_path" option
203- #$backup_innodb_data_file_path =
204- # get_option(\%backup_config, 'mysqld', 'innodb_data_file_path');
205- #if (!are_equal_innodb_data_file_paths($orig_innodb_data_file_path,
206- # $backup_innodb_data_file_path)
207- #) {
208- # Die "The value of 'innodb_data_file_path' option in the original "
209- # . "my.cnf file '$config_file' is different from the value "
210- # . "in the backup my.cnf file '$backup_config_file'.\n(original: "
211- # . "'$orig_innodb_data_file_path')\n"
212- # . "(backup: '$backup_innodb_data_file_path')";
213- #}
214-
215 # make a list of all ibdata files in the backup directory and all
216 # directories in the backup directory under which there are ibdata files
217 foreach my $c (parse_innodb_data_file_path($orig_innodb_data_file_path)) {
218@@ -1064,7 +1094,7 @@
219 # check that the backup data file exists
220 if (! -e "$backup_dir/$c->{filename}") {
221 if (-e "$backup_dir/$c->{filename}.ibz") {
222- Die "Backup data file '$backup_dir/$c->{filename}' "
223+ die "Backup data file '$backup_dir/$c->{filename}' "
224 . "does not exist, but "
225 . "its compressed copy '$c->{path}.ibz' exists. Check "
226 . "that you have decompressed "
227@@ -1072,7 +1102,7 @@
228 . "'$innobackup_script --copy-back ...' "
229 . "or '$innobackup_script --move-back ...' !";
230 } elsif (-e "$backup_dir/$c->{filename}.qp") {
231- Die "Backup data file '$backup_dir/$c->{filename}' "
232+ die "Backup data file '$backup_dir/$c->{filename}' "
233 . "does not exist, but "
234 . "its compressed copy '$c->{path}.qp' exists. Check "
235 . "that you have run "
236@@ -1081,7 +1111,7 @@
237 . "'$innobackup_script --copy-back ...' "
238 . "or '$innobackup_script --move-back ...' !";
239 } elsif (-e "$backup_dir/$c->{filename}.xbcrypt") {
240- Die "Backup data file '$backup_dir/$c->{filename}' "
241+ die "Backup data file '$backup_dir/$c->{filename}' "
242 . "does not exist, but "
243 . "its compressed copy '$c->{path}.xbcrypt' exists. Check "
244 . "that you have run "
245@@ -1090,7 +1120,7 @@
246 . "'$innobackup_script --copy-back ...' "
247 . "or '$innobackup_script --move-back ...' !";
248 } else {
249- Die "Backup data file '$backup_dir/$c->{filename}' "
250+ die "Backup data file '$backup_dir/$c->{filename}' "
251 . "does not exist.";
252 }
253 }
254@@ -1123,7 +1153,7 @@
255 print STDERR "$prefix in '$backup_dir'\n";
256 print STDERR "$prefix back to '$orig_undo_dir'\n";
257 opendir(DIR, $backup_dir)
258- || Die "Can't open directory '$backup_dir': $!\n";
259+ || die "Can't open directory '$backup_dir': $!";
260 while (defined($file = readdir(DIR))) {
261 if ($file =~ /^$ibundo_files$/ && -f "$backup_dir/$file") {
262 $src_name = escape_path("$backup_dir/$file");
263@@ -1135,7 +1165,7 @@
264
265 # copy InnoDB log files to original InnoDB log directory
266 opendir(DIR, $backup_dir)
267- || Die "Can't open directory '$backup_dir': $!\n";
268+ || die "Can't open directory '$backup_dir': $!";
269 print STDERR "\n$prefix Starting to $operation InnoDB log files\n";
270 print STDERR "$prefix in '$backup_dir'\n";
271 print STDERR "$prefix back to original InnoDB log directory '$orig_iblog_dir'\n";
272@@ -1216,7 +1246,7 @@
273 $rcode = system("$cmdline");
274 if ($rcode) {
275 # failure
276- Die "\n$prefix ibbackup failed";
277+ die "\n$prefix ibbackup failed";
278 }
279
280 # We should not create ib_logfile files if we prepare for following incremental applies
281@@ -1228,7 +1258,7 @@
282 $rcode = system("$cmdline");
283 if ($rcode) {
284 # failure
285- Die "\n$prefix xtrabackup (2nd execution) failed";
286+ die "\n$prefix xtrabackup (2nd execution) failed";
287 }
288 }
289
290@@ -1275,7 +1305,8 @@
291
292 if ($ibbackup_pid == $pid) {
293 # The file doesn't exist, but the process has terminated
294- Die "ibbackup child process has died";
295+ $ibbackup_pid = '';
296+ die "The xtrabackup child process has died";
297 }
298
299 sleep 1;
300@@ -1309,7 +1340,7 @@
301 #
302 sub resume_ibbackup {
303 my $suspend_file = shift;
304- unlink $suspend_file || Die "Failed to delete '$suspend_file': $!";
305+ unlink $suspend_file || die "Failed to delete '$suspend_file': $!";
306 }
307
308 #
309@@ -1325,7 +1356,7 @@
310
311 wait_for_ibbackup_file_create($suspend_file);
312
313- unlink $suspend_file || Die "Failed to delete '$suspend_file': $!";
314+ unlink $suspend_file || die "Failed to delete '$suspend_file': $!";
315 }
316
317 #
318@@ -1460,10 +1491,10 @@
319 $ibbackup_pid = $pid;
320 } else {
321 # child process
322- exec($cmdline) || Die "Failed to exec ibbackup: $!";
323+ exec($cmdline) || die "Failed to exec ibbackup: $!";
324 }
325 } else {
326- Die "failed to fork ibbackup child process: $!";
327+ die "failed to fork ibbackup child process: $!";
328 }
329 }
330
331@@ -1513,7 +1544,7 @@
332 my $con = shift;
333
334 if (defined($con->{keep_alive_pid})) {
335- Die "Keep-alive process has already been started for this connection."
336+ die "Keep-alive process has already been started for this connection."
337 }
338
339 my $keep_alive_pid = fork();
340@@ -1557,7 +1588,7 @@
341 my $con = shift;
342
343 if (!defined($con->{keep_alive_pid})) {
344- Die "Keep-alive process has never been started for this connection."
345+ die "Keep-alive process has never been started for this connection."
346 }
347
348 kill 'INT', $con->{keep_alive_pid};
349@@ -1565,7 +1596,7 @@
350 my $rc = $? >> 8;
351
352 if ($rc != 0) {
353- Die "Keep-alive process died with exit code " . $rc;
354+ die "Keep-alive process died with exit code " . $rc;
355 }
356 undef $con->{keep_alive_pid};
357 }
358@@ -1611,11 +1642,11 @@
359
360 if ($args{abort_on_error}) {
361 if (!$dbd_mysql_installed) {
362- die "ERROR: Failed to connect to MySQL server as " .
363+ die "Failed to connect to MySQL server as " .
364 "DBD::mysql module is not installed";
365 } else {
366 if (!$con{dbh}) {
367- die "ERROR: Failed to connect to MySQL server: " .
368+ die "Failed to connect to MySQL server: " .
369 $con{connect_error};
370 }
371 }
372@@ -1670,7 +1701,7 @@
373 }
374 };
375 if ($EVAL_ERROR) {
376- Die "\nError executing '$query': $EVAL_ERROR\n";
377+ die "\nError executing '$query': $EVAL_ERROR";
378 }
379 }
380
381@@ -1925,7 +1956,7 @@
382 sleep(1);
383 }
384
385- Die "Unable to obtain lock. Please try again.";
386+ die "Unable to obtain lock. Please try again.";
387 }
388
389
390@@ -1964,6 +1995,7 @@
391 if (defined($query_killer_pid)) {
392 kill 'HUP' => $query_killer_pid;
393 waitpid($query_killer_pid, 0);
394+ undef $query_killer_pid;
395 print STDERR "Query killing process is finished\n";
396 }
397 }
398@@ -2029,18 +2061,6 @@
399 }
400
401 #
402-# kill_child_processes subroutine kills all child processes of this process.
403-#
404-sub kill_child_processes {
405- if ($ibbackup_pid) {
406- kill($kill_signal, $ibbackup_pid);
407- $ibbackup_pid = '';
408- }
409- stop_query_killer();
410-}
411-
412-
413-#
414 # require_external subroutine checks that an external program is runnable
415 # via the shell. This is tested by calling the program with the
416 # given arguments. It is checked that the program returns 0 and does
417@@ -2075,11 +2095,11 @@
418 if ($stderr ne '') {
419 # failure
420 unlink $tmp_stdout;
421- Die "Couldn't run $program: $stderr";
422+ die "Couldn't run $program: $stderr";
423 } elsif ($rcode) {
424 # failure
425 unlink $tmp_stdout;
426- Die "Couldn't run $program: $error";
427+ die "Couldn't run $program: $error";
428 }
429
430 # success
431@@ -2186,7 +2206,7 @@
432 && $ibbackup_version le "2.0") {
433 # --include option was given, but ibbackup is too
434 # old to support it
435- Die "--include option was given, but ibbackup is too old"
436+ die "--include option was given, but ibbackup is too old"
437 . " to support it. You must upgrade to InnoDB Hot Backup"
438 . " v2.0 in order to use --include option.\n";
439 }
440@@ -2229,7 +2249,7 @@
441 "WARNING : A left over instance of " .
442 "suspend file '$suspend_file' was found.\n";
443 unlink "$suspend_file"
444- || Die "Failed to delete '$suspend_file': $!";
445+ || die "Failed to delete '$suspend_file': $!";
446 }
447 }
448
449@@ -2238,7 +2258,7 @@
450 "file '$option_tmpdir/$xtrabackup_pid_file' " .
451 "was found.\n";
452 unlink $option_tmpdir . "/" . $xtrabackup_pid_file ||
453- Die "Failed to delete " .
454+ die "Failed to delete " .
455 "'$option_tmpdir/$xtrabackup_pid_file': $!";
456 }
457
458@@ -2313,12 +2333,6 @@
459 }
460 }
461
462- if (@ARGV == 0) {
463- # no command line arguments
464- print STDERR "$prefix You must specify the backup directory.\n";
465- exit(1);
466- }
467-
468 # read command line options
469 $rcode = GetOptions('compress' => \$option_compress,
470 'decompress' => \$option_decompress,
471@@ -2383,11 +2397,16 @@
472 'lock-wait-query-type=s' =>
473 \$option_lock_wait_query_type
474 );
475-
476+
477+ if (@ARGV == 0) {
478+ die "You must specify the backup directory.\n";
479+ } elsif (@ARGV > 1) {
480+ die "Too many command line arguments\n";
481+ }
482+
483 if (!$rcode) {
484 # failed to read options
485- print STDERR "$prefix Bad command line arguments\n";
486- exit(1);
487+ die "Bad command line arguments\n";
488 }
489 if ($option_help) {
490 # print help text and exit
491@@ -2401,9 +2420,8 @@
492 }
493
494 if ($option_defaults_file && $option_defaults_extra_file) {
495- print STDERR "$prefix --defaults-file and --defaults-extra-file " .
496+ die "--defaults-file and --defaults-extra-file " .
497 "options are mutually exclusive";
498- exit(1);
499 }
500
501 if ($option_copy_back && $option_move_back) {
502@@ -2423,19 +2441,18 @@
503
504 # validate lock-wait-query-type and kill-long-query-type values
505 if (!(grep {$_ eq $option_lock_wait_query_type} qw/all update/)) {
506- Die "Wrong value of lock-wait-query-type. ".
507+ die "Wrong value of lock-wait-query-type. ".
508 "Possible values are all|update, but $option_lock_wait_query_type ".
509 "is specified.";
510 }
511 if (!(grep {$_ eq $option_kill_long_query_type} qw/all select/)) {
512- Die "Wrong value of kill-long-query-type. ".
513+ die "Wrong value of kill-long-query-type. ".
514 "Possible values are all|select, but $option_kill_long_query_type ".
515 "is specified.";
516 }
517
518 if ($option_parallel && $option_parallel < 1) {
519- Die "$prefix --parallel must be a positive numerical value" .
520- "greater than 0";
521+ die "--parallel must be a positive value.\n";
522 }
523
524 if ($option_stream eq 'tar') {
525@@ -2457,14 +2474,6 @@
526 }
527 }
528
529- if (@ARGV < 1) {
530- print STDERR "$prefix Missing command line argument\n";
531- exit(1);
532- } elsif (@ARGV > 1) {
533- print STDERR "$prefix Too many command line arguments\n";
534- exit(1);
535- }
536-
537 if (!$option_apply_log && !$option_copy_back && !$option_move_back
538 && !$option_decrypt && !$option_decompress) {
539 # we are making a backup, get backup root directory
540@@ -2487,20 +2496,17 @@
541
542 if ($option_slave_info) {
543 if ($option_no_lock and !$option_safe_slave_backup) {
544- print STDERR "--slave-info is used with --no-lock but without --safe-slave-backup. The binlog position cannot be consistent with the backup data.\n";
545- exit(1);
546+ die "--slave-info is used with --no-lock but without --safe-slave-backup. The binlog position cannot be consistent with the backup data.\n";
547 }
548 }
549
550 if ($option_rsync && $option_stream) {
551- print STDERR "--rsync doesn't work with --stream\n";
552- exit(1);
553+ die "--rsync doesn't work with --stream\n";
554 }
555
556 if ($option_decompress) {
557 if (system("which qpress &>/dev/null") >> 8 != 0) {
558- print STDERR "--decompress requires qpress\n";
559- exit(1);
560+ die "--decompress requires qpress\n";
561 }
562 }
563
564@@ -2528,7 +2534,7 @@
565
566 $dir .= '/' . strftime("%Y-%m-%d_%H-%M-%S", localtime())
567 unless $option_no_timestamp;
568- mkdir($dir, 0777) || Die "Failed to create backup directory $dir: $!";
569+ mkdir($dir, 0777) || die "Failed to create backup directory $dir: $!";
570
571 # create subdirectories for ibdata files if needed
572 # foreach my $a (split(/;/, $innodb_data_file_path)) {
573@@ -2566,7 +2572,7 @@
574 $path = $path . "/" . $a;
575 if (! -d $path) {
576 # this directory does not exist, create it !
577- mkdir($path, 0777) || Die "Failed to create backup directory: $!";
578+ mkdir($path, 0777) || die "Failed to create backup directory: $!";
579 }
580 }
581 }
582@@ -2626,11 +2632,11 @@
583 $rsync_file_list = $rsync_tmpfile_pass2;
584 }
585 open(RSYNC, ">$rsync_file_list")
586- || Die "Can't open $rsync_file_list for writing: $!\n";
587+ || die "Can't open $rsync_file_list for writing: $!";
588 }
589
590 opendir(DIR, $source_dir)
591- || Die "Can't open directory '$source_dir': $!\n";
592+ || die "Can't open directory '$source_dir': $!";
593 $now = current_time();
594 if ($prep_mode) {
595 $operation = "a prep copy of";
596@@ -2653,7 +2659,7 @@
597 if (! -e "$backup_dir/$database") {
598 # create database directory for the backup
599 mkdir("$backup_dir/$database", 0777)
600- || Die "Couldn't create directory '$backup_dir/$database': $!";
601+ || die "Couldn't create directory '$backup_dir/$database': $!";
602 }
603 }
604
605@@ -2720,7 +2726,7 @@
606 # ignore errors in the prep mode, since we are running without lock,
607 # so some files may have disappeared.
608 if (system("$rsync_cmd") && !$prep_mode) {
609- Die "rsync failed: $!\n";
610+ die "rsync failed: $!";
611 }
612
613 $now = current_time();
614@@ -2731,7 +2737,7 @@
615 # with --files-from.
616 if (!$prep_mode && !$option_no_lock) {
617 open(RSYNC, "<$rsync_tmpfile_pass1")
618- || Die "Can't open $rsync_tmpfile_pass1 for reading: $!\n";
619+ || die "Can't open $rsync_tmpfile_pass1 for reading: $!";
620
621 while (<RSYNC>) {
622 chomp;
623@@ -2743,9 +2749,9 @@
624
625 close(RSYNC);
626 unlink "$rsync_tmpfile_pass1" || \
627- Die "Failed to delete $rsync_tmpfile_pass1: $!";
628+ die "Failed to delete $rsync_tmpfile_pass1: $!";
629 unlink "$rsync_tmpfile_pass2" || \
630- Die "Failed to delete $rsync_tmpfile_pass2: $!";
631+ die "Failed to delete $rsync_tmpfile_pass2: $!";
632 }
633 }
634
635@@ -2771,9 +2777,9 @@
636 my $filename = shift;
637 my $lines_ref = shift;
638
639- open(FILE, $filename) || Die "can't open file '$filename': $!";
640+ open(FILE, $filename) || die "can't open file '$filename': $!";
641 @{$lines_ref} = <FILE>;
642- close(FILE) || Die "can't close file '$filename': $!";
643+ close(FILE) || die "can't close file '$filename': $!";
644
645 foreach my $a (@{$lines_ref}) {
646 chomp($a);
647@@ -2943,8 +2949,7 @@
648
649 if (!exists ${$config_ref}{$group}) {
650 # no group
651- print STDERR "$prefix fatal error: no '$group' group in MySQL options\n";
652- exit(1);
653+ die "no '$group' group in MySQL options";
654 }
655
656 $group_hash_ref = ${$config_ref}{$group};
657@@ -2970,15 +2975,13 @@
658
659 if (!exists $config{$group}) {
660 # no group
661- print STDERR "$prefix fatal error: no '$group' group in MySQL options\n";
662- exit(1);
663+ die "no '$group' group in MySQL options";
664 }
665
666 $group_hash_ref = ${$config_ref}{$group};
667 if (!exists ${$group_hash_ref}{$option_name}) {
668 # no option
669- print STDERR "$prefix fatal error: no '$option_name' option in group '$group' in MySQL options\n";
670- exit(1);
671+ die "no '$option_name' option in group '$group' in MySQL options";
672 }
673
674 return ${$group_hash_ref}{$option_name};
675@@ -3089,7 +3092,7 @@
676 # the option value is pathname of the file containing
677 # list of databases
678 if (! -f $option_databases) {
679- Die "can't find file '$option_databases'";
680+ die "can't find file '$option_databases'";
681 }
682
683 # read from file the value of --databases option
684@@ -3199,11 +3202,11 @@
685
686
687 if($var_version =~ m/5\.0\.\d/) {
688- Die "MySQL 5.0 support was removed in Percona XtraBackup 2.1. The last version to support MySQL 5.0 was Percona XtraBackup 2.0.";
689+ die "MySQL 5.0 support was removed in Percona XtraBackup 2.1. The last version to support MySQL 5.0 was Percona XtraBackup 2.0.\n";
690 }
691
692 if($var_version =~ m/5\.1\.\d/ && !defined($var_innodb_version)) {
693- Die "Support for MySQL 5.1 with builtin InnoDB (not the plugin) was removed in Percona XtraBackup 2.1. The last version to support MySQL 5.1 with builtin InnoDB was Percona XtraBackup 2.0.";
694+ die "Support for MySQL 5.1 with builtin InnoDB (not the plugin) was removed in Percona XtraBackup 2.1. The last version to support MySQL 5.1 with builtin InnoDB was Percona XtraBackup 2.0.\n";
695 }
696
697 if($var_version =~ m/5\.1\.\d/) {
698@@ -3227,7 +3230,7 @@
699 }
700
701 if (!$ibbackup_binary) {
702- Die "Unsupported server version: '$var_version' " .
703+ die "Unsupported server version: '$var_version' " .
704 "(InnoDB version: '$var_innodb_version'). " .
705 "Please report a bug at ".
706 "https://bugs.launchpad.net/percona-xtrabackup\n";
707@@ -3295,7 +3298,7 @@
708 mysql_query($con, 'START SLAVE SQL_THREAD');
709 }
710
711- Die "Slave_open_temp_tables did not become zero after waiting $option_safe_slave_backup_timeout seconds";
712+ die "Slave_open_temp_tables did not become zero after $option_safe_slave_backup_timeout seconds";
713 }
714
715 sub get_slave_open_temp_tables {
716@@ -3304,10 +3307,10 @@
717 get_mysql_status($con);
718
719 if (!defined($con->{status}->{Slave_open_temp_tables})) {
720- Die "Failed to get Slave_open_temp_tables from SHOW STATUS"
721+ die "Failed to get Slave_open_temp_tables from SHOW STATUS"
722 }
723 if (!defined($con->{status}->{Slave_open_temp_tables}->{Value})) {
724- Die "SHOW STATUS LIKE 'slave_open_temp_tables' did not return anything"
725+ die "SHOW STATUS LIKE 'slave_open_temp_tables' did not return anything"
726 }
727
728 return $con->{status}->{Slave_open_temp_tables}->{Value};
729@@ -3352,7 +3355,7 @@
730 }
731 # Only treat as fatal cases where the file exists
732 if ( -e "$src_path/$src_file" ) {
733- Die "Failed to stream '$src_path/$src_file': $ret";
734+ die "Failed to stream '$src_path/$src_file': $ret";
735 } else {
736 print STDERR "$prefix Ignoring nonexistent file '$src_path/$src_file'.\n";
737 }
738@@ -3377,12 +3380,12 @@
739 $dst_file_esc = $dst_file_esc . ".xbcrypt";
740 $ret = system("$encrypt_cmd -i \"$src_file_esc\" -o \"$dst_file_esc\"");
741 if ($ret != 0) {
742- Die "Failed to copy and encrypt file '$src_file': $ret";
743+ die "Failed to copy and encrypt file '$src_file': $ret";
744 }
745 } elsif ( -e "$src_file_esc" ) {
746 $ret = system("$CP_CMD \"$src_file_esc\" \"$dst_file_esc\"");
747 if ($ret != 0) {
748- Die "Failed to copy file '$src_file': $ret";
749+ die "Failed to copy file '$src_file': $ret";
750 }
751 }
752 }
753
754=== modified file 'src/xtrabackup.cc'
755--- src/xtrabackup.cc 2013-08-12 11:42:38 +0000
756+++ src/xtrabackup.cc 2013-08-15 09:38:11 +0000
757@@ -59,6 +59,10 @@
758
759 #include <fcntl.h>
760
761+#ifdef __linux__
762+# include <sys/prctl.h>
763+#endif
764+
765 #define G_PTR uchar*
766
767 #include "common.h"
768@@ -5595,6 +5599,15 @@
769 {
770 int ho_error;
771
772+#ifdef __linux__
773+ /* Ensure xtrabackup process is killed when the parent one
774+ (innobackupex) is terminated with an unhandled signal */
775+
776+ if (prctl(PR_SET_PDEATHSIG, SIGINT)) {
777+ msg("prctl() failed with errno = %d\n", errno);
778+ exit(EXIT_FAILURE);
779+ }
780+#endif
781 MY_INIT(argv[0]);
782 xb_regex_init();
783

Subscribers

People subscribed via source and target branches

to all changes: