summaryrefslogtreecommitdiff
path: root/src/mongo/client/replica_set_monitor.h
diff options
context:
space:
mode:
authorAndrew Shuvalov <andrew.shuvalov@mongodb.com>2020-11-19 18:40:54 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-08 17:14:50 +0000
commitf3a221e769527f1709dae21e832729da52af6e83 (patch)
tree9f8a0987f873d3086b1cf8fb4a484bc68f4758cb /src/mongo/client/replica_set_monitor.h
parent387db376255427ec3bae648f7529d9d6e56dd64e (diff)
downloadmongo-f3a221e769527f1709dae21e832729da52af6e83.tar.gz
SERVER-50467: Ensure that tenant migration donor only removes a ReplicaSetMonitor for a recipient when the last migration to that recipient completes
Diffstat (limited to 'src/mongo/client/replica_set_monitor.h')
-rw-r--r--src/mongo/client/replica_set_monitor.h25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/mongo/client/replica_set_monitor.h b/src/mongo/client/replica_set_monitor.h
index 9472ae2d241..532ee1d520a 100644
--- a/src/mongo/client/replica_set_monitor.h
+++ b/src/mongo/client/replica_set_monitor.h
@@ -52,7 +52,7 @@ namespace mongo {
*/
class ReplicaSetMonitor : public ReplicaSetMonitorInterface {
public:
- ~ReplicaSetMonitor() override = default;
+ ~ReplicaSetMonitor() override;
/**
* Creates a new ReplicaSetMonitor, if it doesn't already exist.
@@ -70,9 +70,14 @@ public:
static std::shared_ptr<ReplicaSetMonitor> get(const std::string& name);
/**
- * Removes the ReplicaSetMonitor for the given set name from _sets, which will delete it.
- * If clearSeedCache is true, then the cached seed std::string for this Replica Set will be
- * removed from _seedServers.
+ * Removes the ReplicaSetMonitor for the given set name from ReplicaSetMonitorManager.
+ * Drop and remove the ReplicaSetMonitor for the given set name if it exists.
+ * Then all connections for this host are deleted from the connection pool DBConnectionPool.
+ * Those two steps are not performed atomically together, but the possible (unlikely) race:
+ * 1. RSM is dropped and removed
+ * 2. Another RSM is created for the same name
+ * 3. Pooled connections are cleared
+ * is not creating any incorrectness, it is only inefficient.
*/
static void remove(const std::string& name);
@@ -92,6 +97,18 @@ public:
* Permanently stops all monitoring on replica sets.
*/
static void shutdown();
+
+protected:
+ explicit ReplicaSetMonitor(const std::function<void()> cleanupCallback);
+
+private:
+ /**
+ * @return callback helper to safely cleanup 'ReplicaSetMonitor' and 'globalConnPool' when the
+ * instance of ReplicaSetMonitor for the 'name' is being destroyed.
+ */
+ static std::function<void()> _getCleanupCallback(StringData name);
+
+ const std::function<void()> _cleanupCallback;
};
} // namespace mongo