Merge lp:~longbow/percona-xtrabackup/fix737569-1.6 into lp:percona-xtrabackup/1.6

Proposed by Valentine Gostev
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 308
Proposed branch: lp:~longbow/percona-xtrabackup/fix737569-1.6
Merge into: lp:percona-xtrabackup/1.6
Diff against target: 92 lines (+58/-12)
2 files modified
innobackupex (+23/-12)
test/t/ib_empty_dir.sh (+35/-0)
To merge this branch: bzr merge lp:~longbow/percona-xtrabackup/fix737569-1.6
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+83588@code.launchpad.net

Description of the change

Added fix and test for bug 737569

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'innobackupex'
2--- innobackupex 2011-11-11 18:12:31 +0000
3+++ innobackupex 2011-11-28 11:54:41 +0000
4@@ -477,6 +477,25 @@
5 return 0;
6 }
7
8+#
9+# if_directory_exists_and_empty accepts two arguments:
10+# variable with directory name and comment.
11+# Sub checks that directory exists and is empty
12+# usage: is_directory_exists_and_empty($directory,"Comment");
13+#
14+
15+sub if_directory_exists_and_empty {
16+ my $empty_dir = shift;
17+ my $is_directory_empty_comment = shift;
18+ if (! -d $empty_dir) {
19+ die "$is_directory_empty_comment directory does not exist!";
20+ }
21+ opendir (my $dh, $empty_dir) or die "Not a directory";
22+ if ( ! scalar( grep { $_ ne "." && $_ ne ".." } readdir($dh)) == 0) {
23+ die "$is_directory_empty_comment directory is not empty!";
24+ }
25+ closedir($dh);
26+}
27
28 #
29 # copy_back subroutine copies data and index files from backup directory
30@@ -497,18 +516,10 @@
31 my $compressed_data_file = '.*\.ibz$';
32 my $file;
33 my $backup_innodb_data_file_path;
34- # check that original data directory exists
35- if (! -d $orig_datadir) {
36- Die "Original data directory '$orig_datadir' does not exist!";
37- }
38- # check that original InnoDB data directory exists
39- if (! -d $orig_ibdata_dir) {
40- Die "Original InnoDB data directory '$orig_ibdata_dir' does not exist!";
41- }
42- # check that original InnoDB log directory exists
43- if (! -d $orig_iblog_dir) {
44- Die "Original InnoDB log directory '$orig_iblog_dir' does not exist!";
45- }
46+ # check that original data directories exist and they are empty
47+ if_directory_exists_and_empty($orig_datadir, "Original data");
48+ if_directory_exists_and_empty($orig_ibdata_dir, "Original InnoDB data");
49+ if_directory_exists_and_empty($orig_iblog_dir, "Original InnoDB log");
50
51 # check that the original options file and the backup options file have
52 # the same value for "innodb_data_file_path" option
53
54=== added file 'test/t/ib_empty_dir.sh'
55--- test/t/ib_empty_dir.sh 1970-01-01 00:00:00 +0000
56+++ test/t/ib_empty_dir.sh 2011-11-28 11:54:41 +0000
57@@ -0,0 +1,35 @@
58+# Test for bug https://bugs.launchpad.net/percona-xtrabackup/+bug/737569
59+. inc/common.sh
60+
61+init
62+run_mysqld
63+
64+innobackupex --no-timestamp $topdir/backup
65+backup_dir=$topdir/backup
66+vlog "Backup created in directory $backup_dir"
67+
68+stop_mysqld
69+# Remove datadir
70+rm -r $mysql_datadir
71+# Restore backup
72+vlog "Applying log"
73+vlog "###########"
74+vlog "# PREPARE #"
75+vlog "###########"
76+innobackupex --apply-log $backup_dir
77+vlog "Restoring MySQL datadir"
78+mkdir -p $mysql_datadir
79+touch $mysql_datadir/anyfile
80+vlog "###########"
81+vlog "# RESTORE #"
82+vlog "###########"
83+run_cmd_expect_failure $IB_BIN $IB_ARGS --copy-back $backup_dir
84+
85+if grep -q "is not empty!" $OUTFILE
86+then
87+ vlog "innobackupex reported error about non-empty dirrectory correctly"
88+ exit 0
89+else
90+ vlog "innobackupex did not report an error about non-empty dir"
91+ exit 1
92+fi

Subscribers

People subscribed via source and target branches