Skip to content

Commit

Permalink
adding documentation to avoid infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
joyjwang committed Oct 9, 2024
1 parent 78b0f61 commit 230c750
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mongo/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,17 @@ func (s *Session) EndSession(ctx context.Context) {
// for any operations that should be part of the transaction. If the ctx
// parameter already has a Session attached to it, it will be replaced by this
// session. The fn callback may be run multiple times during WithTransaction due
// to retry attempts, so it must be idempotent. Non-retryable operation errors
// or any operation errors that occur after the timeout expires will be returned
// without retrying. If the callback fails, the driver will call
// to retry attempts, so it must be idempotent.
// If a command inside the callback fn fails, it may cause the transaction on the
// server to be aborted. This situation is normally handled transparently by the
// driver. However, if the application does not return that error from the fn,
// the driver will not be able to determine whether the transaction was aborted or
// not. The driver will then retry the block indefinitely.
// To avoid this situation, the application MUST NOT silently handle errors within
// the callback fn. If the application needs to handle errors within the block,
// it MUST return them after doing so.
// Non-retryable operation errors or any operation errors that occur after the timeout
// expires will be returned without retrying. If the callback fails, the driver will call
// AbortTransaction. Because this method must succeed to ensure that server-side
// resources are properly cleaned up, context deadlines and cancellations will
// not be respected during this call. For a usage example, see the
Expand Down

0 comments on commit 230c750

Please sign in to comment.