[MDEV-27268] Failed InnoDB initialization leaves garbage files behind Created: 2021-12-15  Updated: 2021-12-15  Resolved: 2021-12-15

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8
Fix Version/s: 10.2.42, 10.3.33, 10.4.23, 10.5.14, 10.6.6, 10.7.2

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: regression-10.5

Issue Links:
Relates
relates to MDEV-27269 Bootstrap ignores failure to initiali... Open
relates to MDEV-12061 Allow innodb_log_files_in_group=1 Closed
relates to MDEV-14425 Change the InnoDB redo log format to ... Closed
relates to MDEV-14462 Confusing error message: ib_logfiles ... Closed

 Description   

The following invocation will fail, leaving behind NUL-filled ibdata1 and ib_logfile0 in InnoDB initialization.

./mtr --mysqld=--innodb-log-file-size=1m --mysqld=--loose-innodb-log-files-in-group=1 innodb.innodb

Note: MDEV-12061 reduced the minimum value of innodb_log_files_in_group to 1. In MariaDB Server 10.5, that parameter was deprecated, and only a single ib_logfile0 can be created.

The actual minimum log file size limit is as follows:

innodb_page_size minimum innodb_log_file_size
4k 1m
8k 1m
16k 2m
32k 4m
64k 7m

MDEV-14425 would change the minimum (logically empty) redo log file size to 12288+16 bytes.

The log must be reasonably large to prevent overrun. Only once MDEV-14462 has been fixed, we could run with a smaller redo log without any fear of data loss. Also in that case, the log must be large enough for a single mini-transaction. A maximal mini-transaction could split a B-tree all way from the leaf to roof, modifying 2*height pages. The maximum height of a B-tree is somewhere around 32 pages when the tree is a binary tree. 2*32*innodb_page_size would be 1MiB at the default innodb_page_size=16k.

The immediate problem here is that if an attempt to initialize InnoDB with a too small log file is made, InnoDB will leave behind NUL-filled system tablespace and log files. That needs to be fixed, to avoid confusing messages like this:

10.2 6b066ec33285c089ce770c2d1eb50bc49787ee92

innodb.innodb 'innodb'                   [ skipped ]  Test requires InnoDB with 16k Page size.
line
2021-12-15 13:36:15 140326778985536 [ERROR] InnoDB: Corrupted page [page id: space=0, page number=0] of datafile './ibdata1' could not be found in the doublewrite buffer.
2021-12-15 13:36:15 140326778985536 [ERROR] InnoDB: Plugin initialization aborted at srv0start.cc[1911] with error Data structure corruption
2021-12-15 13:36:15 140326778985536 [ERROR] Plugin 'InnoDB' init function returned error.
2021-12-15 13:36:15 140326778985536 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
^ Found warnings in /dev/shm/10.2o/mysql-test/var/log/mysqld.1.err



 Comments   
Comment by Marko Mäkelä [ 2021-12-15 ]

After a fix, the invocation of the test will fail like this:

./mtr --mysqld=--innodb-log-file-size=1m --mysqld=--loose-innodb-log-files-in-group=1 innodb.innodb

10.2 72b9ee7aaefb2fc5c6a1c18d477434449e880504

innodb.innodb 'innodb'                   [ skipped ]  Test requires InnoDB with 16k Page size.
line
2021-12-15 13:54:57 140423379827776 [ERROR] InnoDB: Cannot continue operation. ib_logfiles are too small for innodb_thread_concurrency=0. The combined size of ib_logfiles should be bigger than 200 kB * innodb_thread_concurrency. Please refer to https://mariadb.com/kb/en/library/innodb-system-variables/
2021-12-15 13:54:57 140423379827776 [ERROR] InnoDB: Database creation was aborted at srv0start.cc[1944] with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2021-12-15 13:54:57 140423379827776 [ERROR] Plugin 'InnoDB' init function returned error.
2021-12-15 13:54:57 140423379827776 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
^ Found warnings in /dev/shm/10.2o/mysql-test/var/log/mysqld.1.err

Generated at Thu Feb 08 09:51:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.