Commit 66ae518a authored by Vlad Lesin's avatar Vlad Lesin

Some debug code

parent 00f0c039
...@@ -203,6 +203,15 @@ wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name __attribute__((unused)), ...@@ -203,6 +203,15 @@ wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name __attribute__((unused)),
return(TRUE); return(TRUE);
} }
extern
bool
fil_space_verify_crypt_checksum(
byte* page,
const page_size_t& page_size,
ulint space,
ulint offset);
/************************************************************************ /************************************************************************
Write the next batch of pages to the destination datasink. Write the next batch of pages to the destination datasink.
...@@ -212,6 +221,37 @@ wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile) ...@@ -212,6 +221,37 @@ wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
{ {
xb_fil_cur_t *cursor = ctxt->cursor; xb_fil_cur_t *cursor = ctxt->cursor;
page_size_t page_size_size(cursor->node->space->flags);
if (cursor->node->space->id != SRV_LOG_SPACE_FIRST_ID &&
!page_size_size.is_compressed() &&
// !FSP_FLAGS_GET_ZIP_SSIZE(cursor->node->space->flags) &&
!FSP_FLAGS_HAS_PAGE_COMPRESSION(cursor->node->space->flags) &&
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 (
!fil_space_verify_crypt_checksum(
page,
page_size_size,
cursor->node->space->id,
mach_read_from_4(page + FIL_PAGE_OFFSET))
&& mach_read_from_4(page + FIL_PAGE_LSN + 4) !=
mach_read_from_4(page
+ UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4))
msg("Warning: page %u of file %s, the LSN at the start %u "
"does match LSN at the end %u",
mach_read_from_4(page + FIL_PAGE_OFFSET),
cursor->node->name,
mach_read_from_4(page + FIL_PAGE_LSN + 4),
mach_read_from_4(page +
UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4));
}
}
if (ds_write(dstfile, cursor->buf, cursor->buf_read)) { if (ds_write(dstfile, cursor->buf, cursor->buf_read)) {
return(FALSE); return(FALSE);
} }
......
...@@ -4438,13 +4438,35 @@ xtrabackup_apply_delta( ...@@ -4438,13 +4438,35 @@ xtrabackup_apply_delta(
} }
} }
success = os_file_write(IORequestWrite,
dst_path, dst_file, buf, off, page_size);
if (!success) { fil_space_t* space = fil_space_acquire(info.space_id);
goto error; if (space) {
page_size_t page_size_size(space->flags);
if (info.space_id != SRV_LOG_SPACE_FIRST_ID
&& fil_is_user_tablespace_id(info.space_id)
&& !FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags)
&& !page_size_size.is_compressed()
&& !fil_space_verify_crypt_checksum(
buf, page_size_size, info.space_id, mach_read_from_4(buf + FIL_PAGE_OFFSET))
&&
(mach_read_from_4(buf + FIL_PAGE_LSN + 4) !=
mach_read_from_4(buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4))
)
msg("Warning: the LSN at the start %u does match LSN at the end %u "
"for tablespace %s",
mach_read_from_4(buf + FIL_PAGE_LSN + 4),
mach_read_from_4(buf +
UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4),
filename);
success = os_file_write(IORequestWrite,
dst_path, dst_file, buf, off, page_size);
if (!success) {
goto error;
}
} }
} }
incremental_buffers++; incremental_buffers++;
} }
......
...@@ -2529,7 +2529,7 @@ encrypted, or corrupted. ...@@ -2529,7 +2529,7 @@ encrypted, or corrupted.
@param[in] space tablespace identifier @param[in] space tablespace identifier
@param[in] offset page number @param[in] offset page number
@return true if page is encrypted AND OK, false otherwise */ @return true if page is encrypted AND OK, false otherwise */
UNIV_INTERN //UNIV_INTERN
bool bool
fil_space_verify_crypt_checksum( fil_space_verify_crypt_checksum(
byte* page, byte* page,
......
...@@ -5017,6 +5017,14 @@ fil_report_invalid_page_access( ...@@ -5017,6 +5017,14 @@ fil_report_invalid_page_access(
: ""); : "");
} }
extern
bool
fil_space_verify_crypt_checksum(
byte* page,
const page_size_t& page_size,
ulint space,
ulint offset);
/** Reads or writes data. This operation could be asynchronous (aio). /** Reads or writes data. This operation could be asynchronous (aio).
@param[in,out] type IO context @param[in,out] type IO context
...@@ -5281,6 +5289,31 @@ fil_io( ...@@ -5281,6 +5289,31 @@ fil_io(
req_type.set_fil_node(node); req_type.set_fil_node(node);
ulint page_type = mach_read_from_2(static_cast<byte *>(buf) + FIL_PAGE_TYPE);
if (req_type.is_write()
&& page_id.space() != SRV_LOG_SPACE_FIRST_ID
&& fil_is_user_tablespace_id(page_id.space())
&& !page_size.is_compressed()
#ifndef UNIV_INNOCHECKSUM
&& !FSP_FLAGS_HAS_PAGE_COMPRESSION(space->flags)
#endif
&& !fil_space_verify_crypt_checksum(
static_cast<byte *>(buf), page_size, page_id.space(), page_id.page_no())
&&
(mach_read_from_4(static_cast<const byte *>(buf) + FIL_PAGE_LSN + 4) !=
mach_read_from_4(static_cast<const byte *>(buf)
+ UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4))) {
ib::error() << "Page write: log sequence number at the start "
<< mach_read_from_4(static_cast<const byte *>(buf) + FIL_PAGE_LSN + 4)
<< " and the end "
<< mach_read_from_4(static_cast<const byte *>(buf) + UNIV_PAGE_SIZE
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)
<< " do not match";
}
/* Queue the aio request */ /* Queue the aio request */
dberr_t err = os_aio( dberr_t err = os_aio(
req_type, req_type,
......
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