Merge lp:~akopytov/percona-xtrabackup/bugs_665210_and_810269 into lp:percona-xtrabackup/1.6

Proposed by Alexey Kopytov
Status: Merged
Approved by: Stewart Smith
Approved revision: no longer in the source branch.
Merged at revision: 275
Proposed branch: lp:~akopytov/percona-xtrabackup/bugs_665210_and_810269
Merge into: lp:percona-xtrabackup/1.6
Diff against target: 649 lines (+318/-66)
2 files modified
patches/tar4ibd_libtar-1.2.11.patch (+236/-66)
test/t/bug810269.sh (+82/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bugs_665210_and_810269
Reviewer Review Type Date Requested Status
Stewart Smith Pending
Review via email: mp+68000@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Added copyright notice to tar4ibd_libtar-1.2.11.patch.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'patches/tar4ibd_libtar-1.2.11.patch'
--- patches/tar4ibd_libtar-1.2.11.patch 2011-05-26 03:56:57 +0000
+++ patches/tar4ibd_libtar-1.2.11.patch 2011-07-18 09:36:44 +0000
@@ -1,7 +1,40 @@
1diff -ruN a/lib/Makefile.in b/lib/Makefile.in1# (c) 2009 - 2011 Percona Inc.
2--- a/lib/Makefile.in 2011-05-25 16:46:41.000000000 +04002#
3+++ b/lib/Makefile.in 2011-05-25 16:47:54.000000000 +04003# This program is free software; you can redistribute it and/or modify
4@@ -29,7 +29,7 @@4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; version 2 of the License.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program; if not, write to the Free Software
14# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15#
16# This patch incorporates code covered by the following copyright and
17# permission notice:
18#
19# Copyright (c) 1995, 2010, Innobase Oy. All Rights Reserved.
20#
21# This program is free software; you can redistribute it and/or modify it under
22# the terms of the GNU General Public License as published by the Free Software
23# Foundation; version 2 of the License.
24#
25# This program is distributed in the hope that it will be useful, but WITHOUT
26# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
28#
29# You should have received a copy of the GNU General Public License along with
30# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
31# Place, Suite 330, Boston, MA 02111-1307 USA
32#
33#
34diff -ruN libtar-1.2.11.orig/lib/Makefile.in libtar-1.2.11/lib/Makefile.in
35--- libtar-1.2.11.orig/lib/Makefile.in 2011-07-14 13:27:10.000000000 +0400
36+++ libtar-1.2.11/lib/Makefile.in 2011-07-14 13:27:37.000000000 +0400
37@@ -29,7 +29,7 @@ CPPFLAGS = -I. \
5 -I${top_srcdir}/compat \38 -I${top_srcdir}/compat \
6 -I../listhash \39 -I../listhash \
7 @CPPFLAGS@40 @CPPFLAGS@
@@ -10,13 +43,19 @@
10 LDFLAGS = @LDFLAGS@43 LDFLAGS = @LDFLAGS@
11 LIBS = @LIBS@44 LIBS = @LIBS@
12 LIBOBJS = @LIBOBJS@45 LIBOBJS = @LIBOBJS@
13diff -ruN a/lib/append.c b/lib/append.c46diff -ruN libtar-1.2.11.orig/lib/append.c libtar-1.2.11/lib/append.c
14--- a/lib/append.c 2011-05-25 16:46:41.000000000 +040047--- libtar-1.2.11.orig/lib/append.c 2011-07-14 13:27:10.000000000 +0400
15+++ b/lib/append.c 2011-05-25 17:42:25.000000000 +040048+++ libtar-1.2.11/lib/append.c 2011-07-14 18:37:57.000000000 +0400
16@@ -27,6 +27,218 @@49@@ -27,6 +27,327 @@
17 # include <unistd.h>50 # include <unistd.h>
18 #endif51 #endif
19 52
53+#ifdef HAVE_LIBZ
54+#include <zlib.h>
55+#else
56+#error "zlib not found"
57+#endif
58+
20+#ifdef POSIX_FADV_NORMAL59+#ifdef POSIX_FADV_NORMAL
21+#define USE_POSIX_FADVISE60+#define USE_POSIX_FADVISE
22+#endif61+#endif
@@ -24,15 +63,26 @@
24+/* all of these ripped from InnoDB code from MySQL 4.0.22 */63+/* all of these ripped from InnoDB code from MySQL 4.0.22 */
25+#define UT_HASH_RANDOM_MASK 146373568764+#define UT_HASH_RANDOM_MASK 1463735687
26+#define UT_HASH_RANDOM_MASK2 165389371165+#define UT_HASH_RANDOM_MASK2 1653893711
27+#define FIL_PAGE_LSN 16 66+#define FIL_PAGE_LSN 16
28+#define FIL_PAGE_FILE_FLUSH_LSN 2667+#define FIL_PAGE_FILE_FLUSH_LSN 26
29+#define FIL_PAGE_OFFSET 468+#define FIL_PAGE_OFFSET 4
30+#define FIL_PAGE_DATA 3869+#define FIL_PAGE_DATA 38
31+#define FIL_PAGE_DATA_ALIGN_32 4070+#define FIL_PAGE_DATA_ALIGN_32 40
32+#define FIL_PAGE_END_LSN_OLD_CHKSUM 871+#define FIL_PAGE_END_LSN_OLD_CHKSUM 8
33+#define FIL_PAGE_SPACE_OR_CHKSUM 072+#define FIL_PAGE_SPACE_OR_CHKSUM 0
34+//#define UNIV_PAGE_SIZE (2 * 8192)
35+#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL73+#define BUF_NO_CHECKSUM_MAGIC 0xDEADBEEFUL
74+#define FSP_EXTENT_SIZE 64
75+#define FSP_HEADER_OFFSET FIL_PAGE_DATA
76+#define FSP_SPACE_FLAGS 16 /* table->flags & ~DICT_TF_COMPACT */
77+#define DICT_TF_ZSSIZE_SHIFT 1
78+#define DICT_TF_ZSSIZE_MASK (15 << DICT_TF_ZSSIZE_SHIFT)
79+#define PAGE_ZIP_MIN_SIZE_SHIFT 10
80+#define PAGE_ZIP_MIN_SIZE (1 << PAGE_ZIP_MIN_SIZE_SHIFT)
81+#define UNIV_PAGE_SIZE (2 * 8192)
82+#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this
83+ contains the space id of the page */
84+#define FIL_PAGE_TYPE 24 /* file page type: FIL_PAGE_INDEX,...,
85+ 2 bytes.
36+86+
37+/* defined in libtar.c. if 1, O_DIRECT will be used for input files */87+/* defined in libtar.c. if 1, O_DIRECT will be used for input files */
38+extern int use_direct;88+extern int use_direct;
@@ -136,6 +186,87 @@
136+}186+}
137+187+
138+ulint188+ulint
189+fsp_header_get_flags(
190+/*=================*/
191+ byte* page) /*!< in: first page of a tablespace */
192+{
193+ return(mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page));
194+}
195+
196+ulint
197+dict_table_flags_to_zip_size(
198+/*=========================*/
199+ ulint flags) /*!< in: flags */
200+{
201+ ulint zip_size = flags & DICT_TF_ZSSIZE_MASK;
202+
203+ if (zip_size) {
204+ zip_size = ((PAGE_ZIP_MIN_SIZE >> 1)
205+ << (zip_size >> DICT_TF_ZSSIZE_SHIFT));
206+ }
207+
208+ return(zip_size);
209+}
210+
211+int
212+fil_fd_get_zip_size(
213+/*===================*/
214+ int fd)
215+{
216+ ulint flags;
217+ byte buf[UNIV_PAGE_SIZE * 2];
218+ byte *page = (byte *) (((unsigned long) buf + UNIV_PAGE_SIZE - 1) &
219+ ~(UNIV_PAGE_SIZE - 1));
220+
221+ if(pread(fd, page, UNIV_PAGE_SIZE, 0) != UNIV_PAGE_SIZE)
222+ return -1;
223+
224+ flags = fsp_header_get_flags(page);
225+
226+ if (flags && flags != (ulint)-1) {
227+ return(dict_table_flags_to_zip_size(flags));
228+ }
229+
230+ return(flags);
231+}
232+
233+ulint
234+fil_fd_get_space_id(
235+/*===================*/
236+ int fd)
237+{
238+ byte buf[UNIV_PAGE_SIZE * 2];
239+ byte *page = (byte *) (((unsigned long) buf + UNIV_PAGE_SIZE - 1) &
240+ ~(UNIV_PAGE_SIZE - 1));
241+
242+ if(pread(fd, page, UNIV_PAGE_SIZE, 0) != UNIV_PAGE_SIZE)
243+ return -1;
244+
245+ return(mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
246+}
247+
248+ulint
249+page_zip_calc_checksum(
250+/*===================*/
251+ const void* data, /*!< in: compressed page */
252+ ulint size) /*!< in: size of compressed page */
253+{
254+ /* Exclude FIL_PAGE_SPACE_OR_CHKSUM, FIL_PAGE_LSN,
255+ and FIL_PAGE_FILE_FLUSH_LSN from the checksum. */
256+
257+ const Bytef* s = data;
258+ uLong adler;
259+
260+ adler = adler32(0L, s + FIL_PAGE_OFFSET,
261+ FIL_PAGE_LSN - FIL_PAGE_OFFSET);
262+ adler = adler32(adler, s + FIL_PAGE_TYPE, 2);
263+ adler = adler32(adler, s + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID,
264+ size - FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
265+
266+ return((ulint) adler);
267+}
268+
269+ulint
139+buf_calc_page_new_checksum_32(270+buf_calc_page_new_checksum_32(
140+/*==========================*/271+/*==========================*/
141+ byte* page,272+ byte* page,
@@ -175,15 +306,17 @@
175+/*==================*/306+/*==================*/
176+ /* out: TRUE if corrupted */307+ /* out: TRUE if corrupted */
177+ byte* read_buf, /* in: a database page */308+ byte* read_buf, /* in: a database page */
178+ ulint page_size)309+ ulint page_size,
310+ ulint zip_size)
179+{311+{
180+ ulint checksum;312+ ulint checksum;
181+ ulint old_checksum;313+ ulint old_checksum;
182+ ulint checksum_field;314+ ulint checksum_field;
183+ ulint old_checksum_field;315+ ulint old_checksum_field;
184+316+
185+ if (mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)317+ if (!zip_size &&
186+ != mach_read_from_4(read_buf + page_size318+ mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)
319+ != mach_read_from_4(read_buf + page_size
187+ - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {320+ - FIL_PAGE_END_LSN_OLD_CHKSUM + 4)) {
188+321+
189+ /* Stored log sequence numbers at the start and the end322+ /* Stored log sequence numbers at the start and the end
@@ -195,18 +328,27 @@
195+ /* If we use checksums validation, make additional check before returning328+ /* If we use checksums validation, make additional check before returning
196+ TRUE to ensure that the checksum is not equal to BUF_NO_CHECKSUM_MAGIC which329+ TRUE to ensure that the checksum is not equal to BUF_NO_CHECKSUM_MAGIC which
197+ might be stored by InnoDB with checksums disabled.330+ might be stored by InnoDB with checksums disabled.
198+ Otherwise, skip checksum calculation and return FALSE */331+ Otherwise, skip checksum calculation and return FALSE */
199+ 332+
200+ old_checksum = buf_calc_page_old_checksum(read_buf); 333+ checksum_field = mach_read_from_4(read_buf +
201+334+ FIL_PAGE_SPACE_OR_CHKSUM);
202+ old_checksum_field = mach_read_from_4(read_buf + page_size335+
203+ - FIL_PAGE_END_LSN_OLD_CHKSUM);336+ if (zip_size) {
337+ return(checksum_field != BUF_NO_CHECKSUM_MAGIC
338+ && checksum_field
339+ != page_zip_calc_checksum(read_buf, zip_size));
340+ }
341+
342+ old_checksum = buf_calc_page_old_checksum(read_buf);
343+
344+ old_checksum_field = mach_read_from_4(read_buf + page_size
345+ - FIL_PAGE_END_LSN_OLD_CHKSUM);
204+346+
205+ /* There are 2 valid formulas for old_checksum_field:347+ /* There are 2 valid formulas for old_checksum_field:
206+ 1. Very old versions of InnoDB only stored 8 byte lsn to the start348+ 1. Very old versions of InnoDB only stored 8 byte lsn to the start
207+ and the end of the page.349+ and the end of the page.
208+ 2. Newer InnoDB versions store the old formula checksum there. */350+ 2. Newer InnoDB versions store the old formula checksum there. */
209+ 351+
210+ if (old_checksum_field != mach_read_from_4(read_buf + FIL_PAGE_LSN)352+ if (old_checksum_field != mach_read_from_4(read_buf + FIL_PAGE_LSN)
211+ && old_checksum_field != old_checksum353+ && old_checksum_field != old_checksum
212+ && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {354+ && old_checksum_field != BUF_NO_CHECKSUM_MAGIC) {
@@ -226,13 +368,13 @@
226+368+
227+ return(1);369+ return(1);
228+ }370+ }
229+ 371+
230+ return(0);372+ return(0);
231+}373+}
232 374
233 struct tar_dev375 struct tar_dev
234 {376 {
235@@ -69,7 +281,7 @@377@@ -69,7 +390,7 @@ tar_append_file(TAR *t, char *realname,
236 (savename ? savename : "[NULL]"));378 (savename ? savename : "[NULL]"));
237 #endif379 #endif
238 380
@@ -241,7 +383,7 @@
241 {383 {
242 #ifdef DEBUG384 #ifdef DEBUG
243 perror("lstat()");385 perror("lstat()");
244@@ -210,11 +422,14 @@386@@ -210,11 +531,17 @@ tar_append_eof(TAR *t)
245 int387 int
246 tar_append_regfile(TAR *t, char *realname)388 tar_append_regfile(TAR *t, char *realname)
247 {389 {
@@ -252,14 +394,17 @@
252- int i, j;394- int i, j;
253- size_t size;395- size_t size;
254+ int j, k, n_retry;396+ int j, k, n_retry;
255+ size_t i, size;397+ long long i, size, offset;
256+ int page_size = 4 * 1024; /* check 4K, 8K and 16K */398+ int page_size = 1 * 1024; /* check 1K, 2K, 4K, 8K and 16K */
399+ int page_size_shift = 10;
400+ int zip_size;
401+ int is_sys_space;
257 402
258+ block = (unsigned char *)(((unsigned long) buf + 16384 - 1) & ~(16384 - 1));403+ block = (unsigned char *)(((unsigned long) buf + 16384 - 1) & ~(16384 - 1));
259 filefd = open(realname, O_RDONLY);404 filefd = open(realname, O_RDONLY);
260 if (filefd == -1)405 if (filefd == -1)
261 {406 {
262@@ -224,28 +439,66 @@407@@ -224,27 +551,93 @@ tar_append_regfile(TAR *t, char *realnam
263 return -1;408 return -1;
264 }409 }
265 410
@@ -273,10 +418,23 @@
273+ fcntl(filefd, F_SETFL, O_DIRECT);418+ fcntl(filefd, F_SETFL, O_DIRECT);
274+#endif419+#endif
275+420+
421+ zip_size = fil_fd_get_zip_size(filefd);
422+ if (zip_size == -1) {
423+ fprintf(stderr,
424+ "tar4ibd: file '%s' has invalid zip_size value.\n",
425+ realname);
426+ return(-1);
427+ } else if (zip_size != 0) {
428+ page_size = zip_size;
429+ }
430+
431+ is_sys_space = (fil_fd_get_space_id(filefd) == 0);
432+
276+ n_retry = 0;433+ n_retry = 0;
277 size = th_get_size(t);434 size = th_get_size(t);
278- for (i = size; i > T_BLOCKSIZE; i -= T_BLOCKSIZE)435- for (i = size; i > T_BLOCKSIZE; i -= T_BLOCKSIZE)
279+ for (i = size; i >= page_size; i -= page_size)436+ for (i = size, offset = 0; i >= page_size;
437+ i -= page_size, offset += page_size)
280 {438 {
281- j = read(filefd, &block, T_BLOCKSIZE);439- j = read(filefd, &block, T_BLOCKSIZE);
282- if (j != T_BLOCKSIZE)440- if (j != T_BLOCKSIZE)
@@ -288,8 +446,19 @@
288 return -1;446 return -1;
289 }447 }
290- if (tar_block_write(t, &block) == -1)448- if (tar_block_write(t, &block) == -1)
291- return -1;449+ if (buf_page_is_corrupted(block, (ulint)page_size,
292+ if (buf_page_is_corrupted(block, (ulint)page_size)) {450+ (ulint)zip_size)) {
451+ ulint page_no = (unsigned long)
452+ (offset >> page_size_shift);
453+ if (is_sys_space &&
454+ page_no >= FSP_EXTENT_SIZE &&
455+ page_no < FSP_EXTENT_SIZE * 3) {
456+ fprintf(stderr, "tar4ibd: page %lu seems to "
457+ "be from the doublewrite buffer. "
458+ "skipping checksum validation.\n",
459+ page_no);
460+ goto write_page;
461+ }
293+ if (n_retry > 9) {462+ if (n_retry > 9) {
294+ fprintf(stderr,463+ fprintf(stderr,
295+"The file '%s' may not be InnoDB datafile or may be corrupted.\n",464+"The file '%s' may not be InnoDB datafile or may be corrupted.\n",
@@ -302,20 +471,23 @@
302+ if (lseek(filefd, - page_size, SEEK_CUR) == -1)471+ if (lseek(filefd, - page_size, SEEK_CUR) == -1)
303+ return -1;472+ return -1;
304+473+
305+ if (i == size474+ if (i == size && !zip_size
306+ && page_size < 16 * 1024) {475+ && page_size < 16 * 1024) {
307+ page_size *= 2;476+ page_size *= 2;
477+ page_size_shift++;
308+ } else {478+ } else {
309+ n_retry++;479+ n_retry++;
310+ }480+ }
311+481+
312+ i += page_size;482+ i += page_size;
483+ offset -= page_size;
313+484+
314+ continue;485+ continue;
315+ }486+ }
487+write_page:
316+ for (k = 0; k < page_size / T_BLOCKSIZE; k++)488+ for (k = 0; k < page_size / T_BLOCKSIZE; k++)
317+ if (tar_block_write(t, &block[T_BLOCKSIZE * k]) == -1)489+ if (tar_block_write(t, &block[T_BLOCKSIZE * k]) == -1)
318+ return -1;490 return -1;
319+ n_retry = 0;491+ n_retry = 0;
320 }492 }
321 493
@@ -327,18 +499,16 @@
327 return -1;499 return -1;
328- memset(&(block[i]), 0, T_BLOCKSIZE - i);500- memset(&(block[i]), 0, T_BLOCKSIZE - i);
329- if (tar_block_write(t, &block) == -1)501- if (tar_block_write(t, &block) == -1)
330- return -1;
331+ memset(&(block[i]), 0, T_BLOCKSIZE * 32 - i);502+ memset(&(block[i]), 0, T_BLOCKSIZE * 32 - i);
332+ for (k = 0; k < ((j - 1) / T_BLOCKSIZE + 1); k++)503+ for (k = 0; k < ((j - 1) / T_BLOCKSIZE + 1); k++)
333+ if (tar_block_write(t, &block[T_BLOCKSIZE * k]) == -1)504+ if (tar_block_write(t, &block[T_BLOCKSIZE * k]) == -1)
334+ return -1;505 return -1;
335 }506 }
336 507
337 close(filefd);508diff -ruN libtar-1.2.11.orig/lib/extract.c libtar-1.2.11/lib/extract.c
338diff -ruN a/lib/extract.c b/lib/extract.c509--- libtar-1.2.11.orig/lib/extract.c 2011-07-14 13:27:10.000000000 +0400
339--- a/lib/extract.c 2011-05-25 16:46:41.000000000 +0400510+++ libtar-1.2.11/lib/extract.c 2011-07-14 13:27:37.000000000 +0400
340+++ b/lib/extract.c 2011-05-25 16:47:54.000000000 +0400511@@ -158,11 +158,11 @@ int
341@@ -158,11 +158,11 @@
342 tar_extract_regfile(TAR *t, char *realname)512 tar_extract_regfile(TAR *t, char *realname)
343 {513 {
344 mode_t mode;514 mode_t mode;
@@ -352,10 +522,10 @@
352 char buf[T_BLOCKSIZE];522 char buf[T_BLOCKSIZE];
353 char *filename;523 char *filename;
354 524
355diff -ruN a/lib/libtar.h b/lib/libtar.h525diff -ruN libtar-1.2.11.orig/lib/libtar.h libtar-1.2.11/lib/libtar.h
356--- a/lib/libtar.h 2011-05-25 16:46:41.000000000 +0400526--- libtar-1.2.11.orig/lib/libtar.h 2011-07-14 13:27:10.000000000 +0400
357+++ b/lib/libtar.h 2011-05-25 16:47:54.000000000 +0400527+++ libtar-1.2.11/lib/libtar.h 2011-07-14 13:27:37.000000000 +0400
358@@ -180,7 +180,7 @@528@@ -180,7 +180,7 @@ int th_write(TAR *t);
359 529
360 /* decode tar header info */530 /* decode tar header info */
361 #define th_get_crc(t) oct_to_int((t)->th_buf.chksum)531 #define th_get_crc(t) oct_to_int((t)->th_buf.chksum)
@@ -364,7 +534,7 @@
364 #define th_get_mtime(t) oct_to_int((t)->th_buf.mtime)534 #define th_get_mtime(t) oct_to_int((t)->th_buf.mtime)
365 #define th_get_devmajor(t) oct_to_int((t)->th_buf.devmajor)535 #define th_get_devmajor(t) oct_to_int((t)->th_buf.devmajor)
366 #define th_get_devminor(t) oct_to_int((t)->th_buf.devminor)536 #define th_get_devminor(t) oct_to_int((t)->th_buf.devminor)
367@@ -204,9 +204,9 @@537@@ -204,9 +204,9 @@ void th_set_user(TAR *t, uid_t uid);
368 void th_set_group(TAR *t, gid_t gid);538 void th_set_group(TAR *t, gid_t gid);
369 void th_set_mode(TAR *t, mode_t fmode);539 void th_set_mode(TAR *t, mode_t fmode);
370 #define th_set_mtime(t, fmtime) \540 #define th_set_mtime(t, fmtime) \
@@ -376,7 +546,7 @@
376 546
377 /* encode everything at once (except the pathname and linkname) */547 /* encode everything at once (except the pathname and linkname) */
378 void th_set_from_stat(TAR *t, struct stat *s);548 void th_set_from_stat(TAR *t, struct stat *s);
379@@ -268,13 +268,16 @@549@@ -268,13 +268,16 @@ int th_crc_calc(TAR *t);
380 550
381 /* string-octal to integer conversion */551 /* string-octal to integer conversion */
382 int oct_to_int(char *oct);552 int oct_to_int(char *oct);
@@ -394,10 +564,10 @@
394 564
395 565
396 /***** wrapper.c **********************************************************/566 /***** wrapper.c **********************************************************/
397diff -ruN a/lib/util.c b/lib/util.c567diff -ruN libtar-1.2.11.orig/lib/util.c libtar-1.2.11/lib/util.c
398--- a/lib/util.c 2011-05-25 16:46:41.000000000 +0400568--- libtar-1.2.11.orig/lib/util.c 2011-07-14 13:27:10.000000000 +0400
399+++ b/lib/util.c 2011-05-25 16:47:54.000000000 +0400569+++ libtar-1.2.11/lib/util.c 2011-07-14 13:27:37.000000000 +0400
400@@ -138,6 +138,14 @@570@@ -138,6 +138,14 @@ oct_to_int(char *oct)
401 return i;571 return i;
402 }572 }
403 573
@@ -412,7 +582,7 @@
412 582
413 /* integer to string-octal conversion, no NULL */583 /* integer to string-octal conversion, no NULL */
414 void584 void
415@@ -147,4 +155,46 @@585@@ -147,4 +155,46 @@ int_to_oct_nonull(int num, char *oct, si
416 oct[octlen - 1] = ' ';586 oct[octlen - 1] = ' ';
417 }587 }
418 588
@@ -459,10 +629,10 @@
459+ }629+ }
460+ return i;630+ return i;
461+}631+}
462diff -ruN a/libtar/Makefile.in b/libtar/Makefile.in632diff -ruN libtar-1.2.11.orig/libtar/Makefile.in libtar-1.2.11/libtar/Makefile.in
463--- a/libtar/Makefile.in 2011-05-25 16:46:41.000000000 +0400633--- libtar-1.2.11.orig/libtar/Makefile.in 2011-07-14 13:27:10.000000000 +0400
464+++ b/libtar/Makefile.in 2011-05-25 16:47:54.000000000 +0400634+++ libtar-1.2.11/libtar/Makefile.in 2011-07-14 13:27:37.000000000 +0400
465@@ -29,7 +29,7 @@635@@ -29,7 +29,7 @@ CPPFLAGS = -I.. \
466 -I${top_srcdir}/lib \636 -I${top_srcdir}/lib \
467 -I${top_srcdir}/compat \637 -I${top_srcdir}/compat \
468 @CPPFLAGS@638 @CPPFLAGS@
@@ -471,7 +641,7 @@
471 LDFLAGS = @LDFLAGS@641 LDFLAGS = @LDFLAGS@
472 LIBS = @LIBS@642 LIBS = @LIBS@
473 LIBOBJS = @LIBOBJS@643 LIBOBJS = @LIBOBJS@
474@@ -46,15 +46,15 @@644@@ -46,15 +46,15 @@ LIBTAR_HDRS = ../config.h \
475 ${top_srcdir}/lib/libtar.h \645 ${top_srcdir}/lib/libtar.h \
476 ../listhash/libtar_listhash.h646 ../listhash/libtar_listhash.h
477 LIBTAR_LIBS = ../lib/libtar.a647 LIBTAR_LIBS = ../lib/libtar.a
@@ -490,16 +660,16 @@
490 660
491 ${LIBTAR_OBJS}: ${LIBTAR_HDRS}661 ${LIBTAR_OBJS}: ${LIBTAR_HDRS}
492 662
493@@ -69,5 +69,5 @@663@@ -69,5 +69,5 @@ distclean: clean
494 664
495 install: ${ALL}665 install: ${ALL}
496 ${MKDIR} ${DESTDIR}${bindir}666 ${MKDIR} ${DESTDIR}${bindir}
497- ${INSTALL_PROGRAM} libtar ${DESTDIR}${bindir}667- ${INSTALL_PROGRAM} libtar ${DESTDIR}${bindir}
498+ ${INSTALL_PROGRAM} tar4ibd ${DESTDIR}${bindir}668+ ${INSTALL_PROGRAM} tar4ibd ${DESTDIR}${bindir}
499 669
500diff -ruN a/libtar/libtar.c b/libtar/libtar.c670diff -ruN libtar-1.2.11.orig/libtar/libtar.c libtar-1.2.11/libtar/libtar.c
501--- a/libtar/libtar.c 2011-05-25 16:46:41.000000000 +0400671--- libtar-1.2.11.orig/libtar/libtar.c 2011-07-14 13:27:10.000000000 +0400
502+++ b/libtar/libtar.c 2011-05-25 16:47:54.000000000 +0400672+++ libtar-1.2.11/libtar/libtar.c 2011-07-14 17:22:13.000000000 +0400
503@@ -14,6 +14,7 @@673@@ -14,6 +14,7 @@
504 #include <libtar.h>674 #include <libtar.h>
505 675
@@ -516,7 +686,7 @@
516 686
517 #ifdef DEBUG687 #ifdef DEBUG
518 void688 void
519@@ -109,7 +111,7 @@689@@ -109,7 +111,7 @@ create(char *tarfile, char *rootdir, lib
520 char buf[MAXPATHLEN];690 char buf[MAXPATHLEN];
521 libtar_listptr_t lp;691 libtar_listptr_t lp;
522 692
@@ -525,7 +695,7 @@
525 #ifdef HAVE_LIBZ695 #ifdef HAVE_LIBZ
526 (use_zlib ? &gztype : NULL),696 (use_zlib ? &gztype : NULL),
527 #else697 #else
528@@ -164,7 +166,7 @@698@@ -164,7 +166,7 @@ list(char *tarfile)
529 TAR *t;699 TAR *t;
530 int i;700 int i;
531 701
@@ -534,7 +704,7 @@
534 #ifdef HAVE_LIBZ704 #ifdef HAVE_LIBZ
535 (use_zlib ? &gztype : NULL),705 (use_zlib ? &gztype : NULL),
536 #else706 #else
537@@ -225,7 +227,7 @@707@@ -225,7 +227,7 @@ extract(char *tarfile, char *rootdir)
538 #ifdef DEBUG708 #ifdef DEBUG
539 puts("opening tarfile...");709 puts("opening tarfile...");
540 #endif710 #endif
@@ -543,7 +713,7 @@
543 #ifdef HAVE_LIBZ713 #ifdef HAVE_LIBZ
544 (use_zlib ? &gztype : NULL),714 (use_zlib ? &gztype : NULL),
545 #else715 #else
546@@ -264,9 +266,9 @@716@@ -264,9 +266,9 @@ extract(char *tarfile, char *rootdir)
547 void717 void
548 usage()718 usage()
549 {719 {
@@ -555,7 +725,7 @@
555 progname);725 progname);
556 exit(-1);726 exit(-1);
557 }727 }
558@@ -287,7 +289,7 @@728@@ -287,7 +289,7 @@ main(int argc, char *argv[])
559 729
560 progname = basename(argv[0]);730 progname = basename(argv[0]);
561 731
@@ -564,7 +734,7 @@
564 switch (c)734 switch (c)
565 {735 {
566 case 'V':736 case 'V':
567@@ -323,11 +325,21 @@737@@ -323,11 +325,21 @@ main(int argc, char *argv[])
568 use_zlib = 1;738 use_zlib = 1;
569 break;739 break;
570 #endif /* HAVE_LIBZ */740 #endif /* HAVE_LIBZ */
@@ -577,7 +747,7 @@
577+ use_direct = 1;747+ use_direct = 1;
578+ break;748+ break;
579+#endif749+#endif
580+ 750+
581 default:751 default:
582 usage();752 usage();
583 }753 }
@@ -587,7 +757,7 @@
587 {757 {
588 #ifdef DEBUG758 #ifdef DEBUG
589 printf("argc - optind == %d\tmode == %d\n", argc - optind,759 printf("argc - optind == %d\tmode == %d\n", argc - optind,
590@@ -343,15 +355,14 @@760@@ -343,15 +355,14 @@ main(int argc, char *argv[])
591 switch (mode)761 switch (mode)
592 {762 {
593 case MODE_EXTRACT:763 case MODE_EXTRACT:
594764
=== added file 'test/t/bug810269.sh'
--- test/t/bug810269.sh 1970-01-01 00:00:00 +0000
+++ test/t/bug810269.sh 2011-07-18 09:36:44 +0000
@@ -0,0 +1,82 @@
1########################################################################
2# Bug #665210: tar4ibd does not support innodb row_format=compressed
3# Bug #810269: tar4ibd does not check for doublewrite buffer pages
4########################################################################
5
6. inc/common.sh
7
8init
9
10if [ -z "$INNODB_VERSION" ]; then
11 echo "Requires InnoDB plugin or XtraDB" >$SKIPPED_REASON
12 exit $SKIPPED_EXIT_CODE
13fi
14
15run_mysqld "--innodb_strict_mode --innodb_file_per_table \
16--innodb_file_format=Barracuda"
17
18load_dbase_schema incremental_sample
19
20vlog "Compressing the table"
21
22run_cmd $MYSQL $MYSQL_ARGS -e \
23 "ALTER TABLE test ENGINE=InnoDB ROW_FORMAT=compressed \
24KEY_BLOCK_SIZE=4" incremental_sample
25
26vlog "Adding initial rows to table"
27
28numrow=10000
29count=0
30while [ "$numrow" -gt "$count" ]; do
31 sql="INSERT INTO test VALUES ($count, $numrow)"
32 let "count=count+1"
33 for ((i=0; $i<99; i++)); do
34 sql="$sql,($count, $numrow)"
35 let "count=count+1"
36 done
37 ${MYSQL} ${MYSQL_ARGS} -e "$sql" incremental_sample
38done
39
40rows=`${MYSQL} ${MYSQL_ARGS} -Ns -e "SELECT COUNT(*) FROM test" \
41 incremental_sample`
42if [ "$rows" != "10000" ]; then
43 vlog "Failed to add initial rows"
44 exit -1
45fi
46
47vlog "Initial rows added"
48
49checksum_a=`${MYSQL} ${MYSQL_ARGS} -Ns -e "checksum table test;" \
50incremental_sample | awk '{print $2}'`
51
52vlog "Starting streaming backup"
53
54mkdir -p $topdir/backup
55
56innobackupex --stream=tar $topdir/backup > $topdir/backup/out.tar
57
58stop_mysqld
59rm -rf $mysql_datadir
60
61vlog "Applying log"
62
63cd $topdir/backup
64$TAR -ixvf out.tar
65cd -
66innobackupex --apply-log $topdir/backup
67
68vlog "Restoring MySQL datadir"
69mkdir -p $mysql_datadir
70innobackupex --copy-back $topdir/backup
71
72run_mysqld
73
74checksum_b=`${MYSQL} ${MYSQL_ARGS} -Ns -e "checksum table test;" \
75incremental_sample | awk '{print $2}'`
76
77if [ "$checksum_a" != "$checksum_b" ]; then
78 vlog "Checksums do not match"
79 exit -1
80fi
81
82vlog "Checksums are OK"

Subscribers

People subscribed via source and target branches