Merge lp:~sergei.glushchenko/percona-xtrabackup/buffer_pool_dump 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: 546
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/buffer_pool_dump
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 291 lines (+194/-19)
5 files modified
innobackupex (+28/-19)
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
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+160825@code.launchpad.net

Description of the change

Support for buffer pool dump MySQL 5.6

   - MySQL 5.6 adds an ability to dump the buffer pool into file for it to be
     possible to load it into memory at startup or on demand. The location of
     buffer pool file is set by global variable innodb_buffer_pool_filename
     and is relative to MySQL data directory.
   - The patch adds an ability to take a backup of buffer pool dump. It has been
     made exactly the same way as XtraDB LRU dump is backed up.
   - Two tests have been added for this feature. One takes regular backup and
     after takes streaming backup. Another one takes backup with --remote-host
     option. Second test has not been ported to 2.1 because --remote-host
     option is not supported in 2.1.
   - Also test for these features to work correctly with incremental backups
     is implemented.

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/419/

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

Sergei,

  - string values for most options in --print-param are enclosed in
    double quotes. It only matters when path or file names contain
    spaces.
  - MP and revision comments refer to a --remote-host test, but I don't
    see it in the code (would also be rather tricky to test in the test
    suite). I thought it was a typo for --rsync, but the rsync test is
    also present in the 2.1 MP as it should be.
  - 5.6 version checks are different in test case. I suggest to use
    "${MYSQL_VERSION:0:3}" != "5.6", the other one looks a bit
    unreliable
  - please rebase it on current trunks. my.cnf is handled differently
    after recent merges, and the way it is done in these tests will
    conflict. You can now specify MYSQLD_EXTRA_MY_CNF_OPTS and it will
    be used by both server (no need for extra start_server arguments)
    and innobackupex/xtrabackup

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

Alexei,

  - string values for most options in --print-param are enclosed in
    double quotes. It only matters when path or file names contain
    spaces.

> I added quotes

  - MP and revision comments refer to a --remote-host test, but I don't
    see it in the code (would also be rather tricky to test in the test
    suite). I thought it was a typo for --rsync, but the rsync test is
    also present in the 2.1 MP as it should be.

> Indeed, I mixed many things in one. And also forgot to add test for incremental backup.

  - 5.6 version checks are different in test case. I suggest to use
    "${MYSQL_VERSION:0:3}" != "5.6", the other one looks a bit
    unreliable

> I modified version check to be comparison with "5.6"

  - please rebase it on current trunks. my.cnf is handled differently
    after recent merges, and the way it is done in these tests will
    conflict. You can now specify MYSQLD_EXTRA_MY_CNF_OPTS and it will
    be used by both server (no need for extra start_server arguments)
    and innobackupex/xtrabackup

> done.

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

Alexey, sorry for typo in name.

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
=== modified file 'innobackupex'
--- innobackupex 2013-04-25 08:27:18 +0000
+++ innobackupex 2013-04-25 14:34:24 +0000
@@ -392,6 +392,8 @@
392#392#
393sub backup {393sub backup {
394 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');394 my $orig_datadir = get_option(\%config, $option_defaults_group, 'datadir');
395 my $buffer_pool_filename = get_option(\%config, $option_defaults_group,
396 'innodb_buffer_pool_filename');
395397
396 # check that we can connect to the database. This done by398 # check that we can connect to the database. This done by
397 # connecting, issuing a query, and closing the connection.399 # connecting, issuing a query, and closing the connection.
@@ -447,21 +449,24 @@
447 # Close the DB connection449 # Close the DB connection
448 mysql_close();450 mysql_close();
449451
450 # copy ib_lru_dump452 # Copy buffer poll dump and/or LRU dump
451 if (-e "$orig_datadir/ib_lru_dump") {453 foreach my $dump_name ($buffer_pool_filename, 'ib_lru_dump') {
452 if ($option_remote_host) {454 if (-e "$orig_datadir/$dump_name") {
453 print STDERR "$prefix Backing up file 'ib_lru_dump'\n";455 if ($option_remote_host) {
454 system("scp $option_scp_opt '$orig_datadir/ib_lru_dump' '$option_remote_host:$backup_dir/ib_lru_dump'")456 print STDERR "$prefix Backing up file '$dump_name'\n";
455 and Die "Failed to scp file 'ib_lru_dump': $!";457 system("scp $option_scp_opt '$orig_datadir/$dump_name' " .
456 } elsif ($option_stream) {458 "'$option_remote_host:$backup_dir/$dump_name'")
457 print STDERR "$prefix Backing up as tar stream 'ib_lru_dump'\n";459 and Die "Failed to scp file '$dump_name': $!";
458 system("cd $orig_datadir; $stream_cmd ib_lru_dump")460 } elsif ($option_stream) {
459 and Die "Failed to stream 'ib_lru_dump': $!";461 print STDERR "$prefix Backing up as tar stream '$dump_name'\n";
460 } elsif (!$option_rsync) {462 system("cd $orig_datadir; $stream_cmd $dump_name")
461 my $src_name = escape_path("$orig_datadir/ib_lru_dump");463 and Die "Failed to stream '$dump_name': $!";
462 my $dst_name = escape_path("$backup_dir/ib_lru_dump");464 } elsif (!$option_rsync) {
463 system("$CP_CMD \"$src_name\" \"$dst_name\"")465 my $src_name = escape_path("$orig_datadir/$dump_name");
464 and Die "Failed to copy file 'ib_lru_dump': $!";466 my $dst_name = escape_path("$backup_dir/$dump_name");
467 system("$CP_CMD \"$src_name\" \"$dst_name\"")
468 and Die "Failed to copy file '$dump_name': $!";
469 }
465 }470 }
466 }471 }
467472
@@ -2204,6 +2209,8 @@
2204sub backup_files {2209sub backup_files {
2205 my $prep_mode = shift;2210 my $prep_mode = shift;
2206 my $source_dir = get_option(\%config, $option_defaults_group, 'datadir');2211 my $source_dir = get_option(\%config, $option_defaults_group, 'datadir');
2212 my $buffer_pool_filename = get_option(\%config, $option_defaults_group,
2213 'innodb_buffer_pool_filename');
2207 my @list;2214 my @list;
2208 my $file;2215 my $file;
2209 my $database;2216 my $database;
@@ -2338,10 +2345,12 @@
2338 closedir(DIR);2345 closedir(DIR);
23392346
2340 if ($option_rsync) {2347 if ($option_rsync) {
2341 if (-e "$source_dir/ib_lru_dump") {2348 foreach my $dump_name ($buffer_pool_filename, 'ib_lru_dump') {
2342 print RSYNC "ib_lru_dump\n";2349 if (-e "$source_dir/$dump_name") {
2343 if (!$prep_mode) {2350 print RSYNC "$dump_name\n";
2344 $rsync_files_hash{"ib_lru_dump"} = 1;2351 if (!$prep_mode) {
2352 $rsync_files_hash{"$dump_name"} = 1;
2353 }
2345 }2354 }
2346 }2355 }
2347 close(RSYNC);2356 close(RSYNC);
23482357
=== modified file 'src/xtrabackup.cc'
--- src/xtrabackup.cc 2013-04-24 14:09:42 +0000
+++ src/xtrabackup.cc 2013-04-25 14:34:24 +0000
@@ -1436,6 +1436,7 @@
1436my_bool innobase_fast_checksum = FALSE;1436my_bool innobase_fast_checksum = FALSE;
1437my_bool innobase_extra_undoslots = FALSE;1437my_bool innobase_extra_undoslots = FALSE;
1438char* innobase_doublewrite_file = NULL;1438char* innobase_doublewrite_file = NULL;
1439char* innobase_buffer_pool_filename = NULL;
14391440
1440longlong innobase_buffer_pool_size = 8*1024*1024L;1441longlong innobase_buffer_pool_size = 8*1024*1024L;
1441longlong innobase_log_file_size = DEFAULT_LOG_FILE_SIZE;1442longlong innobase_log_file_size = DEFAULT_LOG_FILE_SIZE;
@@ -1633,6 +1634,7 @@
1633 OPT_INNODB_EXTRA_UNDOSLOTS,1634 OPT_INNODB_EXTRA_UNDOSLOTS,
1634 OPT_INNODB_DOUBLEWRITE_FILE,1635 OPT_INNODB_DOUBLEWRITE_FILE,
1635#endif1636#endif
1637 OPT_INNODB_BUFFER_POOL_FILENAME,
1636 OPT_INNODB_FORCE_RECOVERY,1638 OPT_INNODB_FORCE_RECOVERY,
1637 OPT_INNODB_LOCK_WAIT_TIMEOUT,1639 OPT_INNODB_LOCK_WAIT_TIMEOUT,
1638 OPT_INNODB_LOG_BUFFER_SIZE,1640 OPT_INNODB_LOG_BUFFER_SIZE,
@@ -1961,6 +1963,11 @@
1961 (G_PTR*) &innobase_doublewrite_file, (G_PTR*) &innobase_doublewrite_file,1963 (G_PTR*) &innobase_doublewrite_file, (G_PTR*) &innobase_doublewrite_file,
1962 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},1964 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1963#endif1965#endif
1966 {"innodb_buffer_pool_filename", OPT_INNODB_BUFFER_POOL_FILENAME,
1967 "Filename to/from which to dump/load the InnoDB buffer pool",
1968 (G_PTR*) &innobase_buffer_pool_filename,
1969 (G_PTR*) &innobase_buffer_pool_filename,
1970 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
19641971
1965#ifndef __WIN__1972#ifndef __WIN__
1966 {"debug-sync", OPT_XTRA_DEBUG_SYNC,1973 {"debug-sync", OPT_XTRA_DEBUG_SYNC,
@@ -8040,6 +8047,10 @@
8040 }8047 }
8041 printf("innodb_undo_tablespaces = %lu\n", srv_undo_tablespaces);8048 printf("innodb_undo_tablespaces = %lu\n", srv_undo_tablespaces);
8042#endif8049#endif
8050 printf("innodb_buffer_pool_filename = \"%s\"\n",
8051 innobase_buffer_pool_filename ?
8052 innobase_buffer_pool_filename :
8053 "ib_buffer_pool");
8043 exit(EXIT_SUCCESS);8054 exit(EXIT_SUCCESS);
8044 }8055 }
80458056
80468057
=== added file 'test/t/ib_buffer_pool.sh'
--- test/t/ib_buffer_pool.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_buffer_pool.sh 2013-04-25 14:34:24 +0000
@@ -0,0 +1,57 @@
1########################################################################
2# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
3########################################################################
4
5. inc/common.sh
6
7if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
8 echo "Requires MySQL 5.6" > $SKIPPED_REASON
9 exit $SKIPPED_EXIT_CODE
10fi
11
12MYSQLD_EXTRA_MY_CNF_OPTS="
13innodb_buffer_pool_filename=pool/dump
14"
15
16start_server
17
18# test presence of innodb_buffer_pool_filename
19${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
20 grep -q "innodb_buffer_pool_filename"
21
22mkdir $mysql_datadir/pool
23
24# produce buffer pool dump
25${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
26
27# take a backup
28innobackupex --no-timestamp $topdir/backup
29
30if [ -f $topdir/backup/pool/dump ] ; then
31 vlog "Buffer pool dump has been backed up"
32else
33 vlog "Buffer pool dump has not been backed up"
34 exit -1
35fi
36
37# take streaming backup
38mkdir -p $topdir/backup
39innobackupex --stream=tar $topdir/backup > $topdir/backup/stream.tar
40
41if $TAR itf $topdir/backup/stream.tar | grep 'pool/dump' ; then
42 vlog "Buffer pool dump has been restored"
43else
44 vlog "Buffer pool dump has not been restored"
45 exit -1
46fi
47
48# restore from backup
49rm -rf $mysql_datadir/*
50innobackupex --copy-back $topdir/backup
51
52if [ -f $mysql_datadir/pool/dump ] ; then
53 vlog "Buffer pool dump has been restored"
54else
55 vlog "Buffer pool dump has not been restored"
56 exit -1
57fi
058
=== added file 'test/t/ib_buffer_pool_dump_incremental.sh'
--- test/t/ib_buffer_pool_dump_incremental.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_buffer_pool_dump_incremental.sh 2013-04-25 14:34:24 +0000
@@ -0,0 +1,58 @@
1########################################################################
2# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
3########################################################################
4
5. inc/common.sh
6
7if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
8 echo "Requires MySQL 5.6" > $SKIPPED_REASON
9 exit $SKIPPED_EXIT_CODE
10fi
11
12MYSQLD_EXTRA_MY_CNF_OPTS="
13innodb_buffer_pool_filename=pool/dump
14"
15
16start_server
17
18# test presence of innodb_buffer_pool_filename
19${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
20 grep -q "innodb_buffer_pool_filename"
21
22mkdir $mysql_datadir/pool
23
24# take a backup
25innobackupex --no-timestamp $topdir/backup
26
27# produce buffer pool dump
28${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
29
30# incremental backup
31innobackupex --no-timestamp --incremental --incremental-basedir=$topdir/backup \
32 $topdir/incremental
33
34if [ -f $topdir/incremental/pool/dump ] ; then
35 vlog "Buffer pool dump has been backed up"
36else
37 vlog "Buffer pool dump has not been backed up"
38 exit -1
39fi
40
41# prepare
42innobackupex --apply-log --redo-only $topdir/backup
43
44innobackupex --apply-log --redo-only --incremental-dir=$topdir/incremental \
45 $topdir/backup
46
47innobackupex --apply-log $topdir/backup
48
49# restore from backup
50rm -rf $mysql_datadir/*
51innobackupex --copy-back $topdir/backup
52
53if [ -f $mysql_datadir/pool/dump ] ; then
54 vlog "Buffer pool dump has been restored"
55else
56 vlog "Buffer pool dump has not been restored"
57 exit -1
58fi
059
=== added file 'test/t/ib_buffer_pool_rsync.sh'
--- test/t/ib_buffer_pool_rsync.sh 1970-01-01 00:00:00 +0000
+++ test/t/ib_buffer_pool_rsync.sh 2013-04-25 14:34:24 +0000
@@ -0,0 +1,40 @@
1########################################################################
2# Blueprint: Support InnoDB buffer pool dumps in MySQL 5.6
3########################################################################
4
5. inc/common.sh
6
7if ! which rsync > /dev/null 2>&1 ; then
8 echo "Requires rsync to be installed" > $SKIPPED_REASON
9 exit $SKIPPED_EXIT_CODE
10fi
11
12if [ "${MYSQL_VERSION:0:3}" != "5.6" ]; then
13 echo "Requires MySQL 5.6" > $SKIPPED_REASON
14 exit $SKIPPED_EXIT_CODE
15fi
16
17MYSQLD_EXTRA_MY_CNF_OPTS="
18innodb_buffer_pool_filename=pool/dump
19"
20
21start_server
22
23# test presence of innodb_buffer_pool_filename
24${XB_BIN} --defaults-file=$topdir/my.cnf --print-param | \
25 grep -q "innodb_buffer_pool_filename"
26
27mkdir $mysql_datadir/pool
28
29# produce buffer pool dump
30${MYSQL} ${MYSQL_ARGS} -e "SET GLOBAL innodb_buffer_pool_dump_now=ON;"
31
32# take a backup with rsync mode
33innobackupex --rsync --no-timestamp $topdir/backup
34
35if [ -f $topdir/backup/pool/dump ] ; then
36 vlog "Buffer pool dump has been backed up"
37else
38 vlog "Buffer pool dump has not been backed up"
39 exit -1
40fi

Subscribers

People subscribed via source and target branches