Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3451

Do not block for connectTimeoutMS when connecting if serverSelectionTimeoutMS exceeded for single-threaded client

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: libmongoc, network, SDAM
    • None

      Currently, attempting to establish a connection to a server will block for connectTimeoutMS, potentially exceeding the overall timeout of serverSelectionTimeoutMS. This causes some surprising behavior. For example the following connection attempt blocks for 5 seconds:

      example-client "mongodb://1.1.1.1:12345/?serverSelectionTryOnce=false&serverSelectionTimeoutMS=1000&connectTimeoutMS=5000"
      

      Strictly speaking, this might be compliant with the server selection spec:

      Because single-threaded selection can do a blocking immediate check, serverSelectionTimeoutMS is not a hard deadline. The actual maximum server selection time for any given request can vary from serverSelectionTimeoutMS minus minHeartbeatFrequencyMS to serverSelectionTimeoutMS plus the time required for a blocking scan.

      But libmongoc does not make a blocking connection, even for single threaded clients, and should be able to cap the timeout of connecting (probably here).

            Assignee:
            Unassigned Unassigned
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: