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

Replica set members not in primary/secondary state should not receive reads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.3, 2.4, 2.4.1
    • 2.4.2
    • None
    • None

    Description

      Starting in version 2.3, replica set members that are no longer primary or secondary are not removed from the list of available readers. This was accidentally broken by the read preference changes in this commit:

      https://github.com/mongodb/mongo-python-driver/commit/f275b2291ab080c111ee99f962cff5f89986bbd5

      Specifically this line:

      https://github.com/mongodb/mongo-python-driver/commit/f275b2291ab080c111ee99f962cff5f89986bbd5#L18L942

      self.__readers is ignored by the current selection code.

      Members in state STARTUP2/RECOVERING/etc. are removed from self.__readers in self.__update_pools, but since we no longer use self.__readers these members still receive queries, even after the replica set monitor has run.

      Another issue is that the Members class ignores the 'secondary' field of the ismaster response:

      https://github.com/mongodb/mongo-python-driver/blob/master/pymongo/mongo_replica_set_client.py#L196-L202

      One solution would be to keep track of the actual state of the member (primary/secondary/other) in the Member object and remove self.__readers completely since it is only currently used in a property.

      Attachments

        Issue Links

          Activity

            People

              jesse@mongodb.com A. Jesse Jiryu Davis
              bernie@mongodb.com Bernie Hackett
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: