RPMs wrongly assumes that .pid file is always located in datadir

Bug #1201896 reported by Valerii Kravchuk
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Fix Released
High
Tomislav Plavcic
5.1
Invalid
Undecided
Unassigned
5.5
Fix Released
High
Tomislav Plavcic
5.6
Fix Released
High
Tomislav Plavcic

Bug Description

The preinstall scriptlet looks up the datadir via:

mysql_datadir=`/usr/bin/my_print_defaults server mysqld | grep '^--datadir=' | sed -n 's/--datadir=//p'`

and then assumes that the server is currently running if one file exists matching:

NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`

This only works if the PID file is located in that directory, though, and it may not be the case if explicit pid-file setting is used.

As a result, during installation of RPMs wrong assumption may be made about server running or not.

Tags: pkg i31091 i33403
Revision history for this message
Valerii Kravchuk (valerii-kravchuk) wrote :

This is easy to verify by code review actually:

openxs@debian7:~/bzr/percona-5.5$ bzr version-info
revision-id: <email address hidden>
date: 2013-07-12 09:17:29 +0000
build-date: 2013-07-16 20:07:15 +0300
revno: 555
branch-nick: percona-5.5
openxs@debian7:~/bzr/percona-5.5$ grep -n NR_PID_FILES build/percona-server.spec
653:NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`
654:case $NR_PID_FILES in
openxs@debian7:~/bzr/percona-5.5$ cd ../percona-5.6
openxs@debian7:~/bzr/percona-5.6$ grep -n NR_PID_FILES build/percona-server.spec
645:NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`
646:case $NR_PID_FILES in
openxs@debian7:~/bzr/percona-5.6$ bzr version-info revision-id: <email address hidden>
date: 2013-07-12 09:09:16 +0000
build-date: 2013-07-16 20:10:41 +0300
revno: 405
branch-nick: percona-5.6

Revision history for this message
Valerii Kravchuk (valerii-kravchuk) wrote :

In 5.1 we do not try to be smart...

tags: added: pkg
Revision history for this message
Scott Dellinger (scott-dellinger) wrote :

I filed the support request leading to this bug, and would love to see this resolved so that my cf-engine package updates stop leading to database services that aren't running. :-) A fix for this issue could be simply to obtain the PID file location in the package preinstall scriptlet via something like:

     pid_file=`/usr/bin/my_print_defaults mysqld | grep '^--pid-file=' | sed -n 's/--pid-file=//p'`

and then replace the line:

    NR_PID_FILES=`ls $mysql_datadir/*.pid 2>/dev/null | wc -l`

with

    NR_PID_FILES=`ls $pid_file 2>/dev/null | wc -l`

leaving everything else alone. This would correctly locate the PID file, if it exists, regardless of configured location.

Revision history for this message
Roel Van de Paar (roel11) wrote :

The fix in #3 does not account for # mysqld's running on one box, as for instance a hosting service would do.

Thinking out loud (without code review):
ps -ef | grep "mysqld" | grep -v "grep" | awk '{print $2}' | sort -u | wc -l
would at least give correct total number of running instances?

Revision history for this message
Tomislav Plavcic (tplavcic) wrote :
Revision history for this message
monty solomon (monty+launchpad) wrote :

I suggest that Percona track changes to the upstream RPM scripts and migrate the changes into the Percona scripts.

There are other bugs here that were caused by stale scripts.

Thanks.

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-694

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.