Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Commit

Permalink
Merge pull request #297 from jonhyman/feature/auth-reconfigure-2x
Browse files Browse the repository at this point in the history
Inspect auth failures to see if we should actually just retry.
  • Loading branch information
arthurnn committed Sep 29, 2014
2 parents b480bb4 + 18d6d9a commit 274610f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/moped/authenticatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,17 @@ def login(database, username, password)
self.write([ authenticate ])
document = self.read.documents.first

raise Errors::AuthenticationFailure.new(authenticate, document) unless document["ok"] == 1
unless result["ok"] == 1
# See if we had connectivity issues so we can retry
e = Errors::PotentialReconfiguration.new(authenticate, document)
if e.reconfiguring_replica_set?
raise Errors::ReplicaSetReconfigured.new(e.command, e.details)
elsif e.connection_failure?
raise Errors::ConnectionFailure.new(e.inspect)
end

raise Errors::AuthenticationFailure.new(authenticate, document)
end
credentials[database] = [username, password]
end

Expand Down
2 changes: 1 addition & 1 deletion lib/moped/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PotentialReconfiguration < MongoError
NOT_MASTER = [ 13435, 13436, 10009 ]

# Error codes received around reconfiguration
CONNECTION_ERRORS_RECONFIGURATION = [ 15988, 10276, 11600, 9001, 13639, 10009 ]
CONNECTION_ERRORS_RECONFIGURATION = [ 15988, 10276, 11600, 9001, 13639, 10009, 11002 ]

# Replica set reconfigurations can be either in the form of an operation
# error with code 13435, or with an error message stating the server is
Expand Down

0 comments on commit 274610f

Please sign in to comment.