Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-218

Connection does not prefer its original host

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Environment:
      pymongo 1.9
    • Fully Compatible

      The Connection is initialized to a single host (and port), which is inserted into the set Connection.__nodes. When the connection negotiates with the server, it populates __nodes with the other hosts in the replica set.

      The problem occurs when we want to maintain load balancing across the read slaves of a MasterSlaveConnection. If a Connection disconnects for any reason, it fails over to whatever host it can connect to from the __nodes set. However, if the connection is purposefully reset through a Connection.disconnect(), such as when we're trying to re-balance the read slaves, it no longer prefers the original host and port because it will connect in whatever order the __nodes iterator returns them in. This means that the only option is to remove the Connection from the slave list and replace it with a fresh Connection pointed to the desired read slave.

      Generally speaking, the Connection should try to connect to the host and port it was originally configured for, and only failover to other hosts in the __nodes list as necessary. I marked this as a "major improvement" because it would add deterministic behavior to a case that could have a major impact on infrastructure scalability.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            aaron.westendorf Aaron Westendorf
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: