Applicable to:
- Plesk for Linux
Symptoms
-
E-Mails are stuck in the queue with below messages in
/var/log/maillog
:amavis[26892]: (26892-01) (!)connect_to_sql: unable to connect to DSN 'DBI:mysql:database=emailsecurity;host=localhost;port=3306': Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
amavis[26892]: (26892-01) (!!)TROUBLE in process_request: connect_to_sql: unable to connect to any dataset at (eval 132) line 253.
amavis[26892]: (26892-01) (!)Requesting process rundown after fatal error -
MariaDB upgrade has been performed recently on the server with SELinux enabled
Cause
MariaDB bug #MDEV-24941: SElinux incorrect label for server socket.
The SELinux context for the MariaDB socket file /var/lib/mysql/mysql.sock
has been lost because of the above because of upgrade to MariaDB version affected by the bug.
Resolution
To workaround the problem until the bug is resolved apply the following steps:
- Connect to the server via SSH
Warning: On applying the following step the database server MariaDB will be restarted, which leads to a short inaccessibility of other Plesk related services and websites accessing the database
-
Run the following command:
# printf '%s\n' '[Service]' 'ExecStartPost=/sbin/restorecon /var/lib/mysql/mysql.sock' > /etc/systemd/system/mariadb.service.d/restorecon_socket.conf && systemctl daemon-reload && systemctl restart mariadb
The following alternative workarounds are also available:
-
Downgrade MariaDB server to version not affected by bug #MDEV-24941
-
Disable Amavis by disabling Plesk Email Security extension
Comments
5 comments
I get the following error with this work around any ideas?
Task "/usr/sbin/restorecon -v /var/lib/mysql/mysql.sock" completed with error in 0 seconds, output:
Number 5 step should I run one time right? No need to set cron job for this, right?
The issue is still open. Just faced on AlmaLinux host.
First of all, to verify if you suffer from this problem, run:
If you see anything other than the line below, you probably experience this issue exactly.
srwxrwxrwx. 1 mysql mysql system_u:object_r:mysqld_var_run_t:s0 0 May 29 16:30 /var/lib/mysql/mysql.sock
On systems that run systemd it is possible to configure a command to run after service has started. Modify /etc/systemd/system/mariadb.service.d/override.conf and add lines below:
then do configuration reload and mariadb restart:
systemctl daemon-reload
systemctl restart mariadb
Verify if it helped with ls command. If it did help, verify it still works after host reboot.
There is no need to do a chcon as the default system policy is correct.
Create a file /etc/systemd/system/mariadb.service.d/restorecon_socket.conf with the following contents:
# Workaround so socket gets correct linux context
[Service]
ExecStartPost=/sbin/restorecon /var/lib/mysql/mysql.sock
Next, run:
# systemctl daemon-reload && systemctl restart mariadb
Source: https://jira.mariadb.org/browse/MDEV-24941?focusedCommentId=233795&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-233795
Hello,
Thank you for the recommendations. We updated the article with another workaround accordingly.
Please sign in to leave a comment.