mariadb/mysql-test/suite/innodb/t/log_file.test
Marko Mäkelä 4ca355d863 MDEV-33894: Resurrect innodb_log_write_ahead_size
As part of commit 685d958e38 (MDEV-14425)
the parameter innodb_log_write_ahead_size was removed, because it was
thought that determining the physical block size would be a sufficient
replacement.

However, we can only determine the physical block size on Linux or
Microsoft Windows. On some file systems, the physical block size
is not relevant. For example, XFS uses a block size of 4096 bytes
even if the underlying block size may be smaller.

On Linux, we failed to determine the physical block size if
innodb_log_file_buffered=OFF was not requested or possible.
This will be fixed.

log_sys.write_size: The value of the reintroduced parameter
innodb_log_write_ahead_size. To keep it simple, this is read-only
and a power of two between 512 and 4096 bytes, so that the previous
alignment guarantees are fulfilled. This will replace the previous
log_sys.get_block_size().

log_sys.block_size, log_t::get_block_size(): Remove.

log_t::set_block_size(): Ensure that write_size will not be less
than the physical block size. There is no point to invoke this
function with 512 or less, because that is the minimum value of
write_size.

innodb_params_adjust(): Add some disabled code for adjusting
the minimum value and default value of innodb_log_write_ahead_size
to reflect the log_sys.write_size.

log_t::set_recovered(): Mark the recovery completed. This is the
place to adjust some things if we want to allow write_size>4096.

log_t::resize_write_buf(): Refer to write_size.

log_t::resize_start(): Refer to write_size instead of get_block_size().

log_write_buf(): Simplify some arithmetics and remove a goto.

log_t::write_buf(): Refer to write_size. If we are writing less than
that, do not switch buffers, but keep writing to the same buffer.
Move some code to improve the locality of reference.

recv_scan_log(): Refer to write_size instead of get_block_size().

os_file_create_func(): For type==OS_LOG_FILE on Linux, always invoke
os_file_log_maybe_unbuffered(), so that log_sys.set_block_size() will
be invoked even if we are not attempting to use O_DIRECT.

recv_sys_t::find_checkpoint(): Read the entire log header
in a single 12 KiB request into log_sys.buf.

Tested with:
./mtr --loose-innodb-log-write-ahead-size=4096
./mtr --loose-innodb-log-write-ahead-size=2048
2024-06-27 16:38:08 +03:00

231 lines
8.7 KiB
Text

--echo # Testcase for the following bugs
--echo # Bug#16691130 - ASSERT WHEN INNODB_LOG_GROUP_HOME_DIR DOES NOT EXIST
--echo # Bug#16418661 - CHANGING NAME IN FOR INNODB_DATA_FILE_PATH SHOULD NOT SUCCEED WITH LOG FILES
--source include/have_innodb.inc
--source include/no_valgrind_without_big.inc
--disable_query_log
call mtr.add_suppression("InnoDB: Could not create undo tablespace.*undo002");
call mtr.add_suppression("InnoDB: InnoDB Database creation was aborted");
call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("InnoDB: Operating system error number \d+ in a file operation");
call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified");
call mtr.add_suppression("InnoDB: File /path/to/non-existent/ib_logfile101 was not found");
call mtr.add_suppression("InnoDB: Cannot create .path.to.non-existent.ib_logfile101");
call mtr.add_suppression("InnoDB: The data file '.*ibdata1' was not found but one of the other data files '.*ibdata2' exists");
call mtr.add_suppression("InnoDB: Tablespace size stored in header is \d+ pages, but the sum of data file sizes is \d+ pages");
call mtr.add_suppression("InnoDB: Cannot start InnoDB. The tail of the system tablespace is missing");
call mtr.add_suppression("InnoDB: undo tablespace '.*undo001' exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.");
call mtr.add_suppression("");
call mtr.add_suppression("");
--enable_query_log
let bugdir= $MYSQLTEST_VARDIR/tmp/log_file;
--mkdir $bugdir
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let $check_no_innodb=SELECT * FROM INFORMATION_SCHEMA.ENGINES
WHERE engine = 'innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
let $check_yes_innodb=SELECT COUNT(*) `1` FROM INFORMATION_SCHEMA.ENGINES
WHERE engine='innodb'
AND support IN ('YES', 'DEFAULT', 'ENABLED');
--let $ibp=--innodb-log-group-home-dir=$bugdir
--let $ibp=$ibp --innodb-data-home-dir=$bugdir --innodb-undo-directory=$bugdir
--let $ibp=$ibp --innodb-undo-logs=20 --innodb-undo-tablespaces=3
--let $ibp=$ibp --innodb-data-file-path=ibdata1:16M;ibdata2:10M:autoextend
--echo # Start mysqld without the possibility to create innodb_undo_tablespaces
--let $restart_parameters= $ibp
--mkdir $bugdir/undo002
--source include/restart_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=\[ERROR\] InnoDB: Could not create undo tablespace '.*undo002';
--source include/search_pattern_in_file.inc
--echo # Remove undo001,undo002,ibdata1,ibdata2,ib_logfile101
--remove_file $bugdir/undo001
--rmdir $bugdir/undo002
--remove_file $bugdir/ibdata1
--remove_file $bugdir/ibdata2
--remove_file $bugdir/ib_logfile101
--list_files $bugdir
--echo # Start mysqld with non existent innodb_log_group_home_dir
--let $restart_parameters= $ibp --innodb_log_group_home_dir=/path/to/non-existent/
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=Cannot create /path/to/non-existent/ib_logfile101;
--source include/search_pattern_in_file.inc
--list_files $bugdir
--echo # Successfully let InnoDB create tablespaces
--let $restart_parameters= $ibp
--source include/start_mysqld.inc
eval $check_yes_innodb;
--source include/shutdown_mysqld.inc
--echo # Backup tmp/logfile/*
--copy_file $bugdir/ibdata1 $bugdir/bak_ibdata1
--copy_file $bugdir/ibdata2 $bugdir/bak_ibdata2
--copy_file $bugdir/ib_logfile0 $bugdir/bak_ib_logfile0
--copy_file $bugdir/undo001 $bugdir/bak_undo001
--copy_file $bugdir/undo002 $bugdir/bak_undo002
--copy_file $bugdir/undo003 $bugdir/bak_undo003
--echo # 1. With ibdata2, Without ibdata1
--remove_file $bugdir/ibdata1
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=The data file '.*ibdata1' was not found but one of the other data files '.*ibdata2' exists;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 2. With ibdata1, without ibdata2
--remove_file $bugdir/ibdata2
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=InnoDB: Tablespace size stored in header is \d+ pages, but the sum of data file sizes is \d+ pages;
--source include/search_pattern_in_file.inc
let SEARCH_PATTERN=InnoDB: Cannot start InnoDB. The tail of the system tablespace is missing;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 3. Without ibdata1 & ibdata2
--remove_file $bugdir/ibdata1
--remove_file $bugdir/ibdata2
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=InnoDB: undo tablespace .*undo001.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 4. Without ibdata*, ib_logfile* and with undo00*
--remove_files_wildcard $bugdir ibdata*
--remove_files_wildcard $bugdir ib_logfile*
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 5. Without ibdata*,ib_logfile* files & Without undo002
--remove_files_wildcard $bugdir ibdata*
--remove_files_wildcard $bugdir ib_logfile*
--remove_file $bugdir/undo002
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 6. Without ibdata*,ib_logfile* files & Without undo001, undo002
# and with undo003
--remove_files_wildcard $bugdir ibdata*
--remove_files_wildcard $bugdir ib_logfile*
--remove_file $bugdir/undo001
--remove_file $bugdir/undo002
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=undo tablespace .*undo003.* exists\. Creating system tablespace with existing undo tablespaces is not supported\. Please delete all undo tablespaces before creating new system tablespace\.;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 7. With ibdata files & Without undo002
--remove_file $bugdir/undo002
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=InnoDB: Failed to open the undo tablespace;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 8. With ibdata files & Without undo001, undo002
--remove_file $bugdir/undo001
--remove_file $bugdir/undo002
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=InnoDB: Failed to open the undo tablespace;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 9. Without ibdata*, without undo*
--remove_files_wildcard $bugdir ibdata*
--remove_files_wildcard $bugdir undo00*
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
let SEARCH_PATTERN=redo log file .*ib_logfile0.* exists\. Creating system tablespace with existing redo log file is not recommended\. Please delete redo log file before creating new system tablespace\.;
--source include/search_pattern_in_file.inc
# clean up & Restore
--source ../include/log_file_cleanup.inc
--echo # 10. With ibdata*, without ib_logfile0
--remove_file $bugdir/ib_logfile0
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
--source ../include/log_file_cleanup.inc
--echo # 11. With ibdata*
--list_files $bugdir
--source include/start_mysqld.inc
eval $check_yes_innodb;
--source include/shutdown_mysqld.inc
--let $restart_parameters=--innodb-log-write-ahead-size=513
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
--let $restart_parameters=--innodb-log-write-ahead-size=4095
--source include/start_mysqld.inc
eval $check_no_innodb;
--source include/shutdown_mysqld.inc
# this will be silently truncated to the maximum
--let $restart_parameters=--innodb-log-write-ahead-size=10000
--source include/start_mysqld.inc
SELECT @@innodb_log_write_ahead_size;
--echo # Cleanup
--list_files $bugdir
--remove_files_wildcard $bugdir
--rmdir $bugdir