-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Replication, Sharding
-
Cluster Scalability
-
Sharding 2020-08-24
-
3
ReplicaSetMonitorManager stores ReplicaSetMonitors by weak_ptr so that the ReplicaSetMonitor is destroyed when the last shared_ptr reference to it goes out of scope.
However, ReplicaSetMonitorManager also has a removeMonitor function, which currently the holder of the last shared_ptr reference has to call to remove the entry for the ReplicaSetMonitor from the ReplicaSetMonitorManager's map.
Instead, the shared_ptr to ReplicaSetMonitor could be created with a custom deleter that removes the entry from the map, like:
std::shared_ptr<Foo> sh5(new Foo, [](auto p) { std::cout << "Call delete from lambda...\n"; delete p; });
See also https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr.
There are a couple complications:
- We probably still want to remove the hosts from the connection pool, which ReplicaSetMonitor::remove currently does.
- There are two implementations of ReplicaSetMonitor, and the Streamable implementation has a factory method to create its monitors.
- is depended on by
-
SERVER-51440 Cleanup refcounting and lifetime of ReplicaSetMonitor
- Closed
- related to
-
SERVER-50093 Test that donor supports running multiple tenant migrations concurrently
- Closed
-
SERVER-50467 Ensure that tenant migration donor only removes a ReplicaSetMonitor for a recipient when the last migration to that recipient completes
- Closed
-
SERVER-51442 ShardRegistry should handle gracefully when ReplicaSetMonitor is deleted
- Closed
-
SERVER-51443 Server should cleanup the ReplicaSetMonitorManager cache when shutting down
- Closed
-
SERVER-51440 Cleanup refcounting and lifetime of ReplicaSetMonitor
- Closed