Merge lp:~sergei.glushchenko/percona-xtrabackup/buffer_pool_dump-2.1 into lp:percona-xtrabackup/2.1

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: 564
Merged at revision: 572
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/buffer_pool_dump-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 281 lines (+189/-14)
5 files modified
innobackupex (+23/-14)
src/xtrabackup.cc (+11/-0)
test/t/ib_buffer_pool.sh (+57/-0)
test/t/ib_buffer_pool_dump_incremental.sh (+58/-0)
test/t/ib_buffer_pool_rsync.sh (+40/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/buffer_pool_dump-2.1
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+160826@code.launchpad.net

Description of the change

To post a comment you must log in.
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-04-25 08:28:19 +0000
3+++ innobackupex 2013-04-25 14:39:35 +0000
4@@ -393,6 +393,8 @@
5 sub backup {
6 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
7 my $suspend_file;
8+ my $buffer_pool_filename = get_option(\%config, $option_defaults_group,
9+ 'innodb_buffer_pool_filename');
10
11 if ($option_incremental) {
12 detect_mysql_capabilities_for_backup(\%mysql);
13@@ -451,16 +453,19 @@
14 }
15
16 # copy ib_lru_dump
17- if (-e "$orig_datadir/ib_lru_dump") {
18- if ($option_stream) {
19- print STDERR "$prefix Backing up as tar stream 'ib_lru_dump'\n";
20- stream_encrypt_file($orig_datadir, "ib_lru_dump")
21- and Die "Failed to stream 'ib_lru_dump': $!";
22- } elsif (!$option_rsync) {
23- my $src_name = escape_path("$orig_datadir/ib_lru_dump");
24- my $dst_name = escape_path("$backup_dir/ib_lru_dump");
25- system("$CP_CMD \"$src_name\" \"$dst_name\"")
26- and Die "Failed to copy file 'ib_lru_dump': $!";
27+ # Copy buffer poll dump and/or LRU dump
28+ foreach my $dump_name ($buffer_pool_filename, 'ib_lru_dump') {
29+ if (-e "$orig_datadir/$dump_name") {
30+ if ($option_stream) {
31+ print STDERR "$prefix Backing up as tar stream '$dump_name'\n";
32+ stream_encrypt_file($orig_datadir, "$dump_name")
33+ and Die "Failed to stream '$dump_name': $!";
34+ } elsif (!$option_rsync) {
35+ my $src_name = escape_path("$orig_datadir/$dump_name");
36+ my $dst_name = escape_path("$backup_dir/$dump_name");
37+ system("$CP_CMD \"$src_name\" \"$dst_name\"")
38+ and Die "Failed to copy file '$dump_name': $!";
39+ }
40 }
41 }
42
43@@ -2126,6 +2131,8 @@
44 sub backup_files {
45 my $prep_mode = shift;
46 my $source_dir = get_option(\%config, $option_defaults_group, 'datadir');
47+ my $buffer_pool_filename = get_option(\%config, $option_defaults_group,
48+ 'innodb_buffer_pool_filename');
49 my @list;
50 my $file;
51 my $database;
52@@ -2247,10 +2254,12 @@
53 closedir(DIR);
54
55 if ($option_rsync) {
56- if (-e "$source_dir/ib_lru_dump") {
57- print RSYNC "ib_lru_dump\n";
58- if (!$prep_mode) {
59- $rsync_files_hash{"ib_lru_dump"} = 1;
60+ foreach my $dump_name ($buffer_pool_filename, 'ib_lru_dump') {
61+ if (-e "$source_dir/$dump_name") {
62+ print RSYNC "$dump_name\n";
63+ if (!$prep_mode) {
64+ $rsync_files_hash{"$dump_name"} = 1;
65+ }
66 }
67 }
68 close(RSYNC);
69
70=== modified file 'src/xtrabackup.cc'
71--- src/xtrabackup.cc 2013-04-24 14:10:22 +0000
72+++ src/xtrabackup.cc 2013-04-25 14:39:35 +0000
73@@ -219,6 +219,7 @@
74 my_bool innobase_fast_checksum = FALSE;
75 my_bool innobase_extra_undoslots = FALSE;
76 char* innobase_doublewrite_file = NULL;
77+char* innobase_buffer_pool_filename = NULL;
78
79 longlong innobase_buffer_pool_size = 8*1024*1024L;
80 longlong innobase_log_file_size = DEFAULT_LOG_FILE_SIZE;
81@@ -428,6 +429,7 @@
82 OPT_INNODB_EXTRA_UNDOSLOTS,
83 OPT_INNODB_DOUBLEWRITE_FILE,
84 #endif
85+ OPT_INNODB_BUFFER_POOL_FILENAME,
86 OPT_INNODB_FORCE_RECOVERY,
87 OPT_INNODB_LOCK_WAIT_TIMEOUT,
88 OPT_INNODB_LOG_BUFFER_SIZE,
89@@ -792,6 +794,11 @@
90 (G_PTR*) &innobase_doublewrite_file, (G_PTR*) &innobase_doublewrite_file,
91 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
92 #endif
93+ {"innodb_buffer_pool_filename", OPT_INNODB_BUFFER_POOL_FILENAME,
94+ "Filename to/from which to dump/load the InnoDB buffer pool",
95+ (G_PTR*) &innobase_buffer_pool_filename,
96+ (G_PTR*) &innobase_buffer_pool_filename,
97+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
98
99 #ifndef __WIN__
100 {"debug-sync", OPT_XTRA_DEBUG_SYNC,
101@@ -5304,6 +5311,10 @@
102 }
103 printf("innodb_undo_tablespaces = %lu\n", srv_undo_tablespaces);
104 #endif
105+ printf("innodb_buffer_pool_filename = \"%s\"\n",
106+ innobase_buffer_pool_filename ?
107+ innobase_buffer_pool_filename :
108+ "ib_buffer_pool");
109 exit(EXIT_SUCCESS);
110 }
111
112
113=== added file 'test/t/ib_buffer_pool.sh'
114--- test/t/ib_buffer_pool.sh 1970-01-01 00:00:00 +0000
115+++ test/t/ib_buffer_pool.sh 2013-04-25 14:39:35 +0000
116@@ -0,0 +1,57 @@
117+########################################################################
118+# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
119+########################################################################
120+
121+. inc/common.sh
122+
123+if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
124+ echo "Requires MySQL 5.6" > $SKIPPED_REASON
125+ exit $SKIPPED_EXIT_CODE
126+fi
127+
128+MYSQLD_EXTRA_MY_CNF_OPTS="
129+innodb_buffer_pool_filename=pool/dump
130+"
131+
132+start_server
133+
134+# test presence of innodb_buffer_pool_filename
135+${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
136+ grep -q "innodb_buffer_pool_filename"
137+
138+mkdir $mysql_datadir/pool
139+
140+# produce buffer pool dump
141+${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
142+
143+# take a backup
144+innobackupex --no-timestamp $topdir/backup
145+
146+if [ -f $topdir/backup/pool/dump ] ; then
147+ vlog "Buffer pool dump has been backed up"
148+else
149+ vlog "Buffer pool dump has not been backed up"
150+ exit -1
151+fi
152+
153+# take streaming backup
154+mkdir -p $topdir/backup
155+innobackupex --stream=tar $topdir/backup > $topdir/backup/stream.tar
156+
157+if $TAR itf $topdir/backup/stream.tar | grep 'pool/dump' ; then
158+ vlog "Buffer pool dump has been restored"
159+else
160+ vlog "Buffer pool dump has not been restored"
161+ exit -1
162+fi
163+
164+# restore from backup
165+rm -rf $mysql_datadir/*
166+innobackupex --copy-back $topdir/backup
167+
168+if [ -f $mysql_datadir/pool/dump ] ; then
169+ vlog "Buffer pool dump has been restored"
170+else
171+ vlog "Buffer pool dump has not been restored"
172+ exit -1
173+fi
174
175=== added file 'test/t/ib_buffer_pool_dump_incremental.sh'
176--- test/t/ib_buffer_pool_dump_incremental.sh 1970-01-01 00:00:00 +0000
177+++ test/t/ib_buffer_pool_dump_incremental.sh 2013-04-25 14:39:35 +0000
178@@ -0,0 +1,58 @@
179+########################################################################
180+# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
181+########################################################################
182+
183+. inc/common.sh
184+
185+if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
186+ echo "Requires MySQL 5.6" > $SKIPPED_REASON
187+ exit $SKIPPED_EXIT_CODE
188+fi
189+
190+MYSQLD_EXTRA_MY_CNF_OPTS="
191+innodb_buffer_pool_filename=pool/dump
192+"
193+
194+start_server
195+
196+# test presence of innodb_buffer_pool_filename
197+${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
198+ grep -q "innodb_buffer_pool_filename"
199+
200+mkdir $mysql_datadir/pool
201+
202+# take a backup
203+innobackupex --no-timestamp $topdir/backup
204+
205+# produce buffer pool dump
206+${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
207+
208+# incremental backup
209+innobackupex --no-timestamp --incremental --incremental-basedir=$topdir/backup \
210+ $topdir/incremental
211+
212+if [ -f $topdir/incremental/pool/dump ] ; then
213+ vlog "Buffer pool dump has been backed up"
214+else
215+ vlog "Buffer pool dump has not been backed up"
216+ exit -1
217+fi
218+
219+# prepare
220+innobackupex --apply-log --redo-only $topdir/backup
221+
222+innobackupex --apply-log --redo-only --incremental-dir=$topdir/incremental \
223+ $topdir/backup
224+
225+innobackupex --apply-log $topdir/backup
226+
227+# restore from backup
228+rm -rf $mysql_datadir/*
229+innobackupex --copy-back $topdir/backup
230+
231+if [ -f $mysql_datadir/pool/dump ] ; then
232+ vlog "Buffer pool dump has been restored"
233+else
234+ vlog "Buffer pool dump has not been restored"
235+ exit -1
236+fi
237
238=== added file 'test/t/ib_buffer_pool_rsync.sh'
239--- test/t/ib_buffer_pool_rsync.sh 1970-01-01 00:00:00 +0000
240+++ test/t/ib_buffer_pool_rsync.sh 2013-04-25 14:39:35 +0000
241@@ -0,0 +1,40 @@
242+########################################################################
243+# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
244+########################################################################
245+
246+. inc/common.sh
247+
248+if ! which rsync > /dev/null 2>&1 ; then
249+ echo "Requires rsync to be installed" > $SKIPPED_REASON
250+ exit $SKIPPED_EXIT_CODE
251+fi
252+
253+if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
254+ echo "Requires MySQL 5.6" > $SKIPPED_REASON
255+ exit $SKIPPED_EXIT_CODE
256+fi
257+
258+MYSQLD_EXTRA_MY_CNF_OPTS="
259+innodb_buffer_pool_filename=pool/dump
260+"
261+
262+start_server
263+
264+# test presence of innodb_buffer_pool_filename
265+${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
266+ grep -q "innodb_buffer_pool_filename"
267+
268+mkdir $mysql_datadir/pool
269+
270+# produce buffer pool dump
271+${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
272+
273+# take a backup with rsync mode
274+innobackupex --rsync --no-timestamp $topdir/backup
275+
276+if [ -f $topdir/backup/pool/dump ] ; then
277+ vlog "Buffer pool dump has been backed up"
278+else
279+ vlog "Buffer pool dump has not been backed up"
280+ exit -1
281+fi

Subscribers

People subscribed via source and target branches