summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Lesin <vlad_lesin@mail.ru>2019-11-28 01:16:22 +0300
committerVlad Lesin <vlad_lesin@mail.ru>2020-05-15 03:30:37 +0300
commit66a1542dcaa55430eca5a9dc0a0096b7f840b4e2 (patch)
treeed6f8ddc335b6b9ef83172fad32f163edb939250
parente5e5877740f248de848219ee3a1d2881cd5c5b82 (diff)
downloadmariadb-git-bb-10.3.21-MDEV-21109-wrong-page-no-log.tar.gz
Add some extra logging to catch the case when page is written with wrong offset.bb-10.3.21-MDEV-21109-wrong-page-no-log
-rw-r--r--extra/mariabackup/write_filt.cc18
-rw-r--r--extra/mariabackup/write_filt.h1
-rw-r--r--extra/mariabackup/xtrabackup.cc14
-rw-r--r--storage/innobase/fil/fil0fil.cc27
4 files changed, 54 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 0af0e8eae7b..dc4ee3c667e 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -2528,12 +2528,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) {
@@ -4981,6 +4976,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) {
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 8ccebff3db0..dbb37d617f8 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
@@ -4385,10 +4387,35 @@ 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);
+ }
/* Queue the aio request */
dberr_t err = os_aio(