Bug 1584023

Summary: systemctl start mariadb - hangs if sock file is used by another process [rhel-7.5.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
Component: mariadbAssignee: Michal Schorm <mschorm>
Status: CLOSED ERRATA QA Contact: Karel Volný <kvolny>
Severity: low Docs Contact:
Priority: high    
Version: 7.1CC: bblaskov, bgollahe, databases-maint, hhorak, kvolny, lmanasko, mmuzila, mschorm, 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: 1145455 Environment:
Last Closed: 2018-08-16 14:17:20 UTC Type: ---
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: 1145455    
Bug Blocks:    

Description Oneata Mircea Teodor 2018-05-30 07:46:31 UTC
This bug has been copied from bug #1145455 and has been proposed to be backported to 7.5 z-stream (EUS).

Comment 6 Karel Volný 2018-07-02 13:30:47 UTC
I cannot test this using the original reproducer because the initscript seems to exit as soon as it finds that another process is hanging on the socket ... any hints?

Comment 7 Karel Volný 2018-07-03 15:44:19 UTC
now this is interesting - after modifying the reproducer to initialise the database at first, i.e. starting and stopping the daemon before, the daemon just starts, no matter that /var/lib/mysql/mysql.sock is used by nc ...

Comment 8 Karel Volný 2018-07-03 16:28:32 UTC
to be precise:

:: [ 12:25:38 ] :: [   PASS   ] :: File /var/lib/mysql/mysql.sock should exist 
srwxr-xr-x. mysql mysql unconfined_u:object_r:mysqld_var_run_t:s0 /var/lib/mysql/mysql.sock
:: [ 12:25:38 ] :: [  BEGIN   ] :: Socket opened by nc should contain /var/lib/mysql/mysql.sock :: actually running 'lsof -U -a -c nc | grep '/var/lib/mysql/mysql.sock''
nc      4873 root    3u  unix 0xffff99f38b7b6c00      0t0 63649 /var/lib/mysql/mysql.sock

...

:: [ 12:25:43 ] :: [   FAIL   ] :: Trying to start mariadb (should fail) (Expected 1, got 0)

...

:: [ 12:25:53 ] :: [   FAIL   ] :: Checking mariadb status (should not be running) (Expected 3, got 0)
:: [ 12:25:53 ] :: [   PASS   ] :: File /var/lib/mysql/mysql.sock should exist 
srwxrwxrwx. mysql mysql system_u:object_r:mysqld_var_run_t:s0 /var/lib/mysql/mysql.sock
COMMAND  PID  USER   FD   TYPE             DEVICE SIZE/OFF  NODE NAME
nc      4873  root    3u  unix 0xffff99f38b7b6c00      0t0 63649 /var/lib/mysql/mysql.sock
mysqld  5168 mysql   15u  unix 0xffff99f38ae99800      0t0 64204 /var/lib/mysql/mysql.sock


so, obviously, mariadb overlays the socket file somehow ...

Comment 9 Karel Volný 2018-07-04 10:33:26 UTC
in /usr/libexec/mariadb-wait-ready there is now connect-timeout added:

RESPONSE=`/usr/bin/mysqladmin --no-defaults --connect-timeout=2 --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`

Comment 10 Karel Volný 2018-07-04 10:59:10 UTC
re comment 7, 8 - there are a few other issues, e.g. bug 1598095

Comment 12 errata-xmlrpc 2018-08-16 14:17:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2439