[CDRIVER-3653] Connections should use server descriptions from handshake, not monitoring Created: 06/May/20  Updated: 28/Oct/23  Resolved: 18/Jul/21

Status: Closed
Project: C Driver
Component/s: libmongoc, network
Affects Version/s: None
Fix Version/s: 1.19.0

Type: Bug Priority: Major - P3
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by PHPC-1979 Use mongoc_client_get_handshake_descr... Closed
is depended on by PHPC-1926 Utilize mongoc_client_get_handshake_d... Closed
Duplicate
is duplicated by CDRIVER-3475 Determine wire version and size limit... Closed
Related
related to CDRIVER-4077 OP_KILLCURSORS incorrectly used to de... Backlog
related to CDRIVER-3563 Cursor may use an invalidated server ... Closed
is related to NODE-4853 Retryability eligibility should be de... Backlog
Epic Link: Load Balancer Support
Quarter: FY22Q2

 Description   

When a stream is fetched for an operation, libmongoc fetches the server description from the topology description and uses that metadata for wire version checks, checking for supported compression.

This is explicitly discouraged by SDAM's Warning about the maxWireVersion from a monitor's ismaster response and may make the driver susceptible to racy comparisons. For example:

1. Thread 1 runs an insert. This creates a stream, performs a handshake, creates a
cluster node, and proceeds to insert.
2. Later, thread 1 begins another insert operation. It selects the primary, but just before it calls _mongoc_cluster_stream_for_server...
3. Thread 2 runs an insert, gets a network error, and marks the server as Unknown.
4. Thread 1 continues, and creates a server stream with an Unknown server description. Any wire version checks it does will check with wire version 0.

We've seen bugs of this type before, example: CDRIVER-3404.

It seems like there was at least some intention to fix this at some point. mongoc_cluster_node_t has its own copies of max_wire_version, min_wire_version, max_write_batch_size, max_bson_obj_size, and max_msg_size. But those fields are unused.



 Comments   
Comment by Githook User [ 18/Jul/21 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: CDRIVER-3653 use handshake metadata for connection checks (#822)

Comment by Kevin Albertson [ 14/Jul/21 ]

PR: https://github.com/mongodb/mongo-c-driver/pull/822

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