Skip to content

Commit d1e182d

Browse files
committed
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.
1 parent 9a646c9 commit d1e182d

File tree

3 files changed

+47
-103
lines changed

3 files changed

+47
-103
lines changed

mysql-test/suite/innodb/t/log_file_size.test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Test resizing the InnoDB redo log.
22

3-
--source include/have_innodb.inc
3+
--source include/innodb_page_size_small.inc
44

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

40+
--let $restart_parameters= --innodb-thread-concurrency=1 --innodb-log-file-size=1m --innodb-log-files-in-group=2
41+
--source include/restart_mysqld.inc
42+
43+
--let $restart_parameters= --innodb-thread-concurrency=100 --innodb-log-file-size=10M --innodb-log-files-in-group=2
44+
--source include/restart_mysqld.inc
45+
4046
CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
4147
BEGIN;
4248
INSERT INTO t1 VALUES (42);

storage/innobase/log/log0log.cc

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -754,43 +754,16 @@ ibool
754754
log_calc_max_ages(void)
755755
/*===================*/
756756
{
757-
log_group_t* group;
758757
lsn_tmargin;
759758
ulint free;
760-
ibool success = TRUE;
761-
lsn_tsmallest_capacity;
762-
lsn_tarchive_margin;
763-
lsn_tsmallest_archive_margin;
764-
765-
mutex_enter(&(log_sys->mutex));
766-
767-
group = UT_LIST_GET_FIRST(log_sys->log_groups);
768-
769-
ut_ad(group);
770-
771-
smallest_capacity = LSN_MAX;
772-
smallest_archive_margin = LSN_MAX;
773-
774-
while (group) {
775-
if (log_group_get_capacity(group) < smallest_capacity) {
776759

777-
smallest_capacity = log_group_get_capacity(group);
778-
}
779-
780-
archive_margin = log_group_get_capacity(group)
781-
- (group->file_size - LOG_FILE_HDR_SIZE)
782-
- LOG_ARCHIVE_EXTRA_MARGIN;
783-
784-
if (archive_margin < smallest_archive_margin) {
785-
786-
smallest_archive_margin = archive_margin;
787-
}
788-
789-
group = UT_LIST_GET_NEXT(log_groups, group);
790-
}
760+
lsn_t smallest_capacity = ((srv_log_file_size_requested
761+
<< srv_page_size_shift)
762+
- LOG_FILE_HDR_SIZE)
763+
* srv_n_log_files;
791764

792765
/* Add extra safety */
793-
smallest_capacity = smallest_capacity - smallest_capacity / 10;
766+
smallest_capacity -= smallest_capacity / 10;
794767

795768
/* For each OS thread we must reserve so much free space in the
796769
smallest log group that it can accommodate the log entries produced
@@ -800,15 +773,16 @@ log_calc_max_ages(void)
800773
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
801774
+ LOG_CHECKPOINT_EXTRA_FREE;
802775
if (free >= smallest_capacity / 2) {
803-
success = FALSE;
804-
805-
goto failure;
806-
} else {
807-
margin = smallest_capacity - free;
776+
ib_logf(IB_LOG_LEVEL_FATAL,
777+
"The combined size of ib_logfiles"
778+
" should be bigger than\n"
779+
"InnoDB: 200 kB * innodb_thread_concurrency.");
808780
}
809-
781+
margin = smallest_capacity - free;
810782
margin = margin - margin / 10;/* Add still some extra safety */
811783

784+
mutex_enter(&log_sys->mutex);
785+
812786
log_sys->log_group_capacity = smallest_capacity;
813787

814788
log_sys->max_modified_age_async = margin
@@ -821,22 +795,17 @@ log_calc_max_ages(void)
821795
log_sys->max_checkpoint_age = margin;
822796

823797
#ifdef UNIV_LOG_ARCHIVE
824-
log_sys->max_archived_lsn_age = smallest_archive_margin;
798+
lsn_t archive_margin = smallest_capacity
799+
- (srv_log_file_size_requested - LOG_FILE_HDR_SIZE)
800+
- LOG_ARCHIVE_EXTRA_MARGIN;
801+
log_sys->max_archived_lsn_age = archive_margin;
825802

826-
log_sys->max_archived_lsn_age_async = smallest_archive_margin
827-
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
803+
log_sys->max_archived_lsn_age_async = archive_margin
804+
- archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
828805
#endif /* UNIV_LOG_ARCHIVE */
829-
failure:
830-
mutex_exit(&(log_sys->mutex));
831-
832-
if (!success) {
833-
ib_logf(IB_LOG_LEVEL_FATAL,
834-
"The combined size of ib_logfiles"
835-
" should be bigger than\n"
836-
"InnoDB: 200 kB * innodb_thread_concurrency.");
837-
}
806+
mutex_exit(&log_sys->mutex);
838807

839-
return(success);
808+
return(true);
840809
}
841810

842811
/******************************************************//**

storage/xtradb/log/log0log.cc

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -860,43 +860,16 @@ ibool
860860
log_calc_max_ages(void)
861861
/*===================*/
862862
{
863-
log_group_t* group;
864863
lsn_tmargin;
865864
ulint free;
866-
ibool success = TRUE;
867-
lsn_tsmallest_capacity;
868-
lsn_tarchive_margin;
869-
lsn_tsmallest_archive_margin;
870-
871-
mutex_enter(&(log_sys->mutex));
872-
873-
group = UT_LIST_GET_FIRST(log_sys->log_groups);
874-
875-
ut_ad(group);
876-
877-
smallest_capacity = LSN_MAX;
878-
smallest_archive_margin = LSN_MAX;
879-
880-
while (group) {
881-
if (log_group_get_capacity(group) < smallest_capacity) {
882865

883-
smallest_capacity = log_group_get_capacity(group);
884-
}
885-
886-
archive_margin = log_group_get_capacity(group)
887-
- (group->file_size - LOG_FILE_HDR_SIZE)
888-
- LOG_ARCHIVE_EXTRA_MARGIN;
889-
890-
if (archive_margin < smallest_archive_margin) {
891-
892-
smallest_archive_margin = archive_margin;
893-
}
894-
895-
group = UT_LIST_GET_NEXT(log_groups, group);
896-
}
866+
lsn_t smallest_capacity = ((srv_log_file_size_requested
867+
<< srv_page_size_shift)
868+
- LOG_FILE_HDR_SIZE)
869+
* srv_n_log_files;
897870

898871
/* Add extra safety */
899-
smallest_capacity = smallest_capacity - smallest_capacity / 10;
872+
smallest_capacity -= smallest_capacity / 10;
900873

901874
/* For each OS thread we must reserve so much free space in the
902875
smallest log group that it can accommodate the log entries produced
@@ -906,15 +879,16 @@ log_calc_max_ages(void)
906879
free = LOG_CHECKPOINT_FREE_PER_THREAD * (10 + srv_thread_concurrency)
907880
+ LOG_CHECKPOINT_EXTRA_FREE;
908881
if (free >= smallest_capacity / 2) {
909-
success = FALSE;
910-
911-
goto failure;
912-
} else {
913-
margin = smallest_capacity - free;
882+
ib_logf(IB_LOG_LEVEL_FATAL,
883+
"The combined size of ib_logfiles"
884+
" should be bigger than\n"
885+
"InnoDB: 200 kB * innodb_thread_concurrency.");
914886
}
915-
887+
margin = smallest_capacity - free;
916888
margin = margin - margin / 10;/* Add still some extra safety */
917889

890+
mutex_enter(&log_sys->mutex);
891+
918892
log_sys->log_group_capacity = smallest_capacity;
919893

920894
log_sys->max_modified_age_async = margin
@@ -927,22 +901,17 @@ log_calc_max_ages(void)
927901
log_sys->max_checkpoint_age = margin;
928902

929903
#ifdef UNIV_LOG_ARCHIVE
930-
log_sys->max_archived_lsn_age = smallest_archive_margin;
904+
lsn_t archive_margin = smallest_capacity
905+
- (srv_log_file_size_requested - LOG_FILE_HDR_SIZE)
906+
- LOG_ARCHIVE_EXTRA_MARGIN;
907+
log_sys->max_archived_lsn_age = archive_margin;
931908

932-
log_sys->max_archived_lsn_age_async = smallest_archive_margin
933-
- smallest_archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
909+
log_sys->max_archived_lsn_age_async = archive_margin
910+
- archive_margin / LOG_ARCHIVE_RATIO_ASYNC;
934911
#endif /* UNIV_LOG_ARCHIVE */
935-
failure:
936-
mutex_exit(&(log_sys->mutex));
937-
938-
if (!success) {
939-
ib_logf(IB_LOG_LEVEL_FATAL,
940-
"The combined size of ib_logfiles"
941-
" should be bigger than\n"
942-
"InnoDB: 200 kB * innodb_thread_concurrency.");
943-
}
912+
mutex_exit(&log_sys->mutex);
944913

945-
return(success);
914+
return(true);
946915
}
947916

948917
/******************************************************//**

0 commit comments

Comments
 (0)