Skip to content
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

Merged
merged 9 commits into from
May 10, 2023

Conversation

congoamz
Copy link
Contributor

@congoamz congoamz commented May 5, 2023

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

private String getPoolKey(HostSpec hostSpec, Properties props) {
return poolMapping.getKey(hostSpec, props)
+ props.getProperty(PropertyDefinition.USER.name)
+ props.getProperty(PropertyDefinition.PASSWORD.name);
Copy link
Contributor

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)
Copy link
Contributor

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.
Copy link
Contributor

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?

@congoamz congoamz merged commit f04b064 into aws:main May 10, 2023
@aaron-congo aaron-congo deleted the pool-key-user branch May 10, 2023 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants