-
Type:
Improvement
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Cluster Management
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When the driver is configured with either a list of servers in a replica set or a list of mongos servers, it should be more responsive to changes in the state of the servers its connected to. Currently there is a single background thread which, every five seconds by default, loops through all the servers, calling isMaster on each to determine its state (whether it's up at all, whether it's a primary or a secondary, what tags it has, its set version). Now let's say the primary server crashes. The next time through the loop, there might already be a new primary elected, but because the thread also tries to connect to the crashed server, it doesn't update its state to the new primary until the connect timeout is reached on the crashed server.
The proposed change here is to dedicate multiple threads to this monitoring task (using a fixed thread pool executor service). With this change, the cluster state can be updated as soon as any server is able to report its status, without waiting for connections to unreachable servers to time out.
Furthermore, application threads should ask the cluster monitor for the current primary on every single use, instead of waiting for the first failure, as is the case now.
- is duplicated by
-
JAVA-438 Block writes when "not master" occurs
-
- Closed
-