summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordi Serra Torrens <jordi.serra-torrens@mongodb.com>2023-08-23 16:16:06 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-09-28 09:15:13 +0000
commitf797f841eaf1759c770271ae00c88b92b2766eed (patch)
tree2683e23292a1b6553c0f88dd7ef7f21083c9df32
parent1241f9610e0d3625b921647653daaec48e691a46 (diff)
SERVER-79781 Fix race in TestGetDestinedRecipientThrowsOnBlockedRefresh unit testr6.0.11-rc0r6.0.11
(cherry picked from commit 2c65a6bf8b42426701f22f0a5e80ab3a0e1dc334) (cherry picked from commit d5345c16735c9ca8ac8dc364157db9e2eddff7e7)
-rw-r--r--src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp26
-rw-r--r--src/mongo/db/s/shard_server_test_fixture.cpp3
2 files changed, 12 insertions, 17 deletions
diff --git a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp
index 28f10ae9143..653d99143f9 100644
--- a/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_destined_recipient_test.cpp
@@ -310,22 +310,18 @@ TEST_F(DestinedRecipientTest, TestGetDestinedRecipientThrowsOnBlockedRefresh) {
auto opCtx = operationContext();
auto env = setupReshardingEnv(opCtx, false);
- {
- AutoGetCollection coll(opCtx, kNss, MODE_IX);
- OperationShardingState::setShardRole(opCtx, kNss, env.version, env.dbVersion);
-
- FailPointEnableBlock failPoint("blockCollectionCacheLookup");
- ASSERT_THROWS_WITH_CHECK(ShardingWriteRouter(opCtx, kNss, Grid::get(opCtx)->catalogCache()),
- ShardCannotRefreshDueToLocksHeldException,
- [&](const ShardCannotRefreshDueToLocksHeldException& ex) {
- const auto refreshInfo =
- ex.extraInfo<ShardCannotRefreshDueToLocksHeldInfo>();
- ASSERT(refreshInfo);
- ASSERT_EQ(refreshInfo->getNss(), env.tempNss);
- });
- }
+ AutoGetCollection coll(opCtx, kNss, MODE_IX);
+ OperationShardingState::setShardRole(opCtx, kNss, env.version, env.dbVersion);
- auto sw = catalogCache()->getCollectionRoutingInfoWithRefresh(opCtx, env.tempNss);
+ FailPointEnableBlock failPoint("blockCollectionCacheLookup");
+ ASSERT_THROWS_WITH_CHECK(ShardingWriteRouter(opCtx, kNss, Grid::get(opCtx)->catalogCache()),
+ ShardCannotRefreshDueToLocksHeldException,
+ [&](const ShardCannotRefreshDueToLocksHeldException& ex) {
+ const auto refreshInfo =
+ ex.extraInfo<ShardCannotRefreshDueToLocksHeldInfo>();
+ ASSERT(refreshInfo);
+ ASSERT_EQ(refreshInfo->getNss(), env.tempNss);
+ });
}
TEST_F(DestinedRecipientTest, TestOpObserverSetsDestinedRecipientOnInserts) {
diff --git a/src/mongo/db/s/shard_server_test_fixture.cpp b/src/mongo/db/s/shard_server_test_fixture.cpp
index fe4de75a820..05bd61a4022 100644
--- a/src/mongo/db/s/shard_server_test_fixture.cpp
+++ b/src/mongo/db/s/shard_server_test_fixture.cpp
@@ -85,9 +85,8 @@ void ShardServerTestFixture::setCatalogCacheLoader(std::unique_ptr<CatalogCacheL
}
void ShardServerTestFixture::tearDown() {
- CatalogCacheLoader::clearForTests(getServiceContext());
-
ShardingMongodTestFixture::tearDown();
+ CatalogCacheLoader::clearForTests(getServiceContext());
}
std::unique_ptr<ShardingCatalogClient> ShardServerTestFixture::makeShardingCatalogClient() {