Skip to content

Commit

Permalink
RUBY-386 ensure that replica set connection doesn't hang when
Browse files Browse the repository at this point in the history
connecting to unreponsive node. set default op timeout to 30 seconds.
  • Loading branch information
banker committed Dec 12, 2011
1 parent ec97bd0 commit 4ed709f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/mongo/repl_set_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class ReplSetConnection < Connection
# @option options [Float] :pool_timeout (5.0) When all of the connections a pool are checked out,
# this is the number of seconds to wait for a new connection to be released before throwing an exception.
# Note: this setting is relevant only for multi-threaded applications.
# @option opts [Float] :op_timeout (nil) The number of seconds to wait for a read operation to time out.
# Disabled by default.
# @option opts [Float] :op_timeout (30) The number of seconds to wait for a read operation to time out.
# @option opts [Float] :connect_timeout (nil) The number of seconds to wait before timing out a
# connection attempt.
# @option opts [Boolean] :ssl (false) If true, create the connection to the server using SSL.
Expand Down Expand Up @@ -470,7 +469,7 @@ def setup(opts)
@pool_timeout = opts[:pool_timeout] || opts[:timeout] || 5.0

# Timeout on socket read operation.
@op_timeout = opts[:op_timeout] || nil
@op_timeout = opts[:op_timeout] || 30

# Timeout on socket connect.
@connect_timeout = opts[:connect_timeout] || nil
Expand Down
2 changes: 1 addition & 1 deletion lib/mongo/util/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def set_config

check_set_membership(config)
check_set_name(config)
rescue ConnectionFailure, OperationFailure, SocketError, SystemCallError, IOError => ex
rescue ConnectionFailure, OperationFailure, OperationTimeout, SocketError, SystemCallError, IOError => ex
@connection.log(:warn, "Attempted connection to node #{host_string} raised " +
"#{ex.class}: #{ex.message}")
return nil
Expand Down

0 comments on commit 4ed709f

Please sign in to comment.