bootstrap-pxc and start does not check if mysqld is already running

Bug #1211505 reported by Martin Arrieta
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MySQL patches by Codership
Opinion
Undecided
Unassigned
Percona XtraDB Cluster moved to https://jira.percona.com/projects/PXC
Fix Released
Undecided
Raghavendra D Prabhu

Bug Description

"/etc/init.d/mysql start" and "/etc/init.d/mysql bootstrap-pxc" doesn't check if mysqld is already running before start the process and return "Success" always.

-----------------
How to reproduce:
-----------------

[root@node1 vagrant]# ps xa | grep mysqld
 3908 pts/0 S 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/node1.pid
 4134 pts/0 Sl 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/error.log --pid-file=/var/lib/mysql/node1.pid --wsrep_start_position=4dc84ac4-fe3f-11e2-900b-8e2af1d75a87:105

[root@node1 vagrant]# /etc/init.d/mysql start
Starting MySQL (Percona XtraDB Cluster) SUCCESS!
[root@node1 vagrant]# echo $?
0
[root@node1 vagrant]# /etc/init.d/mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster)Starting MySQL (Percona XtraDB Cluster) SUCCESS!
[root@node1 vagrant]# echo $?
0

-----------
How to fix
-----------

Check if mysql is already running before start the server:

# diff /etc/init.d/mysql-new /etc/init.d/mysql
285,293d284
< # Check if mysqld is already running
< if test -s "$mysqld_pid_file_path" ; then
< read mysqld_pid < "$mysqld_pid_file_path"
< if kill -0 $mysqld_pid 2>/dev/null ; then
< log_failure_msg "MySQL (Percona XtraDB Cluster) is already running ($mysqld_pid)"
< exit 1
< fi
< fi
<

[root@node1 vagrant]# /etc/init.d/mysql-new bootstrap-pxc
Bootstrapping PXC (Percona XtraDB Cluster) ERROR! MySQL (Percona XtraDB Cluster) is already running (4134)
[root@node1 vagrant]# echo $?
1
[root@node1 vagrant]# /etc/init.d/mysql-new start
 ERROR! MySQL (Percona XtraDB Cluster) is already running (4134)
[root@node1 vagrant]# echo $?
1

This will only check for the pid file, we can also add another check for the mysqld process.

Regards,

Martin.

Revision history for this message
Raghavendra D Prabhu (raghavendra-prabhu) wrote :

Yes, the CentOS init script didn't check that whereas the debian one did. Fixing it.

Changed in percona-xtradb-cluster:
milestone: none → 5.5.33-23.7.6
assignee: nobody → Raghavendra D Prabhu (raghavendra-prabhu)
status: New → Fix Committed
Revision history for this message
Alex Yurchenko (ayurchen) wrote :
Changed in codership-mysql:
status: New → Opinion
Changed in percona-xtradb-cluster:
status: Fix Committed → Fix Released
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/PXC-1418

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

Other bug subscribers

Remote bug watches

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