Commit 4383897a authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 37e7bde1
...@@ -3860,7 +3860,9 @@ static bool xtrabackup_backup_low() ...@@ -3860,7 +3860,9 @@ static bool xtrabackup_backup_low()
if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS
&& log_sys.log.format != 0) { && log_sys.log.format != 0) {
if (max_cp_field == LOG_CHECKPOINT_1) { 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( metadata_to_lsn = mach_read_from_8(
log_sys.checkpoint_buf + LOG_CHECKPOINT_LSN); log_sys.checkpoint_buf + LOG_CHECKPOINT_LSN);
...@@ -4067,11 +4069,11 @@ static bool xtrabackup_backup_func() ...@@ -4067,11 +4069,11 @@ static bool xtrabackup_backup_func()
goto fail; goto fail;
} }
const byte* buf = log_sys.checkpoint_buf; byte* buf = log_sys.checkpoint_buf;
checkpoint_lsn_start = log_sys.log.get_lsn(); checkpoint_lsn_start = log_sys.log.get_lsn();
checkpoint_no_start = log_sys.next_checkpoint_no; 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) if (checkpoint_no_start != mach_read_from_8(buf + LOG_CHECKPOINT_NO)
|| checkpoint_lsn_start || checkpoint_lsn_start
......
...@@ -211,9 +211,6 @@ shutdown. This function also writes all log in log file to the log archive. */ ...@@ -211,9 +211,6 @@ shutdown. This function also writes all log in log file to the log archive. */
void void
logs_empty_and_mark_files_at_shutdown(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(). /** Write checkpoint info to the log header and invoke log_mutex_exit().
@param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */ @param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */
void log_write_checkpoint_info(lsn_t end_lsn); void log_write_checkpoint_info(lsn_t end_lsn);
......
...@@ -1340,20 +1340,6 @@ static bool log_preflush_pool_modified_pages(lsn_t new_oldest) ...@@ -1340,20 +1340,6 @@ static bool log_preflush_pool_modified_pages(lsn_t new_oldest)
return(success); 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(). /** Write checkpoint info to the log header and invoke log_mutex_exit().
@param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */ @param[in] end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */
void log_write_checkpoint_info(lsn_t end_lsn) void log_write_checkpoint_info(lsn_t end_lsn)
......
...@@ -1353,7 +1353,7 @@ recv_find_max_checkpoint_0(ulint* max_field) ...@@ -1353,7 +1353,7 @@ recv_find_max_checkpoint_0(ulint* max_field)
for (ulint field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; for (ulint field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { 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)) if (static_cast<uint32_t>(ut_fold_binary(buf, CHECKSUM_1))
!= mach_read_from_4(buf + CHECKSUM_1) != mach_read_from_4(buf + CHECKSUM_1)
...@@ -1552,7 +1552,7 @@ recv_find_max_checkpoint(ulint* max_field) ...@@ -1552,7 +1552,7 @@ recv_find_max_checkpoint(ulint* max_field)
buf = log_sys.checkpoint_buf; 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 /* Check the header page checksum. There was no
checksum in the first redo log format (version 0). */ checksum in the first redo log format (version 0). */
log_sys.log.format = mach_read_from_4(buf + LOG_HEADER_FORMAT); log_sys.log.format = mach_read_from_4(buf + LOG_HEADER_FORMAT);
...@@ -1591,8 +1591,7 @@ recv_find_max_checkpoint(ulint* max_field) ...@@ -1591,8 +1591,7 @@ recv_find_max_checkpoint(ulint* max_field)
for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2; for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) { field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
log_sys.log.read(field, {buf, OS_FILE_LOG_BLOCK_SIZE});
log_header_read(field);
const ulint crc32 = log_block_calc_checksum_crc32(buf); const ulint crc32 = log_block_calc_checksum_crc32(buf);
const ulint cksum = log_block_get_checksum(buf); const ulint cksum = log_block_get_checksum(buf);
...@@ -3306,9 +3305,8 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn) ...@@ -3306,9 +3305,8 @@ recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
return(err); return(err);
} }
log_header_read(max_cp_field);
buf = log_sys.checkpoint_buf; 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_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO); checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
......
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