Browse Source

MDEV-14425 preparation: Remove log_header_read()

The function log_header_read() was only used during server startup,
and it will mostly be used only for reading checkpoint information
from pre-MDEV-14425 format redo log files.

Let us replace the function with more direct calls, so that
it is clearer what is going on. It is not strictly necessary to
hold any mutex during this operation, and because there will be
only a limited number of operations during early server startup,
it is not necessary to increment any I/O counters.
pull/1451/head
Marko Mäkelä 6 years ago
parent
commit
4383897a01
  1. 8
      extra/mariabackup/xtrabackup.cc
  2. 3
      storage/innobase/include/log0log.h
  3. 14
      storage/innobase/log/log0log.cc
  4. 10
      storage/innobase/log/log0recv.cc

8
extra/mariabackup/xtrabackup.cc

@ -3860,7 +3860,9 @@ static bool xtrabackup_backup_low()
if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS
&& log_sys.log.format != 0) {
if (max_cp_field == LOG_CHECKPOINT_1) {
log_header_read(max_cp_field);
log_sys.log.read(max_cp_field,
{log_sys.checkpoint_buf,
OS_FILE_LOG_BLOCK_SIZE});
}
metadata_to_lsn = mach_read_from_8(
log_sys.checkpoint_buf + LOG_CHECKPOINT_LSN);
@ -4067,11 +4069,11 @@ reread_log_header:
goto fail;
}
const byte* buf = log_sys.checkpoint_buf;
byte* buf = log_sys.checkpoint_buf;
checkpoint_lsn_start = log_sys.log.get_lsn();
checkpoint_no_start = log_sys.next_checkpoint_no;
log_header_read(max_cp_field);
log_sys.log.read(max_cp_field, {buf, OS_FILE_LOG_BLOCK_SIZE});
if (checkpoint_no_start != mach_read_from_8(buf + LOG_CHECKPOINT_NO)
|| checkpoint_lsn_start

3
storage/innobase/include/log0log.h

@ -211,9 +211,6 @@ shutdown. This function also writes all log in log file to the log archive. */
void
logs_empty_and_mark_files_at_shutdown(void);
/*=======================================*/
/** Read a log group header page to log_sys.checkpoint_buf.
@param[in] header 0 or LOG_CHECKPOINT_1 or LOG_CHECKPOINT2 */
void log_header_read(ulint header);
/** Write checkpoint info to the log header and invoke log_mutex_exit().
@param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */
void log_write_checkpoint_info(lsn_t end_lsn);

14
storage/innobase/log/log0log.cc

@ -1340,20 +1340,6 @@ static bool log_preflush_pool_modified_pages(lsn_t new_oldest)
return(success);
}
/** Read a log group header page to log_sys.checkpoint_buf.
@param[in] header 0 or LOG_CHECKPOINT_1 or LOG_CHECKPOINT2 */
void log_header_read(ulint header)
{
ut_ad(log_mutex_own());
log_sys.n_log_ios++;
MONITOR_INC(MONITOR_LOG_IO);
log_sys.log.read(header,
{log_sys.checkpoint_buf, OS_FILE_LOG_BLOCK_SIZE});
}
/** Write checkpoint info to the log header and invoke log_mutex_exit().
@param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */
void log_write_checkpoint_info(lsn_t end_lsn)

10
storage/innobase/log/log0recv.cc

@ -1353,7 +1353,7 @@ recv_find_max_checkpoint_0(ulint* max_field)
for (ulint field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
log_header_read(field);
log_sys.log.read(field, {buf, OS_FILE_LOG_BLOCK_SIZE});
if (static_cast<uint32_t>(ut_fold_binary(buf, CHECKSUM_1))
!= mach_read_from_4(buf + CHECKSUM_1)
@ -1552,7 +1552,7 @@ recv_find_max_checkpoint(ulint* max_field)
buf = log_sys.checkpoint_buf;
log_header_read(0);
log_sys.log.read(0, {buf, OS_FILE_LOG_BLOCK_SIZE});
/* Check the header page checksum. There was no
checksum in the first redo log format (version 0). */
log_sys.log.format = mach_read_from_4(buf + LOG_HEADER_FORMAT);
@ -1591,8 +1591,7 @@ recv_find_max_checkpoint(ulint* max_field)
for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
log_header_read(field);
log_sys.log.read(field, {buf, OS_FILE_LOG_BLOCK_SIZE});
const ulint crc32 = log_block_calc_checksum_crc32(buf);
const ulint cksum = log_block_get_checksum(buf);
@ -3306,9 +3305,8 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
return(err);
}
log_header_read(max_cp_field);
buf = log_sys.checkpoint_buf;
log_sys.log.read(max_cp_field, {buf, OS_FILE_LOG_BLOCK_SIZE});
checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);

Loading…
Cancel
Save