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

The topology description should be protected be a read-write lock instead of a mutex

    • Type: Icon: Improvement Improvement
    • Resolution: Gone away
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: SDAM
    • Labels:
      None

      The mutex on mongoc_topology_t is locked and unlocked at a rather coarse level.

      • when reading or writing to the topology description
      • it remains locked for the duration of SRV polling
      • it is locked when accessing shared state of the mongoc_topology_scanner_t (e.g. the cached cluster time)
      • it is locked when setting up a mongoc_topology_scanner_node_t. Which means it remains locked during blocking DNS lookup.

      A potentially big problem with this is that application threads need to lock the topology mutex during server selection when reading the topology description.

      CDRIVER-3535 may reduce the situations where the topology lock is held. But a read-write lock still seems like a sensible improvement for the topology description. If a client is performing many operations, the topology description will be read much more than it is written too.

      Before making this change, let's validate with some form of benchmarking that this is really a point of contention that could be improved by a read-write lock.

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

              Created:
              Updated:
              Resolved: