-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.6
-
Component/s: None
-
None
-
Environment:Ubuntu, standalone Mongo 2.4.9 with SSL and authentication enabled.
1. Stop the server, then try to run a query. The driver fails to connect.
2. Start the server again, then run the query again. The driver tries for 30 seconds, then gives up.
The driver never manages to connect to the server again, until restarting the Ruby process.
D, [2015-08-28T08:29:29.713169 #22895] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 2.9919ms D, [2015-08-28T08:29:29.713653 #22895] DEBUG -- : MONGODB | Connection refused - connect(2) | runtime: 0.0145ms D, [2015-08-28T08:29:30.942360 #22895] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 0.2193ms D, [2015-08-28T08:29:30.942475 #22895] DEBUG -- : MONGODB | no implicit conversion of nil into IO | runtime: 0.0045ms
The "no implicit conversion of nil into IO" error keeps on repeating after this, and the driver can never connect again.
The full stacktrace can be seen with when running:
server.monitor.connection.connected?
TypeError: no implicit conversion of nil into IO from .../shared/bundle/ruby/2.0.0/gems/mongo-2.0.6/lib/mongo/socket.rb:60:in `select' from .../shared/bundle/ruby/2.0.0/gems/mongo-2.0.6/lib/mongo/socket.rb:60:in `alive?' from .../shared/bundle/ruby/2.0.0/gems/mongo-2.0.6/lib/mongo/server/connectable.rb:47:in `connected?' from (irb):134
The issue seems to be that @socket on the Socket object is nil for some reason, causing a failure in #eof?:
https://github.com/mongodb/mongo-ruby-driver/blob/v2.1.0.rc0/lib/mongo/socket.rb#L60
Adding a check for a nil @socket there seems to solve the issue, allowing the driver to automatically reconnect again.