Bug #77498 mysqld_safe fails to restart mysqld if init_file is used
Submitted: 26 Jun 2015 7:43 Modified: 28 Oct 2015 10:25
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Options Severity:S2 (Serious)
Version:5.6.25, 5.6.26 OS:Any
Assigned to: CPU Architecture:Any

[26 Jun 2015 7:43] Daniël van Eeden
Description:
If mysql is started with the --init_file option (not init_file in my.cnf) and the it crashes then mysqld_safe starts it again and it fails.

When mysqld gets stared 
2015-06-26 09:35:24 6266 [Note] Execution of init_file '/tmp/test.sql' started.
2015-06-26 09:35:24 6266 [ERROR] /opt/mysql/5.6.25/bin/mysqld: File '/tmp/test.sql' not found (Errcode: 2 - No such file or directory)
2015-06-26 09:35:24 6266 [ERROR] Aborting

How to repeat:
$ echo 'select count(*) from dual' > /tmp/test.sql
$ ./start --init_file=/tmp/test.sql
$ rm /tmp/test.sql
$ pkill -9 -x mysqld

Suggested fix:
Make sure mysqld_safe can restart mysqld even if init_file is used. Make the behaviour similar to when init_file is set in my.cnf. 

Maybe don't use init_file on crash recovery? or don't abort if it doesn't exist?
[26 Jun 2015 8:36] MySQL Verification Team
Hello Daniël,

Thank you for the report.

Thanks,
Umesh
[26 Jun 2015 8:36] MySQL Verification Team
// 5.6.26

2015-06-26 10:33:22 19522 [Note] Execution of init_file '/tmp/test.sql' started.
2015-06-26 10:33:22 19522 [ERROR] /export/umesh/server/binaries/mysql-5.6.26/bin/mysqld: File '/tmp/test.sql' not found (Errcode: 2 - No such file or directory)
2015-06-26 10:33:22 19522 [ERROR] Aborting
[28 Oct 2015 8:51] Shishir Jaiswal
The main role of mysqld_safe script is to restart the
server when an error occurs. If the option "init_file" (or
any other option which is known to just mysqld and not to
script mysqld_safe) is passed via command line or is
mentioned in my.cnf file under [mysqld], mysqld_safe has to
pass it to mysqld.

When mysqld is killed here, mysqld_safe tries to restart the
server by passing all the options (including --init_file=
/tmp/test.sql option) to mysqld "as is". On finding this
"init_file" to be absent, mysqld throws an error and brings
itself down.

Its logically correct that mysqld_safe aborts restarting
mysqld if the latter has once failed to start due to some
critical error. Since "init_file" contains the set of
commands which *has to* be executed everytime the server
comes up, ignoring this error (mentioned under "Suggested
fix") is not a good idea. For reference:
https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_init_file

According to me this is an expected behaviour and not a bug
. For once, it would have been a bug if the behaviour was
different (mentioned under "Suggested Fix" as, "Make the
behaviour similar to when init_file is set in my.cnf")
between command line and my.cnf file, but this is not the
case as confirmed internally.