Skip to content

Conversation

@karenc-bq
Copy link
Contributor

@karenc-bq karenc-bq commented May 5, 2023

Summary

Integration Test Run

https://github.com/Bit-Quill/aws-advanced-jdbc-wrapper/actions/runs/4920404497

Description

Issues fixed

  1. After failover Aurora Connection Tracker incorrectly invalidates the newly promoted writer
  2. After failover Aurora Connection Tracker incorrectly invalidates a random reader that is neither the old or new writer.
  3. If the initial connection is established using an cluster endpoint, EFM plugin uses the cluster endpoint as the monitoring endpoint

Issue 1 Solution

Issue one is caused by the following check.

  private boolean isRoleChanged(final EnumSet<NodeChangeOptions> changes) {
    return changes.contains(NodeChangeOptions.PROMOTED_TO_WRITER)
        || changes.contains(NodeChangeOptions.PROMOTED_TO_READER);
  }

We need to remove the check for PROMOTED_TO_WRITER

Issue 2 & 3

Issues 2 and 3 are both caused by missing or incorrect instance endpoint in the hostspec's aliases. Issues 2 and 3 were originally fixed in #428 and #428, and the fixes contain a lot of similarities. This refactoring centralizes the logic populating the aliases and make it less error prone.

More information in respective tickets:
https://github.com/orgs/awslabs/projects/91/views/13?pane=issue&itemId=27190320
https://github.com/orgs/awslabs/projects/91/views/13?pane=issue&itemId=27190427

Additional Reviewers

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

if (resultSet.next()) {
final String instanceName = resultSet.getString(1);
if (this.getCachedTopology() == null) {
final HostSpec host = new HostSpec(getHostEndpoint(instanceName));
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 refresh topology with provided connection?

Copy link
Contributor

Choose a reason for hiding this comment

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

return null;


@Override
public HostSpec identifyConnection(Connection connection) throws SQLException {
return this.hostList.get(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

return null?

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, we need to get sql from dialect, fetch node id, try to find it in topology.


if (conn != null) {
generateHostAliases(driverProtocol, conn, hostSpec);
hostSpec.resetAliases();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why to reset? Some other plugin might already filled aliases for this host spec.

@karenc-bq karenc-bq force-pushed the refactor/host_alias branch from 3a0b9c6 to 2997d86 Compare May 5, 2023 23:16
"MonitorServiceImpl.emptyAliasSet",
new Object[] {hostSpec}));
hostSpec.addAlias(hostSpec.asAlias());
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove this entire try-catch block. We just rely on provided nodeKeys, and if they empty then we raise an exception.

@karenc-bq karenc-bq force-pushed the refactor/host_alias branch from 9f49f77 to 10f4a56 Compare May 6, 2023 00:28
PluginServiceImpl.hostAliasNotFound=Can''t find any host by the following aliases: ''{0}''.
PluginServiceImpl.hostsChangelistEmpty=There are no changes in the hosts' availability.
PluginServiceImpl.failedToRetrieveHostPort=Could not retrieve Host:Port for connection.
PluginServiceImpl.nonEmptyAliases=fillAliases called when HostSpec already contains the following aliases: ''{0}''. Please reset HostSpec aliases before calling this method.
Copy link
Contributor

Choose a reason for hiding this comment

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

"Please reset HostSpec aliases before calling this method."

I think it may mislead developers.
"Please reset HostSpec aliases if you need to re-fill them again." ?

@karenc-bq karenc-bq force-pushed the refactor/host_alias branch from e3b98ad to c9a45a7 Compare May 8, 2023 18:09
@karenc-bq karenc-bq merged commit 036a92c into aws:main May 9, 2023
@karenc-bq karenc-bq deleted the refactor/host_alias branch May 9, 2023 17:22
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.

3 participants