Bug #84427 mysqld_safe fails to start when using a fifo for log-error (regression)
Submitted: 6 Jan 2017 2:38 Modified: 24 Feb 2017 1:48
Reporter: Travers Carter Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Packaging Severity:S2 (Serious)
Version:5.6.35 OS:Linux (CentOS 7)
Assigned to: Terje Røsten CPU Architecture:Any

[6 Jan 2017 2:38] Travers Carter
Description:
The changes made to mysqld_safe log file handling in MySQL 5.6.35 prevent mysqld from starting if the log-error points to a fifo rather than a regular file.

mysqld safe complains:

170106 12:54:26 mysqld_safe error: log-error set to '/var/run/mysqld/log.fifo', however file don't exists. Create writable for user 'mysql'.

However /var/run/mysqld/log.fifo does exist and is writeable by mysql, it is however a fifo and not a regular file.

[root@dev conf.d]# ls -l /var/run/mysqld/log.fifo
prw-r-----. 1 mysql mysql 0 Jan  6 13:05 /var/run/mysqld/log.fifo

How to repeat:

# Set up a fifo and listen on it
mkfifo -m 0640 /var/run/mysqld/log.fifo
chown mysql:mysql /var/run/mysqld/log.fifo
cat /var/run/mysqld/log.fifo

# Configure mysqld_safe to log to the fifo
----%<---- my.cnf ----%<---- 
[mysqld_safe]
log-error = /var/run/mysqld/log.fifo
----%<--------%<--------%<---- 

# Start mysqld
systemctl start mysqld.service

Suggested fix:
Extend the existence check in mysqld_safe to check for fifo (named pipe) files as well as regular files

--- a/mysqld_safe    2017-01-06 13:34:21.237081735 +1100
+++ b/mysqld_safe    2017-01-06 13:32:41.941291759 +1100
@@ -633,7 +633,7 @@
     fi
   fi

-  if [ -f "$err_log" ]; then        # Log to err_log file
+  if [ -f "$err_log" -o -p "$err_log" ]; then        # Log to err_log file
     log_notice "Logging to '$err_log'."
   elif [ "x$user" = "xroot" ]; then # running as root, mysqld can create log file; continue
     echo "Logging to '$err_log'." >&2
[6 Jan 2017 5:44] Terje Røsten
Hi!

Thanks for your report! A fix will be included in the next batch of releases.
[25 Jan 2017 21:11] Jesse Duce
This happens on regular files as well when started with sudo.

I normally run sudo service mysql start, which works fine on 5.6.34, but now, if the mysql_error.log doesn't exist beforehand, that command fails and now requires the service to be started as mysql. sudo -u mysql service mysql start.

I will be skipping this patch in my test and production environments because of the potential for the service not to start on reboot.
[5 Feb 2017 3:17] Phil Hildebrand
This also seems to happen on 5.5.54-38.6 on ubuntu.

If the error.log does not exist, mysql will not start (same error).

touching (creating one)  the file fixes the issue
[24 Feb 2017 1:48] Paul DuBois
Posted by developer:
 
Noted in 5.5.55, 5.6.36, 5.7.18, 8.0.1 changelogs.

mysqld_safe failed if the error log file named by the --log-error
option was a FIFO.