lib/mongo/operation/shared/response_handling.rb
# A method that will add the RetryableWriteError label to an error if
# any of the following conditions are true:
#
# The error meets the criteria for a retryable error (i.e. has one
#   of the retryable error codes or error messages)
#
# AND the server does not support adding the RetryableWriteError label OR
#   the error is a network error (i.e. the driver must add the label)
#
# AND the error occured during a commitTransaction or abortTransaction
#   OR the error occured during a write outside of a transaction on a
#   client that has retry writes enabled.
#
# If these conditions are met, the original error will be mutated.
# If they're not met, the error will not be changed.
#
# @param [ Mongo::Error ] error The error to which to add the label.
# @param [ Mongo::Server::Connection ] connection The connection on which
#   the operation is performed.
# @param [ Mongo::Operation::Context ] context The operation context.
#
# @note The client argument is optional because some operations, such as
#   end_session, do not pass the client as an argument to the execute
#   method.
A method that will add the RetryableWriteError label to an error if
any of the following conditions are true.

The error meets the criteria for a retryable error

AND the server does not support adding the RetryableWriteError label OR
the error is a network error

AND the error occured during a commitTransaction or abortTransaction
OR the error occured during a write outside of a transaction on a
client that has retry writes enabled.

If these conditions are met, the original error will be mutated.
If they're not met, the error will not be changed.
A method that will add the RetryableWriteError label to an error if any of the following conditions are true . The error meets the criteria for a retryable error AND the server does not support adding the RetryableWriteError label OR the error is a network error AND the error occured during a commitTransaction or abortTransaction OR the error occured during a write outside of a transaction on a client that has retry writes enabled . If these conditions are met the original error will be mutated . If they ' re not met the error will not be changed .
def maybe_add_retryable_write_error_label!(error, connection, context)
         Note: any write operation within a transaction (excepting commit and
         abort is NOT a retryable operation)
        retryable_operation = context.committing_transaction? ||
          context.aborting_transaction? ||
          !context.in_transaction? && context.any_retry_writes?
         An operation should add the RetryableWriteError label if one of the
         following conditions is met:
         - The server does not support adding the RetryableWriteError label
         - The error is a network error
        should_add_error_label =
          !connection.description.features.retryable_write_error_label_enabled? ||
          error.write_concern_error_label?('RetryableWriteError') ||
          error.is_a?(Mongo::Error::SocketError) ||
          error.is_a?(Mongo::Error::SocketTimeoutError)
        if retryable_operation && should_add_error_label && error.write_retryable?
          error.add_label('RetryableWriteError')
        end
      end
def maybe_add_retryable_write_error_label! ( error , connection , context ) retryable_operation = context . committing_transaction? || context . aborting_transaction? || ! context . in_transaction? && context . any_retry_writes? should_add_error_label = ! connection . description . features . retryable_write_error_label_enabled? || error . write_concern_error_label? ( 'RetryableWriteError' ) || error . is_a? ( Mongo :: Error :: SocketError ) || error . is_a? ( Mongo :: Error :: SocketTimeoutError ) if retryable_operation && should_add_error_label && error . write_retryable? error . add_label ( 'RetryableWriteError' ) end end
A method that will add the RetryableWriteError label to an error if
any of the following conditions are true:
A method that will add the RetryableWriteError label to an error if any of the following conditions are true :
# An operation is retryable if it meets one of the following criteria: # - It is a commitTransaction or abortTransaction # - It does not occur during a transaction and the client has enabled #   modern or legacy writes # # Note: any write operation within a transaction (excepting commit and # abort is NOT a retryable operation) # An operation should add the RetryableWriteError label if one of the # following conditions is met: # - The server does not support adding the RetryableWriteError label # - The error is a network error
error
<not_specific>
connection
<not_specific>
context
<not_specific>
<not_specific>
context The operation context.
context The operation context .
note
The client argument is optional because some operations, such as end_session, do not pass the client as an argument to the execute method.
The client argument is optional because some operations such as end_session do not pass the client as an argument to the execute method .