PyMongo does not publish Server or Topology change events for "Network error when reading or writing" or "not master" and "node is recovering"

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 3.11
    • Affects Version/s: None
    • Component/s: Monitoring
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      When application operations fail with network errors or not master errors, we reset the server to Unknown according to the rules in SDAM Error Handling section. However pymongo does not publish any ServerDescriptionChangedEvent or TopologyDescriptionChangedEvent:
      https://github.com/mongodb/mongo-python-driver/blob/3.10.1/pymongo/topology.py#L552-L554

          def _reset_server(self, address, reset_pool):
      ...
                  # Mark this server Unknown.
                  self._description = self._description.reset_server(address)
                  self._update_servers()
      

      We should mark the server unknown like this:

          def _reset_server(self, address, reset_pool):
      ...
                  # Mark this server Unknown.
                  unknown_sd = ServerDescription(address)
                  self._process_change(unknown_sd)
      

      _process_change automatically handles the event publishing.

            Assignee:
            Shane Harvey
            Reporter:
            Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: