diff --git a/aws_advanced_python_wrapper/stale_dns_plugin.py b/aws_advanced_python_wrapper/stale_dns_plugin.py index dc5efd83..4b7d60e3 100644 --- a/aws_advanced_python_wrapper/stale_dns_plugin.py +++ b/aws_advanced_python_wrapper/stale_dns_plugin.py @@ -76,7 +76,8 @@ def get_verified_connection(self, is_initial_connection: bool, host_list_provide if cluster_inet_address is None: return conn - if self._plugin_service.get_host_role(conn) == HostRole.READER: + connected_to_reader = self._plugin_service.get_host_role(conn) == HostRole.READER + if connected_to_reader: # This if-statement is only reached if the connection url is a writer cluster endpoint. # If the new connection resolves to a reader instance, this means the topology is outdated. # Force refresh to update the topology. @@ -109,7 +110,7 @@ def get_verified_connection(self, is_initial_connection: bool, host_list_provide if self._writer_host_address is None: return conn - if self._writer_host_address != cluster_inet_address: + if self._writer_host_address != cluster_inet_address or connected_to_reader: logger.debug("StaleDnsHelper.StaleDnsDetected", self._writer_host_info) allowed_hosts = self._plugin_service.hosts