Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-961

Support serverSelectionTryOnce in multi-threaded drivers

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: SDAM
    • None

      The current spec indicates that single-threaded drivers must implement serverselectiontryonce but multi-threaded drivers must not.

      There's benefit in implementing serverselectiontryonce in multi-threaded drivers as well so they can fail fast in case the server isn't running.
      Using a low serverSelectionTimeout isn't sufficient as we need to distinguish between a case in which the server is actually down (where the dialer returns connection refused) or the connection is closed and other cases in which the server is simply slow to respond.

      Current workarounds are a bit cumbersome - for example when working with the Go Driver we were able to workaround this using the following approaches:
      1. Connect to the host:port with a simple TCP dialer before we attempt to Connect/Ping using the driver
      2. Pass on a custom dialer with a cancel function and invoke the cancel function if we hit "connection refused"

      To highlight the benefit of this (on top of cleaner code) - this is expected to introduce a significant performance boost to the MongoDB agent, especially in large clusters deployments

            Assignee:
            rachelle.palmer@mongodb.com Rachelle Palmer
            Reporter:
            tomer.yakir@mongodb.com Tomer Yakir
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: