Skip to content

Commit 0f8faa4

Browse files
committed
WIP: send RESET when putting a connection back into the pool
1 parent ee2a5cd commit 0f8faa4

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

neo4j/io/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
ClientError,
8181
ConfigurationError,
8282
DriverError,
83+
Neo4jError,
8384
ReadServiceUnavailable,
8485
ServiceUnavailable,
8586
SessionExpired,
@@ -107,6 +108,8 @@ class Bolt:
107108

108109
PROTOCOL_VERSION = None
109110

111+
_is_reset = True
112+
110113
@classmethod
111114
def protocol_handlers(cls, protocol_version=None):
112115
""" Return a dictionary of available Bolt protocol handlers,
@@ -342,6 +345,10 @@ def commit(self, **handlers):
342345
def rollback(self, **handlers):
343346
raise NotImplementedError
344347

348+
@property
349+
def is_reset(self):
350+
return self._is_reset
351+
345352
def reset(self):
346353
""" Add a RESET message to the outgoing queue, send
347354
it and consume all remaining messages.
@@ -483,6 +490,13 @@ def release(self, *connections):
483490
"""
484491
with self.lock:
485492
for connection in connections:
493+
if not connection.is_reset:
494+
try:
495+
connection.reset()
496+
except (Neo4jError, DriverError, BoltError) as e:
497+
log.debug(
498+
"Reset on IOPool.release failed: {}".format(e)
499+
)
486500
connection.in_use = False
487501
self.cond.notify_all()
488502

neo4j/io/_bolt3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def __init__(self, unresolved_address, sock, max_connection_lifetime, *, auth=No
9999
self._creation_timestamp = perf_counter()
100100
self.supports_multiple_results = False
101101
self.supports_multiple_databases = False
102-
self._is_reset = True
103102
self.routing_context = routing_context
104103

105104
# Determine the user agent

neo4j/io/_bolt4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def __init__(self, unresolved_address, sock, max_connection_lifetime, *, auth=No
9999
self._creation_timestamp = perf_counter()
100100
self.supports_multiple_results = True
101101
self.supports_multiple_databases = True
102-
self._is_reset = True
103102
self.routing_context = routing_context
104103

105104
# Determine the user agent

neo4j/work/transaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def rollback(self):
160160
raise TransactionError("Transaction closed")
161161
metadata = {}
162162
try:
163-
if not self._connection._is_reset:
163+
if not self._connection.is_reset:
164164
# DISCARD pending records then do a rollback.
165165
self._consume_results()
166166
self._connection.rollback(on_success=metadata.update)

0 commit comments

Comments
 (0)