Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 786153 - dev-db/mysql-init-scripts incorrectly verify mysqld aliveness
Summary: dev-db/mysql-init-scripts incorrectly verify mysqld aliveness
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Gentoo Linux MySQL bugs team
Depends on:
Reported: 2021-04-27 21:03 UTC by Dmitry Bogun
Modified: 2021-04-27 21:59 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Bogun 2021-04-27 21:03:47 UTC
Instantiated systemd unit (/lib/systemd/system/mysqld@.service) uses mysqld-wait-ready script to check status of launched mysqld daemon. Which internally uses /usr/bin/my_print_defaults to read socket address from config(defaults) file.

So if config file (/etc/mysql/my%I.cnf) redefines socket path mysqld-wait-ready will use incorred (readed from default config file /etc/mysql/my.cnf) value of socket path. 

As result, it will or report that mysqld daemon does not start (after 300 seconds timeout) or it will read check "other" mysqld instance status (accessible via socket path defined into /etc/mysqld/my.cnf) file.

Proposed fix into mysqld-wait-ready script:
diff -Nau a/mysqld-wait-ready b/mysqld-wait-ready
--- a/mysqld-wait-ready 2021-04-27 23:44:51.949666241 +0300
+++ b/mysqld-wait-ready 2021-04-27 23:45:36.758275459 +0300
@@ -8,6 +8,7 @@
 # Service file passes us the daemon's PID (actually, mysqld_safe's PID)
 # extract value of a MySQL option from config files
 # Usage: get_mysql_option SECTION VARNAME DEFAULT
@@ -15,7 +16,7 @@
 # We use my_print_defaults which prints all options from multiple files,
 # with the more specific ones later; hence take the last match.
-       result=`/usr/bin/my_print_defaults "$1" | sed -n "s/^--$2=//p" | tail -n 1`
+       result=`/usr/bin/my_print_defaults ${defaults_file:+--defaults-file="$defaults_file"} "$1" | sed -n "s/^--$2=//p" | tail -n 1`
        if [ -z "$result" ]; then
            # not found, use default

And change PostExec into unit file to the:
ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID /etc/mysql/my%I.cnf

Reproducible: Always