Bug #58874 generic error given with failed queries
Submitted: 10 Dec 2010 18:22 Modified: 23 Aug 2011 10:36
Reporter: Lig Isler-Turmelle Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Agent Severity:S4 (Feature request)
Version:all OS:Any
Assigned to: Mark Leith CPU Architecture:Any

[10 Dec 2010 18:22] Lig Isler-Turmelle
Description:
getting the error message:

(critical) agent_mysqld.c:512: [unix:/mysql/mysql/mysql.sock] mysql_real_query("SELECT value FROM mysql.inventory WHERE name = 'uuid'") failed: Lost connection to MySQL server during query (errno=2013)
Please GRANT SELECT ON mysql.inventory TO 'mysql_monitor'@'%';

Even with the correct permissions for the user.

When speaking with Oldag got this reply:

Dec 09 12:24:48 <oldag>	it doesn't look like we actually check for a permission error
Dec 09 12:24:53 <oldag>	and that is just a blanket message
Dec 09 12:24:58 <oldag>	2013 is anyone's guess
Dec 09 12:25:47 <oldag>	all we check is 
Dec 09 12:25:50 <oldag>		if (!(query_succeeded = agent_mysqld_query_raw(m, C(SELECT_UUID), 0))) {
Dec 09 12:26:09 <oldag>	then, 1146, table does not exist (we create it)
Dec 09 12:26:16 <oldag>	otherwise, generic permissions error message
Dec 09 12:26:19 <oldag>	even though here it was 2013
Dec 09 12:26:23 <oldag>	which is out of my league
Dec 09 12:26:46 <oldag>	so, the log message is lame.  you could write up a bug on that
Dec 09 12:26:57 <oldag>	"only suggest permission error if it is ding ding!  a permission error!"

So here I am asking for some better error messages when the query fails.

How to repeat:
na

Suggested fix:
for debugging purposes the more detailed the error message you can give the better.
[13 Dec 2010 8:10] Andrii Nikitin
The real problem is not just misleading message, but the fact that agent justcompletely shuts down (receiving 2013).

So, no further monitoring possible until manual restart if following occurs, e.g. when connection to monitored sever is not stable for some period of time:

1. Agent connection established to monitored mysql
2. But immediately got timeout querying mysql.inventory 
->
3. Agent will shutdown

2010-12-11 17:52:02: (critical) agent_mysqld.c:723: successfully connected to database at myhost.com:3308 as user myuser (with password: YES)
2010-12-11 17:52:32: (critical) agent_mysqld.c:512: [myhost.com:3308] mysql_real_query("SELECT value FROM mysql.inventory WHERE name = 'uuid'") failed: Lost connection to MySQL server during query (errno=2013)
Please GRANT SELECT ON mysql.inventory TO 'myuser'@'%';
This necessary for correct execution of the agent. 
Shutting down now.
[13 Dec 2010 13:02] Enterprise Tools JIRA Robot
Mark Leith writes: 
Patch pushed to 2.3.2:

1993 Mark Leith	2010-12-13
     Bug#58874 / EM-5093 - agent may shutdown after error 2013
     - Split out the error message as requested

Note that this does not implement retry logic in this case, if that is required, please open a separate issue for this.
[11 Jan 2011 16:48] Enterprise Tools JIRA Robot
Andy Bang writes: 
Fix is in build 2.3.2.2050.
[22 Apr 2011 22:56] Marcos Palacios
Verified fixed on 2.3.2.2053

You now see on the agent log:

(critical) agent_mysqld.c:712: [127.0.0.1:5132] agent connecting to mysql-server failed: mysql_real_connect(host = '127.0.0.1', port = 5132, socket = ''): Lost connection to MySQL server at 'reading initial communication packet', system error: 54 (mysql-errno = 2013)
(critical) proxy-plugin.c.1612: Cannot connect, all backends are down.
[23 Aug 2011 10:36] Stefan Hinz
Added to 2.3.2 changelog:

The Agent could die with a vague error message when encountering a
SQL error code 2013, requiring a manual restart.
The message is now more specific.
[23 Aug 2011 10:36] Stefan Hinz
Thank you for your bug report. This issue has already been fixed in the latest released version of that product, which you can download at

  http://www.mysql.com/downloads/