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

find_one with sort and PRIMARY_PREFERRED returning no output

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.0
    • 3.0.1
    • None
    • None
    • pymongo==3.0.1-2-81549e

    Description

      This is a really strange one...

      When connecting through a mongos, I'm seeing an issue where find_one with PRIMARY_PREFERRED doesn't return any output.

      c = ...some_collection ...
      c.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED)
      c.find_one({'symbol': symbol}, sort=[('version', pymongo.DESCENDING)])
      

      returns None. Whereas:

      c.find_one({'symbol': symbol})
      

      return an item.

      len(list(c.find({'symbol': symbol}))
      Out[76]: 25
       
      In [79]: [x for x in list(c.find({'symbol': symbol})) if x is None]
      Out[79]: []
      

      Note a normal find finds nothing too.

      In [84]: c = lib._versions.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED)
      In [85]: len(list(c.find({'symbol': symbol}, sort=[('version', pymongo.DESCENDING)])))
      Out[85]: 0
      

      If I change the read-preference, it works!

      In [82]: c = lib._versions.with_options(read_preference=ReadPreference.PRIMARY)
      In [83]: len(list(c.find({'symbol': symbol}, sort=[('version', pymongo.DESCENDING)])))
      Out[83]: 25
      

      Attachments

        Issue Links

          Activity

            People

              bernie@mongodb.com Bernie Hackett
              jblackburn James Blackburn
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: