[CDRIVER-4171] Single-threaded server selection should eagerly validate service ID Created: 01/Oct/21  Updated: 31/Mar/22

Status: Backlog
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.19.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-4174 First outgoing command in single-thre... Backlog

 Description   

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.


Generated at Wed Feb 07 21:20:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.