-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
This is an umbrella task to keep track of all smaller tasks to accomplish the refactoring.
UPDATE: hopefully we don't need TTL. I will rename or delete this ticket when it's more clear. For now it holds the list of other tickets needed for refactoring, below.
The problem: the lifetime if the ReplicaSetMonitor is managed by the shared_ptr. The ownership graph has circular dependencies (like _eventsPublisher and TopologyListenerPtr) that prevent the instance to be deleted. At the same time, breaking those circular dependencies by replacing a listener with weak_ptr is making the RSM to be deleted too fast.
The solution: convert the ReplicaSetMonitor factory and ReplicaSetMonitorManager to cache with TTL:
- Do not have a strict refcounting delete policy, have a lazy delete with TTL (about 1 hour or so)
- Make the callers to not keep the reference for a while, even use a weak pointer when possible. TTL will prevent the immediate deletion
- Remove the get() method, so an entry in the cache is always recreated. With 1 hour TTL it is guaranteed that each record is recreated not more often than once per hour, so the cost is very low
- Thus we still have the remove() method that clears the entry from cache immediately, and the dangling references will delete the instance soon, however we cannot force it to terminate immediately. I think the remove() should set a flag in the instance that it should terminate asap
In the tests, set TTL to be short, like 10 seconds.
- depends on
-
SERVER-50189 Replace ReplicaSetMonitorManager::removeMonitor with a custom deleter for shared_ptr<ReplicaSetMonitor>
- Backlog
-
SERVER-50467 Ensure that tenant migration donor only removes a ReplicaSetMonitor for a recipient when the last migration to that recipient completes
- Closed
-
SERVER-51413 RemoteCommandTargeterRS custom deleter in TenantMigrationDonorService::Instance::run does not need to capture 'this' or 'self'
- Closed
-
SERVER-51441 Get rid of ReplicaSetMonitor::get()
- 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-51480 Clear circular dependency of shared_ptr in StreamableReplicaSetMonitor by changing the TopologyListenerPtr
- Closed
- is related to
-
SERVER-50189 Replace ReplicaSetMonitorManager::removeMonitor with a custom deleter for shared_ptr<ReplicaSetMonitor>
- Backlog
- related to
-
SERVER-49789 Make tenant migration donor use a StreamableReplicaSetMonitor to monitor and send commands to the recipient
- Closed