Skip to content

Commit 76869d4

Browse files
authored
RUBY-3444 Server timeout error (#2860)
* extract Mongo::Error::OperationFailure::Family * add server timeout error, raised when error code == 50 * silence FLE errors on latest server * only raise ServerTimeoutError when csot timeout is present on the context * consolidate timeouts under TimeoutError * reorder exception handlers to accomodate new base class for socket timeout errors
1 parent 4133a25 commit 76869d4

38 files changed

+313
-271
lines changed

lib/mongo/auth/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def dispatch_msg(connection, conversation, msg)
117117
else
118118
nil
119119
end
120-
result = Operation::Result.new(reply, connection.description, connection_global_id)
120+
result = Operation::Result.new(reply, connection.description, connection_global_id, context: context)
121121
connection.update_cluster_time(result)
122122
reply_document
123123
end

lib/mongo/collection/helpers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Helpers
3030
# @return [ Result ] The result of the execution.
3131
def do_drop(operation, session, context)
3232
operation.execute(next_primary(nil, session), context: context)
33-
rescue Error::OperationFailure => ex
33+
rescue Error::OperationFailure::Family => ex
3434
# NamespaceNotFound
3535
if ex.code == 26 || ex.code.nil? && ex.message =~ /ns not found/
3636
false

lib/mongo/collection/view/change_stream.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def close
238238
unless closed?
239239
begin
240240
@cursor.close
241-
rescue Error::OperationFailure, Error::SocketError, Error::SocketTimeoutError, Error::MissingConnection
241+
rescue Error::OperationFailure::Family, Error::SocketError, Error::SocketTimeoutError, Error::MissingConnection
242242
# ignore
243243
end
244244
@cursor = nil

lib/mongo/collection/view/iterable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def each
100100
#
101101
# @return [ nil ] Always nil.
102102
#
103-
# @raise [ Error::OperationFailure ] If the server cursor close fails.
103+
# @raise [ Error::OperationFailure::Family ] If the server cursor close fails.
104104
#
105105
# @since 2.1.0
106106
def close_query

lib/mongo/collection/view/readable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def estimated_document_count(opts = {})
304304
result.n.to_i
305305
end
306306
end
307-
rescue Error::OperationFailure => exc
307+
rescue Error::OperationFailure::Family => exc
308308
if exc.code == 26
309309
# NamespaceNotFound
310310
# This should only happen with the aggregation pipeline path

lib/mongo/cursor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def close
299299
end
300300

301301
nil
302-
rescue Error::OperationFailure, Error::SocketError, Error::SocketTimeoutError, Error::ServerNotUsable
302+
rescue Error::OperationFailure::Family, Error::SocketError, Error::SocketTimeoutError, Error::ServerNotUsable
303303
# Errors are swallowed since there is noting can be done by handling them.
304304
ensure
305305
end_session

lib/mongo/error.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ def write_concern_error_labels
217217
require 'mongo/error/server_api_conflict'
218218
require 'mongo/error/server_api_not_supported'
219219
require 'mongo/error/server_not_usable'
220+
require 'mongo/error/server_timeout_error'
220221
require 'mongo/error/transactions_not_supported'
221222
require 'mongo/error/timeout_error'
222223
require 'mongo/error/unknown_payload_type'

0 commit comments

Comments
 (0)