JDBC Connection.valid() implementation execute a COM_PING, indicating that socket is OK.
When connecting a Galera server in non-primary state:
- Connection can be established
- Connection.valid() will validate that socket is ok, with a COM_PING.
When a master become non-primary, a SQLException will be thrown for any INSERT or SELECT (if variable wsrep_dirty_reads is false), problem is all other connection is pool are still considered valid until having these kind of query.
Goal is to permit that pool discard those connection with the standard JDBC Connection.valid() verification, and avoid connect to non primary server when driver is configured with multi-master configuration.
When driver use multi-master configuration, when establishing the connection, or validating the connection, driver must ensure that if wsrep_cluster_status variable exists, it's set to PRIMARY
When this occur, server must be blacklisted (Driver will try to reconnect only if no other master are found, or after a certain amount of time).