Details
- 
    
Bug
 - 
    Status: Closed (View Workflow)
 - 
    
Minor
 - 
    Resolution: Fixed
 - 
    None
 - 
    None
 - 
    MariaDB 10.1, Connector/J 1.3.2
 
Description
I'm trying to use failover option for Galera Cluster.
URL is like this:
					jdbc:mysql:failover://192.168.33.11,192.168.33.12,192.168.33.13/test?autoReconnect=true
			 | 
		
And when failover occurred in a transaction with connection to 192.168.33.13, the driver threw an exception with this message:
					Communications link failure with primary host 192.168.33.11:3306. unexpected end of stream, read 0 bytes from 4.  Driver as successfully reconnect connection
			 | 
		
But "192.168.33.11" is not the host which caused "communications link failure".
It should be "Communications link failure with primary host 192.168.33.13:3306".
"192.168.33.11" is the new, active master host.
(I have checked it with query log.)
I think the cause of this problem is in FailoverProxy#handleFailover().
The message above is created in listener.throwFailoverMessage(),
and in throwFailoverMessage(), the failed host address is retrieved from currentProtocol.getHostAddress().
However, currentProtocol is already updated in listener.handleFailover().
					  FailoverProxy#handleFailOver()
			 | 
		
					  -> AbstractMastersListener#handleFailover()
			 | 
		
					  -> MastersFailoverListener#primaryFail()
			 | 
		
					  -> MastersFailoverListener#reconnectFailedConnection()
			 | 
		
					  -> MasterProtocol#loop()
			 | 
		
					  -> MastersFailoverListener#foundActiveMaster()
			 | 
		
I found this problem with multi master (MastersFailoverListener),
but it might happen with master/slave replication (MastersSlavesListener)
because it has very similar implementation.