diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2020-04-05 22:20:49 +0300 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2020-04-08 12:02:35 +0300 |
commit | 66ae518a5842e5a3e33eb141b4b5156a048828be (patch) | |
tree | edde5eb845d4eb2b06fee9168d3250276b163ecc | |
parent | 00f0c039d2f4213ccf0a0202349ecb162a799989 (diff) | |
download | mariadb-git-bb-10.2-MDEV-21681-page-LSN-doesnt-match-cb.tar.gz |
Some debug codebb-10.2-MDEV-21681-page-LSN-doesnt-match-cb
-rw-r--r-- | extra/mariabackup/write_filt.cc | 40 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 32 | ||||
-rw-r--r-- | storage/innobase/fil/fil0crypt.cc | 2 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 33 |
4 files changed, 101 insertions, 6 deletions
diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc index 40ecef6ff79..1ceeac98470 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -203,6 +203,15 @@ wf_wt_init(xb_write_filt_ctxt_t *ctxt, char *dst_name __attribute__((unused)), 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. @@ -212,6 +221,37 @@ wf_wt_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile) { 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)) { return(FALSE); } diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 7ac168b1778..f1a5f84b4d8 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4438,13 +4438,35 @@ xtrabackup_apply_delta( } } - success = os_file_write(IORequestWrite, - dst_path, dst_file, buf, off, page_size); - if (!success) { - goto error; + + + fil_space_t* space = fil_space_acquire(info.space_id); + 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++; } diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index 08a832a4cd5..7d89fec5ada 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2529,7 +2529,7 @@ encrypted, or corrupted. @param[in] space tablespace identifier @param[in] offset page number @return true if page is encrypted AND OK, false otherwise */ -UNIV_INTERN +//UNIV_INTERN bool fil_space_verify_crypt_checksum( byte* page, diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index f3bb127020a..eb92de53bfe 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -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). @param[in,out] type IO context @@ -5281,6 +5289,31 @@ fil_io( 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 */ dberr_t err = os_aio( req_type, |