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

Store server_description_t hostname fields after lowercasing and using a set

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: libmongoc
    • None

      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.

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

              Created:
              Updated: