Skip to content

Conversation

@sergiyvamz
Copy link
Contributor

@sergiyvamz sergiyvamz commented May 26, 2023

Summary

  • Fix issue with HikariCP integration test.
  • rework AwsWrapperDataSource: removed properties for property names, introduced a set of simple properties to set database, server name and server port.

Additional Reviewers

@karenc-bq
@aaron-congo
@aaronchung-bitquill
@crystall-bitquill

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

@sergiyvamz sergiyvamz changed the title [WIP] fix lost database name in properties during writer failover [WIP] fix failing HikariCP integration test Jun 2, 2023
@sergiyvamz sergiyvamz force-pushed the writer-failover-properties branch from 9627073 to e537560 Compare June 2, 2023 20:21
@sergiyvamz sergiyvamz changed the title [WIP] fix failing HikariCP integration test fix failing HikariCP integration test Jun 2, 2023
@sergiyvamz sergiyvamz force-pushed the writer-failover-properties branch 2 times, most recently from 7f97ca2 to 6a8931a Compare June 2, 2023 22:16
// Configure the driver-specific data source:
Properties targetDataSourceProps = new Properties();
targetDataSourceProps.setProperty("serverName", "db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com");
targetDataSourceProps.setProperty("databaseName", "employees");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In ReadWriteSplittingSpringJdbcTemplateExample we set the database by calling ds.setDatabase instead of setting it on the target data source props like in this example. Do both ways accomplish the same thing? Should we use the same way in both examples to make things clearer for the user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Both approaches work for AwsWrapperDataSource. Probably the simplest one when database is set with ds.setDatabase() is preferable.

}
}

// Identify what connection provider to use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we change this comment since we have a ConnectionProvider class but that class is not what we're referring to here? eg Identify what target data source to use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean explicitly mention DataSourceConnectionProvider and DriverConnectionProvider?

final @Nullable String databaseName) throws SQLException {

if (StringUtils.isNullOrEmpty(jdbcProtocol) || StringUtils.isNullOrEmpty(serverName)) {
throw new SQLException(Messages.get("ConnectionUrlBuilder.missingJdbcProtocol"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the error message say we are missing the jdbc protocol if the jdbc protocol is defined but the server name is not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message says either jdbc protocol or server name is missing. ConnectionUrlBuilder.missingJdbcProtocol might be not the best message ID since it doesn't mention server name.

final Properties props) throws SQLException {

if (StringUtils.isNullOrEmpty(jdbcProtocol)) {
if (StringUtils.isNullOrEmpty(jdbcProtocol) || hostSpec == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question, why does the error message say we are missing the jdbc protocol if it is defined but the host spec is null?

copy.put(this.databasePropertyName, PropertyDefinition.DATABASE.getString(props));
}

copy.setProperty("url", url);
Copy link
Contributor

@congoamz congoamz Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this property used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not in use and it's deprecated. We just assume that target data source has url property.

while ((instanceIDs.size()
!= testRequest.getNumOfInstances()
while ((instanceIDs.size() != testRequest.getNumOfInstances()
|| instanceIDs.size() == 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
|| instanceIDs.size() == 0
|| instanceIDs.isEmpty()

@sergiyvamz sergiyvamz merged commit d006fdd into main Jun 3, 2023
@sergiyvamz sergiyvamz deleted the writer-failover-properties branch June 3, 2023 00:28
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.

4 participants