Merge lp:~akopytov/percona-xtrabackup/bug1217426-2.2 into lp:percona-xtrabackup/2.2

Proposed by Alexey Kopytov
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 4886
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1217426-2.2
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 73 lines (+39/-0)
4 files modified
xtrabackup/innobackupex (+19/-0)
xtrabackup/test/inc/ib_stream_common.sh (+8/-0)
xtrabackup/test/inc/xb_local.sh (+6/-0)
xtrabackup/test/t/ib_rsync.sh (+6/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1217426-2.2
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Sergei Glushchenko (community) g2 Approve
Review via email: mp+187729@code.launchpad.net

Description of the change

Bug #1217426: Empty directory is not backed when stream is used

The problem was that innobackupex ignored empty directories when
creating streaming backups. Normally a database created by the server
contains a ?db.opt? file, and so the corresponding directory is not
empty. However, in some circumstances a database may be created with
?mkdir?. This is what mysql_install_db does to create the default ?test?
database. Since there are no files to send into the
stream, the resulting stream would contain no references to the empty
directory, so it would not be created when the stream is unpacked and
thus, missing in the backup. Which resulted in inconsistency between the
original data directory and the one after restoring from the backup.

One solution to this problem would be to stream empty directories. This
is rather complicated from the implementation point of view. Since both
xbcrypt and xbstream only deal with files, it would require implementing
support for directory units, i.e. introducing new ?directory? chunk
types, bumping the format version, modifications to the datasink API and
utility command line interface, etc.

A much easier solution is to stream a fake empty ?db.opt? file for empty
directories. This way the corresponding database will be present in the
backup, and the empty db.opt file will be ignored by the server after
restore.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.2-param/15/

To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve

review: Approve (g2)
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 'xtrabackup/innobackupex'
2--- xtrabackup/innobackupex 2013-09-26 06:26:18 +0000
3+++ xtrabackup/innobackupex 2013-09-26 11:19:41 +0000
4@@ -4018,6 +4018,25 @@
5 print STDERR "$prefix Backing up files " .
6 "'$source_dir/$database/$wildcard' ($file_c files)\n";
7 }
8+
9+ if ($file_c == 0 && $option_stream) {
10+ # Stream/encrypt empty directories by backing up a fake empty
11+ # db.opt file, so that empty databases are created in the backup
12+ mkdir("$option_tmpdir/$database") ||
13+ die "Failed to create directory $option_tmpdir/$database: $!";
14+
15+ open XTRABACKUP_FH, "> $option_tmpdir/$database/db.opt"
16+ || die "Cannot create file $option_tmpdir/db.opt: $!";
17+ close XTRABACKUP_FH;
18+
19+ backup_file_via_stream("$option_tmpdir", "$database/db.opt");
20+
21+ unlink("$option_tmpdir/$database/db.opt") ||
22+ die "Failed to remove file $database/db.opt: $!";
23+ rmdir("$option_tmpdir/$database") ||
24+ die "Failed to remove directory $database: $!";
25+ }
26+
27 foreach $file (@list) {
28 next unless check_if_required($database, $file);
29
30
31=== modified file 'xtrabackup/test/inc/ib_stream_common.sh'
32--- xtrabackup/test/inc/ib_stream_common.sh 2013-06-05 19:15:00 +0000
33+++ xtrabackup/test/inc/ib_stream_common.sh 2013-09-26 11:19:41 +0000
34@@ -55,3 +55,11 @@
35 start_server
36 # Check sakila
37 run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT count(*) from actor" sakila
38+
39+########################################################################
40+# Bug #1217426: Empty directory is not backed when stream is used
41+########################################################################
42+
43+# Check if the 'test' database is accessible by the server
44+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t(a INT)" test
45+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT * FROM t" test
46
47=== modified file 'xtrabackup/test/inc/xb_local.sh'
48--- xtrabackup/test/inc/xb_local.sh 2013-07-25 22:02:50 +0000
49+++ xtrabackup/test/inc/xb_local.sh 2013-09-26 11:19:41 +0000
50@@ -52,3 +52,9 @@
51 start_server
52 # Check sakila
53 run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT count(*) from actor" sakila
54+
55+########################################################################
56+# Bug #1217426: Empty directory is not backed when stream is used
57+########################################################################
58+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t(a INT)" test
59+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT * FROM t" test
60
61=== modified file 'xtrabackup/test/t/ib_rsync.sh'
62--- xtrabackup/test/t/ib_rsync.sh 2013-08-14 18:36:12 +0000
63+++ xtrabackup/test/t/ib_rsync.sh 2013-09-26 11:19:41 +0000
64@@ -34,3 +34,9 @@
65
66 start_server
67 run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT COUNT(*) FROM actor" sakila
68+
69+########################################################################
70+# Bug #1217426: Empty directory is not backed when stream is used
71+########################################################################
72+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "CREATE TABLE t(a INT)" test
73+run_cmd ${MYSQL} ${MYSQL_ARGS} -e "SELECT * FROM t" test

Subscribers

People subscribed via source and target branches

to all changes: