Skip to content

Commit 743ac7c

Browse files
committed
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.
1 parent 3d85292 commit 743ac7c

File tree

8 files changed

+8
-75
lines changed

8 files changed

+8
-75
lines changed

mysql-test/suite/innodb/r/log_file.result

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -335,50 +335,12 @@ ibdata2
335335
undo001
336336
undo002
337337
undo003
338-
SELECT * FROM INFORMATION_SCHEMA.ENGINES
339-
WHERE engine = 'innodb'
340-
AND support IN ('YES', 'DEFAULT', 'ENABLED');
341-
ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS
342-
FOUND /Only one log file found/ in mysqld.1.err
343-
bak_ib_logfile0
344-
bak_ib_logfile1
345-
bak_ib_logfile2
346-
bak_ibdata1
347-
bak_ibdata2
348-
bak_undo001
349-
bak_undo002
350-
bak_undo003
351-
ib_buffer_pool
352-
ib_logfile0
353-
ib_logfile2
354-
ibdata1
355-
ibdata2
356-
undo001
357-
undo002
358-
undo003
359-
# 12. With ibdata*, without ib_logfile2
360-
bak_ib_logfile0
361-
bak_ib_logfile1
362-
bak_ib_logfile2
363-
bak_ibdata1
364-
bak_ibdata2
365-
bak_undo001
366-
bak_undo002
367-
bak_undo003
368-
ib_buffer_pool
369-
ib_logfile0
370-
ib_logfile1
371-
ibdata1
372-
ibdata2
373-
undo001
374-
undo002
375-
undo003
376338
SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES
377339
WHERE engine='innodb'
378340
AND support IN ('YES', 'DEFAULT', 'ENABLED');
379341
1
380342
1
381-
FOUND /Resizing redo log from 2\*\d+ to 3\*\d+ pages, LSN=\d+/ in mysqld.1.err
343+
FOUND /Resizing redo log from 1\*\d+ to 3\*\d+ pages, LSN=\d+/ in mysqld.1.err
382344
# Cleanup
383345
bak_ib_logfile0
384346
bak_ib_logfile1

mysql-test/suite/innodb/r/log_file_size.result

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ ERROR 42000: Unknown storage engine 'InnoDB'
5353
SELECT * FROM t1;
5454
ERROR 42000: Unknown storage engine 'InnoDB'
5555
SELECT * FROM t1;
56-
ERROR 42000: Unknown storage engine 'InnoDB'
57-
SELECT * FROM t1;
5856
a
5957
42
6058
123

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let bugdir= $MYSQLTEST_VARDIR/tmp/log_file;
2626
--mkdir $bugdir
2727

2828
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
29-
let SEARCH_RANGE = -50000;
29+
let SEARCH_RANGE = -100000;
3030
let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES
3131
WHERE engine = 'innodb'
3232
AND support IN ('YES', 'DEFAULT', 'ENABLED');
@@ -217,21 +217,9 @@ eval $check_no_innodb;
217217
--remove_file $bugdir/ib_logfile1
218218
--list_files $bugdir
219219
--source include/start_mysqld.inc
220-
eval $check_no_innodb;
221-
--source include/shutdown_mysqld.inc
222-
let SEARCH_PATTERN=Only one log file found;
223-
--source include/search_pattern_in_file.inc
224-
225-
# clean up & Restore
226-
--source ../include/log_file_cleanup.inc
227-
228-
--echo # 12. With ibdata*, without ib_logfile2
229-
--remove_file $bugdir/ib_logfile2
230-
--list_files $bugdir
231-
--source include/start_mysqld.inc
232220
eval $check_yes_innodb;
233221
--source include/shutdown_mysqld.inc
234-
let SEARCH_PATTERN=Resizing redo log from 2\*\d+ to 3\*\d+ pages, LSN=\d+;
222+
--let SEARCH_PATTERN=Resizing redo log from 1\*\d+ to 3\*\d+ pages, LSN=\d+
235223
--source include/search_pattern_in_file.inc
236224

237225
--let $restart_parameters=

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,25 +163,15 @@ let SEARCH_PATTERN= InnoDB: Setting log file .*ib_logfile[0-9]+ size to;
163163

164164
# We should have perfectly synced files here.
165165
# Rename the log files, and trigger an error in recovery.
166-
--move_file $MYSQLD_DATADIR/ib_logfile101 $MYSQLD_DATADIR/ib_logfile0
167166
--move_file $MYSQLD_DATADIR/ib_logfile1 $MYSQLD_DATADIR/ib_logfile1_hidden
168167

169-
--let $restart_parameters=
170-
--source include/start_mysqld.inc
171-
--error ER_UNKNOWN_STORAGE_ENGINE
172-
SELECT * FROM t1;
173-
174-
let SEARCH_PATTERN= InnoDB: Only one log file found;
175-
--source include/search_pattern_in_file.inc
176-
--move_file $MYSQLD_DATADIR/ib_logfile0 $MYSQLD_DATADIR/ib_logfile101
177-
178168
perl;
179169
die unless open(FILE, ">$ENV{MYSQLD_DATADIR}/ib_logfile0");
180170
print FILE "garbage";
181171
close(FILE);
182172
EOF
183173

184-
--source include/restart_mysqld.inc
174+
--source include/start_mysqld.inc
185175
--error ER_UNKNOWN_STORAGE_ENGINE
186176
SELECT * FROM t1;
187177
let SEARCH_PATTERN= InnoDB: Log file .*ib_logfile0 size 7 is not a multiple of innodb_page_size;

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ DEFAULT_VALUE 2
14701470
VARIABLE_SCOPE GLOBAL
14711471
VARIABLE_TYPE BIGINT UNSIGNED
14721472
VARIABLE_COMMENT Number of log files in the log group. InnoDB writes to the files in a circular fashion.
1473-
NUMERIC_MIN_VALUE 2
1473+
NUMERIC_MIN_VALUE 1
14741474
NUMERIC_MAX_VALUE 100
14751475
NUMERIC_BLOCK_SIZE 0
14761476
ENUM_VALUE_LIST NULL

storage/innobase/handler/ha_innodb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21265,7 +21265,7 @@ static MYSQL_SYSVAR_LONGLONG(log_file_size, innobase_log_file_size,
2126521265
static MYSQL_SYSVAR_ULONG(log_files_in_group, srv_n_log_files,
2126621266
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
2126721267
"Number of log files in the log group. InnoDB writes to the files in a circular fashion.",
21268-
NULL, NULL, 2, 2, SRV_N_LOG_FILES_MAX, 0);
21268+
NULL, NULL, 2, 1, SRV_N_LOG_FILES_MAX, 0);
2126921269

2127021270
static MYSQL_SYSVAR_ULONG(log_write_ahead_size, srv_log_write_ahead_size,
2127121271
PLUGIN_VAR_RQCMDARG,

storage/innobase/srv/srv0srv.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ extern bool trx_commit_disallowed;
205205
#endif /* UNIV_DEBUG */
206206

207207
/*------------------------- LOG FILES ------------------------ */
208-
char* srv_log_group_home_dir = NULL;
208+
char* srv_log_group_home_dir;
209209

210-
ulong srv_n_log_files = SRV_N_LOG_FILES_MAX;
210+
ulong srv_n_log_files;
211211
/** At startup, this is the current redo log file size.
212212
During startup, if this is different from srv_log_file_size_requested
213213
(innodb_log_file_size), the redo log will be rebuilt and this size

storage/innobase/srv/srv0start.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,11 +1977,6 @@ innobase_start_or_create_for_mysql(void)
19771977
crash recovery. */
19781978
flushed_lsn = log_get_lsn();
19791979
goto files_checked;
1980-
} else if (i < 2) {
1981-
/* must have at least 2 log files */
1982-
ib::error() << "Only one log file"
1983-
" found.";
1984-
return(srv_init_abort(err));
19851980
}
19861981

19871982
/* opened all files */

0 commit comments

Comments
 (0)