module Mongo::Error::ReadWriteRetryable

A module encapsulating functionality to indicate whether errors are retryable.

@note Although methods of this module are part of the public API,

the fact that these methods are defined on this module and not on
the classes which include this module is not part of the public API.

@api semipublic

Constants

RETRY_MESSAGES

These are magic error messages that could indicate a cluster reconfiguration behind a mongos.

@api private

WRITE_RETRY_ERRORS

Error codes and code names that should result in a failing write being retried.

@api private

WRITE_RETRY_MESSAGES

These are magic error messages that could indicate a master change.

@api private

Public Instance Methods

retryable?() click to toggle source

Whether the error is a retryable error according to the legacy read retry logic.

@return [ true, false ]

@deprecated

# File lib/mongo/error/read_write_retryable.rb, line 81
def retryable?
  write_retryable? ||
  code.nil? && RETRY_MESSAGES.any?{ |m| message.include?(m) }
end
write_retryable?() click to toggle source

Whether the error is a retryable error according to the modern retryable reads and retryable writes specifications.

This method is also used by the legacy retryable write logic to determine whether an error is a retryable one.

@return [ true, false ]

# File lib/mongo/error/read_write_retryable.rb, line 93
def write_retryable?
  write_retryable_code? ||
  code.nil? && WRITE_RETRY_MESSAGES.any? { |m| message.include?(m) }
end

Private Instance Methods

write_retryable_code?() click to toggle source
# File lib/mongo/error/read_write_retryable.rb, line 98
        def write_retryable_code?
  if code
    WRITE_RETRY_ERRORS.any? { |e| e[:code] == code }
  else
    # return false rather than nil
    false
  end
end