Merge lp:~percona-dev/percona-xtrabackup/bugfix717300 into lp:percona-xtrabackup/2.0

Proposed by Vadim Tkachenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 223
Proposed branch: lp:~percona-dev/percona-xtrabackup/bugfix717300
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 129 lines (+107/-0)
2 files modified
innobackupex (+4/-0)
test/t/ib_incremental.sh (+103/-0)
To merge this branch: bzr merge lp:~percona-dev/percona-xtrabackup/bugfix717300
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Vadim Tkachenko Abstain
Review via email: mp+49532@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Should we have a test case for the bug? Something like ib_incremental.sh which uses innobackupex where possible and parses the InnoDB errors from the bug #713300 (since the test would succeed otherwise)?

review: Needs Fixing
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

Alexey,

I included test, please review again

review: Needs Resubmitting
Revision history for this message
Vadim Tkachenko (vadim-tk) :
review: Abstain
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Looks good to me.

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 2011-02-12 04:49:26 +0000
3+++ innobackupex 2011-02-13 19:06:56 +0000
4@@ -892,6 +892,9 @@
5 Die "\n$prefix ibbackup failed";
6 }
7
8+ # We should not create ib_logfile files if we prepare for following incremental applies
9+ # Also we do not prepare ib_logfile if we applied incremental changes
10+ if (!( ($option_redo_only) or ($option_incremental_dir))) {
11 $now = current_time();
12 print STDERR "\n$now $prefix Restarting xtrabackup with command: $cmdline\nfor creating ib_logfile*\n\n";
13 $rcode = system("$cmdline");
14@@ -899,6 +902,7 @@
15 # failure
16 Die "\n$prefix xtrabackup (2nd execution) failed";
17 }
18+ }
19 }
20
21
22
23=== added file 'test/t/ib_incremental.sh'
24--- test/t/ib_incremental.sh 1970-01-01 00:00:00 +0000
25+++ test/t/ib_incremental.sh 2011-02-13 19:06:56 +0000
26@@ -0,0 +1,103 @@
27+. inc/common.sh
28+
29+OUTFILE=results/ib_incremental_innobackupex.out
30+
31+init
32+run_mysqld --innodb_file_per_table
33+load_dbase_schema incremental_sample
34+
35+# creating my.cnf for innobackupex
36+echo "
37+[mysqld]
38+datadir=$mysql_datadir" > $topdir/my.cnf
39+
40+# Adding initial rows
41+vlog "Adding initial rows to database..."
42+numrow=100
43+count=0
44+while [ "$numrow" -gt "$count" ]
45+do
46+ ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
47+ let "count=count+1"
48+done
49+vlog "Initial rows added"
50+
51+# Full backup
52+# backup root directory
53+mkdir -p $topdir/backup
54+
55+vlog "Starting backup"
56+innobackupex --user=root --socket=$mysql_socket --defaults-file=$topdir/my.cnf $topdir/backup > $OUTFILE 2>&1 || die "innobackupex died with exit code $?"
57+full_backup_dir=`grep "innobackupex: Backup created in directory" $OUTFILE | awk -F\' '{print $2}'`
58+vlog "Full backup done to folder $full_backup_dir"
59+
60+# Changing data
61+
62+vlog "Making changes to database"
63+let "count=numrow+1"
64+let "numrow=500"
65+while [ "$numrow" -gt "$count" ]
66+do
67+ ${MYSQL} ${MYSQL_ARGS} -e "insert into test values ($count, $numrow);" incremental_sample
68+ let "count=count+1"
69+done
70+vlog "Changes done"
71+
72+# Saving the checksum of original table
73+checksum_a=`${MYSQL} ${MYSQL_ARGS} -Ns -e "checksum table test;" incremental_sample | awk '{print $2}'`
74+vlog "Table checksum is $checksum_a"
75+
76+vlog "Making incremental backup"
77+
78+echo "###############" >> $OUTFILE
79+echo "# INCREMENTAL #" >> $OUTFILE
80+echo "###############" >> $OUTFILE
81+
82+# Incremental backup
83+innobackupex --user=root --socket=$mysql_socket --defaults-file=$topdir/my.cnf --incremental --incremental-basedir=$full_backup_dir $topdir/backup >> $OUTFILE 2>&1 || die "innobackupex died with exit code $?"
84+inc_backup_dir=`grep "innobackupex: Backup created in directory" $OUTFILE | tail -n 1 | awk -F\' '{print $2}'`
85+vlog "Incremental backup done to filder $inc_backup_dir"
86+
87+vlog "Preparing backup"
88+# Prepare backup
89+echo "##############" >> $OUTFILE
90+echo "# PREPARE #1 #" >> $OUTFILE
91+echo "##############" >> $OUTFILE
92+innobackupex --defaults-file=$topdir/my.cnf --apply-log --redo-only $full_backup_dir >> $OUTFILE 2>&1 || die "innobackupex died with exit code $?"
93+vlog "Log applied to full backup"
94+echo "##############" >> $OUTFILE
95+echo "# PREPARE #2 #" >> $OUTFILE
96+echo "##############" >> $OUTFILE
97+innobackupex --defaults-file=$topdir/my.cnf --apply-log --redo-only --incremental-dir=$inc_backup_dir $full_backup_dir >> $OUTFILE 2>&1 || die "innobackupex died with exit code $?"
98+vlog "Delta applied to full backup"
99+echo "##############" >> $OUTFILE
100+echo "# PREPARE #3 #" >> $OUTFILE
101+echo "##############" >> $OUTFILE
102+innobackupex --defaults-file=$topdir/my.cnf --apply-log $full_backup_dir >> $OUTFILE 2>&1 || die "innobackupex died with exit code $?"
103+vlog "Data prepared for restore"
104+
105+# Destroying mysql data
106+stop_mysqld
107+rm -rf $mysql_datadir/*
108+vlog "Data destroyed"
109+
110+# Restore backup
111+vlog "Copying files"
112+run_cmd innobackupex --defaults-file=$topdir/my.cnf --copy-back $full_backup_dir
113+vlog "Data restored"
114+
115+run_mysqld --innodb_file_per_table
116+
117+vlog "Cheking checksums"
118+checksum_b=`${MYSQL} ${MYSQL_ARGS} -Ns -e "checksum table test;" incremental_sample | awk '{print $2}'`
119+
120+if [ $checksum_a -ne $checksum_b ]
121+then
122+ vlog "Checksums are not equal"
123+ exit -1
124+fi
125+
126+vlog "Checksums are OK"
127+
128+stop_mysqld
129+clean

Subscribers

People subscribed via source and target branches