Merge lp:~akopytov/percona-xtrabackup/bug1135441-2.1 into lp:percona-xtrabackup/2.1
- bug1135441-2.1
- Merge into 2.1
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Stewart Smith | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
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 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stewart Smith (community) | Approve | ||
Registry Administrators | Pending | ||
Review via email: mp+180050@code.launchpad.net |
Commit message
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).
Alexey Kopytov (akopytov) wrote : | # |
Alexey Kopytov (akopytov) wrote : | # |
Heh, bug664986.sh still cowardly fails with the fix. Will investigate and recommit.
Alexey Kopytov (akopytov) wrote : | # |
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.
Preview Diff
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 | 200 | # run on a slave server | 200 | # run on a slave server |
6 | 201 | my $mysql_slave_position = ''; | 201 | my $mysql_slave_position = ''; |
7 | 202 | 202 | ||
8 | 203 | # process id if the script itself | ||
9 | 204 | my $innobackupex_pid = $$; | ||
10 | 205 | |||
11 | 203 | # process id of ibbackup program (runs as a child process of this script) | 206 | # process id of ibbackup program (runs as a child process of this script) |
12 | 204 | my $ibbackup_pid = ''; | 207 | my $ibbackup_pid = ''; |
13 | 205 | 208 | ||
14 | @@ -400,22 +403,63 @@ | |||
15 | 400 | return strftime("%y%m%d %H:%M:%S", localtime()); | 403 | return strftime("%y%m%d %H:%M:%S", localtime()); |
16 | 401 | } | 404 | } |
17 | 402 | 405 | ||
34 | 403 | 406 | # | |
35 | 404 | # | 407 | # Global initialization: |
36 | 405 | # Die subroutine kills all child processes and exits this process. | 408 | # 1. Override the 'die' builtin to customize the format of error messages |
37 | 406 | # This subroutine takes the same argument as the built-in die function. | 409 | # |
38 | 407 | # Parameters: | 410 | # 2. Setup signal handlers to terminate gracefully on fatal signals |
39 | 408 | # message string which is printed to stdout | 411 | # |
40 | 409 | # | 412 | BEGIN { |
41 | 410 | sub Die { | 413 | *CORE::GLOBAL::die = sub { |
42 | 411 | my $message = shift; | 414 | |
43 | 412 | 415 | print STDERR "$prefix Error: @_"; | |
44 | 413 | # kill all child processes of this process | 416 | |
45 | 414 | kill_child_processes(); | 417 | # Mimic the default 'die' behavior: append information about the caller |
46 | 415 | 418 | # and the new line, if the argument does not already end with a newline | |
47 | 416 | die "$prefix Error: $message"; | 419 | if ($_[-1] !~ m(\n$)) { |
48 | 417 | } | 420 | my ($pkg, $file, $line) = caller 0; |
49 | 418 | 421 | ||
50 | 422 | print STDERR " at $file line $line.\n"; | ||
51 | 423 | } | ||
52 | 424 | |||
53 | 425 | exit(1); | ||
54 | 426 | }; | ||
55 | 427 | |||
56 | 428 | foreach ('HUP', 'INT', 'QUIT', 'ABRT', 'PIPE', 'TERM', 'XFSZ') { | ||
57 | 429 | $SIG{$_} = \&catch_fatal_signal; | ||
58 | 430 | } | ||
59 | 431 | } | ||
60 | 432 | |||
61 | 433 | # | ||
62 | 434 | # Make sure all child processes are killed on exit. This doesn't cover cases | ||
63 | 435 | # when innobackupex is terminated with a signal. | ||
64 | 436 | # | ||
65 | 437 | END { | ||
66 | 438 | # We only want to execute this in the parent script process, and ignore | ||
67 | 439 | # for all child processes it may spawn | ||
68 | 440 | if ($$ == $innobackupex_pid) { | ||
69 | 441 | kill_child_processes(); | ||
70 | 442 | } | ||
71 | 443 | } | ||
72 | 444 | |||
73 | 445 | # | ||
74 | 446 | # kill child processes spawned by the script | ||
75 | 447 | # | ||
76 | 448 | sub kill_child_processes { | ||
77 | 449 | if ($ibbackup_pid) { | ||
78 | 450 | kill($kill_signal, $ibbackup_pid); | ||
79 | 451 | wait_for_ibbackup_finish(); | ||
80 | 452 | } | ||
81 | 453 | stop_query_killer(); | ||
82 | 454 | } | ||
83 | 455 | |||
84 | 456 | sub catch_fatal_signal { | ||
85 | 457 | # Don't print anything if a child process is terminated with a signal | ||
86 | 458 | if ($$ == $innobackupex_pid) { | ||
87 | 459 | die "Terminated with SIG$_[0]" | ||
88 | 460 | } | ||
89 | 461 | } | ||
90 | 462 | |||
91 | 419 | # | 463 | # |
92 | 420 | # Finds all files that match the given pattern recursively beneath | 464 | # Finds all files that match the given pattern recursively beneath |
93 | 421 | # the given directory. Returns a list of files with their paths relative | 465 | # the given directory. Returns a list of files with their paths relative |
94 | @@ -429,7 +473,7 @@ | |||
95 | 429 | my @retlist; | 473 | my @retlist; |
96 | 430 | 474 | ||
97 | 431 | opendir(FINDDIR, $dir) | 475 | opendir(FINDDIR, $dir) |
99 | 432 | || Die "Can't open directory '$dir': $!\n"; | 476 | || die "Can't open directory '$dir': $!"; |
100 | 433 | 477 | ||
101 | 434 | while (defined($child = readdir(FINDDIR))) { | 478 | while (defined($child = readdir(FINDDIR))) { |
102 | 435 | next if $child eq "." || $child eq ".."; | 479 | next if $child eq "." || $child eq ".."; |
103 | @@ -464,10 +508,10 @@ | |||
104 | 464 | } elsif ($mode == 2) { | 508 | } elsif ($mode == 2) { |
105 | 465 | $file_cmd = "qpress -do " . $file . " > " . $dest_file; | 509 | $file_cmd = "qpress -do " . $file . " > " . $dest_file; |
106 | 466 | } else { | 510 | } else { |
108 | 467 | Die("Unknown decrypt_decompress mode : $mode\n"); | 511 | die "Unknown decrypt_decompress mode : $mode"; |
109 | 468 | } | 512 | } |
110 | 469 | print STDERR "$prefix $file_cmd\n"; | 513 | print STDERR "$prefix $file_cmd\n"; |
112 | 470 | system("$file_cmd") && Die "$file_cmd failed with $!\n"; | 514 | system("$file_cmd") && die "$file_cmd failed with $!"; |
113 | 471 | system("rm -f $file"); | 515 | system("rm -f $file"); |
114 | 472 | } | 516 | } |
115 | 473 | 517 | ||
116 | @@ -505,7 +549,7 @@ | |||
117 | 505 | } elsif ($mode == 2) { | 549 | } elsif ($mode == 2) { |
118 | 506 | $file_ext = ".qp"; | 550 | $file_ext = ".qp"; |
119 | 507 | } else { | 551 | } else { |
121 | 508 | Die("Unknown decrypt_decompress mode : $mode\n"); | 552 | die "Unknown decrypt_decompress mode : $mode"; |
122 | 509 | } | 553 | } |
123 | 510 | 554 | ||
124 | 511 | # recursively find all files of interest in the backup set | 555 | # recursively find all files of interest in the backup set |
125 | @@ -547,11 +591,11 @@ | |||
126 | 547 | if ($status == $pids[$freepidindex]) { | 591 | if ($status == $pids[$freepidindex]) { |
127 | 548 | my $childretcode = $? >> 8; | 592 | my $childretcode = $? >> 8; |
128 | 549 | if ($childretcode != 0) { | 593 | if ($childretcode != 0) { |
130 | 550 | Die("Child failed on $workingfiles[$freepidindex] : $childretcode"); | 594 | die "Child failed on $workingfiles[$freepidindex] : $childretcode"; |
131 | 551 | } | 595 | } |
132 | 552 | last; | 596 | last; |
133 | 553 | } elsif ($status == -1) { | 597 | } elsif ($status == -1) { |
135 | 554 | Die("waitpid failed on $workingfiles[$freepidindex] : $status"); | 598 | die "waitpid failed on $workingfiles[$freepidindex] : $status"; |
136 | 555 | } | 599 | } |
137 | 556 | } | 600 | } |
138 | 557 | # couldn't find a free slot yet so sleep for 1/10 th of a second or so. | 601 | # couldn't find a free slot yet so sleep for 1/10 th of a second or so. |
139 | @@ -581,10 +625,10 @@ | |||
140 | 581 | my $childretcode = $? >> 8; | 625 | my $childretcode = $? >> 8; |
141 | 582 | if ($status == $pids[$freepidindex]) { | 626 | if ($status == $pids[$freepidindex]) { |
142 | 583 | if ($childretcode != 0) { | 627 | if ($childretcode != 0) { |
144 | 584 | Die("Child failed on $workingfiles[$freepidindex] : $childretcode"); | 628 | die "Child failed on $workingfiles[$freepidindex] : $childretcode"; |
145 | 585 | } | 629 | } |
146 | 586 | } else { | 630 | } else { |
148 | 587 | Die("waitpid failed on $workingfiles[$freepidindex] : $status"); | 631 | die "waitpid failed on $workingfiles[$freepidindex] : $status"; |
149 | 588 | } | 632 | } |
150 | 589 | } | 633 | } |
151 | 590 | } | 634 | } |
152 | @@ -795,7 +839,7 @@ | |||
153 | 795 | my $dst_path = shift; | 839 | my $dst_path = shift; |
154 | 796 | 840 | ||
155 | 797 | print STDERR "$prefix Copying '$src_path' to '$dst_path'\n"; | 841 | print STDERR "$prefix Copying '$src_path' to '$dst_path'\n"; |
157 | 798 | copy($src_path, $dst_path) or Die "copy failed: $!"; | 842 | copy($src_path, $dst_path) or die "copy failed: $!"; |
158 | 799 | } | 843 | } |
159 | 800 | 844 | ||
160 | 801 | # | 845 | # |
161 | @@ -806,7 +850,7 @@ | |||
162 | 806 | my $dst_path = shift; | 850 | my $dst_path = shift; |
163 | 807 | 851 | ||
164 | 808 | print STDERR "$prefix Moving '$src_path' to '$dst_path'\n"; | 852 | print STDERR "$prefix Moving '$src_path' to '$dst_path'\n"; |
166 | 809 | move($src_path, $dst_path) or Die "move failed: $!"; | 853 | move($src_path, $dst_path) or die "move failed: $!"; |
167 | 810 | } | 854 | } |
168 | 811 | 855 | ||
169 | 812 | 856 | ||
170 | @@ -851,14 +895,14 @@ | |||
171 | 851 | # Create the directory in the destination if necessary | 895 | # Create the directory in the destination if necessary |
172 | 852 | if (! -e "$dst_path") { | 896 | if (! -e "$dst_path") { |
173 | 853 | print STDERR "$prefix Creating directory '$dst_path'\n"; | 897 | print STDERR "$prefix Creating directory '$dst_path'\n"; |
175 | 854 | mkdir "$dst_path" or Die "mkdir failed: $!"; | 898 | mkdir "$dst_path" or die "mkdir failed: $!"; |
176 | 855 | } elsif (! -d "$dst_path") { | 899 | } elsif (! -d "$dst_path") { |
178 | 856 | Die "$dst_path exists, but is not a directory"; | 900 | die "$dst_path exists, but is not a directory"; |
179 | 857 | } | 901 | } |
180 | 858 | } else { | 902 | } else { |
181 | 859 | # Don't overwrite files unless $copy_dir_overwrite is 1 | 903 | # Don't overwrite files unless $copy_dir_overwrite is 1 |
182 | 860 | if (!$copy_dir_overwrite && -e "$copy_dir_dst/$_") { | 904 | if (!$copy_dir_overwrite && -e "$copy_dir_dst/$_") { |
184 | 861 | Die "Failed to process file $File::Find::name: " . | 905 | die "Failed to process file $File::Find::name: " . |
185 | 862 | "not overwriting file $copy_dir_dst/$_"; | 906 | "not overwriting file $copy_dir_dst/$_"; |
186 | 863 | } | 907 | } |
187 | 864 | 908 | ||
188 | @@ -898,7 +942,7 @@ | |||
189 | 898 | } | 942 | } |
190 | 899 | if (! exists $processed_files{$rel_path}) { | 943 | if (! exists $processed_files{$rel_path}) { |
191 | 900 | unlink($File::Find::name) or | 944 | unlink($File::Find::name) or |
193 | 901 | Die("Cannot remove file $File::Find::name"); | 945 | die "Cannot remove file $File::Find::name"; |
194 | 902 | } | 946 | } |
195 | 903 | } | 947 | } |
196 | 904 | 948 | ||
197 | @@ -1043,20 +1087,6 @@ | |||
198 | 1043 | "Original undo directory"); | 1087 | "Original undo directory"); |
199 | 1044 | } | 1088 | } |
200 | 1045 | 1089 | ||
201 | 1046 | # check that the original options file and the backup options file have | ||
202 | 1047 | # the same value for "innodb_data_file_path" option | ||
203 | 1048 | #$backup_innodb_data_file_path = | ||
204 | 1049 | # get_option(\%backup_config, 'mysqld', 'innodb_data_file_path'); | ||
205 | 1050 | #if (!are_equal_innodb_data_file_paths($orig_innodb_data_file_path, | ||
206 | 1051 | # $backup_innodb_data_file_path) | ||
207 | 1052 | #) { | ||
208 | 1053 | # Die "The value of 'innodb_data_file_path' option in the original " | ||
209 | 1054 | # . "my.cnf file '$config_file' is different from the value " | ||
210 | 1055 | # . "in the backup my.cnf file '$backup_config_file'.\n(original: " | ||
211 | 1056 | # . "'$orig_innodb_data_file_path')\n" | ||
212 | 1057 | # . "(backup: '$backup_innodb_data_file_path')"; | ||
213 | 1058 | #} | ||
214 | 1059 | |||
215 | 1060 | # make a list of all ibdata files in the backup directory and all | 1090 | # make a list of all ibdata files in the backup directory and all |
216 | 1061 | # directories in the backup directory under which there are ibdata files | 1091 | # directories in the backup directory under which there are ibdata files |
217 | 1062 | foreach my $c (parse_innodb_data_file_path($orig_innodb_data_file_path)) { | 1092 | foreach my $c (parse_innodb_data_file_path($orig_innodb_data_file_path)) { |
218 | @@ -1064,7 +1094,7 @@ | |||
219 | 1064 | # check that the backup data file exists | 1094 | # check that the backup data file exists |
220 | 1065 | if (! -e "$backup_dir/$c->{filename}") { | 1095 | if (! -e "$backup_dir/$c->{filename}") { |
221 | 1066 | if (-e "$backup_dir/$c->{filename}.ibz") { | 1096 | if (-e "$backup_dir/$c->{filename}.ibz") { |
223 | 1067 | Die "Backup data file '$backup_dir/$c->{filename}' " | 1097 | die "Backup data file '$backup_dir/$c->{filename}' " |
224 | 1068 | . "does not exist, but " | 1098 | . "does not exist, but " |
225 | 1069 | . "its compressed copy '$c->{path}.ibz' exists. Check " | 1099 | . "its compressed copy '$c->{path}.ibz' exists. Check " |
226 | 1070 | . "that you have decompressed " | 1100 | . "that you have decompressed " |
227 | @@ -1072,7 +1102,7 @@ | |||
228 | 1072 | . "'$innobackup_script --copy-back ...' " | 1102 | . "'$innobackup_script --copy-back ...' " |
229 | 1073 | . "or '$innobackup_script --move-back ...' !"; | 1103 | . "or '$innobackup_script --move-back ...' !"; |
230 | 1074 | } elsif (-e "$backup_dir/$c->{filename}.qp") { | 1104 | } elsif (-e "$backup_dir/$c->{filename}.qp") { |
232 | 1075 | Die "Backup data file '$backup_dir/$c->{filename}' " | 1105 | die "Backup data file '$backup_dir/$c->{filename}' " |
233 | 1076 | . "does not exist, but " | 1106 | . "does not exist, but " |
234 | 1077 | . "its compressed copy '$c->{path}.qp' exists. Check " | 1107 | . "its compressed copy '$c->{path}.qp' exists. Check " |
235 | 1078 | . "that you have run " | 1108 | . "that you have run " |
236 | @@ -1081,7 +1111,7 @@ | |||
237 | 1081 | . "'$innobackup_script --copy-back ...' " | 1111 | . "'$innobackup_script --copy-back ...' " |
238 | 1082 | . "or '$innobackup_script --move-back ...' !"; | 1112 | . "or '$innobackup_script --move-back ...' !"; |
239 | 1083 | } elsif (-e "$backup_dir/$c->{filename}.xbcrypt") { | 1113 | } elsif (-e "$backup_dir/$c->{filename}.xbcrypt") { |
241 | 1084 | Die "Backup data file '$backup_dir/$c->{filename}' " | 1114 | die "Backup data file '$backup_dir/$c->{filename}' " |
242 | 1085 | . "does not exist, but " | 1115 | . "does not exist, but " |
243 | 1086 | . "its compressed copy '$c->{path}.xbcrypt' exists. Check " | 1116 | . "its compressed copy '$c->{path}.xbcrypt' exists. Check " |
244 | 1087 | . "that you have run " | 1117 | . "that you have run " |
245 | @@ -1090,7 +1120,7 @@ | |||
246 | 1090 | . "'$innobackup_script --copy-back ...' " | 1120 | . "'$innobackup_script --copy-back ...' " |
247 | 1091 | . "or '$innobackup_script --move-back ...' !"; | 1121 | . "or '$innobackup_script --move-back ...' !"; |
248 | 1092 | } else { | 1122 | } else { |
250 | 1093 | Die "Backup data file '$backup_dir/$c->{filename}' " | 1123 | die "Backup data file '$backup_dir/$c->{filename}' " |
251 | 1094 | . "does not exist."; | 1124 | . "does not exist."; |
252 | 1095 | } | 1125 | } |
253 | 1096 | } | 1126 | } |
254 | @@ -1123,7 +1153,7 @@ | |||
255 | 1123 | print STDERR "$prefix in '$backup_dir'\n"; | 1153 | print STDERR "$prefix in '$backup_dir'\n"; |
256 | 1124 | print STDERR "$prefix back to '$orig_undo_dir'\n"; | 1154 | print STDERR "$prefix back to '$orig_undo_dir'\n"; |
257 | 1125 | opendir(DIR, $backup_dir) | 1155 | opendir(DIR, $backup_dir) |
259 | 1126 | || Die "Can't open directory '$backup_dir': $!\n"; | 1156 | || die "Can't open directory '$backup_dir': $!"; |
260 | 1127 | while (defined($file = readdir(DIR))) { | 1157 | while (defined($file = readdir(DIR))) { |
261 | 1128 | if ($file =~ /^$ibundo_files$/ && -f "$backup_dir/$file") { | 1158 | if ($file =~ /^$ibundo_files$/ && -f "$backup_dir/$file") { |
262 | 1129 | $src_name = escape_path("$backup_dir/$file"); | 1159 | $src_name = escape_path("$backup_dir/$file"); |
263 | @@ -1135,7 +1165,7 @@ | |||
264 | 1135 | 1165 | ||
265 | 1136 | # copy InnoDB log files to original InnoDB log directory | 1166 | # copy InnoDB log files to original InnoDB log directory |
266 | 1137 | opendir(DIR, $backup_dir) | 1167 | opendir(DIR, $backup_dir) |
268 | 1138 | || Die "Can't open directory '$backup_dir': $!\n"; | 1168 | || die "Can't open directory '$backup_dir': $!"; |
269 | 1139 | print STDERR "\n$prefix Starting to $operation InnoDB log files\n"; | 1169 | print STDERR "\n$prefix Starting to $operation InnoDB log files\n"; |
270 | 1140 | print STDERR "$prefix in '$backup_dir'\n"; | 1170 | print STDERR "$prefix in '$backup_dir'\n"; |
271 | 1141 | print STDERR "$prefix back to original InnoDB log directory '$orig_iblog_dir'\n"; | 1171 | print STDERR "$prefix back to original InnoDB log directory '$orig_iblog_dir'\n"; |
272 | @@ -1216,7 +1246,7 @@ | |||
273 | 1216 | $rcode = system("$cmdline"); | 1246 | $rcode = system("$cmdline"); |
274 | 1217 | if ($rcode) { | 1247 | if ($rcode) { |
275 | 1218 | # failure | 1248 | # failure |
277 | 1219 | Die "\n$prefix ibbackup failed"; | 1249 | die "\n$prefix ibbackup failed"; |
278 | 1220 | } | 1250 | } |
279 | 1221 | 1251 | ||
280 | 1222 | # We should not create ib_logfile files if we prepare for following incremental applies | 1252 | # We should not create ib_logfile files if we prepare for following incremental applies |
281 | @@ -1228,7 +1258,7 @@ | |||
282 | 1228 | $rcode = system("$cmdline"); | 1258 | $rcode = system("$cmdline"); |
283 | 1229 | if ($rcode) { | 1259 | if ($rcode) { |
284 | 1230 | # failure | 1260 | # failure |
286 | 1231 | Die "\n$prefix xtrabackup (2nd execution) failed"; | 1261 | die "\n$prefix xtrabackup (2nd execution) failed"; |
287 | 1232 | } | 1262 | } |
288 | 1233 | } | 1263 | } |
289 | 1234 | 1264 | ||
290 | @@ -1275,7 +1305,8 @@ | |||
291 | 1275 | 1305 | ||
292 | 1276 | if ($ibbackup_pid == $pid) { | 1306 | if ($ibbackup_pid == $pid) { |
293 | 1277 | # The file doesn't exist, but the process has terminated | 1307 | # The file doesn't exist, but the process has terminated |
295 | 1278 | Die "ibbackup child process has died"; | 1308 | $ibbackup_pid = ''; |
296 | 1309 | die "The xtrabackup child process has died"; | ||
297 | 1279 | } | 1310 | } |
298 | 1280 | 1311 | ||
299 | 1281 | sleep 1; | 1312 | sleep 1; |
300 | @@ -1309,7 +1340,7 @@ | |||
301 | 1309 | # | 1340 | # |
302 | 1310 | sub resume_ibbackup { | 1341 | sub resume_ibbackup { |
303 | 1311 | my $suspend_file = shift; | 1342 | my $suspend_file = shift; |
305 | 1312 | unlink $suspend_file || Die "Failed to delete '$suspend_file': $!"; | 1343 | unlink $suspend_file || die "Failed to delete '$suspend_file': $!"; |
306 | 1313 | } | 1344 | } |
307 | 1314 | 1345 | ||
308 | 1315 | # | 1346 | # |
309 | @@ -1325,7 +1356,7 @@ | |||
310 | 1325 | 1356 | ||
311 | 1326 | wait_for_ibbackup_file_create($suspend_file); | 1357 | wait_for_ibbackup_file_create($suspend_file); |
312 | 1327 | 1358 | ||
314 | 1328 | unlink $suspend_file || Die "Failed to delete '$suspend_file': $!"; | 1359 | unlink $suspend_file || die "Failed to delete '$suspend_file': $!"; |
315 | 1329 | } | 1360 | } |
316 | 1330 | 1361 | ||
317 | 1331 | # | 1362 | # |
318 | @@ -1460,10 +1491,10 @@ | |||
319 | 1460 | $ibbackup_pid = $pid; | 1491 | $ibbackup_pid = $pid; |
320 | 1461 | } else { | 1492 | } else { |
321 | 1462 | # child process | 1493 | # child process |
323 | 1463 | exec($cmdline) || Die "Failed to exec ibbackup: $!"; | 1494 | exec($cmdline) || die "Failed to exec ibbackup: $!"; |
324 | 1464 | } | 1495 | } |
325 | 1465 | } else { | 1496 | } else { |
327 | 1466 | Die "failed to fork ibbackup child process: $!"; | 1497 | die "failed to fork ibbackup child process: $!"; |
328 | 1467 | } | 1498 | } |
329 | 1468 | } | 1499 | } |
330 | 1469 | 1500 | ||
331 | @@ -1513,7 +1544,7 @@ | |||
332 | 1513 | my $con = shift; | 1544 | my $con = shift; |
333 | 1514 | 1545 | ||
334 | 1515 | if (defined($con->{keep_alive_pid})) { | 1546 | if (defined($con->{keep_alive_pid})) { |
336 | 1516 | Die "Keep-alive process has already been started for this connection." | 1547 | die "Keep-alive process has already been started for this connection." |
337 | 1517 | } | 1548 | } |
338 | 1518 | 1549 | ||
339 | 1519 | my $keep_alive_pid = fork(); | 1550 | my $keep_alive_pid = fork(); |
340 | @@ -1557,7 +1588,7 @@ | |||
341 | 1557 | my $con = shift; | 1588 | my $con = shift; |
342 | 1558 | 1589 | ||
343 | 1559 | if (!defined($con->{keep_alive_pid})) { | 1590 | if (!defined($con->{keep_alive_pid})) { |
345 | 1560 | Die "Keep-alive process has never been started for this connection." | 1591 | die "Keep-alive process has never been started for this connection." |
346 | 1561 | } | 1592 | } |
347 | 1562 | 1593 | ||
348 | 1563 | kill 'INT', $con->{keep_alive_pid}; | 1594 | kill 'INT', $con->{keep_alive_pid}; |
349 | @@ -1565,7 +1596,7 @@ | |||
350 | 1565 | my $rc = $? >> 8; | 1596 | my $rc = $? >> 8; |
351 | 1566 | 1597 | ||
352 | 1567 | if ($rc != 0) { | 1598 | if ($rc != 0) { |
354 | 1568 | Die "Keep-alive process died with exit code " . $rc; | 1599 | die "Keep-alive process died with exit code " . $rc; |
355 | 1569 | } | 1600 | } |
356 | 1570 | undef $con->{keep_alive_pid}; | 1601 | undef $con->{keep_alive_pid}; |
357 | 1571 | } | 1602 | } |
358 | @@ -1611,11 +1642,11 @@ | |||
359 | 1611 | 1642 | ||
360 | 1612 | if ($args{abort_on_error}) { | 1643 | if ($args{abort_on_error}) { |
361 | 1613 | if (!$dbd_mysql_installed) { | 1644 | if (!$dbd_mysql_installed) { |
363 | 1614 | die "ERROR: Failed to connect to MySQL server as " . | 1645 | die "Failed to connect to MySQL server as " . |
364 | 1615 | "DBD::mysql module is not installed"; | 1646 | "DBD::mysql module is not installed"; |
365 | 1616 | } else { | 1647 | } else { |
366 | 1617 | if (!$con{dbh}) { | 1648 | if (!$con{dbh}) { |
368 | 1618 | die "ERROR: Failed to connect to MySQL server: " . | 1649 | die "Failed to connect to MySQL server: " . |
369 | 1619 | $con{connect_error}; | 1650 | $con{connect_error}; |
370 | 1620 | } | 1651 | } |
371 | 1621 | } | 1652 | } |
372 | @@ -1670,7 +1701,7 @@ | |||
373 | 1670 | } | 1701 | } |
374 | 1671 | }; | 1702 | }; |
375 | 1672 | if ($EVAL_ERROR) { | 1703 | if ($EVAL_ERROR) { |
377 | 1673 | Die "\nError executing '$query': $EVAL_ERROR\n"; | 1704 | die "\nError executing '$query': $EVAL_ERROR"; |
378 | 1674 | } | 1705 | } |
379 | 1675 | } | 1706 | } |
380 | 1676 | 1707 | ||
381 | @@ -1925,7 +1956,7 @@ | |||
382 | 1925 | sleep(1); | 1956 | sleep(1); |
383 | 1926 | } | 1957 | } |
384 | 1927 | 1958 | ||
386 | 1928 | Die "Unable to obtain lock. Please try again."; | 1959 | die "Unable to obtain lock. Please try again."; |
387 | 1929 | } | 1960 | } |
388 | 1930 | 1961 | ||
389 | 1931 | 1962 | ||
390 | @@ -1964,6 +1995,7 @@ | |||
391 | 1964 | if (defined($query_killer_pid)) { | 1995 | if (defined($query_killer_pid)) { |
392 | 1965 | kill 'HUP' => $query_killer_pid; | 1996 | kill 'HUP' => $query_killer_pid; |
393 | 1966 | waitpid($query_killer_pid, 0); | 1997 | waitpid($query_killer_pid, 0); |
394 | 1998 | undef $query_killer_pid; | ||
395 | 1967 | print STDERR "Query killing process is finished\n"; | 1999 | print STDERR "Query killing process is finished\n"; |
396 | 1968 | } | 2000 | } |
397 | 1969 | } | 2001 | } |
398 | @@ -2029,18 +2061,6 @@ | |||
399 | 2029 | } | 2061 | } |
400 | 2030 | 2062 | ||
401 | 2031 | # | 2063 | # |
402 | 2032 | # kill_child_processes subroutine kills all child processes of this process. | ||
403 | 2033 | # | ||
404 | 2034 | sub kill_child_processes { | ||
405 | 2035 | if ($ibbackup_pid) { | ||
406 | 2036 | kill($kill_signal, $ibbackup_pid); | ||
407 | 2037 | $ibbackup_pid = ''; | ||
408 | 2038 | } | ||
409 | 2039 | stop_query_killer(); | ||
410 | 2040 | } | ||
411 | 2041 | |||
412 | 2042 | |||
413 | 2043 | # | ||
414 | 2044 | # require_external subroutine checks that an external program is runnable | 2064 | # require_external subroutine checks that an external program is runnable |
415 | 2045 | # via the shell. This is tested by calling the program with the | 2065 | # via the shell. This is tested by calling the program with the |
416 | 2046 | # given arguments. It is checked that the program returns 0 and does | 2066 | # given arguments. It is checked that the program returns 0 and does |
417 | @@ -2075,11 +2095,11 @@ | |||
418 | 2075 | if ($stderr ne '') { | 2095 | if ($stderr ne '') { |
419 | 2076 | # failure | 2096 | # failure |
420 | 2077 | unlink $tmp_stdout; | 2097 | unlink $tmp_stdout; |
422 | 2078 | Die "Couldn't run $program: $stderr"; | 2098 | die "Couldn't run $program: $stderr"; |
423 | 2079 | } elsif ($rcode) { | 2099 | } elsif ($rcode) { |
424 | 2080 | # failure | 2100 | # failure |
425 | 2081 | unlink $tmp_stdout; | 2101 | unlink $tmp_stdout; |
427 | 2082 | Die "Couldn't run $program: $error"; | 2102 | die "Couldn't run $program: $error"; |
428 | 2083 | } | 2103 | } |
429 | 2084 | 2104 | ||
430 | 2085 | # success | 2105 | # success |
431 | @@ -2186,7 +2206,7 @@ | |||
432 | 2186 | && $ibbackup_version le "2.0") { | 2206 | && $ibbackup_version le "2.0") { |
433 | 2187 | # --include option was given, but ibbackup is too | 2207 | # --include option was given, but ibbackup is too |
434 | 2188 | # old to support it | 2208 | # old to support it |
436 | 2189 | Die "--include option was given, but ibbackup is too old" | 2209 | die "--include option was given, but ibbackup is too old" |
437 | 2190 | . " to support it. You must upgrade to InnoDB Hot Backup" | 2210 | . " to support it. You must upgrade to InnoDB Hot Backup" |
438 | 2191 | . " v2.0 in order to use --include option.\n"; | 2211 | . " v2.0 in order to use --include option.\n"; |
439 | 2192 | } | 2212 | } |
440 | @@ -2229,7 +2249,7 @@ | |||
441 | 2229 | "WARNING : A left over instance of " . | 2249 | "WARNING : A left over instance of " . |
442 | 2230 | "suspend file '$suspend_file' was found.\n"; | 2250 | "suspend file '$suspend_file' was found.\n"; |
443 | 2231 | unlink "$suspend_file" | 2251 | unlink "$suspend_file" |
445 | 2232 | || Die "Failed to delete '$suspend_file': $!"; | 2252 | || die "Failed to delete '$suspend_file': $!"; |
446 | 2233 | } | 2253 | } |
447 | 2234 | } | 2254 | } |
448 | 2235 | 2255 | ||
449 | @@ -2238,7 +2258,7 @@ | |||
450 | 2238 | "file '$option_tmpdir/$xtrabackup_pid_file' " . | 2258 | "file '$option_tmpdir/$xtrabackup_pid_file' " . |
451 | 2239 | "was found.\n"; | 2259 | "was found.\n"; |
452 | 2240 | unlink $option_tmpdir . "/" . $xtrabackup_pid_file || | 2260 | unlink $option_tmpdir . "/" . $xtrabackup_pid_file || |
454 | 2241 | Die "Failed to delete " . | 2261 | die "Failed to delete " . |
455 | 2242 | "'$option_tmpdir/$xtrabackup_pid_file': $!"; | 2262 | "'$option_tmpdir/$xtrabackup_pid_file': $!"; |
456 | 2243 | } | 2263 | } |
457 | 2244 | 2264 | ||
458 | @@ -2313,12 +2333,6 @@ | |||
459 | 2313 | } | 2333 | } |
460 | 2314 | } | 2334 | } |
461 | 2315 | 2335 | ||
462 | 2316 | if (@ARGV == 0) { | ||
463 | 2317 | # no command line arguments | ||
464 | 2318 | print STDERR "$prefix You must specify the backup directory.\n"; | ||
465 | 2319 | exit(1); | ||
466 | 2320 | } | ||
467 | 2321 | |||
468 | 2322 | # read command line options | 2336 | # read command line options |
469 | 2323 | $rcode = GetOptions('compress' => \$option_compress, | 2337 | $rcode = GetOptions('compress' => \$option_compress, |
470 | 2324 | 'decompress' => \$option_decompress, | 2338 | 'decompress' => \$option_decompress, |
471 | @@ -2383,11 +2397,16 @@ | |||
472 | 2383 | 'lock-wait-query-type=s' => | 2397 | 'lock-wait-query-type=s' => |
473 | 2384 | \$option_lock_wait_query_type | 2398 | \$option_lock_wait_query_type |
474 | 2385 | ); | 2399 | ); |
476 | 2386 | 2400 | ||
477 | 2401 | if (@ARGV == 0) { | ||
478 | 2402 | die "You must specify the backup directory.\n"; | ||
479 | 2403 | } elsif (@ARGV > 1) { | ||
480 | 2404 | die "Too many command line arguments\n"; | ||
481 | 2405 | } | ||
482 | 2406 | |||
483 | 2387 | if (!$rcode) { | 2407 | if (!$rcode) { |
484 | 2388 | # failed to read options | 2408 | # failed to read options |
487 | 2389 | print STDERR "$prefix Bad command line arguments\n"; | 2409 | die "Bad command line arguments\n"; |
486 | 2390 | exit(1); | ||
488 | 2391 | } | 2410 | } |
489 | 2392 | if ($option_help) { | 2411 | if ($option_help) { |
490 | 2393 | # print help text and exit | 2412 | # print help text and exit |
491 | @@ -2401,9 +2420,8 @@ | |||
492 | 2401 | } | 2420 | } |
493 | 2402 | 2421 | ||
494 | 2403 | if ($option_defaults_file && $option_defaults_extra_file) { | 2422 | if ($option_defaults_file && $option_defaults_extra_file) { |
496 | 2404 | print STDERR "$prefix --defaults-file and --defaults-extra-file " . | 2423 | die "--defaults-file and --defaults-extra-file " . |
497 | 2405 | "options are mutually exclusive"; | 2424 | "options are mutually exclusive"; |
498 | 2406 | exit(1); | ||
499 | 2407 | } | 2425 | } |
500 | 2408 | 2426 | ||
501 | 2409 | if ($option_copy_back && $option_move_back) { | 2427 | if ($option_copy_back && $option_move_back) { |
502 | @@ -2423,19 +2441,18 @@ | |||
503 | 2423 | 2441 | ||
504 | 2424 | # validate lock-wait-query-type and kill-long-query-type values | 2442 | # validate lock-wait-query-type and kill-long-query-type values |
505 | 2425 | if (!(grep {$_ eq $option_lock_wait_query_type} qw/all update/)) { | 2443 | if (!(grep {$_ eq $option_lock_wait_query_type} qw/all update/)) { |
507 | 2426 | Die "Wrong value of lock-wait-query-type. ". | 2444 | die "Wrong value of lock-wait-query-type. ". |
508 | 2427 | "Possible values are all|update, but $option_lock_wait_query_type ". | 2445 | "Possible values are all|update, but $option_lock_wait_query_type ". |
509 | 2428 | "is specified."; | 2446 | "is specified."; |
510 | 2429 | } | 2447 | } |
511 | 2430 | if (!(grep {$_ eq $option_kill_long_query_type} qw/all select/)) { | 2448 | if (!(grep {$_ eq $option_kill_long_query_type} qw/all select/)) { |
513 | 2431 | Die "Wrong value of kill-long-query-type. ". | 2449 | die "Wrong value of kill-long-query-type. ". |
514 | 2432 | "Possible values are all|select, but $option_kill_long_query_type ". | 2450 | "Possible values are all|select, but $option_kill_long_query_type ". |
515 | 2433 | "is specified."; | 2451 | "is specified."; |
516 | 2434 | } | 2452 | } |
517 | 2435 | 2453 | ||
518 | 2436 | if ($option_parallel && $option_parallel < 1) { | 2454 | if ($option_parallel && $option_parallel < 1) { |
521 | 2437 | Die "$prefix --parallel must be a positive numerical value" . | 2455 | die "--parallel must be a positive value.\n"; |
520 | 2438 | "greater than 0"; | ||
522 | 2439 | } | 2456 | } |
523 | 2440 | 2457 | ||
524 | 2441 | if ($option_stream eq 'tar') { | 2458 | if ($option_stream eq 'tar') { |
525 | @@ -2457,14 +2474,6 @@ | |||
526 | 2457 | } | 2474 | } |
527 | 2458 | } | 2475 | } |
528 | 2459 | 2476 | ||
529 | 2460 | if (@ARGV < 1) { | ||
530 | 2461 | print STDERR "$prefix Missing command line argument\n"; | ||
531 | 2462 | exit(1); | ||
532 | 2463 | } elsif (@ARGV > 1) { | ||
533 | 2464 | print STDERR "$prefix Too many command line arguments\n"; | ||
534 | 2465 | exit(1); | ||
535 | 2466 | } | ||
536 | 2467 | |||
537 | 2468 | if (!$option_apply_log && !$option_copy_back && !$option_move_back | 2477 | if (!$option_apply_log && !$option_copy_back && !$option_move_back |
538 | 2469 | && !$option_decrypt && !$option_decompress) { | 2478 | && !$option_decrypt && !$option_decompress) { |
539 | 2470 | # we are making a backup, get backup root directory | 2479 | # we are making a backup, get backup root directory |
540 | @@ -2487,20 +2496,17 @@ | |||
541 | 2487 | 2496 | ||
542 | 2488 | if ($option_slave_info) { | 2497 | if ($option_slave_info) { |
543 | 2489 | if ($option_no_lock and !$option_safe_slave_backup) { | 2498 | if ($option_no_lock and !$option_safe_slave_backup) { |
546 | 2490 | 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"; | 2499 | die "--slave-info is used with --no-lock but without --safe-slave-backup. The binlog position cannot be consistent with the backup data.\n"; |
545 | 2491 | exit(1); | ||
547 | 2492 | } | 2500 | } |
548 | 2493 | } | 2501 | } |
549 | 2494 | 2502 | ||
550 | 2495 | if ($option_rsync && $option_stream) { | 2503 | if ($option_rsync && $option_stream) { |
553 | 2496 | print STDERR "--rsync doesn't work with --stream\n"; | 2504 | die "--rsync doesn't work with --stream\n"; |
552 | 2497 | exit(1); | ||
554 | 2498 | } | 2505 | } |
555 | 2499 | 2506 | ||
556 | 2500 | if ($option_decompress) { | 2507 | if ($option_decompress) { |
557 | 2501 | if (system("which qpress &>/dev/null") >> 8 != 0) { | 2508 | if (system("which qpress &>/dev/null") >> 8 != 0) { |
560 | 2502 | print STDERR "--decompress requires qpress\n"; | 2509 | die "--decompress requires qpress\n"; |
559 | 2503 | exit(1); | ||
561 | 2504 | } | 2510 | } |
562 | 2505 | } | 2511 | } |
563 | 2506 | 2512 | ||
564 | @@ -2528,7 +2534,7 @@ | |||
565 | 2528 | 2534 | ||
566 | 2529 | $dir .= '/' . strftime("%Y-%m-%d_%H-%M-%S", localtime()) | 2535 | $dir .= '/' . strftime("%Y-%m-%d_%H-%M-%S", localtime()) |
567 | 2530 | unless $option_no_timestamp; | 2536 | unless $option_no_timestamp; |
569 | 2531 | mkdir($dir, 0777) || Die "Failed to create backup directory $dir: $!"; | 2537 | mkdir($dir, 0777) || die "Failed to create backup directory $dir: $!"; |
570 | 2532 | 2538 | ||
571 | 2533 | # create subdirectories for ibdata files if needed | 2539 | # create subdirectories for ibdata files if needed |
572 | 2534 | # foreach my $a (split(/;/, $innodb_data_file_path)) { | 2540 | # foreach my $a (split(/;/, $innodb_data_file_path)) { |
573 | @@ -2566,7 +2572,7 @@ | |||
574 | 2566 | $path = $path . "/" . $a; | 2572 | $path = $path . "/" . $a; |
575 | 2567 | if (! -d $path) { | 2573 | if (! -d $path) { |
576 | 2568 | # this directory does not exist, create it ! | 2574 | # this directory does not exist, create it ! |
578 | 2569 | mkdir($path, 0777) || Die "Failed to create backup directory: $!"; | 2575 | mkdir($path, 0777) || die "Failed to create backup directory: $!"; |
579 | 2570 | } | 2576 | } |
580 | 2571 | } | 2577 | } |
581 | 2572 | } | 2578 | } |
582 | @@ -2626,11 +2632,11 @@ | |||
583 | 2626 | $rsync_file_list = $rsync_tmpfile_pass2; | 2632 | $rsync_file_list = $rsync_tmpfile_pass2; |
584 | 2627 | } | 2633 | } |
585 | 2628 | open(RSYNC, ">$rsync_file_list") | 2634 | open(RSYNC, ">$rsync_file_list") |
587 | 2629 | || Die "Can't open $rsync_file_list for writing: $!\n"; | 2635 | || die "Can't open $rsync_file_list for writing: $!"; |
588 | 2630 | } | 2636 | } |
589 | 2631 | 2637 | ||
590 | 2632 | opendir(DIR, $source_dir) | 2638 | opendir(DIR, $source_dir) |
592 | 2633 | || Die "Can't open directory '$source_dir': $!\n"; | 2639 | || die "Can't open directory '$source_dir': $!"; |
593 | 2634 | $now = current_time(); | 2640 | $now = current_time(); |
594 | 2635 | if ($prep_mode) { | 2641 | if ($prep_mode) { |
595 | 2636 | $operation = "a prep copy of"; | 2642 | $operation = "a prep copy of"; |
596 | @@ -2653,7 +2659,7 @@ | |||
597 | 2653 | if (! -e "$backup_dir/$database") { | 2659 | if (! -e "$backup_dir/$database") { |
598 | 2654 | # create database directory for the backup | 2660 | # create database directory for the backup |
599 | 2655 | mkdir("$backup_dir/$database", 0777) | 2661 | mkdir("$backup_dir/$database", 0777) |
601 | 2656 | || Die "Couldn't create directory '$backup_dir/$database': $!"; | 2662 | || die "Couldn't create directory '$backup_dir/$database': $!"; |
602 | 2657 | } | 2663 | } |
603 | 2658 | } | 2664 | } |
604 | 2659 | 2665 | ||
605 | @@ -2720,7 +2726,7 @@ | |||
606 | 2720 | # ignore errors in the prep mode, since we are running without lock, | 2726 | # ignore errors in the prep mode, since we are running without lock, |
607 | 2721 | # so some files may have disappeared. | 2727 | # so some files may have disappeared. |
608 | 2722 | if (system("$rsync_cmd") && !$prep_mode) { | 2728 | if (system("$rsync_cmd") && !$prep_mode) { |
610 | 2723 | Die "rsync failed: $!\n"; | 2729 | die "rsync failed: $!"; |
611 | 2724 | } | 2730 | } |
612 | 2725 | 2731 | ||
613 | 2726 | $now = current_time(); | 2732 | $now = current_time(); |
614 | @@ -2731,7 +2737,7 @@ | |||
615 | 2731 | # with --files-from. | 2737 | # with --files-from. |
616 | 2732 | if (!$prep_mode && !$option_no_lock) { | 2738 | if (!$prep_mode && !$option_no_lock) { |
617 | 2733 | open(RSYNC, "<$rsync_tmpfile_pass1") | 2739 | open(RSYNC, "<$rsync_tmpfile_pass1") |
619 | 2734 | || Die "Can't open $rsync_tmpfile_pass1 for reading: $!\n"; | 2740 | || die "Can't open $rsync_tmpfile_pass1 for reading: $!"; |
620 | 2735 | 2741 | ||
621 | 2736 | while (<RSYNC>) { | 2742 | while (<RSYNC>) { |
622 | 2737 | chomp; | 2743 | chomp; |
623 | @@ -2743,9 +2749,9 @@ | |||
624 | 2743 | 2749 | ||
625 | 2744 | close(RSYNC); | 2750 | close(RSYNC); |
626 | 2745 | unlink "$rsync_tmpfile_pass1" || \ | 2751 | unlink "$rsync_tmpfile_pass1" || \ |
628 | 2746 | Die "Failed to delete $rsync_tmpfile_pass1: $!"; | 2752 | die "Failed to delete $rsync_tmpfile_pass1: $!"; |
629 | 2747 | unlink "$rsync_tmpfile_pass2" || \ | 2753 | unlink "$rsync_tmpfile_pass2" || \ |
631 | 2748 | Die "Failed to delete $rsync_tmpfile_pass2: $!"; | 2754 | die "Failed to delete $rsync_tmpfile_pass2: $!"; |
632 | 2749 | } | 2755 | } |
633 | 2750 | } | 2756 | } |
634 | 2751 | 2757 | ||
635 | @@ -2771,9 +2777,9 @@ | |||
636 | 2771 | my $filename = shift; | 2777 | my $filename = shift; |
637 | 2772 | my $lines_ref = shift; | 2778 | my $lines_ref = shift; |
638 | 2773 | 2779 | ||
640 | 2774 | open(FILE, $filename) || Die "can't open file '$filename': $!"; | 2780 | open(FILE, $filename) || die "can't open file '$filename': $!"; |
641 | 2775 | @{$lines_ref} = <FILE>; | 2781 | @{$lines_ref} = <FILE>; |
643 | 2776 | close(FILE) || Die "can't close file '$filename': $!"; | 2782 | close(FILE) || die "can't close file '$filename': $!"; |
644 | 2777 | 2783 | ||
645 | 2778 | foreach my $a (@{$lines_ref}) { | 2784 | foreach my $a (@{$lines_ref}) { |
646 | 2779 | chomp($a); | 2785 | chomp($a); |
647 | @@ -2943,8 +2949,7 @@ | |||
648 | 2943 | 2949 | ||
649 | 2944 | if (!exists ${$config_ref}{$group}) { | 2950 | if (!exists ${$config_ref}{$group}) { |
650 | 2945 | # no group | 2951 | # no group |
653 | 2946 | print STDERR "$prefix fatal error: no '$group' group in MySQL options\n"; | 2952 | die "no '$group' group in MySQL options"; |
652 | 2947 | exit(1); | ||
654 | 2948 | } | 2953 | } |
655 | 2949 | 2954 | ||
656 | 2950 | $group_hash_ref = ${$config_ref}{$group}; | 2955 | $group_hash_ref = ${$config_ref}{$group}; |
657 | @@ -2970,15 +2975,13 @@ | |||
658 | 2970 | 2975 | ||
659 | 2971 | if (!exists $config{$group}) { | 2976 | if (!exists $config{$group}) { |
660 | 2972 | # no group | 2977 | # no group |
663 | 2973 | print STDERR "$prefix fatal error: no '$group' group in MySQL options\n"; | 2978 | die "no '$group' group in MySQL options"; |
662 | 2974 | exit(1); | ||
664 | 2975 | } | 2979 | } |
665 | 2976 | 2980 | ||
666 | 2977 | $group_hash_ref = ${$config_ref}{$group}; | 2981 | $group_hash_ref = ${$config_ref}{$group}; |
667 | 2978 | if (!exists ${$group_hash_ref}{$option_name}) { | 2982 | if (!exists ${$group_hash_ref}{$option_name}) { |
668 | 2979 | # no option | 2983 | # no option |
671 | 2980 | print STDERR "$prefix fatal error: no '$option_name' option in group '$group' in MySQL options\n"; | 2984 | die "no '$option_name' option in group '$group' in MySQL options"; |
670 | 2981 | exit(1); | ||
672 | 2982 | } | 2985 | } |
673 | 2983 | 2986 | ||
674 | 2984 | return ${$group_hash_ref}{$option_name}; | 2987 | return ${$group_hash_ref}{$option_name}; |
675 | @@ -3089,7 +3092,7 @@ | |||
676 | 3089 | # the option value is pathname of the file containing | 3092 | # the option value is pathname of the file containing |
677 | 3090 | # list of databases | 3093 | # list of databases |
678 | 3091 | if (! -f $option_databases) { | 3094 | if (! -f $option_databases) { |
680 | 3092 | Die "can't find file '$option_databases'"; | 3095 | die "can't find file '$option_databases'"; |
681 | 3093 | } | 3096 | } |
682 | 3094 | 3097 | ||
683 | 3095 | # read from file the value of --databases option | 3098 | # read from file the value of --databases option |
684 | @@ -3199,11 +3202,11 @@ | |||
685 | 3199 | 3202 | ||
686 | 3200 | 3203 | ||
687 | 3201 | if($var_version =~ m/5\.0\.\d/) { | 3204 | if($var_version =~ m/5\.0\.\d/) { |
689 | 3202 | 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."; | 3205 | 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 | 3203 | } | 3206 | } |
691 | 3204 | 3207 | ||
692 | 3205 | if($var_version =~ m/5\.1\.\d/ && !defined($var_innodb_version)) { | 3208 | if($var_version =~ m/5\.1\.\d/ && !defined($var_innodb_version)) { |
694 | 3206 | 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."; | 3209 | 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 | 3207 | } | 3210 | } |
696 | 3208 | 3211 | ||
697 | 3209 | if($var_version =~ m/5\.1\.\d/) { | 3212 | if($var_version =~ m/5\.1\.\d/) { |
698 | @@ -3227,7 +3230,7 @@ | |||
699 | 3227 | } | 3230 | } |
700 | 3228 | 3231 | ||
701 | 3229 | if (!$ibbackup_binary) { | 3232 | if (!$ibbackup_binary) { |
703 | 3230 | Die "Unsupported server version: '$var_version' " . | 3233 | die "Unsupported server version: '$var_version' " . |
704 | 3231 | "(InnoDB version: '$var_innodb_version'). " . | 3234 | "(InnoDB version: '$var_innodb_version'). " . |
705 | 3232 | "Please report a bug at ". | 3235 | "Please report a bug at ". |
706 | 3233 | "https://bugs.launchpad.net/percona-xtrabackup\n"; | 3236 | "https://bugs.launchpad.net/percona-xtrabackup\n"; |
707 | @@ -3295,7 +3298,7 @@ | |||
708 | 3295 | mysql_query($con, 'START SLAVE SQL_THREAD'); | 3298 | mysql_query($con, 'START SLAVE SQL_THREAD'); |
709 | 3296 | } | 3299 | } |
710 | 3297 | 3300 | ||
712 | 3298 | Die "Slave_open_temp_tables did not become zero after waiting $option_safe_slave_backup_timeout seconds"; | 3301 | die "Slave_open_temp_tables did not become zero after $option_safe_slave_backup_timeout seconds"; |
713 | 3299 | } | 3302 | } |
714 | 3300 | 3303 | ||
715 | 3301 | sub get_slave_open_temp_tables { | 3304 | sub get_slave_open_temp_tables { |
716 | @@ -3304,10 +3307,10 @@ | |||
717 | 3304 | get_mysql_status($con); | 3307 | get_mysql_status($con); |
718 | 3305 | 3308 | ||
719 | 3306 | if (!defined($con->{status}->{Slave_open_temp_tables})) { | 3309 | if (!defined($con->{status}->{Slave_open_temp_tables})) { |
721 | 3307 | Die "Failed to get Slave_open_temp_tables from SHOW STATUS" | 3310 | die "Failed to get Slave_open_temp_tables from SHOW STATUS" |
722 | 3308 | } | 3311 | } |
723 | 3309 | if (!defined($con->{status}->{Slave_open_temp_tables}->{Value})) { | 3312 | if (!defined($con->{status}->{Slave_open_temp_tables}->{Value})) { |
725 | 3310 | Die "SHOW STATUS LIKE 'slave_open_temp_tables' did not return anything" | 3313 | die "SHOW STATUS LIKE 'slave_open_temp_tables' did not return anything" |
726 | 3311 | } | 3314 | } |
727 | 3312 | 3315 | ||
728 | 3313 | return $con->{status}->{Slave_open_temp_tables}->{Value}; | 3316 | return $con->{status}->{Slave_open_temp_tables}->{Value}; |
729 | @@ -3352,7 +3355,7 @@ | |||
730 | 3352 | } | 3355 | } |
731 | 3353 | # Only treat as fatal cases where the file exists | 3356 | # Only treat as fatal cases where the file exists |
732 | 3354 | if ( -e "$src_path/$src_file" ) { | 3357 | if ( -e "$src_path/$src_file" ) { |
734 | 3355 | Die "Failed to stream '$src_path/$src_file': $ret"; | 3358 | die "Failed to stream '$src_path/$src_file': $ret"; |
735 | 3356 | } else { | 3359 | } else { |
736 | 3357 | print STDERR "$prefix Ignoring nonexistent file '$src_path/$src_file'.\n"; | 3360 | print STDERR "$prefix Ignoring nonexistent file '$src_path/$src_file'.\n"; |
737 | 3358 | } | 3361 | } |
738 | @@ -3377,12 +3380,12 @@ | |||
739 | 3377 | $dst_file_esc = $dst_file_esc . ".xbcrypt"; | 3380 | $dst_file_esc = $dst_file_esc . ".xbcrypt"; |
740 | 3378 | $ret = system("$encrypt_cmd -i \"$src_file_esc\" -o \"$dst_file_esc\""); | 3381 | $ret = system("$encrypt_cmd -i \"$src_file_esc\" -o \"$dst_file_esc\""); |
741 | 3379 | if ($ret != 0) { | 3382 | if ($ret != 0) { |
743 | 3380 | Die "Failed to copy and encrypt file '$src_file': $ret"; | 3383 | die "Failed to copy and encrypt file '$src_file': $ret"; |
744 | 3381 | } | 3384 | } |
745 | 3382 | } elsif ( -e "$src_file_esc" ) { | 3385 | } elsif ( -e "$src_file_esc" ) { |
746 | 3383 | $ret = system("$CP_CMD \"$src_file_esc\" \"$dst_file_esc\""); | 3386 | $ret = system("$CP_CMD \"$src_file_esc\" \"$dst_file_esc\""); |
747 | 3384 | if ($ret != 0) { | 3387 | if ($ret != 0) { |
749 | 3385 | Die "Failed to copy file '$src_file': $ret"; | 3388 | die "Failed to copy file '$src_file': $ret"; |
750 | 3386 | } | 3389 | } |
751 | 3387 | } | 3390 | } |
752 | 3388 | } | 3391 | } |
753 | 3389 | 3392 | ||
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 | 59 | 59 | ||
759 | 60 | #include <fcntl.h> | 60 | #include <fcntl.h> |
760 | 61 | 61 | ||
761 | 62 | #ifdef __linux__ | ||
762 | 63 | # include <sys/prctl.h> | ||
763 | 64 | #endif | ||
764 | 65 | |||
765 | 62 | #define G_PTR uchar* | 66 | #define G_PTR uchar* |
766 | 63 | 67 | ||
767 | 64 | #include "common.h" | 68 | #include "common.h" |
768 | @@ -5595,6 +5599,15 @@ | |||
769 | 5595 | { | 5599 | { |
770 | 5596 | int ho_error; | 5600 | int ho_error; |
771 | 5597 | 5601 | ||
772 | 5602 | #ifdef __linux__ | ||
773 | 5603 | /* Ensure xtrabackup process is killed when the parent one | ||
774 | 5604 | (innobackupex) is terminated with an unhandled signal */ | ||
775 | 5605 | |||
776 | 5606 | if (prctl(PR_SET_PDEATHSIG, SIGINT)) { | ||
777 | 5607 | msg("prctl() failed with errno = %d\n", errno); | ||
778 | 5608 | exit(EXIT_FAILURE); | ||
779 | 5609 | } | ||
780 | 5610 | #endif | ||
781 | 5598 | MY_INIT(argv[0]); | 5611 | MY_INIT(argv[0]); |
782 | 5599 | xb_regex_init(); | 5612 | xb_regex_init(); |
783 | 5600 | 5613 |
http:// jenkins. percona. com/job/ percona- xtrabackup- 2.1-param/ 429/