Skip to content

Commit 8794226

Browse files
micahkevinAlbs
andauthored
CXX-2778 document a warning against catching with_transaction_cb errors (#1241)
Co-authored-by: Kevin Albertson <[email protected]>
1 parent 470b996 commit 8794226

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/mongocxx/include/mongocxx/v_noabi/mongocxx/client_session.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,18 @@ class client_session {
185185
/// the transaction, the entire sequence may be retried, and the callback
186186
/// may be run multiple times.
187187
///
188-
/// If the user callback calls driver methods that run operations against the
189-
/// server that can throw an operation_exception (ex: collection::insert_one),
190-
/// the user callback should allow those exceptions to propagate up the stack
191-
/// so they can be caught and processed by the with_transaction helper.
188+
/// This method has an internal non-adjustable time limit of 120 seconds,
189+
/// including all retries.
190+
///
191+
/// If the user callback invokes driver methods that run operations against the
192+
/// server which could throw an operation_exception, the user callback MUST allow
193+
/// those exceptions to propagate up the stack so they can be caught and processed
194+
/// by the with_transaction() helper.
195+
///
196+
/// For example, a callback that invokes collection::insert_one may encounter a
197+
/// "duplicate key" error with accompanying server-side transaction abort. If this
198+
/// error were not seen by the with_transaction() helper, the entire transaction
199+
/// would retry repeatedly until the overall time limit expires.
192200
///
193201
/// @param cb
194202
/// The callback to run inside of a transaction.

0 commit comments

Comments
 (0)