Skip to content

Commit

Permalink
Fix incorrect setting of failed-host-reconnect-delay-secs
Browse files Browse the repository at this point in the history
  • Loading branch information
ashetkar committed Jul 15, 2024
1 parent 03926ad commit 1054410
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ public String processURLAndProperties() {
DEFAULT_REFRESH_INTERVAL, MAX_REFRESH_INTERVAL);
}
if (originalProperties.containsKey(EXPLICIT_FALLBACK_ONLY_KEY)) {
failedHostReconnectDelaySpecified = true;
String propValue = originalProperties.getProperty(EXPLICIT_FALLBACK_ONLY_KEY);
if (propValue.equalsIgnoreCase("true")) {
explicitFallbackOnly = true;
}
}
if (originalProperties.containsKey(FAILED_HOST_RECONNECT_DELAY_SECS_KEY)) {
failedHostReconnectDelaySpecified = true;
failedHostReconnectDelaySecs =
parseAndGetValue(originalProperties.getProperty(FAILED_HOST_RECONNECT_DELAY_SECS_KEY),
DEFAULT_FAILED_HOST_TTL_SECONDS, MAX_FAILED_HOST_RECONNECT_DELAY_SECS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class LoadBalanceService {

private static ConcurrentHashMap<String, NodeInfo> clusterInfoMap = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<String, NodeInfo> clusterInfoMap = new ConcurrentHashMap<>();
private static Connection controlConnection = null;
protected static final String GET_SERVERS_QUERY = "select * from yb_servers()";
protected static final Logger LOGGER = Logger.getLogger("org.postgresql." + LoadBalanceService.class.getName());
Expand Down Expand Up @@ -109,10 +109,10 @@ private static synchronized boolean refresh(Connection conn, long refreshInterva
long failedHostTTL = Long.getLong(FAILED_HOST_RECONNECT_DELAY_SECS_KEY, DEFAULT_FAILED_HOST_TTL_SECONDS);
if (nodeInfo.isDown) {
if (System.currentTimeMillis() - nodeInfo.isDownSince > (failedHostTTL * 1000)) {
LOGGER.fine("Marking " + nodeInfo.host + " as UP since failed-host-reconnect-delay-secs has elapsed");
LOGGER.fine("Marking " + nodeInfo.host + " as UP since failed-host-reconnect-delay-secs (" + failedHostTTL + "s) has elapsed");
nodeInfo.isDown = false;
} else {
LOGGER.fine("Keeping " + nodeInfo.host + " as DOWN since failed-host-reconnect-delay-secs has not elapsed");
LOGGER.fine("Keeping " + nodeInfo.host + " as DOWN since failed-host-reconnect-delay-secs (" + failedHostTTL + "s) has not elapsed");
}
}
}
Expand Down

0 comments on commit 1054410

Please sign in to comment.