Merge lp:~gl-az/percona-xtrabackup/bug1211263 into lp:percona-xtrabackup/2.1

Proposed by George Ormond Lorch III
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 660
Proposed branch: lp:~gl-az/percona-xtrabackup/bug1211263
Merge into: lp:percona-xtrabackup/2.1
Prerequisite: lp:~akopytov/percona-xtrabackup/bug1210266-2.1
Diff against target: 61 lines (+30/-10)
2 files modified
innobackupex (+17/-9)
test/t/ib_rsync.sh (+13/-1)
To merge this branch: bzr merge lp:~gl-az/percona-xtrabackup/bug1211263
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+180219@code.launchpad.net

This proposal supersedes a proposal from 2013-08-14.

Description of the change

Fix for bug 1211263 : innobackupex unnecessarily calls 'cp' for metadata files

Fix is fairly simple an inelegant, check for streaming in innobckupex write_to_backup_file.
If streaming, continue to use the original method of writing a temp file, then calling backup_file.
Otherwise write directly to the result file.

Slightly modified the ib_rsync.sh test case to use a 'fake' cp command that will always fail and thus cause the test to fail if cp is ever called from innobackupex during --rsync.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.1-param/430/

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

Here's an idea for a test case:

cat >$topdir/cp <<EOF
#!/bin/sh
false
EOF

chmod +x $topdir/cp

PATH=$topdir:$PATH innobackupex --rsync ...

I.e. supply a fake 'cp' to innobackupex which always fails to make sure it is never used for --rsync.

review: Needs Fixing
Revision history for this message
George Ormond Lorch III (gl-az) wrote : Posted in a previous version of this proposal

Aye! Very cool idea!

On 8/14/2013 12:55 AM, Alexey Kopytov wrote:
> Review: Needs Fixing
>
> Here's an idea for a test case:
>
> cat >$topdir/cp <<EOF
> #!/bin/sh
> false
> EOF
>
> chmod +x $topdir/cp
>
> PATH=$topdir:$PATH innobackupex --rsync ...
>
> I.e. supply a fake 'cp' to innobackupex which always fails to make sure it is never used for --rsync.

--
George O. Lorch III
Software Engineer, Percona
+1-888-401-3401 x542 US/Arizona (GMT -7)
skype: george.ormond.lorch.iii

Revision history for this message
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 'innobackupex'
2--- innobackupex 2013-07-31 11:28:11 +0000
3+++ innobackupex 2013-08-14 19:21:01 +0000
4@@ -3414,16 +3414,24 @@
5 sub write_to_backup_file {
6 my $file_name = shift;
7 my $write_data = shift;
8- my $filepos = rindex($file_name, '/');
9- my $dst_file = substr($file_name, $filepos + 1);
10- my $dst_path = substr($file_name, 0, $filepos + 1);
11
12- open XTRABACKUP_FH, "> $option_tmpdir/$dst_file"
13- || die "Cannot open file $option_tmpdir/$dst_file: $!\n";
14- print XTRABACKUP_FH $write_data;
15- close XTRABACKUP_FH;
16- backup_file($option_tmpdir, $dst_file, $file_name);
17- unlink "$option_tmpdir/$dst_file";
18+ if ($option_stream) {
19+ my $filepos = rindex($file_name, '/');
20+ my $dst_file = substr($file_name, $filepos + 1);
21+ my $dst_path = substr($file_name, 0, $filepos + 1);
22+
23+ open XTRABACKUP_FH, "> $option_tmpdir/$dst_file"
24+ || die "Cannot open file $option_tmpdir/$dst_file: $!\n";
25+ print XTRABACKUP_FH $write_data;
26+ close XTRABACKUP_FH;
27+ backup_file($option_tmpdir, $dst_file, $file_name);
28+ unlink "$option_tmpdir/$dst_file";
29+ } else {
30+ open XTRABACKUP_FH, "> $file_name"
31+ || die "Cannot open file $file_name: $!\n";
32+ print XTRABACKUP_FH $write_data;
33+ close XTRABACKUP_FH;
34+ }
35 }
36
37 #
38
39=== modified file 'test/t/ib_rsync.sh'
40--- test/t/ib_rsync.sh 2013-07-25 15:04:49 +0000
41+++ test/t/ib_rsync.sh 2013-08-14 19:21:01 +0000
42@@ -8,7 +8,19 @@
43 start_server --innodb_file_per_table
44 load_sakila
45
46-innobackupex --rsync --no-timestamp $topdir/backup
47+# Bug #1211263: innobackupex unnecessarily calls 'cp' for metadata files
48+# Create a 'fake' cp command that will be called instead and will always 'fail'
49+# If any portion of innobackupex script attempts to use cp instead of rsync,
50+# the backup and subsequently the test will fail.
51+cat >$topdir/cp <<EOF
52+#!/bin/sh
53+false
54+EOF
55+
56+chmod +x $topdir/cp
57+
58+# Calling with $topdir in the path first so the 'fake' cp is used
59+PATH=$topdir:$PATH innobackupex --rsync --no-timestamp $topdir/backup
60
61 stop_server
62

Subscribers

People subscribed via source and target branches