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-02-16 16:36:22 +0300
commitf85483892530d2ca5f55a5b3afa3bc6c3299fada (patch)
tree0405a28d387ab5f273f63816227d1278fb4b1d9a
parent0789a1a18f0e780c0412667e7b6e0a9970aa6905 (diff)
downloadmariadb-git-bb-10.3.16-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.16-MDEV-21109-wrong-page-no-log
-rw-r--r--extra/mariabackup/write_filt.cc17
-rw-r--r--extra/mariabackup/write_filt.h1
-rw-r--r--extra/mariabackup/xtrabackup.cc14
-rw-r--r--storage/innobase/fil/fil0fil.cc26
4 files changed, 52 insertions, 6 deletions
diff --git a/extra/mariabackup/write_filt.cc b/extra/mariabackup/write_filt.cc
index 75ddf9fa99e..27b298048ab 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,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);
}
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 c06d677786c..cecb6317b02 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -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;
- }
+ read_filter = &rf_pass_through;
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) {
diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc
index 9fb9e1a4138..14d893cf61f 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
@@ -4372,6 +4374,30 @@ fil_io(
req_type.set_fil_node(node);
+
+ 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(
req_type,