jnunemaker/mongomapper — Issue #331: Mongo Mapper not auto reconnecting
Author: jknipp
Created: 2011-10-25 20:41:05+00:00
State: open

When my Mongo DB server goes down, Mongo Mapper tries to use the existing connection. Only after the second request to connect is Mongo Mapper able to complete the request.

Test Scenario:

Preqrequisite:
MongoDB Server running

From a Rails app or console, make call to a Mongo Mapper object to verify a connection is ok. Shutdown and restart Mongo DB. Attempt same same Rails action again, this time Mongo Mapper will not be connected and no error is thrown. Trying a second time will make the re-establish the connection.

Environment:

Windows 7
JRuby 1.6.2
Java 1.6

mongo.yml

defaults: &defaults
host: 127.0.0.1
port: 27017

development:
<<: *defaults
database: dev

test:
<<: *defaults
database: test

# set these environment variables on your prod server
production:
<<: *defaults
database: prod
username: <%= ENV['MONGO_USERNAME'] %>
password: <%= ENV['MONGO_PASSWORD'] %>