Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-101078

Do not close connection sending loadBalanced:true in mongod

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • 8.1 Required
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Security
    • ALL

      Summary

      When a non-load-balanced mongod receives a loadBalanced:true in the hello command, do not close the connection.

      Background & Motivation

      Drivers expect a non-load-balanced server to accept loadBalanced:true, and instead raise a driver-side error. From spec:

      When the server's hello response does not contain a serviceId field, the driver MUST throw an exception with the message "Driver attempted to initialize in load balancing mode, but the server does not support this mode."

      On latest 8.1 builds, mongod appears to close the connection. With a non-LB server:

      $ mongosh --eval "db.version()"
      8.1.0-alpha0-451-gde379ff
      $ mongosh "mongodb://localhost:27017/?loadBalanced=true"  --eval "db.runCommand({'ping': 1})"
      MongoNetworkError: connection 5 to 127.0.0.1:27017 closed
      

      Compared with an 8.0 server:

      $ mongosh --eval "db.version()"
      8.0.5-rc2
      $ mongosh "mongodb://localhost:27017/?loadBalanced=true"  --eval "db.runCommand({'ping': 1})"
      MongoCompatibilityError: Driver attempted to initialize in load balancing mode, but the server does not support this mode.
      

      Latest 8.1 builds failed this driver test expecting the driver-side error. I expect the connection close is caused by this error check added to mongod in SERVER-85804.

      This ticket requests restoring the old behavior (i.e. do not close connection). The driver-side error seems more informative than a connection close. Not closing a connection seems consistent with mongos behavior.

      See also: slack conversation.

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

              Created:
              Updated: