Bug #87657 Trailing # comment on !includedir / !include directive causes error

Submitted: 4 Sep 2017 12:56 Modified: 15 Jan 17:30
Reporter: Oli Sennhauser Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any

[4 Sep 2017 12:56] Oli Sennhauser
Description:
mysqld does not report my.cnf configuration errors to error log or journalctl

How to repeat:
# /etc/my.cnf

!includedir /home/mydir
log_bin = bin-log   # --> this is weong

systemctl start mysql
-> fails
-> journalctl -xe --> no information other than failed
-> mysql error log is not touched

can be found with mysqld --user=mysql

mysqld: Can't read dir of '/home/mydir' (Errcode: 2 - No such file or directory)
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

Suggested fix:
report also these early stage error message to journalctl and mysql error log.
[4 Sep 2017 13:50] Peter Laursen
Maybe I am missing something, but I don't see how mysqld should be able to write at all (to error log or any file) when it is not running. 

What do you suggest: it should then ignore the erroneous option, start, write to log and next abort? Or "inject/pass on" some information to the system (systemctrl or whatever) that the system next can/will log?

-- Peter
-- not a MySQL/Oracle person
[4 Sep 2017 16:29] Terje Røsten
Seems to be dup of https://bugs.mysql.com/bug.php?id=87087:

 Bug#87087 mysqld completely silent even in failure if log-error is not writable
[4 Sep 2017 16:42] Oli Sennhauser
I am not so sure if this is the same problem. Because MySQL is/was writeable to MySQL error log file. It somehow looks more like the error message was not redirected to log/systemd error trap.

I think I have seen this already in older version but was too lazy to file a but.
[5 Sep 2017 10:30] Terje Røsten
Hi Oli!

I can't reproduce:

$ grep -v \# /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

!includedir /invalid/mydir

$ systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

$ journalctl -xe |grep invalid|head -3
Sep 05 12:18:09 vide27 mysqld_pre_systemd[10535]: my_print_defaults: Can't read dir of '/invalid/mydir' (Errcode: 2 - No such file or directory)
Sep 05 12:18:09 vide27 mysqld_pre_systemd[10535]: my_print_defaults: Can't read dir of '/invalid/mydir' (Errcode: 2 - No such file or directory)
Sep 05 12:18:09 vide27 mysqld[10563]: mysqld: Can't read dir of '/invalid/mydir' (Errcode: 2 - No such file or directory)

This is with MySQL 5.7.19 RPMS on EL7.
[5 Sep 2017 12:23] Oli Sennhauser
Hello Terje

I tried to reproduce as well an I can confirm your finding. Error message is displayed with journalctl -xe.

So either I did not look well or I did something else wrong. I will investigate further...

Never the less: The error message is wrong. This is my test case:

# Fresh MySQL 5.7 installation via MySQL repository
systemctl stop mysqld
cat >> /etc/my.cnf << _EOF
[mysqld]
!includedir /etc/my.cnf.d/   # this directory exists!
log_bin = bin-log
_EOF
systemctl start mysqld

Sep 05 14:03:42 centos7tpl mysqld[2496]: mysqld: Can't read dir of '/etc/my.cnf.d/   # this directory exists!'
Sep 05 14:03:42 centos7tpl mysqld[2496]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

This directory is perfectly readable. The problem is the comment AFTER the !includedir directive...

--> this works
!includedir /etc/my.cnf.d

--> this does not work
!includedir /etc/my.cnf.d   # some comment here

Regards,
Oli
[5 Sep 2017 14:11] Terje Røsten
Using a trailing # comment in my.cnf on !includedir or !include directives breaks parsing or makes directive silently ignored.

Example 1):

Adding this line

!includedir /etc/my.cnf.d # comment breaks parsing

in my.cnf breaks everything after 

'!includedir ' is regarded as argument:

$ my_print_defaults  mysqld
my_print_defaults: Can't read dir of '/etc/my.cnf.d # comment breaks parsing'
  (Errcode: 2 - No such file or directory)

Example 2)

With the line

!include /etc/foo.cnf     # comment breaks parsing

in my.cnf MySQL looks for file named 'etc/foo.cnf     # comment breaks parsing'
don't find it and ignores the error.
[15 Jan 17:30] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Server 9.6.0 release notes:
		
Trailing comments on the !includedir or !include directives in the MySQL
configuration file could prevent the server from starting.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.