Bug #68733 ReplicationConnection doesn't ping all slaves
Submitted: 20 Mar 2013 21:35 Modified: 11 Apr 2013 19:53
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.24 OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[20 Mar 2013 21:35] Todd Farmer
Description:
When using Connector/J in a replication deployment (URL prefix "jdbc:mysql:replication://"), the slave connections are not all pinged by the special syntax (queries starting with "/* ping */" exactly) as they are with load-balanced connections (which is the infrastructure handling slave connections under the hood).

How to repeat:
1. Open a connection for multiple slaves with replication.
2. Ensure connections are opened to all slaves.
3. Issue a ping via Connector/J, observe that the inactive slave was not pinged.

Suggested fix:
Ping all active physical connections to slaves.  Throw CommunicationException only if:

1.  The master connection ping fails, and the connection is currently set to use the master connection (via Connection.setReadOnly(false)).
2.  The Connection object is set to use the master (via Connection.setReadOnly(true)), and the currently-selected slave connection ping fails.
[26 Mar 2013 14:49] Todd Farmer
Fix pushed in r1222.
[11 Apr 2013 19:53] Bugs System
Added changelog entry for 5.1.25:

When using Connector/J in a replication deployment, all of the slave
connections would not be pinged. This fix ensures that all active physical
connections to slaves are pinged, and that communication exceptions are
thrown if: 

The master connection ping fails, and the connection is
currently set to use the master connection via
"Connection.setReadOnly(false)."

The Connection object is set to use the
master via "Connection.setReadOnly(true)", and the currently-selected
slave connection ping fails.