Method: Mongo::Session#unpin_maybe

Defined in:
lib/mongo/session.rb

#unpin_maybe(error, connection = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Unpins this session from the pinned server or connection, if the session was pinned and the specified exception instance and the session’s transaction state require it to be unpinned.

The exception instance should already have all of the labels set on it (both client- and server-side generated ones).

Parameters:

  • error (Error)

    The exception instance to process.

  • connection (Connection | nil) (defaults to: nil)

    Connection to unpin from.

Since:

  • 2.5.0



876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/mongo/session.rb', line 876

def unpin_maybe(error, connection = nil)
  if !within_states?(Session::NO_TRANSACTION_STATE) &&
    error.label?('TransientTransactionError')
  then
    unpin(connection)
  end

  if committing_transaction? &&
    error.label?('UnknownTransactionCommitResult')
  then
    unpin(connection)
  end
end