Skip to content

[4.3] Improve logging around connection errors #595

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 1 commit into from
Sep 29, 2021
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
8 changes: 5 additions & 3 deletions neo4j/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def open(cls, address, *, auth=None, timeout=None, routing_context=None, **pool_
from neo4j.io._bolt4 import Bolt4x3
connection = Bolt4x3(address, s, pool_config.max_connection_lifetime, auth=auth, user_agent=pool_config.user_agent, routing_context=routing_context)
else:
log.debug("[#%04X] S: <CLOSE>", s.getpeername()[1])
log.debug("[#%04X] S: <CLOSE>", s.getsockname()[1])
_close_socket(s)

supported_versions = Bolt.protocol_handlers().keys()
Expand Down Expand Up @@ -540,7 +540,7 @@ def _set_defunct(self, message, error=None, silent=False):
direct_driver = isinstance(self.pool, BoltPool)

if error:
log.error(str(error))
log.debug("[#%04X] %s", self.socket.getsockname()[1], error)
log.error(message)
# We were attempting to receive data but the connection
# has unexpectedly terminated. So, we need to close the
Expand Down Expand Up @@ -703,7 +703,9 @@ def release(self, *connections):
"""
with self.lock:
for connection in connections:
if not connection.is_reset:
if not (connection.is_reset
or connection.defunct()
or connection.closed()):
try:
connection.reset()
except (Neo4jError, DriverError, BoltError) as e:
Expand Down