Bug #76874 Mysql fabric JDBC driver doens't update master server on fail
Submitted: 28 Apr 2015 15:23 Modified: 11 May 2015 16:33
Reporter: Davide Malagoli Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:5.1.35 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: fabric

[28 Apr 2015 15:23] Davide Malagoli
Description:
I've 2 mysql nodes (one primary and one secondary) and a simple java program that every 3 seconds try to make an insert and select on the database.

Has soon as i promote a new server to master the java starts getting errors cause is always connecting to the old server (now slave).

The strange is that:
- a lot of request are sent to fabric server (with tcpdump I've seen that both request and response are correct)
- when I restart the java it correctly connects to the new master

How to repeat:
sample java program:

FabricMySQLConnection    rawConnection = (FabricMySQLConnection)DriverManager.getConnection(baseUrl + database + "?fabricServerGroup=test&fabricReportErrors=true", user, password);

while(true) {

try{
	Statement statement  = rawConnection.createStatement();
        statement.executeUpdate("insert into test values ('1'');");
        statement.close();
}
catch (SQLException sql) {
	System.out.println("sql ex" + sql.getSQLState());
	rawConnection.clearServerSelectionCriteria();
	 rawConnection = (FabricMySQLConnection)DriverManager.getConnection(baseUrl + database + "?fabricServerGroup=testgroup3", user, password);
}

catch(Exception ex) {
	System.out.println(ex.toString());
 }

       PreparedStatement  ps = rawConnection.prepareStatement("select @@hostname;");
           ResultSet rs = ps.executeQuery();
            rs.next();
            System.out.println( rs.getString(1));
            rs.close();
ps.close();

 Thread.sleep(2000);

    }
[5 May 2015 10:37] Paulo Jesus
Thank you for your bug report.

Can you please indicate what is the version of MySQL Connector/J that you are using?

Note: If you are not using the most recent one, please try it to confirm if you still observe the problem.
[5 May 2015 10:42] Davide Malagoli
Tested both with latest (5.1.35) and 5.1.34.
Same problem
[11 May 2015 16:33] Jess Balint
This is a duplicate of Bug#75113. It is in the process of being fixed. Please track progress there.