Bug #93007 LoadBalancedConnectionProxy.getGlobalBlacklist bug
Submitted: 30 Oct 2018 10:41 Modified: 8 Apr 2019 19:25
Reporter: Konstantin Pavelko Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8, 8.0.13 OS:Any
Assigned to: CPU Architecture:Any
Tags: LoadBalancedConnectionProxy

[30 Oct 2018 10:41] Konstantin Pavelko
Description:
LoadBalancedConnectionProxy.getGlobalBlacklist incorrectly used hostsList->getHost, but globalBlacklist consists of host:port strings. As result getGlobalBlacklist always returns empty map

How to repeat:
Specify not alive host in the hosts list:
jdbc:mysql:loadbalance://bad_host:3306,good_host:3306/
Load Balance Strategy will always try to connect to the bad_host, it is never blacklisted.

Suggested fix:
src/main/user-impl/java/com/mysql/cj/jdbc/ha/LoadBalancedConnectionProxy.java
@@ -728,7 +728,7 @@
         Set<String> keys = blacklistClone.keySet();
 
         // We're only interested in blacklisted hosts that are in the hostList
-        keys.retainAll(this.hostsList.stream().map(hi -> hi.getHost()).collect(Collectors.toList()));
+        keys.retainAll(this.hostsList.stream().map(hi -> hi.getHostPortPair()).collect(Collectors.toList()));
 
         // Don't need to synchronize here as we using a local copy
         for (Iterator<String> i = keys.iterator(); i.hasNext();) {
[30 Oct 2018 11:28] MySQL Verification Team
Hello Konstantin,

Thank you for the report and feedback.
Verifying based on my internal discussion with Alex(C/J Dev).

regards,
Umesh
[8 Apr 2019 19:25] Daniel So
Posted by developer:
 
Added the following entry to the Connector/J 8.0.16 changelog:

"The method LoadBalancedConnectionProxy.getGlobalBlacklist() always returned an empty map, thus there was never a blacklist for load-balabced connections."