Description:
The retriesAllDown parameter isn't documented (and isn't part of ConnectionPropertiesImpl.java). The release notes aren't specific on the intended behavior:
We solve this problem with a black list that is used during the picking of new hosts. If the black list ends up including all configured hosts, the driver will retry for a configurable number of times (the retriesAllDown configuration property, with a default of 120 times), sleeping 250ms between attempts to pick a new connection.
The way this is implemented in both Random and BestResponse starts compares the number of connections attempted against retriesAllDown. If retriesAllDown is less than the number of servers in the server list, it could exhaust the number of attempts against unavailable servers, never attempting to check available servers.
How to repeat:
Start one server on localhost:3310, then repeatedly run:
Class.forName ("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection ( "jdbc:mysql:loadbalance://localhost:3310,localhost:3311/test?retriesAllDown=1", "root", null);
Suggested fix:
1. Add retriesAllDown to ConnectionPropertiesImpl.java
2. Redefine and reimplement retriesAllDown to control the number of times C/J will cycle through the *full* list of servers.
Changes:
for (int attempts = 0; attempts < numRetries; attempts++) {
...
becomes:
for (int attempts = 0; attempts < numRetries;) {
...
and the cases where no available servers are found should increment attempts instead:
if (blackList.size() == configuredHosts.size()) {
attempts++
...
and
if (whiteList.size() == 0) {
attempts++
...
in BestResponseTimeBalanceStrategy and RandomBalanceStrategy, respectively.