stopping mysql with inet script doesn't work if pid-file is provided as pid_file in my.cnf

Bug #1208865 reported by Frederic Descamps on 2013-08-06
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server
Status tracked in 5.6
5.1
Medium
Unassigned
5.5
Medium
Unassigned
5.6
Medium
Unassigned
Percona XtraDB Cluster
Medium
Raghavendra D Prabhu

Bug Description

When you define the pid-file in my.cnf using (underscore) instead of -, it won't stop.

in my.cnf:

pid_file = /mysql/data/mysql.pid

mysqld print-defaults output:

mysqld --print-defaults
mysqld would have been started with the following arguments:
--user=mysql --default_storage_engine=InnoDB --socket=/mysql/data/mysql.sock --pid_file=/mysql/data/mysql.pid
 [...]
--wsrep_sst_donor=db1

mysqld --print-defaults \
> | tr " " "\n" \
> | grep -- "--pid-file" \
> | tail -n 1 \
> | cut -d= -f2

---> nothing

mysqld --print-defaults \
> | tr " " "\n" \
> | grep -- "--pid_file" \
> | tail -n 1 \
> | cut -d= -f2
/mysql/data/mysql.pid

Changed in percona-xtradb-cluster:
status: New → Fix Committed
assignee: nobody → Raghavendra D Prabhu (raghavendra-prabhu)
importance: Undecided → Medium
milestone: none → 5.5.32-23.7.6
Changed in percona-xtradb-cluster:
status: Fix Committed → Fix Released

Percona Server 5.1 and 5.6 are also affected:

[openxs@chief ~]$ cd /tmp/Percona-Server-5.1.72-rel14.10
[openxs@chief Percona-Server-5.1.72-rel14.10]$ grep -- --pid-file support-files/mysql.server.sh
      --pid-file=*) server_pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
        --pid-file="$pid_file" >/dev/null 2>&1 &
      $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
[openxs@chief Percona-Server-5.1.72-rel14.10]$ grep -- --pid_file support-files/mysql.server.sh

[openxs@chief Percona-Server-5.6.14-rel62.0]$ grep -- --pid_file support-files/mysql.server.sh
[openxs@chief Percona-Server-5.6.14-rel62.0]$ grep -- --pid-file support-files/mysql.server.sh
      --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &

This is what we see in current cluster code (with the fix, I assume):

[openxs@chief percona-xtradb-cluster]$ bzr version-info
revision-id: <email address hidden>
date: 2013-12-03 17:43:41 +0100
build-date: 2013-12-04 13:03:18 +0200
revno: 590
branch-nick: percona-xtradb-cluster
[openxs@chief percona-xtradb-cluster]$ grep -- --pid-file Percona-Server/support-files/mysql.server.sh
      --pid-file=*|--pid_file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;;
      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null 2>&1 &

tags: added: upstream
zoxa (azakhidov) wrote :

Just installed latest Percona-Server-server-55 from yum repository

Installed Packages
Name : Percona-Server-server-55
Arch : x86_64
Version : 5.5.43
Release : rel37.2.el7
Size : 66 M

have exactly the same problem: since default my.cnf has line like
[mysql_safe]
pid-file=/var/run/mysqld/mysqld.pid

init script cannot find it in proper location

Tomislav Plavcic (tplavcic) wrote :

@zoxa:
From you output I see you are using packages for centos7.
Here's my output on centos7 with specified pid-file and it seems to work ok.

INSTALLED PACKAGES:
[vagrant@t-centos7-64 ~]$ sudo yum list installed|grep Percona-Server
Percona-Server-client-55.x86_64 5.5.43-rel37.2.el7 @percona-release-x86_64
Percona-Server-server-55.x86_64 5.5.43-rel37.2.el7 @percona-release-x86_64
Percona-Server-shared-55.x86_64 5.5.43-rel37.2.el7 @percona-release-x86_64

MY.CNF FILE:
...
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

STATUS:
[vagrant@t-centos7-64 ~]$ sudo systemctl status mysqld
mysqld.service - MySQL Percona Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: active (running) since Sri 2015-05-13 08:54:22 CEST; 11s ago
  Process: 13925 ExecStartPost=/usr/bin/mysql-systemd post (code=exited, status=0/SUCCESS)
  Process: 13891 ExecStartPre=/usr/bin/mysql-systemd pre (code=exited, status=0/SUCCESS)
 Main PID: 13924 (mysqld_safe)
   CGroup: /system.slice/mysqld.service
           ├─13924 /bin/sh /usr/bin/mysqld_safe
           └─14056 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.so...

SHUTDOWN:
[vagrant@t-centos7-64 ~]$ sudo systemctl stop mysqld
[vagrant@t-centos7-64 ~]$ sudo systemctl status mysqld
mysqld.service - MySQL Percona Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)
   Active: inactive (dead) since Sri 2015-05-13 08:55:01 CEST; 15s ago
  Process: 13925 ExecStartPost=/usr/bin/mysql-systemd post (code=exited, status=0/SUCCESS)
  Process: 13924 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
  Process: 13891 ExecStartPre=/usr/bin/mysql-systemd pre (code=exited, status=0/SUCCESS)
 Main PID: 13924 (code=exited, status=0/SUCCESS)

[vagrant@t-centos7-64 ~]$ ps aux|grep mysqld
vagrant 14100 0.0 0.1 112640 992 pts/0 S+ 08:55 0:00 grep --color=auto mysqld

If I disable the pid-file option the pid-file is specified in /var/lib/mysql/t-centos7-64.pid and it starts and stops also ok.

Are you using packages on another distribution or something else is different?

To post a comment you must log in.
This report contains Public information  Edit
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.