Bug 1145455

Summary: systemctl start mariadb - hangs if sock file is used by another process
Product: Red Hat Enterprise Linux 7 Reporter: Branislav Blaškovič <bblaskov>
Component: mariadbAssignee: Michal Schorm <mschorm>
Status: CLOSED CURRENTRELEASE QA Contact: qe-baseos-daemons
Severity: low Docs Contact:
Priority: high    
Version: 7.1CC: bgollahe, databases-maint, hhorak, kvolny, toneata, vdanek
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, the mysqladmin tool waited for an inadequate length of time if the socket it listened on did not respond in a specific way. Consequently, when the socket was used while the MariaDB server was starting, the mariadb service became unresponsive for a long time. With this update, the mysqladmin timeout has been shortened to 2 seconds. As a result, the mariadb service either starts or fails but no longer hangs in the described situation.
Story Points: ---
Clone Of:
: 1584023 (view as bug list) Environment:
Last Closed: 2018-10-30 15:42:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1400961, 1472751, 1584023    

Description Branislav Blaškovič 2014-09-23 06:33:06 UTC
Description of problem:
If I listen on sock file which is the same for mariadb, starting of mariadb service hangs.

Version-Release number of selected component (if applicable):
mariadb-server-5.5.35-3.el7.x86_64

How reproducible:
always

Steps to Reproduce:
# systemctl stop mariadb
# ls /var/lib/mysql/mysql.sock
ls: cannot access /var/lib/mysql/mysql.sock: No such file or directory
# nc -k -l -U /var/lib/mysql/mysql.sock &
# chown mysql:mysql /var/lib/mysql/mysql.sock
# restorecon -v /var/lib/mysql/mysql.sock
restorecon reset /var/lib/mysql/mysql.sock context unconfined_u:object_r:mysqld_db_t:s0->unconfined_u:object_r:mysqld_var_run_t:s0
# systemctl start mariadb
.. it hangs here ..

Comment 2 Honza Horak 2015-03-14 19:38:51 UTC
This issue is caused by mysqladmin pinging the socket file and this tool expects the socket responds in a specific way, which doesn't happen (nc doesn't respond) and the mysqladmin tool waits for too long time by default. This time may either be shortened by using --connect-timeout=10 for example (shortens the hang to 10s) or better to use a check if socket is used before actually starting the daemon process, similar to what Fedora does:

http://pkgs.fedoraproject.org/cgit/mariadb.git/tree/mysql-check-socket.sh?id=c9d7d6f31d5f8ad7979201b65c03cb7fec4fd157

What is important, this shouldn't be a real issue, since if another mysql daemon is using the socket, the daemon's respond is sane and mysqladmin doesn't hang.