Skip to content

Commit 2095013

Browse files
committed
PYTHON-4019 Infinite loop in generic transactional provider due to dup keys
1 parent fed738d commit 2095013

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pymongo/asynchronous/client_session.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,11 @@ async def callback(session, custom_arg, custom_kwarg=None):
660660
``with_transaction`` starts a new transaction and re-executes
661661
the ``callback``.
662662
663+
The ``callback`` MUST NOT silently handle command errors
664+
without allowing such errors to propagate. Command errors may abort the
665+
transaction on the server, and an attempt to commit the transaction will
666+
be rejected with a ``NoSuchTransaction`` error.
667+
663668
When :meth:`~AsyncClientSession.commit_transaction` raises an exception with
664669
the ``"UnknownTransactionCommitResult"`` error label,
665670
``with_transaction`` retries the commit until the result of the

pymongo/synchronous/client_session.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ def callback(session, custom_arg, custom_kwarg=None):
659659
``with_transaction`` starts a new transaction and re-executes
660660
the ``callback``.
661661
662+
The ``callback`` MUST NOT silently handle command errors
663+
without allowing such errors to propagate. Command errors may abort the
664+
transaction on the server, and an attempt to commit the transaction will
665+
be rejected with a ``NoSuchTransaction`` error.
666+
662667
When :meth:`~ClientSession.commit_transaction` raises an exception with
663668
the ``"UnknownTransactionCommitResult"`` error label,
664669
``with_transaction`` retries the commit until the result of the

0 commit comments

Comments
 (0)