From 743ac7c2d0f7c27699d53f35137e02ee3cfd4b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 14 Feb 2017 11:13:24 +0200 Subject: [PATCH] MDEV-12061 Allow innodb_log_files_in_group=1 The InnoDB redo log consists of a list of files that logically form a bigger file, as if the individual files were concatenated together. The first file will always be written on redo log checkpoint, because the two checkpoint pages are at the start of the single logical redo log file. There is no technical reason why InnoDB requires at least 2 files to exist. Let us reduce the minimum number to 1. In that way, restoring from backups will become easier, since InnoDB can directly deal with a single backed-up redo log file. --- mysql-test/suite/innodb/r/log_file.result | 40 +------------------ .../suite/innodb/r/log_file_size.result | 2 - mysql-test/suite/innodb/t/log_file.test | 16 +------- mysql-test/suite/innodb/t/log_file_size.test | 12 +----- .../suite/sys_vars/r/sysvars_innodb.result | 2 +- storage/innobase/handler/ha_innodb.cc | 2 +- storage/innobase/srv/srv0srv.cc | 4 +- storage/innobase/srv/srv0start.cc | 5 --- 8 files changed, 8 insertions(+), 75 deletions(-) diff --git a/mysql-test/suite/innodb/r/log_file.result b/mysql-test/suite/innodb/r/log_file.result index b0351232ed9..0003f7d3c3a 100644 --- a/mysql-test/suite/innodb/r/log_file.result +++ b/mysql-test/suite/innodb/r/log_file.result @@ -335,50 +335,12 @@ ibdata2 undo001 undo002 undo003 -SELECT * FROM INFORMATION_SCHEMA.ENGINES -WHERE engine = 'innodb' -AND support IN ('YES', 'DEFAULT', 'ENABLED'); -ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS -FOUND /Only one log file found/ in mysqld.1.err -bak_ib_logfile0 -bak_ib_logfile1 -bak_ib_logfile2 -bak_ibdata1 -bak_ibdata2 -bak_undo001 -bak_undo002 -bak_undo003 -ib_buffer_pool -ib_logfile0 -ib_logfile2 -ibdata1 -ibdata2 -undo001 -undo002 -undo003 -# 12. With ibdata*, without ib_logfile2 -bak_ib_logfile0 -bak_ib_logfile1 -bak_ib_logfile2 -bak_ibdata1 -bak_ibdata2 -bak_undo001 -bak_undo002 -bak_undo003 -ib_buffer_pool -ib_logfile0 -ib_logfile1 -ibdata1 -ibdata2 -undo001 -undo002 -undo003 SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); 1 1 -FOUND /Resizing redo log from 2\*\d+ to 3\*\d+ pages, LSN=\d+/ in mysqld.1.err +FOUND /Resizing redo log from 1\*\d+ to 3\*\d+ pages, LSN=\d+/ in mysqld.1.err # Cleanup bak_ib_logfile0 bak_ib_logfile1 diff --git a/mysql-test/suite/innodb/r/log_file_size.result b/mysql-test/suite/innodb/r/log_file_size.result index 3f8f99fe8c7..e07dba67a7b 100644 --- a/mysql-test/suite/innodb/r/log_file_size.result +++ b/mysql-test/suite/innodb/r/log_file_size.result @@ -53,8 +53,6 @@ ERROR 42000: Unknown storage engine 'InnoDB' SELECT * FROM t1; ERROR 42000: Unknown storage engine 'InnoDB' SELECT * FROM t1; -ERROR 42000: Unknown storage engine 'InnoDB' -SELECT * FROM t1; a 42 123 diff --git a/mysql-test/suite/innodb/t/log_file.test b/mysql-test/suite/innodb/t/log_file.test index f7a8ef36cc0..0bb8ee8845c 100644 --- a/mysql-test/suite/innodb/t/log_file.test +++ b/mysql-test/suite/innodb/t/log_file.test @@ -26,7 +26,7 @@ let bugdir= $MYSQLTEST_VARDIR/tmp/log_file; --mkdir $bugdir let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err; -let SEARCH_RANGE = -50000; +let SEARCH_RANGE = -100000; let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED'); @@ -217,21 +217,9 @@ eval $check_no_innodb; --remove_file $bugdir/ib_logfile1 --list_files $bugdir --source include/start_mysqld.inc -eval $check_no_innodb; ---source include/shutdown_mysqld.inc -let SEARCH_PATTERN=Only one log file found; ---source include/search_pattern_in_file.inc - -# clean up & Restore ---source ../include/log_file_cleanup.inc - ---echo # 12. With ibdata*, without ib_logfile2 ---remove_file $bugdir/ib_logfile2 ---list_files $bugdir ---source include/start_mysqld.inc eval $check_yes_innodb; --source include/shutdown_mysqld.inc -let SEARCH_PATTERN=Resizing redo log from 2\*\d+ to 3\*\d+ pages, LSN=\d+; +--let SEARCH_PATTERN=Resizing redo log from 1\*\d+ to 3\*\d+ pages, LSN=\d+ --source include/search_pattern_in_file.inc --let $restart_parameters= diff --git a/mysql-test/suite/innodb/t/log_file_size.test b/mysql-test/suite/innodb/t/log_file_size.test index 25988fc6fd8..179472a45a1 100644 --- a/mysql-test/suite/innodb/t/log_file_size.test +++ b/mysql-test/suite/innodb/t/log_file_size.test @@ -163,25 +163,15 @@ let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to; # We should have perfectly synced files here. # Rename the log files, and trigger an error in recovery. ---move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0 --move_file $MYSQLD_DATADIR/ib_logfile1 $MYSQLD_DATADIR/ib_logfile1_hidden ---let $restart_parameters= ---source include/start_mysqld.inc ---error ER_UNKNOWN_STORAGE_ENGINE -SELECT * FROM t1; - -let SEARCH_PATTERN= InnoDB: Only one log file found; ---source include/search_pattern_in_file.inc ---move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101 - perl; die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile0"); print FILE "garbage"; close(FILE); EOF ---source include/restart_mysqld.inc +--source include/start_mysqld.inc --error ER_UNKNOWN_STORAGE_ENGINE SELECT * FROM t1; let SEARCH_PATTERN= InnoDB: Log file .*ib_logfile0 size 7 is not a multiple of innodb_page_size; diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb.result b/mysql-test/suite/sys_vars/r/sysvars_innodb.result index 74d5abaf1d4..9394692b526 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb.result +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb.result @@ -1470,7 +1470,7 @@ DEFAULT_VALUE 2 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_COMMENT Number of log files in the log group. InnoDB writes to the files in a circular fashion. -NUMERIC_MIN_VALUE 2 +NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 100 NUMERIC_BLOCK_SIZE 0 ENUM_VALUE_LIST NULL diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6dbf1b6a8f5..20e412b9f13 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -21265,7 +21265,7 @@ static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size, static MYSQL_SYSVAR_ULONG(log_files_in_group, srv_n_log_files, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, "Number of log files in the log group. InnoDB writes to the files in a circular fashion.", - NULL, NULL, 2, 2, SRV_N_LOG_FILES_MAX, 0); + NULL, NULL, 2, 1, SRV_N_LOG_FILES_MAX, 0); static MYSQL_SYSVAR_ULONG(log_write_ahead_size, srv_log_write_ahead_size, PLUGIN_VAR_RQCMDARG, diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 9f61d43463b..a979b107825 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -205,9 +205,9 @@ extern bool trx_commit_disallowed; #endif /* UNIV_DEBUG */ /*------------------------- LOG FILES ------------------------ */ -char* srv_log_group_home_dir = NULL; +char* srv_log_group_home_dir; -ulong srv_n_log_files = SRV_N_LOG_FILES_MAX; +ulong srv_n_log_files; /** At startup, this is the current redo log file size. During startup, if this is different from srv_log_file_size_requested (innodb_log_file_size), the redo log will be rebuilt and this size diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 89acdec72da..88998b8b453 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -1977,11 +1977,6 @@ innobase_start_or_create_for_mysql(void) crash recovery. */ flushed_lsn = log_get_lsn(); goto files_checked; - } else if (i < 2) { - /* must have at least 2 log files */ - ib::error() << "Only one log file" - " found."; - return(srv_init_abort(err)); } /* opened all files */