Open wereHamster opened 10 years ago
can you give more details on this? Is this an option that should be set?
Some other mongodb drivers have an option, called something like auto_reconnect
, which will instruct the driver to automatically reconnect to the server if the connection goes down (due to server restart, or when a replica set elects a new master).
Examples from other drivers:
Why not always attempt to automatically re-connect? I am wondering if this is functionality that can be built into resource-pool rather than mongoDB. Probably should switch to resource-pool before trying to implement this.
Automatic reconnect by default? That would work for me as well :)
I saw this in my error logs:
PersistMongoDBError "ConnectionFailure <socket: 4>: hGetBuf: resource vanished (Connection reset by peer)"
Is that what you saw also? (Minus the Persist wrapper if you aren't using persistent)
I don't have access the the logs anymore. But the symptom was that after I restarted, the application didn't work anymore.
after you restarted the database?
Oh, I deleted too much text while editing the comment, should have read 'after I restarted mongodb, the app...'
I was easily able to write a one-off for mongodb-queue that does this
https://github.com/docmunch/haskell-mongodb-queue/blob/master/Database/MongoDB/Queue.hs#L158
It would be nice to have this option so that the driver automatically reconnects to the server if the connection goes down.