Merge lp:~stewart/percona-xtrabackup/bug766607-1.6 into lp:percona-xtrabackup/1.6

Proposed by Stewart Smith
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 273
Proposed branch: lp:~stewart/percona-xtrabackup/bug766607-1.6
Merge into: lp:percona-xtrabackup/1.6
Diff against target: 287 lines (+131/-53)
4 files modified
test/inc/incremental_sample-db/incremental_sample-schema.sql (+0/-35)
test/run.sh (+14/-1)
test/t/bug766607.sh (+51/-0)
xtrabackup.c (+66/-17)
To merge this branch: bzr merge lp:~stewart/percona-xtrabackup/bug766607-1.6
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+66848@code.launchpad.net

Description of the change

backport bug 766607 fix to 1.6

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

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/inc/incremental_sample-db/incremental_sample-schema.sql'
2--- test/inc/incremental_sample-db/incremental_sample-schema.sql 2010-12-09 09:37:20 +0000
3+++ test/inc/incremental_sample-db/incremental_sample-schema.sql 2011-07-05 04:23:38 +0000
4@@ -1,40 +1,5 @@
5--- MySQL dump 10.13 Distrib 5.1.51, for unknown-linux-gnu (x86_64)
6---
7--- Host: localhost Database: test
8--- ------------------------------------------------------
9--- Server version 5.1.51-rel11.5-log
10-
11-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
12-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
13-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
14-/*!40101 SET NAMES utf8 */;
15-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
16-/*!40103 SET TIME_ZONE='+00:00' */;
17-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
18-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
19-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
20-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
21-
22---
23--- Table structure for table `test`
24---
25-
26 DROP TABLE IF EXISTS `test`;
27-/*!40101 SET @saved_cs_client = @@character_set_client */;
28-/*!40101 SET character_set_client = utf8 */;
29 CREATE TABLE `test` (
30 `a` int(11) DEFAULT NULL,
31 `number` int(11) DEFAULT NULL
32 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
33-/*!40101 SET character_set_client = @saved_cs_client */;
34-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
35-
36-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
37-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
38-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
39-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
40-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
41-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
42-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
43-
44--- Dump completed on 2010-11-15 15:02:47
45
46=== modified file 'test/run.sh'
47--- test/run.sh 2011-06-29 05:35:15 +0000
48+++ test/run.sh 2011-07-05 04:23:38 +0000
49@@ -219,7 +219,20 @@
50 total_count=0
51
52 export OUTFILE="$PWD/results/setup"
53-get_version_info >>$OUTFILE 2>&1
54+if ! get_version_info
55+then
56+ echo "get_version_info failed. See $OUTFILE for details."
57+ exit -1
58+fi
59+
60+if [ -n "$XTRADB_VERSION" ]
61+then
62+ echo "Running against Percona Server $MYSQL_VERSION (XtraDB $INNODB_VERSION)" | tee -a $OUTFILE
63+else
64+ echo "Running against MySQL $MYSQL_VERSION (InnoDB $INNODB_VERSION)" | tee -a $OUTFILE
65+fi
66+echo "Using '`basename $XB_BIN`' as xtrabackup binary" | tee -a $OUTFILE
67+echo | tee -a $OUTFILE
68 kill_leftovers >>$OUTFILE 2>&1
69 clean >>$OUTFILE 2>&1
70
71
72=== added file 'test/t/bug766607.sh'
73--- test/t/bug766607.sh 1970-01-01 00:00:00 +0000
74+++ test/t/bug766607.sh 2011-07-05 04:23:38 +0000
75@@ -0,0 +1,51 @@
76+. inc/common.sh
77+
78+init
79+run_mysqld --innodb_file_per_table
80+load_dbase_schema incremental_sample
81+
82+# Full backup dir
83+mkdir -p $topdir/data/full
84+# Incremental backup dir
85+mkdir -p $topdir/data/delta
86+
87+xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/data/full
88+
89+vlog "Creating and filling a new table"
90+run_cmd $MYSQL $MYSQL_ARGS test <<EOF
91+CREATE TABLE t(a int) ENGINE=InnoDB;
92+INSERT INTO t VALUES (1), (2), (3);
93+FLUSH LOGS;
94+EOF
95+
96+stop_mysqld
97+run_mysqld --innodb_file_per_table
98+
99+vlog "Making incremental backup"
100+xtrabackup --datadir=$mysql_datadir --backup --target-dir=$topdir/data/delta --incremental-basedir=$topdir/data/full
101+
102+vlog "Preparing full backup"
103+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
104+ --target-dir=$topdir/data/full
105+
106+# The following would fail before the bugfix
107+vlog "Applying incremental delta"
108+xtrabackup --datadir=$mysql_datadir --prepare --apply-log-only \
109+ --target-dir=$topdir/data/full --incremental-dir=$topdir/data/delta
110+
111+vlog "Preparing full backup"
112+xtrabackup --datadir=$mysql_datadir --prepare --target-dir=$topdir/data/full
113+vlog "Data prepared for restore"
114+
115+stop_mysqld
116+
117+vlog "Copying files"
118+
119+cd $topdir/data/full/
120+cp -r * $mysql_datadir
121+cd $topdir
122+
123+vlog "Data restored"
124+run_mysqld --innodb_file_per_table
125+
126+run_cmd $MYSQL $MYSQL_ARGS -e "SELECT * FROM t" test
127
128=== modified file 'xtrabackup.c'
129--- xtrabackup.c 2011-06-30 02:28:49 +0000
130+++ xtrabackup.c 2011-07-05 04:23:38 +0000
131@@ -4940,7 +4940,11 @@
132 return TRUE;
133 }
134
135-static void
136+/************************************************************************
137+Applies a given .delta file to the corresponding data file.
138+@return TRUE on success */
139+static
140+ibool
141 xtrabackup_apply_delta(
142 const char* dirname, /* in: dir name of incremental */
143 const char* dbname, /* in: database name (ibdata: NULL) */
144@@ -5030,8 +5034,38 @@
145 0 /* dummy of innodb_file_data_key */,
146 #endif
147 dst_path, OS_FILE_OPEN, OS_FILE_READ_WRITE, &success);
148+
149+again:
150 if (!success) {
151- os_file_get_last_error(TRUE);
152+ ulint errcode = os_file_get_last_error(TRUE);
153+
154+ if (errcode == OS_FILE_NOT_FOUND) {
155+ fprintf(stderr, "xtrabackup: target data file %s "
156+ "is not found, creating a new one\n", dst_path);
157+ /* Create the database directory if it doesn't exist yet
158+ */
159+ if (dbname) {
160+ char dst_dir[FN_REFLEN];
161+
162+ snprintf(dst_dir, sizeof(dst_dir), "%s/%s",
163+ xtrabackup_real_target_dir, dbname);
164+ srv_normalize_path_for_win(dst_dir);
165+
166+ if (!os_file_create_directory(dst_dir, FALSE))
167+ goto error;
168+ }
169+ dst_file =
170+ os_file_create_simple_no_error_handling(
171+#if (MYSQL_VERSION_ID > 50500)
172+ 0 /* dummy of innodb_file_data_key */,
173+#endif
174+ dst_path,
175+ OS_FILE_CREATE,
176+ OS_FILE_READ_WRITE,
177+ &success);
178+ goto again;
179+ }
180+
181 fprintf(stderr,
182 "xtrabackup: error: cannot open %s\n",
183 dst_path);
184@@ -5046,7 +5080,7 @@
185 os_file_set_nocache(dst_file, dst_path, "OPEN");
186 }
187
188- printf("Applying %s ...\n", src_path);
189+ fprintf(stderr, "Applying %s ...\n", src_path);
190
191 while (!last_buffer) {
192 ulint cluster_header;
193@@ -5132,18 +5166,23 @@
194 os_file_close(src_file);
195 if (dst_file != -1)
196 os_file_close(dst_file);
197- return;
198+ return TRUE;
199
200 error:
201 if (src_file != -1)
202 os_file_close(src_file);
203 if (dst_file != -1)
204 os_file_close(dst_file);
205- fprintf(stderr, "xtrabackup: Error: xtrabackup_apply_delta() failed.\n");
206- return;
207+ fprintf(stderr, "xtrabackup: Error: xtrabackup_apply_delta(): "
208+ "failed to apply %s to %s.\n", src_path, dst_path);
209+ return FALSE;
210 }
211
212-static void
213+/************************************************************************
214+Applies all .delta files from incremental_dir to the full backup.
215+@return TRUE on success. */
216+static
217+ibool
218 xtrabackup_apply_deltas(my_bool check_newer)
219 {
220 int ret;
221@@ -5174,9 +5213,12 @@
222 && 0 == strcmp(fileinfo.name +
223 strlen(fileinfo.name) - 6,
224 ".delta")) {
225- xtrabackup_apply_delta(
226- xtrabackup_incremental_dir, NULL,
227- fileinfo.name, check_newer);
228+ if (!xtrabackup_apply_delta(
229+ xtrabackup_incremental_dir, NULL,
230+ fileinfo.name, check_newer))
231+ {
232+ return FALSE;
233+ }
234 }
235 next_file_item_1:
236 ret = fil_file_readdir_next_file(&err,
237@@ -5228,9 +5270,13 @@
238 ".delta")) {
239 /* The name ends in .delta; try opening
240 the file */
241- xtrabackup_apply_delta(
242- xtrabackup_incremental_dir, dbinfo.name,
243- fileinfo.name, check_newer);
244+ if (!xtrabackup_apply_delta(
245+ xtrabackup_incremental_dir,
246+ dbinfo.name,
247+ fileinfo.name, check_newer))
248+ {
249+ return FALSE;
250+ }
251 }
252 next_file_item_2:
253 ret = fil_file_readdir_next_file(&err,
254@@ -5248,6 +5294,7 @@
255
256 os_file_closedir(dir);
257
258+ return TRUE;
259 }
260
261 static my_bool
262@@ -5408,8 +5455,8 @@
263 if(xtrabackup_init_temp_log())
264 goto error;
265
266- if(xtrabackup_incremental)
267- xtrabackup_apply_deltas(TRUE);
268+ if(xtrabackup_incremental && !xtrabackup_apply_deltas(TRUE))
269+ goto error;
270
271 sync_close();
272 sync_initialized = FALSE;
273@@ -6097,10 +6144,12 @@
274 print_version();
275 if (xtrabackup_incremental) {
276 #ifndef INNODB_VERSION_SHORT
277- printf("incremental backup from %lu:%lu is enabled.\n",
278+ fprintf(stderr,
279+ "incremental backup from %lu:%lu is enabled.\n",
280 incremental_lsn.high, incremental_lsn.low);
281 #else
282- printf("incremental backup from %llu is enabled.\n",
283+ fprintf(stderr,
284+ "incremental backup from %llu is enabled.\n",
285 incremental_lsn);
286 #endif
287 }

Subscribers

People subscribed via source and target branches