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

Provide diagnostic information in ServerSelectionTimeoutError exception message

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.11
    • None

    Description

      In https://github.com/rueckstiess/mtools/issues/691#issuecomment-590933618 I am getting a ServerSelectionTimeoutError from the Python driver, as used by mlaunch. The error produced is:

      [2020/02/24 18:21:34.359] pymongo.errors.ServerSelectionTimeoutError: No replica set members match selector "Primary()"
      

      This error provides just about no assistance in determining and resolving the problem.

      The Ruby driver produces the following message when server selection fails:

      Mongo::Error::NoServerAvailable (No primary server is available in cluster: #<Cluster topology=ReplicaSetNoPrimary[ip-10-1-1-165:27017,ip-10-1-1-11.ap-northeast-1.compute.internal:27017,ip-10-1-1-135.ap-northeast-1.compute.internal:27017,name=mongoTest,v=29,e=7fffffff0000000000000013] servers=#<Server address=ip-10-1-1-165:27017 SECONDARY replica_set=mongoTest>,#<Server address=ip-10-1-1-11.ap-northeast-1.compute.internal:27017 UNKNOWN>,#<Server address=ip-10-1-1-135.ap-northeast-1.compute.internal:27017 SECONDARY replica_set=mongoTest>> with timeout=30, LT=0.015. The following servers have dead monitor threads: #<Server address=ip-10-1-1-165:27017 SECONDARY replica_set=mongoTest>, #<Server address=ip-10-1-1-11.ap-northeast-1.compute.internal:27017 UNKNOWN>, #<Server address=ip-10-1-1-135.ap-northeast-1.compute.internal:27017 SECONDARY replica_set=mongoTest>)
      

      This message provides the following information:

      1. Addresses of all the servers in the cluster.
      2. The state of each server.
      3. Server selection timeout used.

      As a result, it is much easier for the user to identify the reason for the failure and subsequently address it.

      Please consider adding similar diagnostics to the Python driver.

      Attachments

        Issue Links

          Activity

            People

              julius.park@mongodb.com Julius Park
              oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: