ConnectorJ doesn't switch to new master (MySQL Fabric)
Posted by: Francois Brun
Date: February 24, 2016 02:02AM

We've got a problem with the java fabric connector...

When the fabric node switches to a new master (failover), the java connector
does not switch to the new master...

Only when we restart the client application, does the connection work again.

Can someone tell us what we are doing wrong !!!

Here is a simple example of the test which works great until the fabric node switches
to a new master (mysql connector v5.1.38)
-------------------------------------------
public class MySQLConnectorJDebug {
public static void main(String args[]) {
try {
String jdbc = "jdbc:mysql:fabric://192.168.0.39:32274/database_schema";
Properties info = new Properties();
info.put("user", "demo");
info.put("password", "demo");
info.put("autoReconnect", "true");
info.put("fabricServerGroup", "test");
info.put("fabricReportErrors", "true");
info.put("logger", "com.mysql.jdbc.log.StandardLogger");
// info.put("useUsageAdvisor", "true");
// info.put("profileSQL", "true");
// info.put("allowMasterDownConnections", "true");
Driver d = (Driver) Class.forName("com.mysql.fabric.jdbc.FabricMySQLDriver").newInstance();
while (true) {
try {
//--- After the fabric switches to a new master, this call throws a null pointer exception
Connection db = d.connect(jdbc, info);

Statement stmt = db.createStatement();
System.out.println("(M) Jdbc access granted");
String SQL = "SELECT COUNT(ID) AS cnt FROM events_table";
ResultSet rs = stmt.executeQuery(SQL);
if (rs.next()) System.out.println("(I) Events count is " + rs.getString("cnt"));
rs.close();
db.close();

} catch (Exception ex) {
ex.printStackTrace();

}
Thread.sleep(1000);

}

} catch (Exception ex) {
ex.printStackTrace();
}
}

}

A strange exception is raised after the fabric node promotes a new master
-------------------------------------------------------------------------
java.sql.SQLException: java.lang.NullPointerException
at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:80)
at debug.jdbc.MySQLConnectorJDebug.main(MySQLConnectorJDebug.java:52)
Caused by: java.sql.SQLException: java.lang.NullPointerException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:422)
at com.mysql.fabric.jdbc.FabricMySQLDriver.connect(FabricMySQLDriver.java:78)
... 1 more
Caused by: java.lang.NullPointerException
at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.syncGroupServersToReplicationConnectionGroup(FabricMySQLConnectionProxy.java:525)
at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.setCurrentServerGroup(FabricMySQLConnectionProxy.java:455)
at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.setServerGroupName(FabricMySQLConnectionProxy.java:359)
at com.mysql.fabric.jdbc.FabricMySQLConnectionProxy.<init>(FabricMySQLConnectionProxy.java:196)
at com.mysql.fabric.jdbc.JDBC4FabricMySQLConnectionProxy.<init>(JDBC4FabricMySQLConnectionProxy.java:91)
at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)

Options: ReplyQuote


Subject
Written By
Posted
ConnectorJ doesn't switch to new master (MySQL Fabric)
February 24, 2016 02:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.