Skip to content

Commit

Permalink
MDEV-12975 InnoDB redo log minimum size check uses detected file size…
Browse files Browse the repository at this point in the history
… instead of requested innodb_log_file_size

log_calc_max_ages(): Use the requested size in the check, instead of
the detected redo log size. The redo log will be resized at startup
if it differs from what has been requested.
  • Loading branch information
dr-m committed Jun 19, 2017
1 parent 9a646c9 commit d1e182d
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 103 deletions.
8 changes: 7 additions & 1 deletion mysql-test/suite/innodb/t/log_file_size.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test resizing the InnoDB redo log.

--source include/have_innodb.inc
--source include/innodb_page_size_small.inc

# Embedded server does not support crashing
--source include/not_embedded.inc
Expand Down Expand Up @@ -37,6 +37,12 @@ call mtr.add_suppression("Attempting backtrace");
FLUSH TABLES;
--enable_query_log

--let $restart_parameters= --innodb-thread-concurrency=1 --innodb-log-file-size=1m --innodb-log-files-in-group=2
--source include/restart_mysqld.inc

--let $restart_parameters= --innodb-thread-concurrency=100 --innodb-log-file-size=10M --innodb-log-files-in-group=2
--source include/restart_mysqld.inc

CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (42);
Expand Down
71 changes: 20 additions & 51 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -754,43 +754,16 @@ ibool
log_calc_max_ages(void)
/*===================*/
{
log_group_t* group;
lsn_t margin;
ulint free;
ibool success = TRUE;
lsn_t smallest_capacity;
lsn_t archive_margin;
lsn_t smallest_archive_margin;

mutex_enter(&(log_sys->mutex));

group = UT_LIST_GET_FIRST(log_sys->log_groups);

ut_ad(group);

smallest_capacity = LSN_MAX;
smallest_archive_margin = LSN_MAX;

while (group) {
if (log_group_get_capacity(group) < smallest_capacity) {

smallest_capacity = log_group_get_capacity(group);
}

archive_margin = log_group_get_capacity(group)
- (group->file_size - LOG_FILE_HDR_SIZE)
- LOG_ARCHIVE_EXTRA_MARGIN;

if (archive_margin < smallest_archive_margin) {

smallest_archive_margin = archive_margin;
}

group = UT_LIST_GET_NEXT(log_groups, group);
}
lsn_t smallest_capacity = ((srv_log_file_size_requested
<< srv_page_size_shift)
- LOG_FILE_HDR_SIZE)
* srv_n_log_files;

/* Add extra safety */
smallest_capacity = smallest_capacity - smallest_capacity / 10;
smallest_capacity -= smallest_capacity / 10;

/* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced
Expand All @@ -800,15 +773,16 @@ log_calc_max_ages(void)
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) {
success = FALSE;

goto failure;
} else {
margin = smallest_capacity - free;
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}

margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */

mutex_enter(&log_sys->mutex);

log_sys->log_group_capacity = smallest_capacity;

log_sys->max_modified_age_async = margin
Expand All @@ -821,22 +795,17 @@ log_calc_max_ages(void)
log_sys->max_checkpoint_age = margin;

#ifdef UNIV_LOG_ARCHIVE
log_sys->max_archived_lsn_age = smallest_archive_margin;
lsn_t archive_margin = smallest_capacity
- (srv_log_file_size_requested - LOG_FILE_HDR_SIZE)
- LOG_ARCHIVE_EXTRA_MARGIN;
log_sys->max_archived_lsn_age = archive_margin;

log_sys->max_archived_lsn_age_async = smallest_archive_margin
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
log_sys->max_archived_lsn_age_async = archive_margin
- archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
#endif /* UNIV_LOG_ARCHIVE */
failure:
mutex_exit(&(log_sys->mutex));

if (!success) {
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}
mutex_exit(&log_sys->mutex);

return(success);
return(true);
}

/******************************************************//**
Expand Down
71 changes: 20 additions & 51 deletions storage/xtradb/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -860,43 +860,16 @@ ibool
log_calc_max_ages(void)
/*===================*/
{
log_group_t* group;
lsn_t margin;
ulint free;
ibool success = TRUE;
lsn_t smallest_capacity;
lsn_t archive_margin;
lsn_t smallest_archive_margin;

mutex_enter(&(log_sys->mutex));

group = UT_LIST_GET_FIRST(log_sys->log_groups);

ut_ad(group);

smallest_capacity = LSN_MAX;
smallest_archive_margin = LSN_MAX;

while (group) {
if (log_group_get_capacity(group) < smallest_capacity) {

smallest_capacity = log_group_get_capacity(group);
}

archive_margin = log_group_get_capacity(group)
- (group->file_size - LOG_FILE_HDR_SIZE)
- LOG_ARCHIVE_EXTRA_MARGIN;

if (archive_margin < smallest_archive_margin) {

smallest_archive_margin = archive_margin;
}

group = UT_LIST_GET_NEXT(log_groups, group);
}
lsn_t smallest_capacity = ((srv_log_file_size_requested
<< srv_page_size_shift)
- LOG_FILE_HDR_SIZE)
* srv_n_log_files;

/* Add extra safety */
smallest_capacity = smallest_capacity - smallest_capacity / 10;
smallest_capacity -= smallest_capacity / 10;

/* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced
Expand All @@ -906,15 +879,16 @@ log_calc_max_ages(void)
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) {
success = FALSE;

goto failure;
} else {
margin = smallest_capacity - free;
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}

margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */

mutex_enter(&log_sys->mutex);

log_sys->log_group_capacity = smallest_capacity;

log_sys->max_modified_age_async = margin
Expand All @@ -927,22 +901,17 @@ log_calc_max_ages(void)
log_sys->max_checkpoint_age = margin;

#ifdef UNIV_LOG_ARCHIVE
log_sys->max_archived_lsn_age = smallest_archive_margin;
lsn_t archive_margin = smallest_capacity
- (srv_log_file_size_requested - LOG_FILE_HDR_SIZE)
- LOG_ARCHIVE_EXTRA_MARGIN;
log_sys->max_archived_lsn_age = archive_margin;

log_sys->max_archived_lsn_age_async = smallest_archive_margin
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
log_sys->max_archived_lsn_age_async = archive_margin
- archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
#endif /* UNIV_LOG_ARCHIVE */
failure:
mutex_exit(&(log_sys->mutex));

if (!success) {
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}
mutex_exit(&log_sys->mutex);

return(success);
return(true);
}

/******************************************************//**
Expand Down

0 comments on commit d1e182d

Please sign in to comment.