getmore explicitly sets readPreference to primary even when connection set secondary

XMLWordPrintableJSON

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

      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
              Reporter:
              Cliff Lyon
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: