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

getmore explicitly sets readPreference to primary even when connection set secondary

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.10
    • Affects Version/s: 3.9
    • Component/s: Wire Protocol
    • Labels:
      None
    • Environment:
      mac osx, linux

      With pymongo 3.6, getMore requests do not explicitly set a readPreference. With version 3.9, getMore specifically sets readPreference to primary even when the connection sets secondary or secondaryPreferred. I didn't specifically test versions greater than 3.6 and less than 3.9, so I am not sure when this change was introduced.

      Snippet to reproduce:

      import pymongo
      
      client = pymongo.MongoClient(port=27017, readPreference="secondary")
      database = "db"
      collection_name = "has_more_than_101_documents"
      collection = client.db.collection_name
      
      docs = list(collection.find({}).limit(102))
      print(len(docs))
      

      With 3.6, the getMore contains no readPreference setting.

      With 3.9, the getMore contains $readPreference mode:primary, even when the initial cursor set secondary.

      Consider changing this behavior such that the getMore requests respect the readPreference set by the cursor.
       

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            clyon@evergage.com Cliff Lyon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: