diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2019-11-28 01:16:22 +0300 |
---|---|---|
committer | Vlad Lesin <vlad_lesin@mail.ru> | 2020-08-20 12:53:12 +0300 |
commit | c2abe708c3f450769a8e11a3f535a768c3dc857e (patch) | |
tree | 5e23fc064ca33d14d33ee4b520e2b5e3badea389 | |
parent | 18bf8c3f1ddd37551db562707db98df44ad33de7 (diff) | |
download | mariadb-git-bb-10.3-10.3.23-MDEV-21109-wrong-page-no.tar.gz |
Add some extra logging to catch the case when page is written with wrong offset.bb-10.3-10.3.23-MDEV-21109-wrong-page-no
-rw-r--r-- | extra/mariabackup/write_filt.cc | 18 | ||||
-rw-r--r-- | extra/mariabackup/write_filt.h | 1 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 14 | ||||
-rw-r--r-- | storage/innobase/fil/fil0fil.cc | 38 |
4 files changed, 65 insertions, 6 deletions
diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc index 75ddf9fa99e..47943b5e85f 100644 --- a/extra/mariabackup/write_filt.cc +++ b/extra/mariabackup/write_filt.cc @@ -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,23 @@ 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) { + uint32_t page_no = mach_read_from_4(page + FIL_PAGE_OFFSET); + if (page_no && page_no != ctxt->dst_page + i) + msg("Warning: 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); } diff --git a/extra/mariabackup/write_filt.h b/extra/mariabackup/write_filt.h index febf25f2a8a..e511ffcddb5 100644 --- a/extra/mariabackup/write_filt.h +++ b/extra/mariabackup/write_filt.h @@ -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; diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 5246ffbda20..4340de45bb7 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2581,12 +2581,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; - } + read_filter = &rf_pass_through; res = xb_fil_cur_open(&cursor, read_filter, node, thread_n,max_size); if (res == XB_FIL_CUR_SKIP) { @@ -5041,6 +5036,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 %" PRIu64, + 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) { diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index 8892c7d7f83..c43c0d94eca 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -52,6 +52,8 @@ Created 10/25/1995 Heikki Tuuri #include "buf0flu.h" #include "os0api.h" +#include <my_stacktrace.h> + /** Tries to close a file in the LRU list. The caller must hold the fil_sys mutex. @return true if success, false if should retry later; since i/o's @@ -4378,10 +4380,46 @@ 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; + my_print_stacktrace(NULL, (ulong)my_thread_stack_size, 0); + } +*/ + + 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() + || 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()))); + /* Queue the aio request */ dberr_t err = os_aio( |