Skip to content

Commit

Permalink
MDEV-13822 mariabackup incremental prepare incorrectly sets file size.
Browse files Browse the repository at this point in the history
MDEV-13310 Preparing an incremental backup twice can corrupt data
  • Loading branch information
vaintroub committed Oct 10, 2017
1 parent b731a5b commit fe18e6b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit fe18e6b

Please sign in to comment.