[CDRIVER-3621] The topology description should be protected be a read-write lock instead of a mutex Created: 14/Apr/20  Updated: 27/Oct/23  Resolved: 24/Jan/22

Status: Closed
Project: C Driver
Component/s: SDAM
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Improve Developer Experience
Case:

 Description   

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.



 Comments   
Comment by Rachelle Palmer [ 13/Jan/22 ]

Asking for re-triage since CDRIVER-4002 is now closed.

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