Module: Mongo::Error::OperationFailure::Family
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Forwardable
|
|
|
Instance Chain:
|
|
| Defined in: | lib/mongo/error/operation_failure.rb |
Overview
Implements the behavior for an ::Mongo::Error::OperationFailure error. Other errors (e.g. ::Mongo::Error::ServerTimeoutError) may also implement this, so that they may be recognized and treated as ::Mongo::Error::OperationFailure errors.
Constant Summary
-
CHANGE_STREAM_RESUME_ERRORS =
Internal use only
# File 'lib/mongo/error/operation_failure.rb', line 60
::Mongo::Errorcodes and code names that should result in a failing getMore command on a change stream NOT being resumed.[ { 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: 10_107 }, { code_name: 'InterruptedAtShutdown', code: 11_600 }, { code_name: 'InterruptedDueToReplStateChange', code: 11_602 }, { code_name: 'NotPrimaryNoSecondaryOk', code: 13_435 }, { code_name: 'NotMasterOrSecondary', code: 13_436 }, { code_name: 'StaleShardVersion', code: 63 }, { code_name: 'FailedToSatisfyReadPreference', code: 133 }, { code_name: 'StaleEpoch', code: 150 }, { code_name: 'RetryChangeStream', code: 234 }, { code_name: 'StaleConfig', code: 13_388 }, ].freeze -
CHANGE_STREAM_RESUME_MESSAGES =
Internal use only
# File 'lib/mongo/error/operation_failure.rb', line 85
Change stream can be resumed when these error messages are encountered.
ReadWriteRetryable::WRITE_RETRY_MESSAGES
::Mongo::Error::SdamErrorDetection - Included
NODE_RECOVERING_CODES, NODE_SHUTTING_DOWN_CODES, NOT_MASTER_CODES
::Mongo::Error::ReadWriteRetryable - Included
Instance Attribute Summary
-
#change_stream_resumable? ⇒ true, false
readonly
Can the change stream on which this error occurred be resumed, provided the operation that triggered this error was a getMore?
- #code ⇒ Integer readonly
- #code_name ⇒ String readonly
- #details ⇒ String | nil readonly
- #document ⇒ BSON::Document | nil readonly
-
#max_time_ms_expired? ⇒ true | false
readonly
Whether the error is MaxTimeMSExpired.
- #result ⇒ Operation::Result readonly Internal use only Internal use only
- #server_message ⇒ String readonly
- #write_concern_error? ⇒ true | false readonly
- #write_concern_error_code ⇒ Integer | nil readonly
- #write_concern_error_code_name ⇒ String | nil readonly
-
#write_concern_error_document ⇒ Hash | nil
readonly
Returns the write concern error document as it was reported by the server, if any.
-
#wtimeout? ⇒ true | false
readonly
Whether the error is a write concern timeout.
- #change_stream_resumable_code? ⇒ Boolean readonly private
::Mongo::Error::ReadWriteRetryable - Included
| #retryable? | Whether the error is a retryable error according to the legacy read retry logic. |
| #write_retryable? | Whether the error is a retryable error according to the modern retryable reads and retryable writes specifications. |
| #write_retryable_code? | |
::Mongo::Error::SdamErrorDetection - Included
| #node_recovering? | Whether the error is a “node is recovering” error, or one of its variants. |
| #node_shutting_down? | Whether the error is a “node is shutting down” type error. |
| #not_master? | Whether the error is a “not master” error, or one of its variants. |
Instance Method Summary
- #connection_description ⇒ Server::Description Internal use only
-
#initialize(message = nil, result = nil, options = {})
Create the operation failure.
-
#append_details(message, details) ⇒ String
private
Append the details to the message.
-
#retrieve_details(document) ⇒ Hash | nil
private
Retrieve the details from a document.
Instance Attribute Details
#change_stream_resumable? ⇒ true, false (readonly)
Can the change stream on which this error occurred be resumed, provided the operation that triggered this error was a getMore?
# File 'lib/mongo/error/operation_failure.rb', line 96
def change_stream_resumable? if @result && @result.is_a?(Mongo::Operation::GetMore::Result) # CursorNotFound exceptions are always resumable because the server # is not aware of the cursor id, and thus cannot determine if # the cursor is a change stream and cannot add the # ResumableChangeStreamError label. return true if code == 43 # Connection description is not populated for unacknowledged writes. if connection_description.max_wire_version >= 9 label?('ResumableChangeStreamError') else change_stream_resumable_code? end else false end end
#change_stream_resumable_code? ⇒ Boolean (readonly, private)
# File 'lib/mongo/error/operation_failure.rb', line 115
def change_stream_resumable_code? CHANGE_STREAM_RESUME_ERRORS.any? { |e| e[:code] == code } end
#code ⇒ Integer (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 43
attr_reader :code
#code_name ⇒ String (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 48
attr_reader :code_name
#details ⇒ String | nil (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 151
attr_reader :details
#document ⇒ BSON::Document | nil (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 156
attr_reader :document
#max_time_ms_expired? ⇒ true | false (readonly)
Whether the error is MaxTimeMSExpired.
# File 'lib/mongo/error/operation_failure.rb', line 217
def max_time_ms_expired? code == 50 # MaxTimeMSExpired end
#result ⇒ Operation::Result (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 161
attr_reader :result
#server_message ⇒ String (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 54
attr_reader :
#write_concern_error? ⇒ true | false (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 125
def write_concern_error? !!@write_concern_error_document end
#write_concern_error_code ⇒ Integer | nil (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 139
attr_reader :write_concern_error_code
#write_concern_error_code_name ⇒ String | nil (readonly)
# File 'lib/mongo/error/operation_failure.rb', line 145
attr_reader :write_concern_error_code_name
#write_concern_error_document ⇒ Hash | nil (readonly)
Returns the write concern error document as it was reported by the server, if any.
# File 'lib/mongo/error/operation_failure.rb', line 133
attr_reader :write_concern_error_document
#wtimeout? ⇒ true | false (readonly)
Whether the error is a write concern timeout.
# File 'lib/mongo/error/operation_failure.rb', line 208
def wtimeout? @wtimeout end
Instance Method Details
#append_details(message, details) ⇒ String (private)
Append the details to the message
#connection_description ⇒ Server::Description
# File 'lib/mongo/error/operation_failure.rb', line 38
def_delegator :@result, :connection_description
#initialize(message = nil, result = nil, options = {})
Create the operation failure.
# File 'lib/mongo/error/operation_failure.rb', line 186
def initialize( = nil, result = nil, = {}) @details = retrieve_details([:document]) super(append_details(, @details)) @result = result @code = [:code] @code_name = [:code_name] @write_concern_error_document = [:write_concern_error_document] @write_concern_error_code = [:write_concern_error_code] @write_concern_error_code_name = [:write_concern_error_code_name] @write_concern_error_labels = [:write_concern_error_labels] || [] @labels = [:labels] || [] @wtimeout = !![:wtimeout] @document = [:document] @server_message = [:] end
#retrieve_details(document) ⇒ Hash | nil (private)
Retrieve the details from a document