Description:
When relay log files are moved to a different partition (and the correct options are set in my.cnf for relay-log, localhost-relay-bin.index and relay-log.info to match) mysqld is unable to find the relay logs that were in progress after the move.
Any new logs seem to be fine (and contain the full path name in the localhost-relay-bin.index and relay-log.info files).
Manually editing the localhost-relay-bin.index and relay-log.info files to specify/include the full path name resolves the issue.
How to repeat:
1. Stop mysqld
2. Move the relay log files, localhost-relay-bin.index and relay-log.info to a different partition
3. Set these params in my.cnf:
relay-log = /{path to different partition/dir}/localhost-relay-bin
relay-log-index = /{path to different partition/dir}/localhost-relay-bin.index
relay-log-info-file = /{path to different partition/dir}/relay-log.info
4. Start mysqld
o Results in the following error:
0901xx xx:xx:xx [ERROR] /{path to your MySQL server install}/bin/mysqld: File './localhost-relay-bin.xxxxx0' not found (Errcode: 2)
o Directory contents of {path to different partition/dir} at this point:
-rw-r----- 1 mysql mysql 254 localhost-relay-bin.xxxxx0
-rw-rw---- 1 mysql mysql 117 localhost-relay-bin.xxxxx1
-rw-r----- 1 mysql mysql 96 localhost-relay-bin.index
-rw-r----- 1 mysql mysql 65 relay-log.info
o localhost-relay-bin.index and relay-log.info contents at this point:
localhost-relay-bin.index:
./localhost-relay-bin.xxxxx0
/{path to different partition/dir}/localhost-relay-bin.xxxxx1
relay-log.info:
./localhost-relay-bin.xxxxx0
o When you modify these files to the following:
localhost-relay-bin.index:
/{path to different partition/dir}/localhost-relay-bin.xxxxx0
/{path to different partition/dir}/localhost-relay-bin.xxxxx1
relay-log.info:
/{path to different partition/dir}/localhost-relay-bin.xxxxx0
Replication resumes correctly.
Suggested fix:
o Check for relay log files in same path as localhost-relay-bin.index and relay-log.info if ./ is specified.
o Additionally, it could maybe be a staged fallback if './' is specified: check the directory that contains the .info file for the relay logs, then check the data directory, then check the base directory?
o Also, this error message can be made clearer:
0901xx xx:xx:xx [ERROR] /{path to your MySQL server install}/bin/mysqld: File './localhost-relay-bin.xxxxx0' not found (Errcode: 2)
Instead of giving './' it should have the actual path the server is trying witg, like for instance:
0901xx xx:xx:xx [ERROR] /{path to your MySQL server install}/bin/mysqld: File '{path to different partition/dir}/localhost-relay-bin.xxxxx0' not found (Errcode: 2)
It would be interesting to find out *where exactly* the server is looking at this point for './localhost-relay-bin.xxxxx0' and why (this is likely where the issue is located in the code)