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

Single-threaded server selection should eagerly validate service ID

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.19.0
    • Component/s: libmongoc
    • Labels:
      None

      Load Balancer: Connection Establishment states:

      When the server's hello response does not contain a serviceId field, the driver MUST throw an exception

      This does not appear to happen when I'd expect for single-threaded clients in libmongoc.

      mongoc_client_select_server calls mongoc_topology_select, which immediately uses mongoc_topology_select_server_id to obtain a server ID. For a LB topology, that function will only call mongoc_topology_select_server_id_loadbalanced, which does select a node and verify that node->stream is non-null (else we get a "Could not establish stream for node" error). However, that doesn't result in _mongoc_cluster_stream_for_server getting called at all, which is where the validation of service ID takes place.

      In practice, this means there is essentially a second state between server selection and executing an operation where we might have selected a LB but won't realize the service ID is missing until the user executes an operation. Historically, PHP has relied on libmongoc's single-threaded server selection to always initialize the connection(s) (and SDAM, although that doesn't apply for LB topologies). Since executing hello is part of connection establishment, it seems reasonable that we'd also validate the service ID at that point.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: