-
Type: Improvement
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
We've seen the master be unable to contact the secondary nodes, so it steps down (and a new master is elected). When this happens, the driver's existing connection suddenly becomes "not master", and throws an error on the next read/write. We'd like the mongo driver to handle (catch error and retry) this instead of bubbling it up to the application level (and having to patch every application.
Our current approach is to actually wrap the methods on Collection/Cursor. We originally tried to handle this on the Connection object directly, but this lead to an unmaintainable fork. If you were to add this directly to the driver, it might be a fine way to approach the problem. We tried to wrap the methods on Collection/Cursor per Kyle Banker's suggestion. Here is the code we are using. https://gist.github.com/d5ea38c973abdaddeeb0
This kind of thing should be turned off by default, but could be configured if the user of the driver wanted this sort of behavior.
- depends on
-
RUBY-456 Read Semantics Update for MongoDB 2.2
- Closed
- is duplicated by
-
RUBY-256 Build automatic failover into the driver when possible
- Closed
- related to
-
RUBY-384 Using a ReplSetConnection raises an exception when a secondary node restarts, even though read secondary is set to false
- Closed