Skip to content

Commit 870592e

Browse files
RUBY-3794 Fix rubocop offenses from removed record_success calls
1 parent 3e398ab commit 870592e

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

lib/mongo/retryable/read_worker.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,7 @@ def modern_read_with_retry(session, server_selector, context, &block)
200200
session,
201201
timeout: context&.remaining_timeout_sec
202202
)
203-
result = yield server
204-
205-
result
203+
yield server
206204
rescue *retryable_exceptions, Error::OperationFailure::Family, Auth::Unauthorized, Error::PoolError => e
207205
e.add_notes('modern retry', 'attempt 1')
208206
raise e if session.in_transaction? && !retryable_overload_error?(e)
@@ -295,8 +293,7 @@ def retry_read(original_error, session, server_selector, context: nil, failed_se
295293
begin
296294
context&.check_timeout!
297295
attempt = attempt ? attempt + 1 : 2
298-
result = yield server, true
299-
result
296+
yield server, true
300297
rescue Error::TimeoutError
301298
raise
302299
rescue *retryable_exceptions => e

lib/mongo/retryable/write_worker.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,9 @@ def nro_write_with_retry(_write_concern, context:, &block)
111111
error_count = 0
112112
error_to_raise = nil
113113
begin
114-
result = server.with_connection(connection_global_id: context.connection_global_id) do |connection|
114+
server.with_connection(connection_global_id: context.connection_global_id) do |connection|
115115
yield connection, nil, context
116116
end
117-
result
118117
rescue Error::TimeoutError
119118
raise
120119
rescue *retryable_exceptions, Error::PoolError, Error::OperationFailure::Family => e
@@ -253,7 +252,7 @@ def modern_write_with_retry(session, server, context, &block)
253252
connection_succeeded = false
254253
was_starting = false
255254

256-
result = server.with_connection(
255+
server.with_connection(
257256
connection_global_id: context.connection_global_id,
258257
context: context
259258
) do |connection|
@@ -267,8 +266,6 @@ def modern_write_with_retry(session, server, context, &block)
267266
# it later for the retry as well.
268267
yield connection, txn_num, context.dup
269268
end
270-
271-
result
272269
rescue *retryable_exceptions, Error::PoolError, Auth::Unauthorized, Error::OperationFailure::Family => e
273270
e.add_notes('modern retry', 'attempt 1')
274271

@@ -343,10 +340,9 @@ def retry_write(original_error, txn_num, context:, failed_server: nil, &block)
343340

344341
attempt = attempt ? attempt + 1 : 2
345342
log_retry(original_error, message: 'Write retry')
346-
result = server.with_connection(connection_global_id: context.connection_global_id) do |connection|
343+
server.with_connection(connection_global_id: context.connection_global_id) do |connection|
347344
yield(connection, txn_num, context)
348345
end
349-
result
350346
rescue *retryable_exceptions, Error::PoolError => e
351347
if retryable_overload_error?(e)
352348
e.add_notes('modern retry', "attempt #{attempt}")

lib/mongo/session.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def with_transaction(options = nil)
461461
overload_error_count = 0
462462
overload_encountered = false
463463

464-
loop do # rubocop:disable Metrics/BlockLength
464+
loop do
465465
if transaction_attempt > 0
466466
if overload_encountered
467467
delay = @client.retry_policy.backoff_delay(overload_error_count)

0 commit comments

Comments
 (0)