Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public void establishConnection(final LimitlessConnectionContext context) throws
try {
context.setConnection(context.getConnectFunc().call());
} catch (final SQLException e) {
if (this.isLoginException(e)) {
throw e;
}
retryConnectWithLeastLoadedRouters(context);
}
}
Expand All @@ -150,6 +153,9 @@ public void establishConnection(final LimitlessConnectionContext context) throws
"LimitlessRouterServiceImpl.selectedHost",
new Object[] {selectedHostSpec != null ? selectedHostSpec.getHost() : "null"}));
} catch (SQLException e) {
if (this.isLoginException(e)) {
throw e;
}
retryConnectWithLeastLoadedRouters(context);
return;
}
Expand All @@ -162,6 +168,9 @@ public void establishConnection(final LimitlessConnectionContext context) throws
try {
context.setConnection(this.pluginService.connect(selectedHostSpec, context.getProps(), context.getPlugin()));
} catch (SQLException e) {
if (this.isLoginException(e)) {
throw e;
}
if (selectedHostSpec != null) {
LOGGER.fine(Messages.get(
"LimitlessRouterServiceImpl.failedToConnectToHost",
Expand Down Expand Up @@ -205,7 +214,12 @@ private void retryConnectWithLeastLoadedRouters(
context.setConnection(context.getConnectFunc().call());
return;
} catch (final SQLException e) {
throw new SQLException(Messages.get("LimitlessRouterServiceImpl.noRoutersAvailable"));
if (this.isLoginException(e)) {
throw e;
}
throw new SQLException(Messages.get(
"LimitlessRouterServiceImpl.unableToConnectNoRoutersAvailable",
new Object[] {context.getHostSpec().getHost()}), e);
}
}
}
Expand Down Expand Up @@ -236,6 +250,9 @@ private void retryConnectWithLeastLoadedRouters(
return;
}
} catch (final SQLException e) {
if (this.isLoginException(e)) {
throw e;
}
selectedHostSpec.setAvailability(HostAvailability.NOT_AVAILABLE);
LOGGER.finest(Messages.get(
"LimitlessRouterServiceImpl.failedToConnectToHost",
Expand All @@ -259,6 +276,9 @@ protected void synchronouslyGetLimitlessRoutersWithRetry(final LimitlessConnecti
}
Thread.sleep(retryIntervalMs);
} catch (final SQLException e) {
if (this.isLoginException(e)) {
throw e;
}
LOGGER.finest(Messages.get("LimitlessRouterServiceImpl.getLimitlessRoutersException", new Object[] {e}));
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
Expand Down Expand Up @@ -309,6 +329,10 @@ protected void synchronouslyGetLimitlessRouters(final LimitlessConnectionContext
}
}

protected boolean isLoginException(Throwable throwable) {
return this.pluginService.isLoginException(throwable, this.pluginService.getTargetDriverDialect());
}

@Override
public void startMonitoring(final @NonNull HostSpec hostSpec,
final @NonNull Properties props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.checkerframework.checker.nullness.qual.NonNull;
import software.amazon.jdbc.AwsWrapperProperty;
import software.amazon.jdbc.ConnectionProviderManager;
import software.amazon.jdbc.HostListProviderService;
import software.amazon.jdbc.HostRole;
import software.amazon.jdbc.HostSpec;
import software.amazon.jdbc.JdbcCallable;
import software.amazon.jdbc.NodeChangeOptions;
import software.amazon.jdbc.OldConnectionSuggestedAction;
import software.amazon.jdbc.PluginService;
import software.amazon.jdbc.PooledConnectionProvider;
import software.amazon.jdbc.PropertyDefinition;
import software.amazon.jdbc.cleanup.CanReleaseResources;
import software.amazon.jdbc.plugin.AbstractConnectionPlugin;
Expand Down Expand Up @@ -484,11 +483,14 @@ private void getNewReaderConnection() throws SQLException {
readerHost = hostSpec;
break;
} catch (final SQLException e) {
LOGGER.warning(
() -> Messages.get(
"ReadWriteSplittingPlugin.failedToConnectToReader",
new Object[] {
hostSpec.getUrl()}));
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING,
Messages.get(
"ReadWriteSplittingPlugin.failedToConnectToReader",
new Object[]{
hostSpec.getUrl()}),
e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ LimitlessRouterServiceImpl.getLimitlessRoutersException=Exception encountered ge
LimitlessRouterServiceImpl.incorrectConfiguration=Limitless Connection Plugin is unable to run. Please ensure the connection settings are correct.
LimitlessRouterServiceImpl.interruptedSynchronousGetRouter=Limitless Router Service thread was interrupted while waiting to fetch Limitless Transaction Routers.
LimitlessRouterServiceImpl.limitlessRouterCacheEmpty=Limitless Router cache is empty. This normal during application start up when the cache is not yet populated.
LimitlessRouterServiceImpl.maxRetriesExceeded=Max number of connection retries has been exceeded.
LimitlessRouterServiceImpl.noRoutersAvailable=No transaction routers available.
LimitlessRouterServiceImpl.maxRetriesExceeded=Max number of connection retries has been exceeded. Unable to connect to any transaction router.
LimitlessRouterServiceImpl.noRoutersAvailable=Unable to connect to any transaction router.
LimitlessRouterServiceImpl.noRoutersAvailableForRetry=No transaction routers available for connection retry. Retrying with original connection.
LimitlessRouterServiceImpl.unableToConnectNoRoutersAvailable=Unable to connect to original host {0}. All transaction routers are unavailable. Please verify connection credentials and network connectivity.
LimitlessRouterServiceImpl.selectedHost=Host {0} has been selected.
LimitlessRouterServiceImpl.selectedHostForRetry=Host {0} has been selected for connection retry.
LimitlessRouterServiceImpl.synchronouslyGetLimitlessRouters=Fetching Limitless Routers synchronously.
Expand Down
Loading