Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-786

Make driver more proactive about setting the new primary

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.0, 3.0.0
    • Affects Version/s: None
    • Component/s: Cluster Management
    • Labels:
      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.

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: