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

Client does not mark server unknown after "not master" error without a code

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0
    • Affects Version/s: None
    • Component/s: Spec Comp
    • None

      PYTHON-2544 change pymongo to never inspect NotPrimary type error messages when a code exists. While investigating PYTHON-2773 we've identified a bug where pymongo does not mark a server unknown after receiving a "not master" error without a code:

       python -m unittest discover -v -k test_not_master_command
      test_not_master_command (test_reset_and_request_check.TestResetAndRequestCheck) ... FAIL
      
      ======================================================================
      FAIL: test_not_master_command (test_reset_and_request_check.TestResetAndRequestCheck)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/Users/shane/git/mongo-python-driver/test/mockupdb/test_reset_and_request_check.py", line 121, in test
          test_method(self, operation)
        File "/Users/shane/git/mongo-python-driver/test/mockupdb/test_reset_and_request_check.py", line 116, in _test_not_master
          self.assertGreater(after, before, 'ismaster not called')
      AssertionError: 1637196202.716165 not greater than 1637196202.716165 : ismaster not called
      
      ----------------------------------------------------------------------
      Ran 1 test in 1.111s
      
      FAILED (failures=1)
      

      Where the error is defined as:

      # EG: {"ok": 0, "errmsg": "not master"}
      not_master_reply = OpMsgReply(ok=0, errmsg='not master')
      

      I believe the bug is that we raise NotPrimaryError in helpers.py correctly but Topology._handle_error() ignores the exception because the error code does not exist.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: