Commit fe18e6b0 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-13822 mariabackup incremental prepare incorrectly sets file size.

MDEV-13310 Preparing an incremental backup twice can corrupt data
parent b731a5bc
...@@ -4413,13 +4413,20 @@ xtrabackup_apply_delta( ...@@ -4413,13 +4413,20 @@ xtrabackup_apply_delta(
if (offset_on_page == 0xFFFFFFFFUL) if (offset_on_page == 0xFFFFFFFFUL)
break; 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, success = os_file_write(IORequestWrite,
dst_path, dst_file, dst_path, dst_file, buf, off, page_size);
incremental_buffer +
page_in_buffer * page_size,
(offset_on_page <<
page_size_shift),
page_size);
if (!success) { if (!success) {
goto error; goto error;
} }
...@@ -4429,8 +4436,10 @@ xtrabackup_apply_delta( ...@@ -4429,8 +4436,10 @@ xtrabackup_apply_delta(
} }
free(incremental_buffer_base); free(incremental_buffer_base);
if (src_file != OS_FILE_CLOSED) if (src_file != OS_FILE_CLOSED) {
os_file_close(src_file); os_file_close(src_file);
os_file_delete(0,src_path);
}
if (dst_file != OS_FILE_CLOSED) if (dst_file != OS_FILE_CLOSED)
os_file_close(dst_file); os_file_close(dst_file);
return TRUE; return TRUE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment