Module: Mongo::Error::ReadWriteRetryable

Included in:
Auth::Unauthorized, OperationFailure
Defined in:
build/ruby-driver-v2.19/lib/mongo/error/read_write_retryable.rb

Overview

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.

A module encapsulating functionality to indicate whether errors are retryable.

Since:

  • 2.0.0

Constant Summary collapse

WRITE_RETRY_ERRORS =

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

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

Since:

  • 2.0.0

[
  {:code_name => 'HostUnreachable', :code => 6},
  {:code_name => 'HostNotFound', :code => 7},
  {:code_name => 'NetworkTimeout', :code => 89},
  {:code_name => 'ShutdownInProgress', :code => 91},
  {:code_name => 'PrimarySteppedDown', :code => 189},
  {:code_name => 'ExceededTimeLimit', :code => 262},
  {:code_name => 'SocketException', :code => 9001},
  {:code_name => 'NotMaster', :code => 10107},
  {:code_name => 'InterruptedAtShutdown', :code => 11600},
  {:code_name => 'InterruptedDueToReplStateChange', :code => 11602},
  {:code_name => 'NotPrimaryNoSecondaryOk', :code => 13435},
  {:code_name => 'NotMasterOrSecondary', :code => 13436},
].freeze
WRITE_RETRY_MESSAGES =

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

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

Since:

  • 2.0.0

[
  'not master',
  'node is recovering',
].freeze
RETRY_MESSAGES =

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

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

Since:

  • 2.0.0

WRITE_RETRY_MESSAGES + [
  'transport error',
  'socket exception',
  "can't connect",
  'connect failed',
  'error querying',
  'could not get last error',
  'connection attempt failed',
  'interrupted at shutdown',
  'unknown replica set',
  'dbclient error communicating with server'
].freeze

Instance Method Summary collapse

Instance Method Details

#retryable?true, false

Deprecated.

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

Returns:

  • (true, false)

Since:

  • 2.0.0



81
82
83
84
# File 'build/ruby-driver-v2.19/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?true, false

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.

Returns:

  • (true, false)

Since:

  • 2.0.0



93
94
95
96
# File 'build/ruby-driver-v2.19/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