diff options
author | Vlad Lesin <vlad_lesin@mail.ru> | 2019-04-08 18:25:43 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-04-08 21:38:32 +0300 |
commit | 05b84b2568ea62a3af69dc50ec346a22c0ac96c6 (patch) | |
tree | 17e82adce39860c4a62d1fbaf6a1b4edcc0910c5 | |
parent | 9ba0865b875c8b11a3ca26c9ee17635961d18b23 (diff) | |
download | mariadb-git-05b84b2568ea62a3af69dc50ec346a22c0ac96c6.tar.gz |
MDEV-14192: Add debug assertions
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 4 | ||||
-rw-r--r-- | storage/innobase/include/log0log.h | 25 | ||||
-rw-r--r-- | storage/innobase/log/log0recv.cc | 25 |
3 files changed, 36 insertions, 18 deletions
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 6b9a466d443..e70295417b7 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -4129,7 +4129,7 @@ reread_log_header: } const byte* buf = log_sys.checkpoint_buf; - checkpoint_lsn_start = log_sys.log.lsn; + checkpoint_lsn_start = log_sys.log.get_lsn(); checkpoint_no_start = log_sys.next_checkpoint_no; log_header_read(max_cp_field); @@ -4181,7 +4181,7 @@ reread_log_header: stored correctly in the copy of the ib_logfile. The most significant bits, which identify the start offset of the log block in the file, we did choose freely, as LOG_FILE_HDR_SIZE. */ - ut_ad(!((log_sys.log.lsn ^ checkpoint_lsn_start) + ut_ad(!((log_sys.log.get_lsn() ^ checkpoint_lsn_start) & (OS_FILE_LOG_BLOCK_SIZE - 1))); log_block_set_checksum(log_hdr, log_block_calc_checksum_crc32(log_hdr)); diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h index 061876022b6..3ea211ed545 100644 --- a/storage/innobase/include/log0log.h +++ b/storage/innobase/include/log0log.h @@ -2,7 +2,7 @@ Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. Copyright (c) 2009, Google Inc. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2019, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -563,11 +563,12 @@ struct log_t{ uint32_t subformat; /** individual log file size in bytes, including the header */ lsn_t file_size; + private: /** lsn used to fix coordinates within the log group */ lsn_t lsn; /** the byte offset of the above lsn */ lsn_t lsn_offset; - + public: /** used only in recovery: recovery scan succeeded up to this lsn in this log group */ lsn_t scanned_lsn; @@ -584,8 +585,9 @@ struct log_t{ /** Set the field values to correspond to a given lsn. */ void set_fields(lsn_t lsn) { - lsn_offset = calc_lsn_offset(lsn); - this->lsn = lsn; + lsn_t c_lsn_offset = calc_lsn_offset(lsn); + set_lsn(lsn); + set_lsn_offset(c_lsn_offset); } /** Read a log segment to log_sys.buf. @@ -604,6 +606,10 @@ struct log_t{ { n_files = 0; } + void set_lsn(lsn_t a_lsn); + lsn_t get_lsn() const { return lsn; } + void set_lsn_offset(lsn_t a_lsn); + lsn_t get_lsn_offset() const { return lsn_offset; } } log; /** The fields involved in the log buffer flush @{ */ @@ -741,6 +747,17 @@ inline lsn_t log_t::files::calc_lsn_offset(lsn_t lsn) const return l + LOG_FILE_HDR_SIZE * (1 + l / (file_size - LOG_FILE_HDR_SIZE)); } +inline void log_t::files::set_lsn(lsn_t a_lsn) { + ut_ad(log_sys.mutex.is_owned() || log_sys.write_mutex.is_owned()); + lsn = a_lsn; +} + +inline void log_t::files::set_lsn_offset(lsn_t a_lsn) { + ut_ad(log_sys.mutex.is_owned() || log_sys.write_mutex.is_owned()); + ut_ad((lsn % OS_FILE_LOG_BLOCK_SIZE) == (a_lsn % OS_FILE_LOG_BLOCK_SIZE)); + lsn_offset = a_lsn; +} + /** Test if flush order mutex is owned. */ #define log_flush_order_mutex_own() \ mutex_own(&log_sys.log_flush_order_mutex) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 60732ed8fef..9930fdeae03 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -990,11 +990,12 @@ recv_find_max_checkpoint_0(ulint* max_field) *max_field = field; max_no = checkpoint_no; - log_sys.log.lsn = mach_read_from_8( - buf + LOG_CHECKPOINT_LSN); - log_sys.log.lsn_offset = static_cast<ib_uint64_t>( - mach_read_from_4(buf + OFFSET_HIGH32)) << 32 - | mach_read_from_4(buf + OFFSET_LOW32); + log_sys.log.set_lsn(mach_read_from_8( + buf + LOG_CHECKPOINT_LSN)); + log_sys.log.set_lsn_offset( + lsn_t(mach_read_from_4(buf + OFFSET_HIGH32)) + << 32 + | mach_read_from_4(buf + OFFSET_LOW32)); } } @@ -1076,7 +1077,7 @@ static dberr_t recv_log_format_0_recover(lsn_t lsn, bool crypt) static dberr_t recv_log_recover_10_4() { ut_ad(!log_sys.is_encrypted()); - const lsn_t lsn = log_sys.log.lsn; + const lsn_t lsn = log_sys.log.get_lsn(); const lsn_t source_offset = log_sys.log.calc_lsn_offset(lsn); const ulint page_no = (ulint) (source_offset / univ_page_size.physical()); @@ -1202,10 +1203,10 @@ recv_find_max_checkpoint(ulint* max_field) if (checkpoint_no >= max_no) { *max_field = field; max_no = checkpoint_no; - log_sys.log.lsn = mach_read_from_8( - buf + LOG_CHECKPOINT_LSN); - log_sys.log.lsn_offset = mach_read_from_8( - buf + LOG_CHECKPOINT_OFFSET); + log_sys.log.set_lsn(mach_read_from_8( + buf + LOG_CHECKPOINT_LSN)); + log_sys.log.set_lsn_offset(mach_read_from_8( + buf + LOG_CHECKPOINT_OFFSET)); log_sys.next_checkpoint_no = checkpoint_no; } } @@ -3713,8 +3714,8 @@ recv_reset_logs( log_sys.lsn = ut_uint64_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE); - log_sys.log.lsn = log_sys.lsn; - log_sys.log.lsn_offset = LOG_FILE_HDR_SIZE; + log_sys.log.set_lsn(log_sys.lsn); + log_sys.log.set_lsn_offset(LOG_FILE_HDR_SIZE); log_sys.buf_next_to_write = 0; log_sys.write_lsn = log_sys.lsn; |