Skip to content

Commit de33b51

Browse files
committed
Fixed bug where broken transaction kills session
1 parent b7e0e3a commit de33b51

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

neo4j/v1/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs):
433433
except (ServiceUnavailable, SessionExpired) as error:
434434
last_error = error
435435
except TransientError as error:
436-
if is_retriable_transientError(error):
436+
if is_retriable_transient_error(error):
437437
last_error = error
438438
else:
439439
raise error
@@ -465,7 +465,7 @@ def __bookmark__(self, result):
465465
pass
466466

467467

468-
def is_retriable_transientError(error):
468+
def is_retriable_transient_error(error):
469469
"""
470470
:type error: TransientError
471471
"""
@@ -572,7 +572,6 @@ def close(self):
572572
""" Close this transaction, triggering either a COMMIT or a ROLLBACK.
573573
"""
574574
if not self.closed():
575-
self.sync()
576575
try:
577576
self.sync()
578577
except CypherError:

test/integration/test_session.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from neo4j.v1 import \
2525
READ_ACCESS, WRITE_ACCESS, \
2626
CypherError, SessionError, TransactionError, \
27-
Node, Relationship, Path
27+
Node, Relationship, Path, CypherSyntaxError
2828

2929
from test.integration.tools import DirectIntegrationTestCase
3030

@@ -339,6 +339,14 @@ def test_can_rollback_transaction_using_with_block(self):
339339
"RETURN a.foo", {"n": node_id})
340340
assert len(list(result)) == 0
341341

342+
def test_broken_transaction_should_not_break_session(self):
343+
with self.driver.session() as session:
344+
with self.assertRaises(CypherSyntaxError):
345+
with session.begin_transaction() as tx:
346+
tx.run("X")
347+
with session.begin_transaction() as tx:
348+
tx.run("RETURN 1")
349+
342350

343351
class BookmarkingTestCase(DirectIntegrationTestCase):
344352

0 commit comments

Comments
 (0)