inconsistent mysqladmin return value, debian init-script dependency

Bug #1379223 reported by Tobias Brox
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Status tracked in 5.7
5.1
Won't Fix
Undecided
Unassigned
5.5
Expired
Undecided
Unassigned
5.6
Expired
Undecided
Unassigned
5.7
Expired
Undecided
Unassigned

Bug Description

One (or two) minor bug(s) that I arbritrary hit on because someone had overwritten /etc/mysql/debian.cnf ...

This doesn't quite make sense:

$ mysqladmin -u foo -pbar ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'foo'@'localhost' (using password: YES)'
$ echo $?
0

At the other hand:

$ mysqladmin --defaults-file=/foo/bar
Could not open required defaults file: /foo/bar
Fatal error in defaults handling. Program aborted
$ echo $?
1

The init-script is checking weather mysql is running or not by doing ...

  mysqladmin --defaults-file=/etc/mysql/debian.cnf ping

This means mysql is always regarded as running if the password in /etc/mysql/debian.cnf is wrong, but always regarded as being down if the password in /etc/mysql/debian.cnf

$ cat /etc/issue
Ubuntu 14.04.1 LTS \n \l

root@glimmer:~# aptitude show percona-server-server-5.5
Package: percona-server-server-5.5
(...)
Version: 5.5.39-rel36.0-697.trusty

Tobias Brox (c-tobias)
description: updated
Changed in percona-server:
assignee: nobody → Muhammad Irfan (muhammad-irfan)
Revision history for this message
Muhammad Irfan (muhammad-irfan) wrote :

I am able to verify with latest Percona Server 5.5 version.

root@testnode:/etc/mysql# lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty

mysql> show global variables like '%version%';
+-------------------------+--------------------------------------------------+
| Variable_name | Value |
+-------------------------+--------------------------------------------------+
| innodb_version | 5.5.40-36.1 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.40-36.1 |
| version_comment | Percona Server (GPL), Release 36.1, Revision 707 |
| version_compile_machine | x86_64 |
| version_compile_os | debian-linux-gnu |
+-------------------------+--------------------------------------------------+

root@testnode:~# mysqladmin --user=root --password=xxxx ping
mysqld is alive
 root@testnode:~# echo $?
0

Exit status is zero which is correct, but below when i used the wrong credentials exit status is still zero instead of non-zero.

root@testnode:~# mysqladmin --user=foo --password=bar ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'foo'@'localhost' (using password: YES)'
 root@testnode:~# echo $?
0

Changed in percona-server:
status: New → Confirmed
Changed in percona-server:
assignee: Muhammad Irfan (muhammad-irfan) → nobody
Revision history for this message
Alexey Kopytov (akopytov) wrote :

I don't understand what exactly is the problem in this report. "mysqladmin ping" works by description:

"Check whether the server is available. The return status from mysqladmin is 0 if the server is running, 1 if it is not. This is 0 even in case of an error such as Access denied, because this means that the server is running but refused the connection, which is different from the server not running. "

http://dev.mysql.com/doc/refman/5.6/en/mysqladmin.html

There may be a problem in the init script, but I don't see it. If there's a wrong password in the configuration file, but the server itself is up, it will report no errors, because the server is running. If the specified configuration file is missing, it will report an error. Which looks correct to me.

Revision history for this message
Valerii Kravchuk (valerii-kravchuk) wrote :

Tobias,

This part is OK (not a bug), mysqladmin works as documented: "This means mysql is always regarded as running if the password in /etc/mysql/debian.cnf is wrong". It's so because if server says "access denied" it means there is a running server to say so.

As for this part: "but always regarded as being down if the password in /etc/mysql/debian.cnf", it seems your sentence is not complete. Do you mean there is problem if /etc/mysql/debian.cnf just does not exist or is nor readable by the user that runs MySQL server? Please, clarify.

Revision history for this message
Tobias Brox (c-tobias) wrote : Re: [Bug 1379223] Re: inconsistent mysqladmin return value, debian init-script dependency

> As for this part: "but always regarded as being down if the password in
> /etc/mysql/debian.cnf", it seems your sentence is not complete. Do you
> mean there is problem if /etc/mysql/debian.cnf just does not exist or is
> nor readable by the user that runs MySQL server? Please, clarify.

Correct, sorry for that.

--
Tobias Brox
Senior System Consultant
Redpill Linpro AS - Changing the game
Mobil: +47 917 000 50
Kontor: +47 215 441 68

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Percona Server 5.7 because there has been no activity for 60 days.]

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Percona Server 5.5 because there has been no activity for 60 days.]

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for Percona Server 5.6 because there has been no activity for 60 days.]

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/PS-3186

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.