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

Connection error is misleading when attempting to connect to a slave

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 1.10.1
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None

      Description

      When failing to connect to a MongoDB slave, the pymongo driver reports "could not find master/primary". This error is misleading, since the master/primary wasn't even requested. For example,

      PS C:\Users\jaraco\> python
      Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
      win32
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import pymongo
      >>> pymongo.Connection('doesnotexist.example.net', slave_okay=True)
      Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "c:\python\lib\site-packages\pymongo-1.10.1-py2.7-win-amd64.egg\pymongo\connection.py", line 352, in _init_
      self.__find_master()
      File "c:\python\lib\site-packages\pymongo-1.10.1-py2.7-win-amd64.egg\pymongo\connection.py", line 576, in __find_master
      raise AutoReconnect("could not find master/primary")
      pymongo.errors.AutoReconnect: could not find master/primary

      From the traceback, it appears as if the driver is attempting to "find_master" and fails to do so, but in reality, I know it's simply failing to make a connection to the slave I requested.

      The error message could be improved to not provide misleading information and possibly to provide more detail about which host or hosts failed.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: