[CDRIVER-3527] Store server_description_t hostname fields after lowercasing and using a set Created: 09/Feb/20  Updated: 31/Mar/22

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

Type: Task Priority: Minor - P4
Reporter: Kevin Albertson 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-3256 SDAM "changed" events emitted even if... Closed
is related to DRIVERS-944 SDAM spec and monitoring spec tests a... Backlog

 Description   

mongoc_server_description_t stores the server description fields "me", "hosts", "passives", "arbiters", "current_primary", and "connection_address" without modification. But the SDAM spec says:

The same as with seeds provided in the initial configuration, all hostnames in the ismaster response's "me", "hosts", "passives", and "arbiters" entries MUST be lower-cased.

Until addressing the bug CDRIVER-3256, this makes no functional difference, since it appears on usage of those fields they are always compared case insensitively (with strcasecmp). However, CDRIVER-3256 requires implementing an equality comparison function of two server descriptions. Though it is simple to case insensitively compare "me", "connection_address", and "current_primary", comparing the lists "hosts", "passives", and "arbiters" is trickier. They are currently stored as bson_t arrays. To compare them accurately, we'd need to do a set compare (to account for duplicates and different ordering) and after lowercasing.

The consequence of considering two "hosts" lists different if one has a duplicate or different order of entries is not very impactful. For example, if an ismaster reply on a single server reported the same information, but with the "hosts" list in a different order, libmongoc would incorrectly emit a server changed event and topology changed event. That means another, much rarer surfacing of CDRIVER-3256.

We should probably be parsing hosts from the ismaster reply, lowercasing them, and storing the host lists in a mongoc_set_t. Note, mongoc_topology_description_t already stores the server list in a mongoc_set_t.


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