Merge lp:~sergei.glushchenko/percona-xtrabackup/bug543134_LRU_dump_restore into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 389
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/bug543134_LRU_dump_restore
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 151 lines (+119/-0)
4 files modified
innobackupex (+24/-0)
test/t/ib_lru_dump_basic.sh (+37/-0)
test/t/ib_lru_dump_rsync.sh (+31/-0)
test/t/ib_lru_dump_stream.sh (+27/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/bug543134_LRU_dump_restore
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Sergei Glushchenko (community) Needs Information
Review via email: mp+90374@code.launchpad.net

Description of the change

Bug 543134: LRU dump/restore support in XtraBackup
Support is done by copying file ib_lru_dump inside of innobackupex script.
Both for local-copy and stream modes this file is copied outside of
FLUSH TABLES WITH READ LOCK section. For rsync mode it is copied along
with other files by single rsync call.

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

Hi Sergei,

On 27.01.12 10:12, Sergei Glushchenko wrote:
> === modified file 'innobackupex'
> --- innobackupex 2012-01-23 21:39:00 +0000
> +++ innobackupex 2012-01-27 06:10:35 +0000
> @@ -423,6 +423,24 @@
> # Close the DB connection
> mysql_close();
>
> + # copy ib_lru_dump
> + if (-e "$orig_datadir/ib_lru_dump") {
> + if ($option_remote_host) {
> + print STDERR "$prefix Backing up file '$src_name'\n";

I think it should be $orig_datadir/ib_lru_dump instead of $src_name on
the above line. But I don't think you really need this code, see the
next comment.

> + } elsif (!$option_rsync) {
> + my $src_name = escape_path("$orig_datadir/ib_lru_dump");
> + my $dst_name = escape_path("$backup_dir/ib_lru_dump");
> + system("$CP_CMD \"$src_name\" \"$dst_name\"")
> + and Die "Failed to copy file 'ib_lru_dump': $!";
> + }
> + }

Why not just add it to the regexp in backup_files() so it's copied as a
regular data file, rather than a special xtrabackup meta info file?

>
> + # copy ib_lru_dump to datadir
> + if (-e "$backup_dir/ib_lru_dump") {
> + print STDERR "$prefix Copying file '$backup_dir/ib_lru_dump'\n";
> + $src_name = escape_path("$backup_dir/ib_lru_dump");
> + $dst_name = escape_path("$orig_datadir");
> + system("$CP_CMD \"$src_name\" \"$dst_name\"")
> + and Die "Failed to copy file 'ib_lru_dump': $!";
> + }
> +

Is it really needed? I think it would be copied by copy_back() even
without this code. Also not that copy_back() has been changed
significantly with the fix for bug #759701, which got merged to main
trees today.

> if ($option_rsync) {
> + if (-e "$source_dir/ib_lru_dump") {
> + print RSYNC "ib_lru_dump\n";
> + if (!$prep_mode) {
> + $rsync_files_hash{"ib_lru_dump"} = 1;
> + }
> + }

You won't need this either with the change in backup_files() I suggested
above.

Revision history for this message
Alexey Kopytov (akopytov) :
review: Needs Fixing
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

There is some meaning in the way I'm copying ib_lru_dump. Since this file is not a table, we couldn't worry about it's consistency and we could copy it without locking all tables. I'm not sure if it give us some advantages. So correct me if it not.
If it is acceptable to copy ib_lru_dump with tables locked then solution would be bit different and much easier.
I also noticed that parts of innobackupex which I touched in this branch changed significantly. It would probably better to rebase this branch on more recent revision.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) :
review: Needs Information
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Alexey,

Anyway regexp /\.(frm)|(MYD)|(MYI)|(MRG)|(TRG)|(TRN)|(ARM)|(ARZ)|(CSM)|(CSV)|(opt)|(par)$/ is not the best place to handle ib_lru_dump. It's because of 2 things:

1. ib_lru_dump placed in mysql datadir, so if we want it to be handled we must change

    if ($database eq '.' || $database eq '..') { next; }

to

    if ($database eq '..') { next; }

2. I think ib_lru_dump shouldn't go thru check_if_required (filter by --databases, --tables-file)

What do you think about it?

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

On 31.01.12 15:44, Sergei Glushchenko wrote:
> There is some meaning in the way I'm copying ib_lru_dump. Since this file is not a table, we couldn't worry about it's consistency and we could copy it without locking all tables. I'm not sure if it give us some advantages. So correct me if it not.
> If it is acceptable to copy ib_lru_dump with tables locked then solution would be bit different and much easier.

Right, I forgot copying it outside FTWRL is required by the bug report.

OK, let's do it outside then.

Few minor notes on test cases:

- You can check if you are running against Percona Server (i.e. require
XtraDB), rather than issue an SQL comment with "set +e" and then
checking if file exists.

- you can also check for XtraDB before calling 'init' and 'run_mysqld'
to save some time when the test should be skipped.

- same goes for rsync: you should normally check if the test should be
skipped as early as possible

- please use $TAR instead of calling tar directly, so that we use gnutar
where applicable.

- I think you can use:

if $TAR itf $topdir/backup/stream.tar | grep ib_lru_dump ; then

instead of:

if [ "`tar itf $topdir/backup/stream.tar | grep ib_lru_dump | wc -l`" ==
"1" ] ; then

- let's follow some common conventions for test headers, see for example
bug759225.sh or bug514068.sh.

- 'backup' is not a verb, but 'back' is. so it should be 'backed up'
rather than 'backuped'.

Revision history for this message
Alexey Kopytov (akopytov) :
review: Needs Fixing
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Alexey,

> - You can check if you are running against Percona Server (i.e. require
> XtraDB), rather than issue an SQL comment with "set +e" and then
> checking if file exists.
>
> - you can also check for XtraDB before calling 'init' and 'run_mysqld'
> to save some time when the test should be skipped.
>
> - same goes for rsync: you should normally check if the test should be
> skipped as early as possible
>
> - please use $TAR instead of calling tar directly, so that we use gnutar
> where applicable.
>
> - I think you can use:
>
> if $TAR itf $topdir/backup/stream.tar | grep ib_lru_dump ; then
>
> instead of:
>
> if [ "`tar itf $topdir/backup/stream.tar | grep ib_lru_dump | wc -l`" ==
> "1" ] ; then
>
> - let's follow some common conventions for test headers, see for example
> bug759225.sh or bug514068.sh.
>
> - 'backup' is not a verb, but 'back' is. so it should be 'backed up'
> rather than 'backuped'.

^ All those thing are fixed.

Removed block of code which from copy-back, as it was not necessary.

Branch based on revision of xtrabackup without kewpie.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :
Revision history for this message
Alexey Kopytov (akopytov) wrote :

OK to merge, thanks!

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 2012-02-06 10:10:40 +0000
3+++ innobackupex 2012-02-06 12:52:23 +0000
4@@ -430,6 +430,24 @@
5 # Close the DB connection
6 mysql_close();
7
8+ # copy ib_lru_dump
9+ if (-e "$orig_datadir/ib_lru_dump") {
10+ if ($option_remote_host) {
11+ print STDERR "$prefix Backing up file 'ib_lru_dump'\n";
12+ system("scp $option_scp_opt '$orig_datadir/ib_lru_dump' '$option_remote_host:$backup_dir/ib_lru_dump'")
13+ and Die "Failed to scp file 'ib_lru_dump': $!";
14+ } elsif ($option_stream) {
15+ print STDERR "$prefix Backing up as tar stream 'ib_lru_dump'\n";
16+ system("cd $orig_datadir; tar chf - ib_lru_dump")
17+ and Die "Failed to stream 'ib_lru_dump': $!";
18+ } elsif (!$option_rsync) {
19+ my $src_name = escape_path("$orig_datadir/ib_lru_dump");
20+ my $dst_name = escape_path("$backup_dir/ib_lru_dump");
21+ system("$CP_CMD \"$src_name\" \"$dst_name\"")
22+ and Die "Failed to copy file 'ib_lru_dump': $!";
23+ }
24+ }
25+
26 if ($option_remote_host) {
27 system("scp $option_scp_opt '$tmp_logfile' '$option_remote_host:$backup_dir/xtrabackup_logfile'")
28 and Die "Failed to scp file '$option_remote_host:$backup_dir/xtrabackup_logfile': $!";
29@@ -2108,6 +2126,12 @@
30 closedir(DIR);
31
32 if ($option_rsync) {
33+ if (-e "$source_dir/ib_lru_dump") {
34+ print RSYNC "ib_lru_dump\n";
35+ if (!$prep_mode) {
36+ $rsync_files_hash{"ib_lru_dump"} = 1;
37+ }
38+ }
39 close(RSYNC);
40
41 # do the actual rsync now
42
43=== added file 'test/t/ib_lru_dump_basic.sh'
44--- test/t/ib_lru_dump_basic.sh 1970-01-01 00:00:00 +0000
45+++ test/t/ib_lru_dump_basic.sh 2012-02-06 12:52:23 +0000
46@@ -0,0 +1,37 @@
47+########################################################################
48+# Bug #543134: Missing support for LRU dump/restore
49+########################################################################
50+
51+. inc/common.sh
52+
53+if [ -z "$XTRADB_VERSION" ]; then
54+ echo "Requires XtraDB" > $SKIPPED_REASON
55+ exit $SKIPPED_EXIT_CODE
56+fi
57+
58+init
59+run_mysqld
60+
61+# produce ib_lru_dump
62+${MYSQL} ${MYSQL_ARGS} -e "select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_LRU_DUMP*/;"
63+
64+# take a backup
65+innobackupex --no-timestamp $topdir/backup
66+
67+if [ -f $topdir/backup/ib_lru_dump ] ; then
68+ vlog "LRU dump has been backed up"
69+else
70+ vlog "LRU dump has not been backed up"
71+ exit -1
72+fi
73+
74+# restore from backup
75+rm -rf $mysql_datadir/*
76+innobackupex --copy-back $topdir/backup
77+
78+if [ -f $mysql_datadir/ib_lru_dump ] ; then
79+ vlog "LRU dump has been restored"
80+else
81+ vlog "LRU dump has not been restored"
82+ exit -1
83+fi
84
85=== added file 'test/t/ib_lru_dump_rsync.sh'
86--- test/t/ib_lru_dump_rsync.sh 1970-01-01 00:00:00 +0000
87+++ test/t/ib_lru_dump_rsync.sh 2012-02-06 12:52:23 +0000
88@@ -0,0 +1,31 @@
89+########################################################################
90+# Bug #543134: Missing support for LRU dump/restore
91+########################################################################
92+
93+. inc/common.sh
94+
95+if [ -z "$XTRADB_VERSION" ]; then
96+ echo "Requires XtraDB" > $SKIPPED_REASON
97+ exit $SKIPPED_EXIT_CODE
98+fi
99+
100+if ! which rsync > /dev/null 2>&1 ; then
101+ echo "Requires rsync to be installed" > $SKIPPED_REASON
102+ exit $SKIPPED_EXIT_CODE
103+fi
104+
105+init
106+run_mysqld
107+
108+# produce ib_lru_dump
109+${MYSQL} ${MYSQL_ARGS} -e "select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_LRU_DUMP*/;"
110+
111+# take a backup with rsync mode
112+innobackupex --rsync --no-timestamp $topdir/backup
113+
114+if [ -f $topdir/backup/ib_lru_dump ] ; then
115+ vlog "LRU dump has been backed up"
116+else
117+ vlog "LRU dump has not been backed up"
118+ exit -1
119+fi
120
121=== added file 'test/t/ib_lru_dump_stream.sh'
122--- test/t/ib_lru_dump_stream.sh 1970-01-01 00:00:00 +0000
123+++ test/t/ib_lru_dump_stream.sh 2012-02-06 12:52:23 +0000
124@@ -0,0 +1,27 @@
125+########################################################################
126+# Bug #543134: Missing support for LRU dump/restore
127+########################################################################
128+
129+. inc/common.sh
130+
131+if [ -z "$XTRADB_VERSION" ]; then
132+ echo "Requires XtraDB" > $SKIPPED_REASON
133+ exit $SKIPPED_EXIT_CODE
134+fi
135+
136+init
137+run_mysqld
138+
139+# produce ib_lru_dump
140+${MYSQL} ${MYSQL_ARGS} -e "select * from information_schema.XTRADB_ADMIN_COMMAND /*!XTRA_LRU_DUMP*/;"
141+
142+# take a backup with stream mode
143+mkdir -p $topdir/backup
144+innobackupex --stream=tar $topdir/backup > $topdir/backup/stream.tar
145+
146+if $TAR itf $topdir/backup/stream.tar | grep ib_lru_dump ; then
147+ vlog "LRU dump has been backed up"
148+else
149+ vlog "LRU dump has not been backed up"
150+ exit -1
151+fi

Subscribers

People subscribed via source and target branches