Replies: 3 comments
-
Note, in this recent discussion: #506, felixdo had the same error message output. |
Beta Was this translation helpful? Give feedback.
-
Oh, I think I see why now. The target Datasource isn't created until the actual getConnection call is made to the AWSWrapperDataSource; therefore no underlying datasource exists to set the loginTimeout on until it's effectively too late to configure. Perhaps this should be stored in a variable, and when getConnection is called (and subsequently when createTargetDataSource is called) any value that was set here before that getConnection call is made can be attempted to be applied to the underlying datasource before the connection wrapper is made? |
Beta Was this translation helpful? Give feedback.
-
I created a quick extension of the AWSWrapper in my code that supports a LoginTimeout using the code below. It works with Hikari; it's a bit gross... but does accomplish the goal. Top of class... (could be a bool + int instead of optional) protected Optional<Integer> loginTimeout; This code starting here: https://github.com/awslabs/aws-advanced-jdbc-wrapper/blob/9fe0cedce2e284618eec2b029213f0dd807ca40c/wrapper/src/main/java/software/amazon/jdbc/ds/AwsWrapperDataSource.java#L155 final DataSource targetDataSource = createTargetDataSource();
if (loginTimeout.isPresent()) {
try {
targetDataSource.setLoginTimeout(loginTimeout.get());
} catch (Exception e) {
//Ignore since this is best effort to set in the underlying dataSource.
}
} set & getLoginTimeout functions are changed to this: @Override
public void setLoginTimeout(final int seconds) {
loginTimeout = Optional.of(seconds);
}
@Override
public int getLoginTimeout() throws SQLException {
if (loginTimeout.isPresent()) {
return loginTimeout.get();
}
throw new SQLFeatureNotSupportedException();
} |
Beta Was this translation helpful? Give feedback.
-
HikariPool, upon the first connection opening, attempts to set the LoginTimeout to be 500MS greater than the connection timeout, rounded up to the nearest second.
However, when I use an AWSWrapperDataSource with a Hikari Connection Pool, I get an error in my info log saying "Failed to set login timeout for data source. (null)". This is because the line here: https://github.com/awslabs/aws-advanced-jdbc-wrapper/blob/9fe0cedce2e284618eec2b029213f0dd807ca40c/wrapper/src/main/java/software/amazon/jdbc/ds/AwsWrapperDataSource.java#L286-L288 simply throws an SQLFeatureNotSupportedException.
Is there a reason SetLoginTimeout is unsupported? Is it to ensure that the IAM Plugin has enough time to do its work?
Should I set the login timeout on the underlying PGSimpleDataSource anyway? Or is there a good reason for the login timeout to not be set?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions