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

Can't use mongos for secondary reads in Sharded mode

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0
    • Affects Version/s: 3.0
    • Component/s: None
    • Labels:
      None

      Bug in unreleased PyMongo 3 code. With mongoses on ports 1031 and 1032, using PyMongo on master, git hash 54b52f2abd3:

      >>> from pymongo import MongoClient
      >>> client = MongoClient('mongodb://localhost:1031,localhost:1032')
      >>> # wait a moment...
      ...
      >>> client.is_mongos
      True
      >>> client.nodes
      frozenset([('localhost', 1031), ('localhost', 1032)])
      >>> client.database.collection.find_one() is None
      True
      
      >>> from pymongo import ReadPreference
      >>> client.get_database('database', 
      ...    read_preference=ReadPreference.SECONDARY).collection.find_one()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "pymongo/collection.py", line 772, in find_one
          for result in cursor.limit(-1):
        File "pymongo/cursor.py", line 977, in __next__
          if len(self.__data) or self._refresh():
        File "pymongo/cursor.py", line 914, in _refresh
          self.__codec_options))
        File "pymongo/cursor.py", line 822, in __send_message
          **kwargs)
        File "pymongo/mongo_client.py", line 804, in _send_message_with_response
          server = topology.select_server(selector)
        File "pymongo/topology.py", line 113, in select_server
          server_selection_timeout))
        File "pymongo/topology.py", line 93, in select_servers
          self._error_message(selector))
      pymongo.errors.ServerSelectionTimeoutError: No mongoses match selector "Secondary(tag_sets=None)"
      

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

              Created:
              Updated:
              Resolved: