lib/mongo/retryable/read_worker.rb in mongo-2.20.0 vs lib/mongo/retryable/read_worker.rb in mongo-2.20.1
- old
+ new
@@ -196,11 +196,11 @@
e.add_notes('modern retry', 'attempt 1')
raise e if session.in_transaction?
raise e if !is_retryable_exception?(e) && !e.write_retryable?
retry_read(e, session, server_selector, failed_server: server, &block)
end
-
+
# Attempts to do a "legacy" read with retry. The operation will be
# attempted multiple times, up to the client's `max_read_retries`
# setting.
#
# @param [ Mongo::Session ] session The session that the operation is
@@ -211,21 +211,22 @@
#
# @return [ Result ] The result of the operation.
def legacy_read_with_retry(session, server_selector, &block)
attempt = attempt ? attempt + 1 : 1
yield select_server(cluster, server_selector, session)
- rescue *retryable_exceptions, Error::OperationFailure, Error::PoolError => e
+ rescue *legacy_retryable_exceptions, Error::OperationFailure => e
e.add_notes('legacy retry', "attempt #{attempt}")
-
- if is_retryable_exception?(e)
+
+ if is_legacy_retryable_exception?(e)
+
raise e if attempt > client.max_read_retries || session&.in_transaction?
elsif e.retryable? && !session&.in_transaction?
raise e if attempt > client.max_read_retries
else
raise e
end
-
+
log_retry(e, message: 'Legacy read retry')
sleep(client.read_retry_interval) unless is_retryable_exception?(e)
retry
end
@@ -259,21 +260,21 @@
# @param [ Mongo::ServerSelector::Selectable ] server_selector Server
# selector for the operation.
# @param [ Mongo::Server ] failed_server The server on which the original
# operation failed.
# @param [ Proc ] block The block to execute.
- #
+ #
# @return [ Result ] The result of the operation.
def retry_read(original_error, session, server_selector, failed_server: nil, &block)
begin
server = select_server(cluster, server_selector, session, failed_server)
rescue Error, Error::AuthError => e
original_error.add_note("later retry failed: #{e.class}: #{e}")
raise original_error
end
-
+
log_retry(original_error, message: 'Read retry')
-
+
begin
yield server, true
rescue *retryable_exceptions => e
e.add_notes('modern retry', 'attempt 2')
raise e