Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-78828

LDAP host timing data can be inconsistent during sorting

    • Fully Compatible
    • v7.0, v6.0, v5.0, v4.4
    • Security 2023-07-24

      When LDAP connection pooling is enabled, the server tracks the average latency for operations on each LDAP host and stores it in a struct called LDAPHostTimingData. This structure is shared between all PooledLDAPConnections that are connected to that particular host and a global LDAPPoolTimingData struct that maintains an unordered map of shared_ptrs to this timing data.

      When these shared_ptrs are accessed via the LDAPPoolTimingData map, they are synchronized via a mutex. They are only used in this context for reads. However, writes to each LDAPHostTimingData occur from within the PooledLDAPConnections themselves, which do not use that mutex to synchronize their writes with reads.

      As a result, it is possible for the comparator used in this stable sort to become inconsistent as values are updated while the comparator is being called by the sorting algorithm. std::stable_sort causes undefined behavior if the comparator does not return deterministic answers throughout the lifetime of the sort, and it's very possible that this is responsible for some crashes that have been seen during this sort in HELP tickets.

            Assignee:
            varun.ravichandran@mongodb.com Varun Ravichandran
            Reporter:
            varun.ravichandran@mongodb.com Varun Ravichandran
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: