MDEV-12975 InnoDB redo log minimum size check uses detected file size 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.
This commit is contained in:
Marko Mäkelä 2017-06-19 15:59:19 +03:00
parent 9a646c91dd
commit d1e182d603
3 changed files with 47 additions and 103 deletions

View File

@ -1,6 +1,6 @@
# Test resizing the InnoDB redo log. # Test resizing the InnoDB redo log.
--source include/have_innodb.inc --source include/innodb_page_size_small.inc
# Embedded server does not support crashing # Embedded server does not support crashing
--source include/not_embedded.inc --source include/not_embedded.inc
@ -37,6 +37,12 @@ call mtr.add_suppression("Attempting backtrace");
FLUSH TABLES; FLUSH TABLES;
--enable_query_log --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; CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN; BEGIN;
INSERT INTO t1 VALUES (42); INSERT INTO t1 VALUES (42);

View File

@ -754,43 +754,16 @@ ibool
log_calc_max_ages(void) log_calc_max_ages(void)
/*===================*/ /*===================*/
{ {
log_group_t* group;
lsn_t margin; lsn_t margin;
ulint free; ulint free;
ibool success = TRUE;
lsn_t smallest_capacity;
lsn_t archive_margin;
lsn_t smallest_archive_margin;
mutex_enter(&(log_sys->mutex)); lsn_t smallest_capacity = ((srv_log_file_size_requested
<< srv_page_size_shift)
group = UT_LIST_GET_FIRST(log_sys->log_groups); - LOG_FILE_HDR_SIZE)
* srv_n_log_files;
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);
}
/* Add extra safety */ /* 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 /* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced smallest log group that it can accommodate the log entries produced
@ -800,15 +773,16 @@ log_calc_max_ages(void)
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency) free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE; + LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) { if (free >= smallest_capacity / 2) {
success = FALSE; ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
goto failure; " should be bigger than\n"
} else { "InnoDB: 200 kB * innodb_thread_concurrency.");
margin = smallest_capacity - free;
} }
margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */ margin = margin - margin / 10; /* Add still some extra safety */
mutex_enter(&log_sys->mutex);
log_sys->log_group_capacity = smallest_capacity; log_sys->log_group_capacity = smallest_capacity;
log_sys->max_modified_age_async = margin log_sys->max_modified_age_async = margin
@ -821,22 +795,17 @@ log_calc_max_ages(void)
log_sys->max_checkpoint_age = margin; log_sys->max_checkpoint_age = margin;
#ifdef UNIV_LOG_ARCHIVE #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 log_sys->max_archived_lsn_age_async = archive_margin
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC; - archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
failure: mutex_exit(&log_sys->mutex);
mutex_exit(&(log_sys->mutex));
if (!success) { return(true);
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}
return(success);
} }
/******************************************************//** /******************************************************//**

View File

@ -860,43 +860,16 @@ ibool
log_calc_max_ages(void) log_calc_max_ages(void)
/*===================*/ /*===================*/
{ {
log_group_t* group;
lsn_t margin; lsn_t margin;
ulint free; ulint free;
ibool success = TRUE;
lsn_t smallest_capacity;
lsn_t archive_margin;
lsn_t smallest_archive_margin;
mutex_enter(&(log_sys->mutex)); lsn_t smallest_capacity = ((srv_log_file_size_requested
<< srv_page_size_shift)
group = UT_LIST_GET_FIRST(log_sys->log_groups); - LOG_FILE_HDR_SIZE)
* srv_n_log_files;
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);
}
/* Add extra safety */ /* 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 /* For each OS thread we must reserve so much free space in the
smallest log group that it can accommodate the log entries produced smallest log group that it can accommodate the log entries produced
@ -906,15 +879,16 @@ log_calc_max_ages(void)
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency) free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
+ LOG_CHECKPOINT_EXTRA_FREE; + LOG_CHECKPOINT_EXTRA_FREE;
if (free >= smallest_capacity / 2) { if (free >= smallest_capacity / 2) {
success = FALSE; ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
goto failure; " should be bigger than\n"
} else { "InnoDB: 200 kB * innodb_thread_concurrency.");
margin = smallest_capacity - free;
} }
margin = smallest_capacity - free;
margin = margin - margin / 10; /* Add still some extra safety */ margin = margin - margin / 10; /* Add still some extra safety */
mutex_enter(&log_sys->mutex);
log_sys->log_group_capacity = smallest_capacity; log_sys->log_group_capacity = smallest_capacity;
log_sys->max_modified_age_async = margin log_sys->max_modified_age_async = margin
@ -927,22 +901,17 @@ log_calc_max_ages(void)
log_sys->max_checkpoint_age = margin; log_sys->max_checkpoint_age = margin;
#ifdef UNIV_LOG_ARCHIVE #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 log_sys->max_archived_lsn_age_async = archive_margin
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC; - archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
#endif /* UNIV_LOG_ARCHIVE */ #endif /* UNIV_LOG_ARCHIVE */
failure: mutex_exit(&log_sys->mutex);
mutex_exit(&(log_sys->mutex));
if (!success) { return(true);
ib_logf(IB_LOG_LEVEL_FATAL,
"The combined size of ib_logfiles"
" should be bigger than\n"
"InnoDB: 200 kB * innodb_thread_concurrency.");
}
return(success);
} }
/******************************************************//** /******************************************************//**