Commit 86927cc7 authored by Marko Mäkelä's avatar Marko Mäkelä

Remove traces of multiple InnoDB redo logs

InnoDB never supported more than one copy of a redo log.
There were provisions to do that. For Mariabackup, let us clean up
this code.

log_sys_init(): Renamed from log_init().

log_set_capacity(): Renamed from log_calc_max_ages().

log_init(): Renamed from log_group_init(). Remove the parameters
id, space_id. Let the caller invoke log_set_capacity() when needed.

log_group_t: Remove id, space_id, log_groups.

log_t: Replace log_groups with a single log.

recv_find_max_checkpoint(): Declare globally. Remove the first parameter.

xtrabackup_choose_lsn_offset(): Remove (dead code).
parent ed2976ca
...@@ -66,7 +66,6 @@ void ...@@ -66,7 +66,6 @@ void
innodb_log_checksum_func_update( innodb_log_checksum_func_update(
/*============================*/ /*============================*/
ulint algorithm) /*!< in: algorithm */; ulint algorithm) /*!< in: algorithm */;
dberr_t recv_find_max_checkpoint(log_group_t** max_group, ulint* max_field);
dberr_t dberr_t
srv_undo_tablespaces_init( srv_undo_tablespaces_init(
/*======================*/ /*======================*/
......
...@@ -564,7 +564,6 @@ enum options_xtrabackup ...@@ -564,7 +564,6 @@ enum options_xtrabackup
OPT_INNODB_LOG_BUFFER_SIZE, OPT_INNODB_LOG_BUFFER_SIZE,
OPT_INNODB_LOG_FILE_SIZE, OPT_INNODB_LOG_FILE_SIZE,
OPT_INNODB_LOG_FILES_IN_GROUP, OPT_INNODB_LOG_FILES_IN_GROUP,
OPT_INNODB_MIRRORED_LOG_GROUPS,
OPT_INNODB_OPEN_FILES, OPT_INNODB_OPEN_FILES,
OPT_INNODB_SYNC_SPIN_LOOPS, OPT_INNODB_SYNC_SPIN_LOOPS,
OPT_INNODB_THREAD_CONCURRENCY, OPT_INNODB_THREAD_CONCURRENCY,
...@@ -2605,96 +2604,6 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n) ...@@ -2605,96 +2604,6 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
return(FALSE); return(FALSE);
} }
static
void
xtrabackup_choose_lsn_offset(lsn_t start_lsn)
{
#if SUPPORT_PERCONA_5_5
ulint no, alt_no, expected_no;
ulint blocks_in_group;
lsn_t tmp_offset, end_lsn;
int lsn_chosen = 0;
log_group_t *group;
start_lsn = ut_uint64_align_down(start_lsn, OS_FILE_LOG_BLOCK_SIZE);
end_lsn = start_lsn + RECV_SCAN_SIZE;
group = UT_LIST_GET_FIRST(log_sys->log_groups);
if (mysql_server_version < 50500 || mysql_server_version > 50600) {
/* only make sense for Percona Server 5.5 */
return;
}
if (server_flavor == FLAVOR_PERCONA_SERVER) {
/* it is Percona Server 5.5 */
group->alt_offset_chosen = true;
group->lsn_offset = group->lsn_offset_alt;
return;
}
if (group->lsn_offset_alt == group->lsn_offset ||
group->lsn_offset_alt == (lsn_t) -1) {
/* we have only one option */
return;
}
no = alt_no = (ulint) -1;
lsn_chosen = 0;
blocks_in_group = log_block_convert_lsn_to_no(
log_group_get_capacity(group)) - 1;
/* read log block number from usual offset */
if (group->lsn_offset < group->file_size * group->n_files &&
(log_group_calc_lsn_offset(start_lsn, group) %
UNIV_PAGE_SIZE) % OS_MIN_LOG_BLOCK_SIZE == 0) {
log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn);
no = log_block_get_hdr_no(log_sys->buf);
}
/* read log block number from Percona Server 5.5 offset */
tmp_offset = group->lsn_offset;
group->lsn_offset = group->lsn_offset_alt;
if (group->lsn_offset < group->file_size * group->n_files &&
(log_group_calc_lsn_offset(start_lsn, group) %
UNIV_PAGE_SIZE) % OS_MIN_LOG_BLOCK_SIZE == 0) {
log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn);
alt_no = log_block_get_hdr_no(log_sys->buf);
}
expected_no = log_block_convert_lsn_to_no(start_lsn);
ut_a(!(no == expected_no && alt_no == expected_no));
group->lsn_offset = tmp_offset;
if ((no <= expected_no &&
((expected_no - no) % blocks_in_group) == 0) ||
((expected_no | 0x40000000UL) - no) % blocks_in_group == 0) {
/* default offset looks ok */
++lsn_chosen;
}
if ((alt_no <= expected_no &&
((expected_no - alt_no) % blocks_in_group) == 0) ||
((expected_no | 0x40000000UL) - alt_no) % blocks_in_group == 0) {
/* PS 5.5 style offset looks ok */
++lsn_chosen;
group->alt_offset_chosen = true;
group->lsn_offset = group->lsn_offset_alt;
}
/* We are in trouble, because we can not make a
decision to choose one over the other. Die just
like a Buridan's ass */
ut_a(lsn_chosen == 1);
#endif
}
extern ibool log_block_checksum_is_ok_or_old_format(const byte* block); extern ibool log_block_checksum_is_ok_or_old_format(const byte* block);
/*******************************************************//** /*******************************************************//**
...@@ -2862,8 +2771,6 @@ static my_bool ...@@ -2862,8 +2771,6 @@ static my_bool
xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last) xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last)
{ {
/* definition from recv_recovery_from_checkpoint_start() */ /* definition from recv_recovery_from_checkpoint_start() */
log_group_t* group;
lsn_t group_scanned_lsn;
lsn_t contiguous_lsn; lsn_t contiguous_lsn;
ut_a(dst_log_file != NULL); ut_a(dst_log_file != NULL);
...@@ -2873,66 +2780,50 @@ xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last) ...@@ -2873,66 +2780,50 @@ xtrabackup_copy_logfile(lsn_t from_lsn, my_bool is_last)
/* TODO: We must check the contiguous_lsn still exists in log file.. */ /* TODO: We must check the contiguous_lsn still exists in log file.. */
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (group) {
bool finished; bool finished;
lsn_t start_lsn; lsn_t start_lsn;
lsn_t end_lsn; lsn_t end_lsn;
/* reference recv_group_scan_log_recs() */ /* reference recv_group_scan_log_recs() */
finished = false;
start_lsn = contiguous_lsn; start_lsn = contiguous_lsn;
while (!finished) { do {
end_lsn = start_lsn + RECV_SCAN_SIZE; end_lsn = start_lsn + RECV_SCAN_SIZE;
xtrabackup_io_throttling(); xtrabackup_io_throttling();
mutex_enter(&log_sys->mutex); log_mutex_enter();
log_group_read_log_seg(LOG_RECOVER, log_sys->buf, log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn, false); &log_sys->log, start_lsn, end_lsn);
if (!xtrabackup_scan_log_recs(group, is_last,
start_lsn, &contiguous_lsn, &group_scanned_lsn,
&finished)) {
goto error;
}
mutex_exit(&log_sys->mutex); bool success = xtrabackup_scan_log_recs(
&log_sys->log, is_last,
start_lsn, &contiguous_lsn,
&log_sys->log.scanned_lsn,
&finished);
start_lsn = end_lsn; log_mutex_exit();
if (!success) {
ds_close(dst_log_file);
msg("xtrabackup: Error: xtrabackup_copy_logfile()"
" failed.\n");
return(TRUE);
} }
group->scanned_lsn = group_scanned_lsn; start_lsn = end_lsn;
} while (!finished);
msg_ts(">> log scanned up to (" LSN_PF ")\n", msg_ts(">> log scanned up to (" LSN_PF ")\n",
group->scanned_lsn); log_sys->log.scanned_lsn);
group = UT_LIST_GET_NEXT(log_groups, group);
/* update global variable*/ /* update global variable*/
log_copy_scanned_lsn = group_scanned_lsn; log_copy_scanned_lsn = log_sys->log.scanned_lsn;
/* innodb_mirrored_log_groups must be 1, no other groups */
ut_a(group == NULL);
debug_sync_point("xtrabackup_copy_logfile_pause"); debug_sync_point("xtrabackup_copy_logfile_pause");
}
return(FALSE); return(FALSE);
error:
mutex_exit(&log_sys->mutex);
ds_close(dst_log_file);
msg("xtrabackup: Error: xtrabackup_copy_logfile() failed.\n");
return(TRUE);
} }
static static
...@@ -3244,13 +3135,12 @@ xb_fil_io_init(void) ...@@ -3244,13 +3135,12 @@ xb_fil_io_init(void)
Populates the tablespace memory cache by scanning for and opening data files. Populates the tablespace memory cache by scanning for and opening data files.
@returns DB_SUCCESS or error code.*/ @returns DB_SUCCESS or error code.*/
static static
ulint dberr_t
xb_load_tablespaces(void) xb_load_tablespaces()
/*=====================*/
{ {
ulint i; ulint i;
ibool create_new_db; ibool create_new_db;
ulint err; dberr_t err;
ulint sum_of_new_sizes; ulint sum_of_new_sizes;
lsn_t min_arch_logno, max_arch_logno; lsn_t min_arch_logno, max_arch_logno;
...@@ -3321,9 +3211,9 @@ xb_load_tablespaces(void) ...@@ -3321,9 +3211,9 @@ xb_load_tablespaces(void)
Initialize the tablespace memory cache and populate it by scanning for and Initialize the tablespace memory cache and populate it by scanning for and
opening data files. opening data files.
@returns DB_SUCCESS or error code.*/ @returns DB_SUCCESS or error code.*/
ulint static
xb_data_files_init(void) dberr_t
/*====================*/ xb_data_files_init()
{ {
xb_fil_io_init(); xb_fil_io_init();
...@@ -3332,9 +3222,9 @@ xb_data_files_init(void) ...@@ -3332,9 +3222,9 @@ xb_data_files_init(void)
/************************************************************************ /************************************************************************
Destroy the tablespace memory cache. */ Destroy the tablespace memory cache. */
static
void void
xb_data_files_close(void) xb_data_files_close()
/*====================*/
{ {
ulint i; ulint i;
...@@ -3745,7 +3635,6 @@ open_or_create_log_file( ...@@ -3745,7 +3635,6 @@ open_or_create_log_file(
ibool log_file_has_been_opened,/*!< in: TRUE if a log file has been ibool log_file_has_been_opened,/*!< in: TRUE if a log file has been
opened before: then it is an error opened before: then it is an error
to try to create another log file */ to try to create another log file */
ulint k, /*!< in: log group number */
ulint i) /*!< in: log file number in group */ ulint i) /*!< in: log file number in group */
{ {
ibool ret; ibool ret;
...@@ -3755,8 +3644,6 @@ open_or_create_log_file( ...@@ -3755,8 +3644,6 @@ open_or_create_log_file(
UT_NOT_USED(create_new_db); UT_NOT_USED(create_new_db);
UT_NOT_USED(log_file_has_been_opened); UT_NOT_USED(log_file_has_been_opened);
UT_NOT_USED(k);
ut_ad(k == 0);
*log_file_created = FALSE; *log_file_created = FALSE;
...@@ -3804,20 +3691,14 @@ open_or_create_log_file( ...@@ -3804,20 +3691,14 @@ open_or_create_log_file(
which is for this log group */ which is for this log group */
fil_space_create(name, fil_space_create(name,
2 * k + SRV_LOG_SPACE_FIRST_ID, 0, FIL_LOG, 0, 0); SRV_LOG_SPACE_FIRST_ID, 0, FIL_TYPE_LOG, 0, 0);
log_init(srv_n_log_files, srv_log_file_size * UNIV_PAGE_SIZE);
} }
ut_a(fil_validate()); ut_a(fil_validate());
ut_a(fil_node_create(name, (ulint)srv_log_file_size, ut_a(fil_node_create(name, (ulint)srv_log_file_size,
2 * k + SRV_LOG_SPACE_FIRST_ID, FALSE)); SRV_LOG_SPACE_FIRST_ID, FALSE));
if (i == 0) {
log_group_init(k, srv_n_log_files,
srv_log_file_size * UNIV_PAGE_SIZE,
2 * k + SRV_LOG_SPACE_FIRST_ID,
SRV_LOG_SPACE_FIRST_ID + 1); /* dummy arch
space id */
}
return(DB_SUCCESS); return(DB_SUCCESS);
} }
...@@ -3911,7 +3792,7 @@ xtrabackup_backup_func(void) ...@@ -3911,7 +3792,7 @@ xtrabackup_backup_func(void)
lsn_t latest_cp; lsn_t latest_cp;
uint i; uint i;
uint count; uint count;
os_ib_mutex_t count_mutex; pthread_mutex_t count_mutex;
data_thread_ctxt_t *data_threads; data_thread_ctxt_t *data_threads;
#ifdef USE_POSIX_FADVISE #ifdef USE_POSIX_FADVISE
...@@ -4031,13 +3912,13 @@ xtrabackup_backup_func(void) ...@@ -4031,13 +3912,13 @@ xtrabackup_backup_func(void)
xb_fil_io_init(); xb_fil_io_init();
log_init(); log_sys_init();
lock_sys_create(srv_lock_table_size); lock_sys_create(srv_lock_table_size);
for (i = 0; i < srv_n_log_files; i++) { for (i = 0; i < srv_n_log_files; i++) {
err = open_or_create_log_file(FALSE, &log_file_created, err = open_or_create_log_file(FALSE, &log_file_created,
log_opened, 0, i); log_opened, i);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
//return((int) err); //return((int) err);
...@@ -4092,72 +3973,60 @@ xtrabackup_backup_func(void) ...@@ -4092,72 +3973,60 @@ xtrabackup_backup_func(void)
fil_system_t* f_system = fil_system; fil_system_t* f_system = fil_system;
/* definition from recv_recovery_from_checkpoint_start() */ /* definition from recv_recovery_from_checkpoint_start() */
log_group_t* max_cp_group;
ulint max_cp_field; ulint max_cp_field;
byte* buf;
byte* log_hdr_buf_;
byte* log_hdr_buf;
ulint err;
/* start back ground thread to copy newer log */ /* start back ground thread to copy newer log */
os_thread_id_t log_copying_thread_id; os_thread_id_t log_copying_thread_id;
datafiles_iter_t *it; datafiles_iter_t *it;
log_hdr_buf_ = static_cast<byte *>
(ut_malloc(LOG_FILE_HDR_SIZE + UNIV_PAGE_SIZE_MAX));
log_hdr_buf = static_cast<byte *>
(ut_align(log_hdr_buf_, UNIV_PAGE_SIZE_MAX));
/* get current checkpoint_lsn */ /* get current checkpoint_lsn */
/* Look for the latest checkpoint from any of the log groups */ /* Look for the latest checkpoint from any of the log groups */
mutex_enter(&log_sys->mutex); log_mutex_enter();
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); dberr_t err = recv_find_max_checkpoint(&max_cp_field);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
exit(EXIT_FAILURE);
}
ut_free(log_hdr_buf_); if (log_sys->log.format == 0) {
old_format:
msg("xtrabackup: Error: cannot process redo log"
" before MariaDB 10.2.2\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
log_group_read_checkpoint_info(max_cp_group, max_cp_field); ut_ad(!((log_sys->log.format ^ LOG_HEADER_FORMAT_CURRENT)
buf = log_sys->checkpoint_buf; & ~LOG_HEADER_FORMAT_ENCRYPTED));
const byte* buf = log_sys->checkpoint_buf;
checkpoint_lsn_start = mach_read_from_8(buf + LOG_CHECKPOINT_LSN); checkpoint_lsn_start = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
checkpoint_no_start = mach_read_from_8(buf + LOG_CHECKPOINT_NO); checkpoint_no_start = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
mutex_exit(&log_sys->mutex);
reread_log_header: reread_log_header:
fil_io(OS_FILE_READ | OS_FILE_LOG, true, max_cp_group->space_id, err = recv_find_max_checkpoint(&max_cp_field);
0,
0, 0, LOG_FILE_HDR_SIZE,
log_hdr_buf, max_cp_group, NULL);
/* check consistency of log file header to copy */
mutex_enter(&log_sys->mutex);
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
ut_free(log_hdr_buf_);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
log_group_read_checkpoint_info(max_cp_group, max_cp_field); if (log_sys->log.format == 0) {
buf = log_sys->checkpoint_buf; goto old_format;
}
ut_ad(!((log_sys->log.format ^ LOG_HEADER_FORMAT_CURRENT)
& ~LOG_HEADER_FORMAT_ENCRYPTED));
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 = mach_read_from_8(buf + LOG_CHECKPOINT_LSN); checkpoint_lsn_start = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
checkpoint_no_start = mach_read_from_8(buf + LOG_CHECKPOINT_NO); checkpoint_no_start = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
mutex_exit(&log_sys->mutex);
goto reread_log_header; goto reread_log_header;
} }
mutex_exit(&log_sys->mutex); log_mutex_exit();
xtrabackup_init_datasinks(); xtrabackup_init_datasinks();
...@@ -4204,10 +4073,6 @@ xtrabackup_backup_func(void) ...@@ -4204,10 +4073,6 @@ xtrabackup_backup_func(void)
&io_watching_thread_id); &io_watching_thread_id);
} }
mutex_enter(&log_sys->mutex);
xtrabackup_choose_lsn_offset(checkpoint_lsn_start);
mutex_exit(&log_sys->mutex);
/* copy log file by current position */ /* copy log file by current position */
if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE)) if(xtrabackup_copy_logfile(checkpoint_lsn_start, FALSE))
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
...@@ -4220,7 +4085,7 @@ xtrabackup_backup_func(void) ...@@ -4220,7 +4085,7 @@ xtrabackup_backup_func(void)
err = xb_load_tablespaces(); err = xb_load_tablespaces();
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
msg("xtrabackup: error: xb_load_tablespaces() failed with" msg("xtrabackup: error: xb_load_tablespaces() failed with"
"error code %lu\n", err); "error code %u\n", err);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -4297,35 +4162,24 @@ xtrabackup_backup_func(void) ...@@ -4297,35 +4162,24 @@ xtrabackup_backup_func(void)
} }
/* read the latest checkpoint lsn */ /* read the latest checkpoint lsn */
latest_cp = 0;
{ {
log_group_t* max_cp_group;
ulint max_cp_field; ulint max_cp_field;
ulint err;
mutex_enter(&log_sys->mutex);
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); log_mutex_enter();
if (err != DB_SUCCESS) {
msg("xtrabackup: Error: recv_find_max_checkpoint() failed.\n");
mutex_exit(&log_sys->mutex);
goto skip_last_cp;
}
log_group_read_checkpoint_info(max_cp_group, max_cp_field);
xtrabackup_choose_lsn_offset(checkpoint_lsn_start);
if (recv_find_max_checkpoint(&max_cp_field) == DB_SUCCESS
&& log_sys->log.format != 0) {
latest_cp = mach_read_from_8(log_sys->checkpoint_buf + latest_cp = mach_read_from_8(log_sys->checkpoint_buf +
LOG_CHECKPOINT_LSN); LOG_CHECKPOINT_LSN);
msg("xtrabackup: The latest check point"
mutex_exit(&log_sys->mutex); " (for incremental): '" LSN_PF "'\n", latest_cp);
} else {
msg("xtrabackup: The latest check point (for incremental): " latest_cp = 0;
"'" LSN_PF "'\n", latest_cp); msg("xtrabackup: Error: recv_find_max_checkpoint() failed.\n");
}
log_mutex_exit();
} }
skip_last_cp:
/* stop log_copying_thread */ /* stop log_copying_thread */
log_copying = FALSE; log_copying = FALSE;
os_event_set(log_copying_stop); os_event_set(log_copying_stop);
......
...@@ -182,15 +182,6 @@ datafiles_iter_t *datafiles_iter_new(fil_system_t *f_system); ...@@ -182,15 +182,6 @@ datafiles_iter_t *datafiles_iter_new(fil_system_t *f_system);
fil_node_t *datafiles_iter_next(datafiles_iter_t *it); fil_node_t *datafiles_iter_next(datafiles_iter_t *it);
void datafiles_iter_free(datafiles_iter_t *it); void datafiles_iter_free(datafiles_iter_t *it);
/************************************************************************
Initialize the tablespace memory cache and populate it by scanning for and
opening data files */
ulint xb_data_files_init(void);
/************************************************************************
Destroy the tablespace memory cache. */
void xb_data_files_close(void);
/*********************************************************************** /***********************************************************************
Reads the space flags from a given data file and returns the compressed Reads the space flags from a given data file and returns the compressed
page size, or 0 if the space is not compressed. */ page size, or 0 if the space is not compressed. */
......
...@@ -151,24 +151,24 @@ UNIV_INLINE ...@@ -151,24 +151,24 @@ UNIV_INLINE
lsn_t lsn_t
log_get_max_modified_age_async(void); log_get_max_modified_age_async(void);
/*================================*/ /*================================*/
/******************************************************//** /** Initializes the redo logging subsystem. */
Initializes the log. */
void void
log_init(void); log_sys_init();
/*==========*/
/******************************************************************//** /** Initialize the redo log.
Inits a log group to the log system. @param[in] n_files number of files
@return true if success, false if not */ @param[in] file_size file size in bytes */
MY_ATTRIBUTE((warn_unused_result)) void
log_init(ulint n_files, lsn_t file_size);
/** Calculate the recommended highest values for lsn - last_checkpoint_lsn
and lsn - buf_get_oldest_modification().
@retval true on success
@retval false if the smallest log group is too small to
accommodate the number of OS threads in the database server */
bool bool
log_group_init( log_set_capacity()
/*===========*/ MY_ATTRIBUTE((warn_unused_result));
ulint id, /*!< in: group id */
ulint n_files, /*!< in: number of log files */
lsn_t file_size, /*!< in: log file size in bytes */
ulint space_id); /*!< in: space id of the file space
which contains the log files of this
group */
/******************************************************//** /******************************************************//**
Completes an i/o to a log file. */ Completes an i/o to a log file. */
void void
...@@ -552,16 +552,12 @@ Currently, this is only protected by log_sys->mutex. However, in the case ...@@ -552,16 +552,12 @@ Currently, this is only protected by log_sys->mutex. However, in the case
of log_write_up_to(), we will access some members only with the protection of log_write_up_to(), we will access some members only with the protection
of log_sys->write_mutex, which should affect nothing for now. */ of log_sys->write_mutex, which should affect nothing for now. */
struct log_group_t{ struct log_group_t{
/** log group identifier (always 0) */
ulint id;
/** number of files in the group */ /** number of files in the group */
ulint n_files; ulint n_files;
/** format of the redo log: e.g., LOG_HEADER_FORMAT_CURRENT */ /** format of the redo log: e.g., LOG_HEADER_FORMAT_CURRENT */
ulint format; ulint format;
/** individual log file size in bytes, including the header */ /** individual log file size in bytes, including the header */
lsn_t file_size lsn_t file_size;
/** file space which implements the log group */;
ulint space_id;
/** corruption status */ /** corruption status */
log_group_state_t state; log_group_state_t state;
/** lsn used to fix coordinates within the log group */ /** lsn used to fix coordinates within the log group */
...@@ -580,8 +576,6 @@ struct log_group_t{ ...@@ -580,8 +576,6 @@ struct log_group_t{
byte* checkpoint_buf_ptr; byte* checkpoint_buf_ptr;
/** buffer for writing a checkpoint header */ /** buffer for writing a checkpoint header */
byte* checkpoint_buf; byte* checkpoint_buf;
/** list of log groups */
UT_LIST_NODE_T(log_group_t) log_groups;
/** @return whether the redo log is encrypted */ /** @return whether the redo log is encrypted */
bool is_encrypted() const bool is_encrypted() const
...@@ -639,8 +633,8 @@ struct log_t{ ...@@ -639,8 +633,8 @@ struct log_t{
max_checkpoint_age; this flag is max_checkpoint_age; this flag is
peeked at by log_free_check(), which peeked at by log_free_check(), which
does not reserve the log mutex */ does not reserve the log mutex */
UT_LIST_BASE_NODE_T(log_group_t) /** the redo log */
log_groups; /*!< log groups */ log_group_t log;
/** The fields involved in the log buffer flush @{ */ /** The fields involved in the log buffer flush @{ */
...@@ -729,7 +723,7 @@ struct log_t{ ...@@ -729,7 +723,7 @@ struct log_t{
/** @return whether the redo log is encrypted */ /** @return whether the redo log is encrypted */
bool is_encrypted() const bool is_encrypted() const
{ {
return(UT_LIST_GET_FIRST(log_groups)->is_encrypted()); return(log.is_encrypted());
} }
}; };
......
...@@ -41,6 +41,13 @@ Created 9/20/1997 Heikki Tuuri ...@@ -41,6 +41,13 @@ Created 9/20/1997 Heikki Tuuri
/** @return whether recovery is currently running. */ /** @return whether recovery is currently running. */
#define recv_recovery_is_on() recv_recovery_on #define recv_recovery_is_on() recv_recovery_on
/** Find the latest checkpoint in the log header.
@param[out] max_field LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2
@return error code or DB_SUCCESS */
dberr_t
recv_find_max_checkpoint(ulint* max_field)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/** Apply the hashed log records to the page, if the page lsn is less than the /** Apply the hashed log records to the page, if the page lsn is less than the
lsn of a log record. lsn of a log record.
@param just_read_in whether the page recently arrived to the I/O handler @param just_read_in whether the page recently arrived to the I/O handler
......
...@@ -667,18 +667,14 @@ log_group_set_fields( ...@@ -667,18 +667,14 @@ log_group_set_fields(
group->lsn = lsn; group->lsn = lsn;
} }
/*****************************************************************//** /** Calculate the recommended highest values for lsn - last_checkpoint_lsn
Calculates the recommended highest values for lsn - last_checkpoint_lsn
and lsn - buf_get_oldest_modification(). and lsn - buf_get_oldest_modification().
@retval true on success @retval true on success
@retval false if the smallest log group is too small to @retval false if the smallest log group is too small to
accommodate the number of OS threads in the database server */ accommodate the number of OS threads in the database server */
static MY_ATTRIBUTE((warn_unused_result))
bool bool
log_calc_max_ages(void) log_set_capacity()
/*===================*/
{ {
log_group_t* group;
lsn_t margin; lsn_t margin;
ulint free; ulint free;
bool success = true; bool success = true;
...@@ -686,21 +682,7 @@ log_calc_max_ages(void) ...@@ -686,21 +682,7 @@ log_calc_max_ages(void)
log_mutex_enter(); log_mutex_enter();
group = UT_LIST_GET_FIRST(log_sys->log_groups); smallest_capacity = log_group_get_capacity(&log_sys->log);
ut_ad(group);
smallest_capacity = LSN_MAX;
while (group) {
if (log_group_get_capacity(group) < smallest_capacity) {
smallest_capacity = log_group_get_capacity(group);
}
group = UT_LIST_GET_NEXT(log_groups, group);
}
/* Add extra safety */ /* Add extra safety */
smallest_capacity = smallest_capacity - smallest_capacity / 10; smallest_capacity = smallest_capacity - smallest_capacity / 10;
...@@ -747,11 +729,9 @@ log_calc_max_ages(void) ...@@ -747,11 +729,9 @@ log_calc_max_ages(void)
return(success); return(success);
} }
/******************************************************//** /** Initializes the redo logging subsystem. */
Initializes the log. */
void void
log_init(void) log_sys_init()
/*==========*/
{ {
log_sys = static_cast<log_t*>(ut_zalloc_nokey(sizeof(log_t))); log_sys = static_cast<log_t*>(ut_zalloc_nokey(sizeof(log_t)));
...@@ -780,7 +760,6 @@ log_init(void) ...@@ -780,7 +760,6 @@ log_init(void)
log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO log_sys->max_buf_free = log_sys->buf_size / LOG_BUF_FLUSH_RATIO
- LOG_BUF_FLUSH_MARGIN; - LOG_BUF_FLUSH_MARGIN;
log_sys->check_flush_or_checkpoint = true; log_sys->check_flush_or_checkpoint = true;
UT_LIST_INIT(log_sys->log_groups, &log_group_t::log_groups);
log_sys->n_log_ios_old = log_sys->n_log_ios; log_sys->n_log_ios_old = log_sys->n_log_ios;
log_sys->last_printout_time = time(NULL); log_sys->last_printout_time = time(NULL);
...@@ -824,32 +803,20 @@ log_init(void) ...@@ -824,32 +803,20 @@ log_init(void)
} }
} }
/******************************************************************//** /** Initialize the redo log.
Inits a log group to the log system. @param[in] n_files number of files
@return true if success, false if not */ @param[in] file_size file size in bytes */
MY_ATTRIBUTE((warn_unused_result)) void
bool log_init(ulint n_files, lsn_t file_size)
log_group_init(
/*===========*/
ulint id, /*!< in: group id */
ulint n_files, /*!< in: number of log files */
lsn_t file_size, /*!< in: log file size in bytes */
ulint space_id) /*!< in: space id of the file space
which contains the log files of this
group */
{ {
ulint i; ulint i;
log_group_t* group; log_group_t* group = &log_sys->log;
group = static_cast<log_group_t*>(ut_malloc_nokey(sizeof(log_group_t)));
group->id = id;
group->n_files = n_files; group->n_files = n_files;
group->format = srv_encrypt_log group->format = srv_encrypt_log
? LOG_HEADER_FORMAT_CURRENT | LOG_HEADER_FORMAT_ENCRYPTED ? LOG_HEADER_FORMAT_CURRENT | LOG_HEADER_FORMAT_ENCRYPTED
: LOG_HEADER_FORMAT_CURRENT; : LOG_HEADER_FORMAT_CURRENT;
group->file_size = file_size; group->file_size = file_size;
group->space_id = space_id;
group->state = LOG_GROUP_OK; group->state = LOG_GROUP_OK;
group->lsn = LOG_START_LSN; group->lsn = LOG_START_LSN;
group->lsn_offset = LOG_FILE_HDR_SIZE; group->lsn_offset = LOG_FILE_HDR_SIZE;
...@@ -875,9 +842,6 @@ log_group_init( ...@@ -875,9 +842,6 @@ log_group_init(
group->checkpoint_buf = static_cast<byte*>( group->checkpoint_buf = static_cast<byte*>(
ut_align(group->checkpoint_buf_ptr,OS_FILE_LOG_BLOCK_SIZE)); ut_align(group->checkpoint_buf_ptr,OS_FILE_LOG_BLOCK_SIZE));
UT_LIST_ADD_LAST(log_sys->log_groups, group);
return(log_calc_max_ages());
} }
/******************************************************//** /******************************************************//**
...@@ -900,12 +864,11 @@ log_io_complete( ...@@ -900,12 +864,11 @@ log_io_complete(
case SRV_O_DIRECT: case SRV_O_DIRECT:
case SRV_O_DIRECT_NO_FSYNC: case SRV_O_DIRECT_NO_FSYNC:
case SRV_ALL_O_DIRECT_FSYNC: case SRV_ALL_O_DIRECT_FSYNC:
fil_flush(group->space_id); fil_flush(SRV_LOG_SPACE_FIRST_ID);
} }
DBUG_PRINT("ib_log", ("checkpoint info written to group %u", DBUG_PRINT("ib_log", ("checkpoint info written"));
unsigned(group->id)));
log_io_complete_checkpoint(); log_io_complete_checkpoint();
return; return;
...@@ -932,7 +895,6 @@ log_group_file_header_flush( ...@@ -932,7 +895,6 @@ log_group_file_header_flush(
ut_ad(log_write_mutex_own()); ut_ad(log_write_mutex_own());
ut_ad(!recv_no_log_write); ut_ad(!recv_no_log_write);
ut_ad(group->id == 0);
ut_a(nth_file < group->n_files); ut_a(nth_file < group->n_files);
ut_ad((group->format & ~LOG_HEADER_FORMAT_ENCRYPTED) ut_ad((group->format & ~LOG_HEADER_FORMAT_ENCRYPTED)
== LOG_HEADER_FORMAT_CURRENT); == LOG_HEADER_FORMAT_CURRENT);
...@@ -951,9 +913,8 @@ log_group_file_header_flush( ...@@ -951,9 +913,8 @@ log_group_file_header_flush(
dest_offset = nth_file * group->file_size; dest_offset = nth_file * group->file_size;
DBUG_PRINT("ib_log", ("write " LSN_PF DBUG_PRINT("ib_log", ("write " LSN_PF
" group " ULINTPF
" file " ULINTPF " header", " file " ULINTPF " header",
start_lsn, group->id, nth_file)); start_lsn, nth_file));
log_sys->n_log_ios++; log_sys->n_log_ios++;
...@@ -965,7 +926,7 @@ log_group_file_header_flush( ...@@ -965,7 +926,7 @@ log_group_file_header_flush(
= (ulint) (dest_offset / univ_page_size.physical()); = (ulint) (dest_offset / univ_page_size.physical());
fil_io(IORequestLogWrite, true, fil_io(IORequestLogWrite, true,
page_id_t(group->space_id, page_no), page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size, univ_page_size,
(ulint) (dest_offset % univ_page_size.physical()), (ulint) (dest_offset % univ_page_size.physical()),
OS_FILE_LOG_BLOCK_SIZE, buf, group); OS_FILE_LOG_BLOCK_SIZE, buf, group);
...@@ -1051,10 +1012,10 @@ log_group_write_buf( ...@@ -1051,10 +1012,10 @@ log_group_write_buf(
DBUG_PRINT("ib_log", DBUG_PRINT("ib_log",
("write " LSN_PF " to " LSN_PF ("write " LSN_PF " to " LSN_PF
": group " ULINTPF " len " ULINTPF ": len " ULINTPF
" blocks " ULINTPF ".." ULINTPF, " blocks " ULINTPF ".." ULINTPF,
start_lsn, next_offset, start_lsn, next_offset,
group->id, write_len, write_len,
log_block_get_hdr_no(buf), log_block_get_hdr_no(buf),
log_block_get_hdr_no( log_block_get_hdr_no(
buf + write_len buf + write_len
...@@ -1092,7 +1053,7 @@ log_group_write_buf( ...@@ -1092,7 +1053,7 @@ log_group_write_buf(
= (ulint) (next_offset / univ_page_size.physical()); = (ulint) (next_offset / univ_page_size.physical());
fil_io(IORequestLogWrite, true, fil_io(IORequestLogWrite, true,
page_id_t(group->space_id, page_no), page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size, univ_page_size,
(ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf, (ulint) (next_offset % UNIV_PAGE_SIZE), write_len, buf,
group); group);
...@@ -1260,7 +1221,6 @@ log_write_up_to( ...@@ -1260,7 +1221,6 @@ log_write_up_to(
return; return;
} }
log_group_t* group;
ulint start_offset; ulint start_offset;
ulint end_offset; ulint end_offset;
ulint area_start; ulint area_start;
...@@ -1304,9 +1264,7 @@ log_write_up_to( ...@@ -1304,9 +1264,7 @@ log_write_up_to(
log_buffer_switch(); log_buffer_switch();
group = UT_LIST_GET_FIRST(log_sys->log_groups); log_group_set_fields(&log_sys->log, log_sys->write_lsn);
log_group_set_fields(group, log_sys->write_lsn);
log_mutex_exit(); log_mutex_exit();
/* Calculate pad_size if needed. */ /* Calculate pad_size if needed. */
...@@ -1317,7 +1275,7 @@ log_write_up_to( ...@@ -1317,7 +1275,7 @@ log_write_up_to(
end_offset = log_group_calc_lsn_offset( end_offset = log_group_calc_lsn_offset(
ut_uint64_align_up(write_lsn, ut_uint64_align_up(write_lsn,
OS_FILE_LOG_BLOCK_SIZE), OS_FILE_LOG_BLOCK_SIZE),
group); &log_sys->log);
end_offset_in_unit = (ulint) (end_offset % write_ahead_size); end_offset_in_unit = (ulint) (end_offset % write_ahead_size);
if (end_offset_in_unit > 0 if (end_offset_in_unit > 0
...@@ -1336,7 +1294,7 @@ log_write_up_to( ...@@ -1336,7 +1294,7 @@ log_write_up_to(
} }
/* Do the write to the log files */ /* Do the write to the log files */
log_group_write_buf( log_group_write_buf(
group, write_buf + area_start, &log_sys->log, write_buf + area_start,
area_end - area_start + pad_size, area_end - area_start + pad_size,
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
pad_size, pad_size,
...@@ -1539,11 +1497,10 @@ log_io_complete_checkpoint(void) ...@@ -1539,11 +1497,10 @@ log_io_complete_checkpoint(void)
} }
/** Write checkpoint info to the log header. /** Write checkpoint info to the log header.
@param[in,out] group redo log
@param[in] end_lsn start LSN of the MLOG_CHECKPOINT mini-transaction */ @param[in] end_lsn start LSN of the MLOG_CHECKPOINT mini-transaction */
static static
void void
log_group_checkpoint(log_group_t* group, lsn_t end_lsn) log_group_checkpoint(lsn_t end_lsn)
{ {
lsn_t lsn_offset; lsn_t lsn_offset;
byte* buf; byte* buf;
...@@ -1556,10 +1513,11 @@ log_group_checkpoint(log_group_t* group, lsn_t end_lsn) ...@@ -1556,10 +1513,11 @@ log_group_checkpoint(log_group_t* group, lsn_t end_lsn)
|| srv_shutdown_state != SRV_SHUTDOWN_NONE); || srv_shutdown_state != SRV_SHUTDOWN_NONE);
DBUG_PRINT("ib_log", ("checkpoint " UINT64PF " at " LSN_PF DBUG_PRINT("ib_log", ("checkpoint " UINT64PF " at " LSN_PF
" written to group " ULINTPF, " written",
log_sys->next_checkpoint_no, log_sys->next_checkpoint_no,
log_sys->next_checkpoint_lsn, log_sys->next_checkpoint_lsn));
group->id));
log_group_t* group = &log_sys->log;
buf = group->checkpoint_buf; buf = group->checkpoint_buf;
memset(buf, 0, OS_FILE_LOG_BLOCK_SIZE); memset(buf, 0, OS_FILE_LOG_BLOCK_SIZE);
...@@ -1601,7 +1559,7 @@ log_group_checkpoint(log_group_t* group, lsn_t end_lsn) ...@@ -1601,7 +1559,7 @@ log_group_checkpoint(log_group_t* group, lsn_t end_lsn)
file write and a checkpoint field write */ file write and a checkpoint field write */
fil_io(IORequestLogWrite, false, fil_io(IORequestLogWrite, false,
page_id_t(group->space_id, 0), page_id_t(SRV_LOG_SPACE_FIRST_ID, 0),
univ_page_size, univ_page_size,
(log_sys->next_checkpoint_no & 1) (log_sys->next_checkpoint_no & 1)
? LOG_CHECKPOINT_2 : LOG_CHECKPOINT_1, ? LOG_CHECKPOINT_2 : LOG_CHECKPOINT_1,
...@@ -1626,7 +1584,8 @@ log_group_header_read( ...@@ -1626,7 +1584,8 @@ log_group_header_read(
MONITOR_INC(MONITOR_LOG_IO); MONITOR_INC(MONITOR_LOG_IO);
fil_io(IORequestLogRead, true, fil_io(IORequestLogRead, true,
page_id_t(group->space_id, header / univ_page_size.physical()), page_id_t(SRV_LOG_SPACE_FIRST_ID,
header / univ_page_size.physical()),
univ_page_size, header % univ_page_size.physical(), univ_page_size, header % univ_page_size.physical(),
OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL); OS_FILE_LOG_BLOCK_SIZE, log_sys->checkpoint_buf, NULL);
} }
...@@ -1640,12 +1599,7 @@ log_write_checkpoint_info(bool sync, lsn_t end_lsn) ...@@ -1640,12 +1599,7 @@ log_write_checkpoint_info(bool sync, lsn_t end_lsn)
ut_ad(log_mutex_own()); ut_ad(log_mutex_own());
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
for (log_group_t* group = UT_LIST_GET_FIRST(log_sys->log_groups); log_group_checkpoint(end_lsn);
group;
group = UT_LIST_GET_NEXT(log_groups, group)) {
log_group_checkpoint(group, end_lsn);
}
log_mutex_exit(); log_mutex_exit();
...@@ -2283,13 +2237,11 @@ log_refresh_stats(void) ...@@ -2283,13 +2237,11 @@ log_refresh_stats(void)
log_sys->last_printout_time = time(NULL); log_sys->last_printout_time = time(NULL);
} }
/********************************************************//** /** Close a log group.
Closes a log group. */ @param[in,out] group log group to close */
static static
void void
log_group_close( log_group_close(log_group_t* group)
/*===========*/
log_group_t* group) /* in,own: log group to close */
{ {
ulint i; ulint i;
...@@ -2300,7 +2252,10 @@ log_group_close( ...@@ -2300,7 +2252,10 @@ log_group_close(
ut_free(group->file_header_bufs_ptr); ut_free(group->file_header_bufs_ptr);
ut_free(group->file_header_bufs); ut_free(group->file_header_bufs);
ut_free(group->checkpoint_buf_ptr); ut_free(group->checkpoint_buf_ptr);
ut_free(group); group->n_files = 0;
group->file_header_bufs_ptr = NULL;
group->file_header_bufs = NULL;
group->checkpoint_buf_ptr = NULL;
} }
/********************************************************//** /********************************************************//**
...@@ -2309,19 +2264,7 @@ void ...@@ -2309,19 +2264,7 @@ void
log_group_close_all(void) log_group_close_all(void)
/*=====================*/ /*=====================*/
{ {
log_group_t* group; log_group_close(&log_sys->log);
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (UT_LIST_GET_LEN(log_sys->log_groups) > 0) {
log_group_t* prev_group = group;
group = UT_LIST_GET_NEXT(log_groups, group);
UT_LIST_REMOVE(log_sys->log_groups, prev_group);
log_group_close(prev_group);
}
} }
/********************************************************//** /********************************************************//**
......
...@@ -717,7 +717,7 @@ log_group_read_log_seg( ...@@ -717,7 +717,7 @@ log_group_read_log_seg(
= (ulint) (source_offset / univ_page_size.physical()); = (ulint) (source_offset / univ_page_size.physical());
fil_io(IORequestLogRead, true, fil_io(IORequestLogRead, true,
page_id_t(group->space_id, page_no), page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size, univ_page_size,
(ulint) (source_offset % univ_page_size.physical()), (ulint) (source_offset % univ_page_size.physical()),
len, buf, NULL); len, buf, NULL);
...@@ -787,20 +787,13 @@ recv_synchronize_groups() ...@@ -787,20 +787,13 @@ recv_synchronize_groups()
const lsn_t start_lsn = ut_uint64_align_down(recovered_lsn, const lsn_t start_lsn = ut_uint64_align_down(recovered_lsn,
OS_FILE_LOG_BLOCK_SIZE); OS_FILE_LOG_BLOCK_SIZE);
log_group_read_log_seg(log_sys->buf, log_group_read_log_seg(log_sys->buf, &log_sys->log,
UT_LIST_GET_FIRST(log_sys->log_groups),
start_lsn, start_lsn + OS_FILE_LOG_BLOCK_SIZE); start_lsn, start_lsn + OS_FILE_LOG_BLOCK_SIZE);
ut_ad(UT_LIST_GET_LEN(log_sys->log_groups) == 1);
for (log_group_t* group = UT_LIST_GET_FIRST(log_sys->log_groups);
group;
group = UT_LIST_GET_NEXT(log_groups, group)) {
/* Update the fields in the group struct to correspond to /* Update the fields in the group struct to correspond to
recovered_lsn */ recovered_lsn */
log_group_set_fields(group, recovered_lsn); log_group_set_fields(&log_sys->log, recovered_lsn);
}
/* Copy the checkpoint info to the log; remember that we have /* Copy the checkpoint info to the log; remember that we have
incremented checkpoint_no by one, and the info will not be written incremented checkpoint_no by one, and the info will not be written
...@@ -831,17 +824,14 @@ recv_check_log_header_checksum( ...@@ -831,17 +824,14 @@ recv_check_log_header_checksum(
@return error code or DB_SUCCESS */ @return error code or DB_SUCCESS */
static MY_ATTRIBUTE((warn_unused_result)) static MY_ATTRIBUTE((warn_unused_result))
dberr_t dberr_t
recv_find_max_checkpoint_0( recv_find_max_checkpoint_0(log_group_t** max_group, ulint* max_field)
log_group_t** max_group,
ulint* max_field)
{ {
log_group_t* group = UT_LIST_GET_FIRST(log_sys->log_groups); log_group_t* group = &log_sys->log;
ib_uint64_t max_no = 0; ib_uint64_t max_no = 0;
ib_uint64_t checkpoint_no; ib_uint64_t checkpoint_no;
byte* buf = log_sys->checkpoint_buf; byte* buf = log_sys->checkpoint_buf;
ut_ad(group->format == 0); ut_ad(group->format == 0);
ut_ad(UT_LIST_GET_NEXT(log_groups, group) == NULL);
/** Offset of the first checkpoint checksum */ /** Offset of the first checkpoint checksum */
static const uint CHECKSUM_1 = 288; static const uint CHECKSUM_1 = 288;
...@@ -852,6 +842,8 @@ recv_find_max_checkpoint_0( ...@@ -852,6 +842,8 @@ recv_find_max_checkpoint_0(
/** Least significant bits of the checkpoint offset */ /** Least significant bits of the checkpoint offset */
static const uint OFFSET_LOW32 = 16; static const uint OFFSET_LOW32 = 16;
*max_group = NULL;
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_group_header_read(group, field); log_group_header_read(group, field);
...@@ -883,9 +875,8 @@ recv_find_max_checkpoint_0( ...@@ -883,9 +875,8 @@ recv_find_max_checkpoint_0(
} }
DBUG_PRINT("ib_log", DBUG_PRINT("ib_log",
("checkpoint " UINT64PF " at " LSN_PF ("checkpoint " UINT64PF " at " LSN_PF " found",
" found in group " ULINTPF, checkpoint_no, group->lsn));
checkpoint_no, group->lsn, group->id));
if (checkpoint_no >= max_no) { if (checkpoint_no >= max_no) {
*max_group = group; *max_group = group;
...@@ -916,7 +907,7 @@ dberr_t ...@@ -916,7 +907,7 @@ dberr_t
recv_log_format_0_recover(lsn_t lsn) recv_log_format_0_recover(lsn_t lsn)
{ {
log_mutex_enter(); log_mutex_enter();
log_group_t* group = UT_LIST_GET_FIRST(log_sys->log_groups); log_group_t* group = &log_sys->log;
const lsn_t source_offset const lsn_t source_offset
= log_group_calc_lsn_offset(lsn, group); = log_group_calc_lsn_offset(lsn, group);
log_mutex_exit(); log_mutex_exit();
...@@ -932,7 +923,7 @@ recv_log_format_0_recover(lsn_t lsn) ...@@ -932,7 +923,7 @@ recv_log_format_0_recover(lsn_t lsn)
REFMAN "upgrading.html"; REFMAN "upgrading.html";
fil_io(IORequestLogRead, true, fil_io(IORequestLogRead, true,
page_id_t(group->space_id, page_no), page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size, univ_page_size,
(ulint) ((source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1)) (ulint) ((source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1))
% univ_page_size.physical()), % univ_page_size.physical()),
...@@ -968,14 +959,10 @@ recv_log_format_0_recover(lsn_t lsn) ...@@ -968,14 +959,10 @@ recv_log_format_0_recover(lsn_t lsn)
} }
/** Find the latest checkpoint in the log header. /** Find the latest checkpoint in the log header.
@param[out] max_group log group, or NULL
@param[out] max_field LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2 @param[out] max_field LOG_CHECKPOINT_1 or LOG_CHECKPOINT_2
@return error code or DB_SUCCESS */ @return error code or DB_SUCCESS */
static MY_ATTRIBUTE((warn_unused_result))
dberr_t dberr_t
recv_find_max_checkpoint( recv_find_max_checkpoint(ulint* max_field)
log_group_t** max_group,
ulint* max_field)
{ {
log_group_t* group; log_group_t* group;
ib_uint64_t max_no; ib_uint64_t max_no;
...@@ -983,15 +970,13 @@ recv_find_max_checkpoint( ...@@ -983,15 +970,13 @@ recv_find_max_checkpoint(
ulint field; ulint field;
byte* buf; byte* buf;
group = UT_LIST_GET_FIRST(log_sys->log_groups); group = &log_sys->log;
max_no = 0; max_no = 0;
*max_group = NULL;
*max_field = 0; *max_field = 0;
buf = log_sys->checkpoint_buf; buf = log_sys->checkpoint_buf;
while (group) {
group->state = LOG_GROUP_CORRUPTED; group->state = LOG_GROUP_CORRUPTED;
log_group_header_read(group, 0); log_group_header_read(group, 0);
...@@ -1006,8 +991,7 @@ recv_find_max_checkpoint( ...@@ -1006,8 +991,7 @@ recv_find_max_checkpoint(
switch (group->format) { switch (group->format) {
case 0: case 0:
return(recv_find_max_checkpoint_0( return(recv_find_max_checkpoint_0(&group, max_field));
max_group, max_field));
case LOG_HEADER_FORMAT_CURRENT: case LOG_HEADER_FORMAT_CURRENT:
case LOG_HEADER_FORMAT_CURRENT | LOG_HEADER_FORMAT_ENCRYPTED: case LOG_HEADER_FORMAT_CURRENT | LOG_HEADER_FORMAT_ENCRYPTED:
break; break;
...@@ -1038,11 +1022,10 @@ recv_find_max_checkpoint( ...@@ -1038,11 +1022,10 @@ recv_find_max_checkpoint(
if (crc32 != cksum) { if (crc32 != cksum) {
DBUG_PRINT("ib_log", DBUG_PRINT("ib_log",
("invalid checkpoint," ("invalid checkpoint,"
" group " ULINTPF " at " ULINTPF " at " ULINTPF
", checksum %x expected %x", ", checksum " ULINTPFx
group->id, field, " expected " ULINTPFx,
(unsigned) cksum, field, cksum, crc32));
(unsigned) crc32));
continue; continue;
} }
...@@ -1063,21 +1046,16 @@ recv_find_max_checkpoint( ...@@ -1063,21 +1046,16 @@ recv_find_max_checkpoint(
buf + LOG_CHECKPOINT_NO); buf + LOG_CHECKPOINT_NO);
DBUG_PRINT("ib_log", DBUG_PRINT("ib_log",
("checkpoint " UINT64PF " at " LSN_PF ("checkpoint " UINT64PF " at " LSN_PF " found ",
" found in group " ULINTPF, checkpoint_no, group->lsn));
checkpoint_no, group->lsn, group->id));
if (checkpoint_no >= max_no) { if (checkpoint_no >= max_no) {
*max_group = group;
*max_field = field; *max_field = field;
max_no = checkpoint_no; max_no = checkpoint_no;
} }
} }
group = UT_LIST_GET_NEXT(log_groups, group); if (*max_field == 0) {
}
if (*max_group == NULL) {
/* Before 5.7.9, we could get here during database /* Before 5.7.9, we could get here during database
initialization if we created an ib_logfile0 file that initialization if we created an ib_logfile0 file that
was filled with zeroes, and were killed. After was filled with zeroes, and were killed. After
...@@ -1798,8 +1776,7 @@ recv_recover_page(bool just_read_in, buf_block_t* block) ...@@ -1798,8 +1776,7 @@ recv_recover_page(bool just_read_in, buf_block_t* block)
while (recv) { while (recv) {
end_lsn = recv->end_lsn; end_lsn = recv->end_lsn;
ut_ad(end_lsn ut_ad(end_lsn <= log_sys->log.scanned_lsn);
<= UT_LIST_GET_FIRST(log_sys->log_groups)->scanned_lsn);
if (recv->len > RECV_DATA_BLOCK_SIZE) { if (recv->len > RECV_DATA_BLOCK_SIZE) {
/* We have to copy the record body to a separate /* We have to copy the record body to a separate
...@@ -2988,10 +2965,9 @@ recv_group_scan_log_recs( ...@@ -2988,10 +2965,9 @@ recv_group_scan_log_recs(
DBUG_RETURN(false); DBUG_RETURN(false);
} }
DBUG_PRINT("ib_log", ("%s " LSN_PF DBUG_PRINT("ib_log", ("%s " LSN_PF " completed",
" completed for log group " ULINTPF,
last_phase ? "rescan" : "scan", last_phase ? "rescan" : "scan",
group->scanned_lsn, group->id)); group->scanned_lsn));
DBUG_RETURN(store_to_hash == STORE_NO); DBUG_RETURN(store_to_hash == STORE_NO);
} }
...@@ -3142,11 +3118,9 @@ recv_init_crash_recovery_spaces() ...@@ -3142,11 +3118,9 @@ recv_init_crash_recovery_spaces()
of first system tablespace page of first system tablespace page
@return error code or DB_SUCCESS */ @return error code or DB_SUCCESS */
dberr_t dberr_t
recv_recovery_from_checkpoint_start( recv_recovery_from_checkpoint_start(lsn_t flush_lsn)
lsn_t flush_lsn)
{ {
log_group_t* group; log_group_t* group;
log_group_t* max_cp_group;
ulint max_cp_field; ulint max_cp_field;
lsn_t checkpoint_lsn; lsn_t checkpoint_lsn;
bool rescan; bool rescan;
...@@ -3172,14 +3146,14 @@ recv_recovery_from_checkpoint_start( ...@@ -3172,14 +3146,14 @@ recv_recovery_from_checkpoint_start(
/* Look for the latest checkpoint from any of the log groups */ /* Look for the latest checkpoint from any of the log groups */
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field); err = recv_find_max_checkpoint(&max_cp_field);
if (err != DB_SUCCESS) { if (err != DB_SUCCESS) {
log_mutex_exit(); log_mutex_exit();
return(err); return(err);
} }
log_group_header_read(max_cp_group, max_cp_field); log_group_header_read(&log_sys->log, max_cp_field);
buf = log_sys->checkpoint_buf; buf = log_sys->checkpoint_buf;
...@@ -3194,8 +3168,7 @@ recv_recovery_from_checkpoint_start( ...@@ -3194,8 +3168,7 @@ recv_recovery_from_checkpoint_start(
ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size); ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
ut_ad(UT_LIST_GET_LEN(log_sys->log_groups) == 1); group = &log_sys->log;
group = UT_LIST_GET_FIRST(log_sys->log_groups);
const lsn_t end_lsn = mach_read_from_8( const lsn_t end_lsn = mach_read_from_8(
buf + LOG_CHECKPOINT_END_LSN); buf + LOG_CHECKPOINT_END_LSN);
...@@ -3483,11 +3456,8 @@ recv_reset_logs( ...@@ -3483,11 +3456,8 @@ recv_reset_logs(
log_sys->lsn = ut_uint64_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE); log_sys->lsn = ut_uint64_align_up(lsn, OS_FILE_LOG_BLOCK_SIZE);
for (log_group_t* group = UT_LIST_GET_FIRST(log_sys->log_groups); log_sys->log.lsn = log_sys->lsn;
group; group = UT_LIST_GET_NEXT(log_groups, group)) { log_sys->log.lsn_offset = LOG_FILE_HDR_SIZE;
group->lsn = log_sys->lsn;
group->lsn_offset = LOG_FILE_HDR_SIZE;
}
log_sys->buf_next_to_write = 0; log_sys->buf_next_to_write = 0;
log_sys->write_lsn = log_sys->lsn; log_sys->write_lsn = log_sys->lsn;
......
...@@ -478,9 +478,8 @@ create_log_files( ...@@ -478,9 +478,8 @@ create_log_files(
} }
} }
if (!log_group_init(0, srv_n_log_files, log_init(srv_n_log_files, srv_log_file_size * UNIV_PAGE_SIZE);
srv_log_file_size * UNIV_PAGE_SIZE, if (!log_set_capacity()) {
SRV_LOG_SPACE_FIRST_ID)) {
return(DB_ERROR); return(DB_ERROR);
} }
...@@ -1835,7 +1834,7 @@ innobase_start_or_create_for_mysql(void) ...@@ -1835,7 +1834,7 @@ innobase_start_or_create_for_mysql(void)
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
fsp_init(); fsp_init();
log_init(); log_sys_init();
recv_sys_create(); recv_sys_create();
recv_sys_init(buf_pool_get_curr_size()); recv_sys_init(buf_pool_get_curr_size());
...@@ -2091,8 +2090,9 @@ innobase_start_or_create_for_mysql(void) ...@@ -2091,8 +2090,9 @@ innobase_start_or_create_for_mysql(void)
} }
} }
if (!log_group_init(0, i, srv_log_file_size * UNIV_PAGE_SIZE, log_init(i, srv_log_file_size * UNIV_PAGE_SIZE);
SRV_LOG_SPACE_FIRST_ID)) {
if (!log_set_capacity()) {
return(srv_init_abort(DB_ERROR)); return(srv_init_abort(DB_ERROR));
} }
} }
......
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