Skip to content

[4.4] Fix missing lock acquisition in pool #953

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

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions neo4j/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,19 +1334,21 @@ def deactivate(self, address):
log.debug("[#0000] C: <ROUTING> Deactivating address %r", address)
# We use `discard` instead of `remove` here since the former
# will not fail if the address has already been removed.
for database in self.routing_tables.keys():
self.routing_tables[database].routers.discard(address)
self.routing_tables[database].readers.discard(address)
self.routing_tables[database].writers.discard(address)
with self.refresh_lock:
for database in self.routing_tables.keys():
self.routing_tables[database].routers.discard(address)
self.routing_tables[database].readers.discard(address)
self.routing_tables[database].writers.discard(address)
log.debug("[#0000] C: <ROUTING> table=%r", self.routing_tables)
super(Neo4jPool, self).deactivate(address)

def on_write_failure(self, address):
""" Remove a writer address from the routing table, if present.
"""
log.debug("[#0000] C: <ROUTING> Removing writer %r", address)
for database in self.routing_tables.keys():
self.routing_tables[database].writers.discard(address)
with self.refresh_lock:
for database in self.routing_tables.keys():
self.routing_tables[database].writers.discard(address)
log.debug("[#0000] C: <ROUTING> table=%r", self.routing_tables)


Expand Down