Skip to content

Commit 965c3dc

Browse files
authored
Check unresolved address when removing connections from pool (#600)
The driver removes connections from the pool when a new routing table is fetched which does not contain the server of those connections anymore. This check, however, should be performed on the unresolved address as this is the one that will be found in the routing table.
1 parent 66b3a9b commit 965c3dc

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

neo4j/addressing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def host(self):
138138
def port(self):
139139
return self[1]
140140

141+
@property
142+
def unresolved(self):
143+
return self
144+
141145
@classmethod
142146
def _dns_resolve(cls, address, family=0):
143147
""" Regular DNS resolver. Takes an address object and optional
@@ -226,6 +230,10 @@ class ResolvedAddress(Address):
226230
def host_name(self):
227231
return self._host_name
228232

233+
@property
234+
def unresolved(self):
235+
return (self._host_name, *self[1:])
236+
229237
def resolve(self, family=0, resolver=None):
230238
return [self]
231239

neo4j/io/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ def update_routing_table(self, *, database, bookmarks):
10701070
def update_connection_pool(self, *, database):
10711071
servers = self.routing_tables[database].servers()
10721072
for address in list(self.connections):
1073-
if address not in servers:
1073+
if address.unresolved not in servers:
10741074
super(Neo4jPool, self).deactivate(address)
10751075

10761076
def ensure_routing_table_is_fresh(self, *, access_mode, database,

testkitbackend/test_config.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
11
{
22
"skips": {
3-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_change_using_tx_function":
4-
"Driver closes connection to router if DNS resolved name not in routing table",
5-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_change_using_tx_function":
6-
"Driver closes connection to router if DNS resolved name not in routing table",
7-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_change_using_tx_function":
8-
"Driver closes connection to router if DNS resolved name not in routing table",
9-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
10-
"Driver closes connection to router if DNS resolved name not in routing table",
11-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
12-
"Driver closes connection to router if DNS resolved name not in routing table",
13-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_change_on_run_using_tx_function":
14-
"Driver closes connection to router if DNS resolved name not in routing table",
15-
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
16-
"Driver closes connection to router if DNS resolved name not in routing table",
17-
"stub.routing.test_routing_v3.RoutingV3.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
18-
"Driver closes connection to router if DNS resolved name not in routing table",
19-
"stub.routing.test_routing_v4x3.RoutingV4x3.test_should_retry_write_until_success_with_leader_shutdown_during_tx_using_tx_function":
20-
"Driver closes connection to router if DNS resolved name not in routing table",
213
"stub.routing.test_routing_v4x1.RoutingV4x1.test_should_successfully_acquire_rt_when_router_ip_changes":
224
"Test makes assumptions about how verify_connectivity is implemented",
235
"stub.routing.test_routing_v3.RoutingV3.test_should_successfully_acquire_rt_when_router_ip_changes":

0 commit comments

Comments
 (0)