Bug #42220 Agent fails to identify local socket as local on MacOSX 10.4
Submitted: 20 Jan 2009 16:32 Modified: 6 Mar 2009 16:36
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Agent Severity:S3 (Non-critical)
Version:2.0.2.7133 OS:MacOS (10.4)
Assigned to: MC Brown CPU Architecture:Any
Tags: mem_20_maint

[20 Jan 2009 16:32] Domas Mituzas
Description:
If agent is configured to use a unix domain socket on MacOSX 10.4, it does not treat connection as local - and fails to provide CPU/memory information to MEM:

2009-01-20 18:15:02: (message) network-socket.c:752: is-local family 0 != 1
2009-01-20 18:15:02: (message) agent_mysqld.c:322: [mysql] mysqld is not local or not directly connected

This does not happen on MacOSX 10.5

How to repeat:
run agent with socket:

[mysqld]
user = root
password = root
socket = /tmp/test.sock

Suggested fix:
treat unix domain sockets as local connections
[21 Jan 2009 12:13] Mark Leith
GDB output looking at agent_mysqld_is_local / network_address_is_local

Attachment: bug42220_gdb.txt (text/plain), 9.69 KiB.

[21 Jan 2009 17:36] Mark Leith
Test case output:

Medusa:~/Desktop mark$ gcc -Wall -O2 unix-getsockname.c -o unix-getsocketname && ./unix-getsocketname
our family: 0
their family: 1
[21 Jan 2009 17:36] Mark Leith
test case

Attachment: unix-getsockname.c (, text), 1.82 KiB.

[28 Jan 2009 20:16] Mark Leith
In the case where we are connecting with a socket connection, there really is no reason to go down this track anyway - can we not always assume we are local when we are connecting file a socket file *first*?
[2 Mar 2009 22:33] Jan Kneschke
Patch and test-case have been committed to trunk.

revno: 1208
committer: jan@mysql.com
branch nick: trunk
timestamp: Mon 2009-03-02 23:03:25 +0100
message:
  fixed network_socket_is_local() for unix-sockets on MacOSX 10.4 (fixes #42220)
[2 Mar 2009 22:53] Jan Kneschke
Committed and pushed to rel-2.0 (and trunk):

revno: 1222
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:50:55 +0100
message:
   fixed network_socket_connect() to return NETWORK_SOCKET_* as the prototype defines
------------------------------------------------------------
revno: 1221
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:50:38 +0100
message:
  check that we don't delete a normal file
------------------------------------------------------------
revno: 1220
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:50:20 +0100
message:
  cleanup socket after we finished the test
------------------------------------------------------------
revno: 1219
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:49:51 +0100
message:
  added proper checks 
------------------------------------------------------------
revno: 1218
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:49:37 +0100
message:
  fixed network_socket_is_local() for unix-sockets on MacOSX 10.4 (fixes #42220)
------------------------------------------------------------
revno: 1217
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:49:02 +0100
message:
  unlink() unix-sockets before we bind() to them if no one else is bound to it
------------------------------------------------------------
revno: 1216
committer: jan@mysql.com
branch nick: rel-2.0
timestamp: Mon 2009-03-02 23:48:15 +0100
message:
  moved accept() code down to network_socket_accept() to make the code testable
[5 Mar 2009 16:15] Diego Medina
Verified fixed on 2.0.5.7150

On the agent logs we see

(critical) agent_mysqld.c:643: successfully connected to database at /Users/mysqldev/dv1/data/mysql.sock as user root (with password: YES)
(message) agent_mysqld.c:320: [dv1] mysqld is local and directly connected
[6 Mar 2009 16:36] Tony Bedford
An entry was added to the 2.0.5 changelog:

The Agent failed to identify local sockets as local on Mac OS X 10.4.

If the Agent was configured to use a Unix domain socket on Mac OS X 10.4, it did not treat the connection as local and failed to provide CPU and memory information to MySQL Enterprise Monitor. This is shown in the log file:

2009-01-20 18:15:02: (message) network-socket.c:752: is-local family 0 != 1
2009-01-20 18:15:02: (message) agent_mysqld.c:322: [mysql] mysqld is not local or not
directly connected

However, this problem did not happen on Mac OS X 10.5.