Bug #50824 Agent is accepting connections before QUAN configuration is known
Submitted: 2 Feb 2010 10:32 Modified: 12 Mar 2010 16:24
Reporter: Andrii Nikitin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Agent Severity:S2 (Serious)
Version:2.1.1.1141 OS:Any
Assigned to: Kay Roepke CPU Architecture:Any

[2 Feb 2010 10:32] Andrii Nikitin
Description:
Proxy starts processing incoming connections before QUAN configuration is fetched from dashboard.

I.e. if proxy is being queried immediately after startup, many following errors may be logged:

(critical) (share/mysql-proxy/quan.lua:775) [proxy] please add SELECT permissions for this user on mysql.inventory to enable the QUAN feature

How to repeat:
1. setup loop which continuously accesses Proxy, e.g. 
bash> while ((1)) ; do mysql -h127.0.0.1 -P6446 -utest -p1 -e "select * from test.t";  done

note that user should have no permissions to access mysql.inventory

2. check that loop is working properly and no errors shown in agent log

3. restart agent

4. check log, a lot of errors logged: 
(critical) (share/mysql-proxy/quan.lua:775) [proxy] please add SELECT permissions for this user on mysql.inventory to enable the QUAN feature

Suggested fix:
Add option which postpones processing incoming connections until Proxy succeeds to fetch QUAN configuration
[2 Feb 2010 17:47] Enterprise Tools JIRA Robot
Kay Roepke writes: 
I do not think we should block queries coming through the proxy at that point.
It would render the application's database connection useless and cause way more problems than the log file does.

A viable fix would be to suppress the log message (or log it just once, or come up with some other way of limiting this message).
[2 Feb 2010 18:08] Andrii Nikitin
Kay,

The problem is that queries are processed before QUAN config is fetched, so agent doesn't know if it should collect QUAN statistics.

It may be a big surprise (with stable connection to dashboard) that not all queries executed via proxy appear in QUAN.

Or we should at least document something like:
"Even if stable connection from agent to dashboard there is a chance that not all queries (executed by proxy) will appear in QUAN (e.g. those which are processed immediately after Proxy startup before QUAN configuration fetched from MEM dashboard)".

Or if you prefer I can change bug description to "Not all queries appear in QUAN" and create corresponding testcase.

Imho Proxy should accept connections only when it knows how to collect QUAN statistics or at least we should have configuration parameter for that.
[2 Feb 2010 19:11] Simon Mudd
My point on this is that the error message "please add SELECT permissions for
this user on mysql.inventory to enable the QUAN feature" is misleading.

What it really should be saying is: "Not yet connected to dashboard, so unable to determine whether to enable the QUAN feature. Feature temporarily disabled."

If you don't connect to the dashboard you many never connect to it so losing QUAN data is not really a problem. Had the dashboard been working before and if the agent had connected to it, then it would know what it had to do.
[4 Feb 2010 9:47] Enterprise Tools JIRA Robot
Kay Roepke writes: 
I agree that in this case the error message is misleading. Unfortunately we haven't distinguished between the startup case and the case when the inventory table couldn't be read (or was empty or something).
[12 Feb 2010 19:44] Enterprise Tools JIRA Robot
Gary Whizin writes: 
Per Kay's suggestions, let's fix error messages now (one should say "you're slightly mis-configured" and the other "I can't read mysql inventory") and address the other  post 2.2.0 release
[17 Feb 2010 13:58] Enterprise Tools JIRA Robot
Kay Roepke writes: 
Well, it turns out that I forgot about the security "features" of SQL.
Both 'table does not exist' and 'no privileges for the table' are the same error code, as mandated by the SQL standard.
I will therefore change the error message slightly, to reflect this, but won't do any special "compression" on the frequency of the error, i.e. it will still get printed for each connection to the proxy until this situation is rectified.
[25 Feb 2010 19:47] Enterprise Tools JIRA Robot
Andy Bang writes: 
Available in build 2.2.0.1631.
[12 Mar 2010 16:24] Enterprise Tools JIRA Robot
Diego Medina writes: 
Verified fixed on 2.2.0.1631

We now see

{noformat}
(lib/mysql-monitor-agent/lua/quan.lua:815) [proxy] please add SELECT permissions for this user on mysql.inventory to enable the QUAN feature or check that the agent has properly set up the mysql.inventory table during first discovery, got SELECT command denied to user 'testuser'@'localhost' for table 'inventory'. QUAN will not work until this problem is solved.
{noformat}