Bug #8374 mysqld_multi usage causing each pid-file to report incorrect value
Submitted: 8 Feb 2005 20:34 Modified: 26 Apr 2005 15:11
Reporter: Daniel Hutchison Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.8a OS:Linux (redhat release 8)
Assigned to: Jani Tolonen CPU Architecture:Any

[8 Feb 2005 20:34] Daniel Hutchison
Description:
when running multiple instances via mysqld_multi wrapper (ex. mysqld_multi start 8), utilizing group ([mysqld#]) sections in /etc/my.cnf, we noticed that the value stored in each pid-file was exactly off by +10:

snippit of ps -elf:

000 S mysql    30027     1  0  69   0    -  1046 wait4  Jan25 ?        00:00:00 /bin/sh /private-1/mysql/bin/mysqld_safe --port=3308 --datadir=/data-1/mysql/dev
000 S mysql    30084 30027  0  73   5    - 13221 do_sel Jan25 ?        00:08:40 /private-1/mysql-4.1.8/libexec/mysqld --basedir=/private-1/mysql-4.1.8 --datadir

> cat /private-1/mysql/admin/yodlee/sock/owl.mesas.com.pid8
30094

here's a portion of the my.cnf:

[mysqld_multi]
mysqld                                  = /private-1/mysql/bin/mysqld_safe
mysqladmin                              = /private-1/mysql/bin/mysqladmin
log                                     = /private-1/mysql/admin/log/multi.log
user                                    = mysql

[mysqld8]
port                                    = 3308
datadir                                 = /data-1/mysql/dev1
tmpdir                                  = /data-1/mysql/dev1/tmpdir
socket                                  = /private-1/mysql/admin/yodlee/sock/mysql.sock8
pid-file                                = /private-1/mysql/admin/yodlee/sock/owl.mesas.com.pid8
#log                                     = /private-1/mysql/admin/yodlee/log/queries.log
log-bin                                 = /private-1/mysql/admin/yodlee/log/yodlee-bin
log-error                               = /private-1/mysql/admin/yodlee/log/error.log
log-slow-queries                        = /private-1/mysql/admin/yodlee/log/slow-queries.log
max_connections                         = 200
default-table-type                      = InnoDB
innodb_data_file_path                   = ibdata1:10M:autoextend
innodb_data_home_dir                    = /data-1/mysql/dev1/innodb/
innodb_log_group_home_dir               = /private-1/mysql/admin/yodlee/arch
innodb_log_arch_dir                     = /private-1/mysql/admin/yodlee/arch

[mysqld9]
port                                    = 3309
datadir                                 = /data-1/mysql/uat1
tmpdir                                  = /data-1/mysql/uat1/tmpdir
socket                                  = /private-1/mysql/admin/yodlee-uat/sock/mysql.sock9
pid-file                                = /private-1/mysql/admin/yodlee-uat/sock/owl.mesas.com.pid9
log-bin                                 = /private-1/mysql/admin/yodlee-uat/log/uat-bin
log-error                               = /private-1/mysql/admin/yodlee-uat/log/error.log
log-slow-queries                        = /private-1/mysql/admin/yodlee-uat/log/slow-queries.log
max_connections                         = 100
default-table-type                      = InnoDB
innodb_data_file_path                   = ibdata1:10M:autoextend
innodb_data_home_dir                    = /data-1/mysql/uat1/innodb/
innodb_log_group_home_dir               = /private-1/mysql/admin/yodlee-uat/arch
innodb_log_arch_dir                     = /private-1/mysql/admin/yodlee-uat/arch

How to repeat:
restart instances and check pid-file value
[14 Feb 2005 17:44] MySQL Verification Team
Hi,

Please, check it with "ps axm" command.
[15 Feb 2005 1:10] Daniel Hutchison
I see, so this pid value always reflects the last thread process spawned (out of 10 total)?  and is there only supposed to be one pid-file, regardless of the # of threads?

Thanks,
Dan
[26 Apr 2005 15:11] Jani Tolonen
There should be only one pid-file per process. In this regard
process is one program running, independent of the connections
(threads) connected to it.

BTW, mysqld server sets the pid-file for itself, not mysqld_multi.

Actually it is a bug in Linux that it shows several processes for
the same process, there really should be just one. Depending
on thread library being used, this problem may occur or not.
Other UNIX systems show only one process for mysqld.

Anyway, the pid-file should always contain the correct (main thread)
program id, as mysqld process gets it from the system at start-up.