-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve internal connection pool key defaults #432
Conversation
wrapper/src/main/java/software/amazon/jdbc/HikariPooledConnectionProvider.java
Outdated
Show resolved
Hide resolved
private String getPoolKey(HostSpec hostSpec, Properties props) { | ||
return poolMapping.getKey(hostSpec, props) | ||
+ props.getProperty(PropertyDefinition.USER.name) | ||
+ props.getProperty(PropertyDefinition.PASSWORD.name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't include password. In case of IAM token (that is changing every15min) we might see more and more connection pools are created.
@@ -758,4 +760,75 @@ public void test_pooledConnection_failoverInTransaction() | |||
ConnectionProviderManager.resetProvider(); | |||
} | |||
} | |||
|
|||
@TestTemplate | |||
@EnableOnTestFeature(TestEnvironmentFeatures.FAILOVER_SUPPORTED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test practically test how well getPoolKey() works. I don't think we need such test as integration test with real database. A simple unit test with mocked connection pools would be more than enough.
@@ -39,7 +39,7 @@ The wrapper driver currently uses [Hikari](https://github.com/brettwooldridge/Hi | |||
- username | |||
- password | |||
|
|||
You can optionally pass in a `HikariPoolMapping` function as a second parameter to the `HikariPooledConnectionProvider`. Internally, the connection pools used by the plugin are maintained as a map from instance URLs to connection pools. If you would like to define a different key system, you should pass in a `HikariPoolMapping` function defining this logic. This is helpful, for example, when you would like to create multiple Connection objects to the same instance with different users. In this scenario, you should pass in a `HikariPoolMapping` that incorporates the instance URL and the username from the `Properties` object into the map key. | |||
You can optionally pass in a `HikariPoolMapping` function as a second parameter to the `HikariPooledConnectionProvider`. This allows you to decide when new connection pools should be created by defining what is included in the pool map key. A new pool will be created each time a new connection is requested with a unique key. By default, a new pool will be created for each unique instance-user combination. If you would like to define a different key system, you should pass in a `HikariPoolMapping` function defining this logic. Note that the user will always be automatically included in the key for security reasons. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide an example?
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.