Bug #68763 ReplicationConnection.isMasterConnection() returns false always
Submitted: 25 Mar 2013 15:59 Modified: 11 Apr 2013 19:31
Reporter: Todd Farmer (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.24 OS:Any
Assigned to: Todd Farmer CPU Architecture:Any

[25 Mar 2013 15:59] Todd Farmer
Description:
ReplicationConnection.isMasterConnection() delegates to the currently-active connection:

    public boolean isMasterConnection() {
        return getCurrentConnection().isMasterConnection();
    } 

This always returns false; all code that returns true is handled at higher levels (e.g., in failover connections).  This code in ReplicationDriver stands in contrast to isReadOnly(), which checks whether the current connection is a slave connection:

    public synchronized boolean isReadOnly() throws SQLException {
        return this.currentConnection == this.slavesConnection;
    } 

How to repeat:
1.  Create a replication connection ("jdbc:mysql:replication://" JDBC URL prefix)
2.  Check return value of isMasterConnection().

Suggested fix:
Implement logic similar to ReplicationConnection.isReadOnly, such that true is returned if the current connection is the master connection.
[26 Mar 2013 14:53] Todd Farmer
Fixed in r1222.
[11 Apr 2013 19:31] Bugs System
Added changelog entry for 5.1.25:
"ReplicationConnection.isMasterConnection()", which is intended to check
if the current connection is the master connection, would always return
"false". This fix implements logic that returns "true" if the current
connection is the master connection."