Skip to content

Commit 3f184c9

Browse files
HanaPearlmanp
authored andcommitted
RUBY-1887 Rescue AuthError with Mongo::Error when appropriate (#1483)
1 parent ffd5686 commit 3f184c9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/mongo/session.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def end_session
299299
if within_states?(TRANSACTION_IN_PROGRESS_STATE)
300300
begin
301301
abort_transaction
302-
rescue Mongo::Error
302+
rescue Mongo::Error, Error::AuthError
303303
end
304304
end
305305
@client.cluster.session_pool.checkin(@server_session)
@@ -429,6 +429,9 @@ def with_transaction(options=nil)
429429
transaction_in_progress = false
430430
raise
431431
end
432+
rescue Error::AuthError
433+
transaction_in_progress = false
434+
raise
432435
end
433436
end
434437
end

lib/mongo/session/session_pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def end_sessions
117117
:selector => {endSessions: @queue.shift(10_000).collect { |s| s.session_id }},
118118
:db_name => Database::ADMIN).execute(server)
119119
end
120-
rescue Mongo::Error
120+
rescue Mongo::Error, Error::AuthError
121121
end
122122

123123
private

0 commit comments

Comments
 (0)