Socket file in multi instance mysql@

I find strange bug or error but I not sure if systemD or mysql.

I have two instance in same server db00, If I stop or restart any instance, it delete the pid and socket file of the other service but the other service is still working.

Server version: 8.0.23-14 Percona Server
[mysqld@db01]
pid-file        = /var/run/mysqld/mysql_db01.pid
socket          = /var/run/mysqld/mysql_db01.sock
datadir         = /var/lib/mysql_db01
log-error       = /var/log/mysql_db01/error.log
port            = 3306
server_id       = 101
mysqlx          = 0
...
[mysqld@db02]
pid-file        = /var/run/mysqld/mysql_db02.pid
socket          = /var/run/mysqld/mysql_db02.sock
datadir         = /var/lib/mysql_db02
log-error       = /var/log/mysql_db02/error.log
port            = 3307
server_id       = 202
mysqlx          = 0
...

for example:

both services are running , and the files exist in /var/run/mysqld/

#ls -l /var/run/mysqld/:
drwxr-xr-x  2 root root   40 May 27 01:15 ./
drwxr-xr-x 35 root root 1080 May 27 01:15 ../
-rw-r-----  1 mysql mysql    7 May 27 01:07 mysql_db01.pid
srwxrwxrwx  1 mysql mysql    0 May 27 01:07 mysql_db01.sock=
-rw-------  1 mysql mysql    7 May 27 01:07 mysql_db01.sock.lock
-rw-r-----  1 mysql mysql    7 May 27 01:08 mysql_db02.pid
srwxrwxrwx  1 mysql mysql    0 May 27 01:08 mysql_db02.sock=
-rw-------  1 mysql mysql    7 May 27 01:08 mysql_db02.sock.lock
#

stop the service ,mysql@db02 and delete all files in /var/run/mysql

#systemctl stop mysql@db02
#ll /var/run/mysqld/:
drwxr-xr-x  2 root root   40 May 27 01:15 ./
drwxr-xr-x 35 root root 1080 May 27 01:15 ../
#

For restore the files we need stop (or restart) the other instance

#systemctl stop mysql@db01
#ll /var/run/mysqld/:
drwxr-xr-x  2 root root   40 May 27 01:15 ./
drwxr-xr-x 35 root root 1080 May 27 01:15 ../
#

And start one by one.

#systemctl start mysql@db01
#ll /var/run/mysqld/
drwxr-xr-x  2 root root   40 May 27 01:15 ./
drwxr-xr-x 35 root root 1080 May 27 01:15 ../
-rw-r----- 1 mysql mysql 7 May 27 01:18 mysql_db01.pid
srwxrwxrwx 1 mysql mysql 0 May 27 01:18 mysql_db01.sock
-rw------- 1 mysql mysql 7 May 27 01:18 mysql_db01.sock.lock
#
#systemctl start mysql@db02
#ll /var/run/mysqld/
drwxr-xr-x  2 root root   40 May 27 01:15 ./
drwxr-xr-x 35 root root 1080 May 27 01:15 ../
-rw-r----- 1 mysql mysql 7 May 27 01:18 mysql_db01.pid
srwxrwxrwx 1 mysql mysql 0 May 27 01:18 mysql_db01.sock
-rw------- 1 mysql mysql 7 May 27 01:18 mysql_db01.sock.lock
-rw-r----- 1 mysql mysql 7 May 27 01:19 mysql_db02.pid
srwxrwxrwx 1 mysql mysql 0 May 27 01:19 mysql_db02.sock
-rw------- 1 mysql mysql 7 May 27 01:19 mysql_db02.sock.lock

I don’t think it is good idea create other dir in /var/run (in case of reboot), any idea? maybe is service or config mysql

1 Like

Hi. Could you please show the part of log to understand the systemd behavior.