summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2017-10-08 22:05:54 +0000
committerVladislav Vaintroub <wlad@mariadb.com>2017-10-10 06:19:50 +0000
commitfe18e6b064a794f3dd84ead92cff3e831d185fdc (patch)
tree2aa574fdcbc49850839e30456e2d023f8cc843f3 /extra
parentb731a5bcf2a0c86b6e31e4a99e3c632bb39a9c53 (diff)
downloadmariadb-git-fe18e6b064a794f3dd84ead92cff3e831d185fdc.tar.gz
MDEV-13822 mariabackup incremental prepare incorrectly sets file size.
MDEV-13310 Preparing an incremental backup twice can corrupt data
Diffstat (limited to 'extra')
-rw-r--r--extra/mariabackup/xtrabackup.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 7daead2ceaf..40736709a39 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -4413,13 +4413,20 @@ xtrabackup_apply_delta(
if (offset_on_page == 0xFFFFFFFFUL)
break;
+ uchar *buf = incremental_buffer + page_in_buffer * page_size;
+ const os_offset_t off = os_offset_t(offset_on_page)*page_size;
+
+ if (off == 0) {
+ /* Read tablespace size from page 0,
+ and extend the file to specified size.*/
+ os_offset_t n_pages = mach_read_from_4(buf + FSP_HEADER_OFFSET + FSP_SIZE);
+ success = os_file_set_size(dst_path, dst_file, n_pages*page_size);
+ if (!success)
+ goto error;
+ }
+
success = os_file_write(IORequestWrite,
- dst_path, dst_file,
- incremental_buffer +
- page_in_buffer * page_size,
- (offset_on_page <<
- page_size_shift),
- page_size);
+ dst_path, dst_file, buf, off, page_size);
if (!success) {
goto error;
}
@@ -4429,8 +4436,10 @@ xtrabackup_apply_delta(
}
free(incremental_buffer_base);
- if (src_file != OS_FILE_CLOSED)
+ if (src_file != OS_FILE_CLOSED) {
os_file_close(src_file);
+ os_file_delete(0,src_path);
+ }
if (dst_file != OS_FILE_CLOSED)
os_file_close(dst_file);
return TRUE;