Commit 05b84b25 authored by Vlad Lesin's avatar Vlad Lesin Committed by Marko Mäkelä

MDEV-14192: Add debug assertions

parent 9ba0865b
......@@ -4129,7 +4129,7 @@ static bool xtrabackup_backup_func()
}
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 @@ static bool xtrabackup_backup_func()
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));
......
......@@ -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)
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment