Wrong PID

Wrong PID

am 30.06.2008 03:43:23 von Marcin Polewski

------=_Part_12860_20018327.1214790203506
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On my machine, I start the following command:
/bin/sh /usr/local/bin/mysqld_safe
--defaults-extra-file=/var/db/mysql/my.cnf --user=mysql
--datadir=/var/db/mysql --pid-file=/var/db/mysql/zigzu.bixbots.com.pid

For some reason my PID file does not contain the parent PID, instead it
contains one the children's PID. So when I attempt to stop MySQL, it stops
only one of the child mysqld processes and not all of them.

For example, when mysqld_safe starts up, the following PIDs are running:

23349 mysqld_safe
+ 23378 mysqld
+ 23379 mysqld
+ 23380 mysqld
+ 23381 mysqld
+ 23382 mysqld
+ 23383 mysqld
+ 23385 mysqld
+ 23386 mysqld
+ 23387 mysqld
+ 23388 mysqld
+ 23389 mysqld
+ 23390 mysqld
+ 23391 mysqld
+ 23392 mysqld
+ 23431 mysqld
+ 23445 mysqld
+ 23567 mysqld
+ 24078 mysqld

But the PID file will contain 23383 which is not the parent process.

How can I resolve this?

Thanks,
--Marcin

------=_Part_12860_20018327.1214790203506--

Re: Wrong PID

am 30.06.2008 04:31:00 von yueliangdao0608

------=_Part_13630_21443478.1214793060048
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

You can write a shell script to kill these threads one by one.

On Mon, Jun 30, 2008 at 9:43 AM, Marcin Polewski
wrote:

> On my machine, I start the following command:
> /bin/sh /usr/local/bin/mysqld_safe
> --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql
> --datadir=/var/db/mysql --pid-file=/var/db/mysql/zigzu.bixbots.com.pid
>
> For some reason my PID file does not contain the parent PID, instead it
> contains one the children's PID. So when I attempt to stop MySQL, it stops
> only one of the child mysqld processes and not all of them.
>
> For example, when mysqld_safe starts up, the following PIDs are running:
>
> 23349 mysqld_safe
> + 23378 mysqld
> + 23379 mysqld
> + 23380 mysqld
> + 23381 mysqld
> + 23382 mysqld
> + 23383 mysqld
> + 23385 mysqld
> + 23386 mysqld
> + 23387 mysqld
> + 23388 mysqld
> + 23389 mysqld
> + 23390 mysqld
> + 23391 mysqld
> + 23392 mysqld
> + 23431 mysqld
> + 23445 mysqld
> + 23567 mysqld
> + 24078 mysqld
>
> But the PID file will contain 23383 which is not the parent process.
>
> How can I resolve this?
>
> Thanks,
> --Marcin
>



--
I'm a MySQL DBA in china.
More about me just visit here:
http://yueliangdao0608.cublog.cn

------=_Part_13630_21443478.1214793060048--

Re: Wrong PID

am 30.06.2008 10:38:39 von Mark Leith

Marcin Polewski wrote:
> On my machine, I start the following command:
> /bin/sh /usr/local/bin/mysqld_safe
> --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql
> --datadir=/var/db/mysql --pid-file=/var/db/mysql/zigzu.bixbots.com.pid
>
> For some reason my PID file does not contain the parent PID, instead it
> contains one the children's PID. So when I attempt to stop MySQL, it stops
> only one of the child mysqld processes and not all of them.
>
> For example, when mysqld_safe starts up, the following PIDs are running:
>
> 23349 mysqld_safe
> + 23378 mysqld
> --snip--
> + 23567 mysqld
> + 24078 mysqld
>
> But the PID file will contain 23383 which is not the parent process.
>
> How can I resolve this?
>

By using the correct way to shut down the server? :)

mysqladmin -u root -p shutdown

If you don't want to put your password in the clear within a script, you
can use something like expect (http://expect.nist.gov/), or put the
password for MySQL's root within ~/.my.cnf for the OS user you are
running the script as.

I certainly don't recommend killing the server (well, depends on the
situation and kill level I guess, but I have to say this up front).
Also, if you're running under mysqld_safe, mysqld will simply be
restarted by that process should it go down (by killing it or not), so
you would also have to kill mysqld_safe first.

Further, the above looks like you are running under LinuxThreads, which
actually shows threads as processes within ps etc. - so the above are
not processes, but threads. If you switch to NPTL (Native Posix
Threading Library) within Linux, you will actually see the single mysqld
process (along with the single mysqld_safe process).

You can tell what you are running with 'getconf GNU_LIBPTHREAD_VERSION',
to switch to NPTL 'export LD_ASSUME_KERNEL=2.6.9', to switch back to
LinuxThreads 'export LD_ASSUME_KERNEL 2.4.19'.

I'd be interested in seeing if that stores the right PID for you whilst
running under NPTL.

Best regards

Mark

--
Mark Leith
MySQL Regional Support Manager, Americas
Sun Microsystems, Inc., http://www.sun.com/mysql/


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org