1

I have a systemd path unit, which watches a config file to apply db changes if the config file changes. To ensure the path unit runs after mysql, I added these lines:

Wants=mysqld.service
After=mysqld.service
Requires=mysqld.service
ConditionPathExists=/run/mysql/mysql.sock

Despite all these, the path unit starts sometimes before mysql is running, I see these in the path status:

Condition: start condition failed at ...; 40s ago
           └─ ConditionPathExists=/run/mysql/mysql.sock was not met

And these in the corresponding service, which is doing the updates with the mysql command:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysql/mysql.sock' (2)

The system is a custom linux setup with buildroot.

ExecStart of mysqld.service:

/usr/bin/mysqld_safe --log-error=/var/log/mysql/mysqld.log

mysql --version:

mysql Ver 15.1 Distrib 10.3.36-MariaDB, for Linux (x86_64) using readline 5.1

How can I ensure mysql is running before the path unit starts watching the config file?

9
  • Which version of mysql, and, which Type= and what ExecStart= does mysqld.service have? Commented Jun 25 at 10:11
  • @grawity_u1686 I added version and ExecStart=, there is no Type=
    – elsamuko
    Commented Jun 25 at 12:14
  • You linked the ExecStart to a unit on GitHub, which has Type=notify – is that the same on your system, or is your version different? Commented Jun 25 at 12:43
  • You might be onto sth, we are using buildroot-2023.05, and Type=notify was added after that: github.com/buildroot/buildroot/commit/…
    – elsamuko
    Commented Jun 25 at 13:31
  • Hmm, but ConditionPathExists= should prevent the service from starting at all if the path doesn't exist (yet), which means you shouldn't see condition failed and the connection error at the same time...
    – Tom Yan
    Commented Jun 25 at 13:32

0

You must log in to answer this question.

Browse other questions tagged .