After a ConnectionFailure exception, the ruby driver tries to reconnect automatically on a "read" operation, but not on a "write" operation.
Let's consider a basic example similar to the one given in the tutorial:
As long as the mongod process is down, we will get a ConnectionFailure exception, but after re-lauching of the mongod process, read operations will work again.
This is because the Cursor attempts to refresh the connection here: https://github.com/mongodb/mongo-ruby-driver/blob/1.7.0/lib/mongo/cursor.rb#L127
But if we do the same test with a "write" operation, it will not reconnect automatically:
Even after the mongod process relaunch, we only get ConnectionFailure exceptions.
With the mongo gem version 1.6.2, it used to reconnect on reads AND writes because the "send_message_on_socket" function closed the connection, see:
It's not the case anymore, see:
Does it work that way by design or is it a bug?
To me, it seems to be a regression (since it worked with version 1.6.2) and it breaks code relying on the mongo gem (e.g. the central logger gem which can be stuck without being able to reconnect, although correctly implementing the retry code described in the driver's documentation).