Bug #95556 Symlink of undo log folder to datadir makes MySQL unable to start
Submitted: 29 May 2019 7:21 Modified: 25 Jul 2019 10:20
Reporter: Ted Wennmark Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.16, 8.0.11 OS:Any
Assigned to: CPU Architecture:Any
Tags: innodb_undo_directory udo logs symlink datadir

[29 May 2019 7:21] Ted Wennmark
Description:
If you create a symlink from your undo log folder to MySQL datadir MySQL fails to start.
It looks like MySQL is looking for undo logs in both  innodb_undo_directory and also scans the complete datadir...

By creating a new MySQL 8.0.16 instance and configuring undo logs outside default location (datadir), like under /tmp/undo-logs. Now creating a symlink from /tmp/undo-logs to the MySQL datadir (you can name the symlink whatever) and MySQL will not start.
You will get errors like:
 2019-05-29T07:03:57.947902Z 1 [ERROR] [MY-012209] [InnoDB] Multiple files found for the same tablespace ID:
2019-05-29T07:03:57.947918Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 4294967278 = ['kalle/undo_002', 'undo_002']

2019-05-29T07:03:57.947930Z 1 [ERROR] [MY-012202] [InnoDB] Tablespace ID: 4294967279 = ['kalle/undo_001', 'undo_001']

How to repeat:
1) Create a new installation of 8.0.16
2) Configure undo logs to dedicated folder like: innodb_undo_directory = /tmp/undo-logs
3) Create a symlink from undo folder to datadir folder using ln -s
4) Try to restart MySQL

In my setup I use our tar packages for Linux and configure innodb_undo_directory = /tmp/undo-logs.
Next after starting MySQL I create a symlink like: ln -s /tmp/undo-logs /home/ted/sandboxes/MySQL-HOWTOs/mysqldata/kalle
My datadir is /home/ted/sandboxes/MySQL-HOWTOs/mysqldata

Full MySQL configuration:
[mysqld_safe]
socket			= /tmp/mysql.sock
 
[mysqld]
basedir			= /home/ted/sandboxes/MySQL-HOWTOs/mysqlsrc
datadir			= /home/ted/sandboxes/MySQL-HOWTOs/mysqldata
port			= 3306
secure_file_priv	= /tmp
default_authentication_plugin = mysql_native_password
performance-schema-instrument='wait/lock/metadata/sql/mdl=ON' 
innodb_undo_directory = /tmp/undo-logs

I create/start MySQL instance by running:
mysqld --initialize-insecure --basedir=$WS_HOME/mysqlsrc --datadir=$WS_HOME/mysqldata --innodb-undo-directory=/tmp/undo-logs
mysqld_safe --defaults-file=$WS_HOME/my.cnf --ledir=$WS_HOME/mysqlsrc/bin &

Suggested fix:
Do not try to auto-discover undo logs in datadir, not sure why this is done.
[29 May 2019 8:53] MySQL Verification Team
Hello Ted,

Thank you for the report and feedback!

Thanks,
Umesh
[25 Jul 2019 10:20] Erlend Dahl
[29 May 2019 11:38] Sunny Bains

This is not a bug. The undo log paths are not constrained, therefore InnoDB
has to search all possible locations.