mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-53830: fix flaky race in replica_set_monitor_integration_test
This commit is contained in:
parent
31c6ccd2a3
commit
fdfc0daa5e
@ -173,13 +173,15 @@ TEST_F(ReplicaSetMonitorFixture, ReplicaSetMonitorCleanup) {
|
|||||||
auto sets = ReplicaSetMonitorManager::get()->getAllSetNames();
|
auto sets = ReplicaSetMonitorManager::get()->getAllSetNames();
|
||||||
ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) == sets.end());
|
ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) == sets.end());
|
||||||
|
|
||||||
Mutex mutex;
|
auto mutex = MONGO_MAKE_LATCH("ReplicaSetMonitorCleanup");
|
||||||
|
stdx::condition_variable cv;
|
||||||
bool cleanupInvoked = false;
|
bool cleanupInvoked = false;
|
||||||
auto rsm =
|
auto rsm = ReplicaSetMonitorManager::get()->getOrCreateMonitor(replSetUri,
|
||||||
ReplicaSetMonitorManager::get()->getOrCreateMonitor(replSetUri, [&cleanupInvoked, &mutex] {
|
[&cleanupInvoked, &mutex, &cv] {
|
||||||
stdx::lock_guard<Latch> lk(mutex);
|
stdx::unique_lock lk(mutex);
|
||||||
cleanupInvoked = true;
|
cleanupInvoked = true;
|
||||||
});
|
cv.notify_one();
|
||||||
|
});
|
||||||
|
|
||||||
sets = ReplicaSetMonitorManager::get()->getAllSetNames();
|
sets = ReplicaSetMonitorManager::get()->getAllSetNames();
|
||||||
ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) != sets.end());
|
ASSERT_TRUE(std::find(sets.begin(), sets.end(), setName) != sets.end());
|
||||||
@ -187,7 +189,8 @@ TEST_F(ReplicaSetMonitorFixture, ReplicaSetMonitorCleanup) {
|
|||||||
shutdownExecutor();
|
shutdownExecutor();
|
||||||
rsm.reset();
|
rsm.reset();
|
||||||
|
|
||||||
stdx::lock_guard<Latch> lk(mutex);
|
stdx::unique_lock lk(mutex);
|
||||||
|
cv.wait(lk, [&cleanupInvoked] { return cleanupInvoked; });
|
||||||
ASSERT_TRUE(cleanupInvoked);
|
ASSERT_TRUE(cleanupInvoked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user