Commit 796d03f5 authored by Vlad Lesin's avatar Vlad Lesin

Add some extra logging to catch the case when page is written with wrong offset.

parent 4b5a14d0
......@@ -199,6 +199,7 @@ wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name __attribute__((unused)),
xb_fil_cur_t *cursor)
{
ctxt->cursor = cursor;
ctxt->dst_page = 0;
return(TRUE);
}
......@@ -212,6 +213,22 @@ wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
{
xb_fil_cur_t *cursor = ctxt->cursor;
if (cursor->node->space->id != SRV_LOG_SPACE_FIRST_ID &&
fil_is_user_tablespace_id(cursor->node->space->id)) {
ulint i;
byte *page;
const ulint page_size
= cursor->page_size.physical();
for (i = 0, page = cursor->buf; i < cursor->buf_npages;
i++, page += page_size) {
if (mach_read_from_4(page + FIL_PAGE_OFFSET) != ctxt->dst_page + i)
msg("Warinig: page %u of file %s is written to wrong offset %llu",
mach_read_from_4(page + FIL_PAGE_OFFSET), cursor->node->name,
ctxt->dst_page + i);
}
}
ctxt->dst_page += cursor->buf_npages;
if (ds_write(dstfile, cursor->buf, cursor->buf_read)) {
return(FALSE);
}
......
......@@ -41,6 +41,7 @@ typedef struct {
union {
xb_wf_incremental_ctxt_t wf_incremental_ctxt;
} u;
my_off_t dst_page;
} xb_write_filt_ctxt_t;
......
......@@ -2526,12 +2526,7 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
goto skip;
}
if (!changed_page_bitmap) {
read_filter = &rf_pass_through;
}
else {
read_filter = &rf_bitmap;
}
res = xb_fil_cur_open(&cursor, read_filter, node, thread_n,max_size);
if (res == XB_FIL_CUR_SKIP) {
......@@ -4979,6 +4974,13 @@ xtrabackup_apply_delta(
}
}
if (info.space_id != SRV_LOG_SPACE_FIRST_ID &&
fil_is_user_tablespace_id(info.space_id) &&
mach_read_from_4(buf + FIL_PAGE_OFFSET) != (off/page_size))
msg("Warning: page %u of file %s is written to wrong offset %lu",
mach_read_from_4(buf + FIL_PAGE_OFFSET), dst_path,
off/page_size);
success = os_file_write(IORequestWrite,
dst_path, dst_file, buf, off, page_size);
if (success != DB_SUCCESS) {
......
......@@ -4378,10 +4378,34 @@ fil_io(
req_type.set_fil_node(node);
/*
ut_ad(!req_type.is_write()
|| page_id.space() == SRV_LOG_SPACE_FIRST_ID
|| !fil_is_user_tablespace_id(page_id.space())
|| offset == page_id.page_no() * page_size.physical());
*/
if (req_type.is_write()
&& page_id.space() != SRV_LOG_SPACE_FIRST_ID
&& fil_is_user_tablespace_id(page_id.space())
&& (offset != page_id.page_no() * page_size.physical()
|| mach_read_from_4(static_cast<const byte *>(buf) + FIL_PAGE_OFFSET)
!= page_id.page_no()
|| mach_read_from_4(static_cast<const byte *>(buf)
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID) != page_id.space())
) {
ib::error() << "Page writes at the wrong offset in file '"
<< name << "' space id: " << page_id.space()
<< "page: " << page_id.page_no()
<< " space id read from buffer: "
<< mach_read_from_4(static_cast<const byte *>(buf)
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID)
<< " page read from buffer: "
<< mach_read_from_4(static_cast<const byte *>(buf) + FIL_PAGE_OFFSET)
<<". Actual Offset should be "
<< offset * page_size.physical()
<< " but the wrong offset is " << offset;
}
/* Queue the aio request */
dberr_t err = os_aio(
......
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