Bug #64927 mysqld --help removes the pid file
Submitted: 10 Apr 2012 11:19 Modified: 10 Apr 2012 13:59
Reporter: Timur Bakeyev Email Updates:
Status: Duplicate Impact on me:
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:5.1.61-rel13.2 OS:Linux (Debian 6.0 amd64)
Assigned to: CPU Architecture:Any

[10 Apr 2012 11:19] Timur Bakeyev
Issuing 'mysqld --help' or 'mysqld --verbose --help' while there is a running instance of the mysqld in memory unconditionally removes existing valid PID file.

This behavior was observed both with Percona 5.1.[59-61] server and:

./mysqld  Ver 5.5.20-ndb-7.2.5-gpl for debian6.0 on x86_64 (MySQL Cluster Community Server (GPL))

That makes me think that this bug isn't Percona server specific, but rather common for all (recent) versions of MySQL.

Side note:

'mysqld --verbose --help' seems to be the only possible way to get list of all MySQL variables with their actual values BEFORE the server started and 'mysqladmin variables' could be used.

I didn't find any better way to retrieve variables like 'ndb-wait-connected' for startup script. This approach works OK when there is no mysqld instance running,  but if there is any - it messes things up, both for starting and stopping of the daemon.

How to repeat:
# cat /var/run/mysqld/mysqld.pid

# ls -l /var/run/mysqld/mysqld.pid
-rw-rw---- 1 mysql mysql 6 Apr 10 12:59 /var/run/mysqld/mysqld.pid

# mysqld --help
120410 13:00:48 [Note] Flashcache bypass: disabled
120410 13:00:48 [Note] Flashcache setup error is : ioctl failed

120410 13:00:48 [Note] Plugin 'FEDERATED' is disabled.
mysqld  Ver 5.1.61-rel13.2 for debian-linux-gnu on x86_64 ((Percona Server (GPL), 13.2, Revision 430))
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Starts the MySQL database server.

Usage: mysqld [OPTIONS]

For more help options (several pages), use mysqld --verbose --help.

# ls -l /var/run/mysqld/mysqld.pid
ls: cannot access /var/run/mysqld/mysqld.pid: No such file or directory

# cat /var/run/mysqld/mysqld.pid
cat: /var/run/mysqld/mysqld.pid: No such file or directory

Suggested fix:
Fix the code. As other informative options, like 'mysqld --print-defaults' or 'mysqld -V' don't exhibit such a (mis)behavior it should be just a matter of some guarding code which is missing for the given selection of options.
[10 Apr 2012 13:38] Valeriy Kravchuk
This is actually a know problem that was probably fixed only in 5.6 recently. Check Bug #23790 and somewhat related Bug #63187.
[10 Apr 2012 13:59] Timur Bakeyev
I couldn't find those reports when I went through the open bugs - but possibly wrong keywords were used.

I can't say that indicated errors are exactly the same, but seems quite similar and related.

It's nice that the problem, which originally was reported for 4.1 is somewhat fixed in 5.6, but what about intermediate versions? 5.5 is still the GA and recommended release and 5.1 is widely used...

Also, '--verbose --help' seems often used to extract values of all the variables available - maybe, it's reasonable just to extend '--print-defaults' to provide such information and stop abusing '--help' flag.