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

Connection does not prefer its original host

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      pymongo 1.9
    • Backwards Compatibility:
      Fully Compatible

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: