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.
- is caused by
-
PYTHON-2544 Drivers should not inspect error messages for "not master" or "node is recovering"
- Closed
- is duplicated by
-
MOTOR-861 Spec test for prefer-error-code.yml needs to contain "not master"
- Closed
- split from
-
DRIVERS-1990 Spec test for prefer-error-code.yml needs to contain "not master"
- Implementing