SERVER-105213 Remove ConcurrentCatalogWriteBatchingMayThrow test case (#36412)

GitOrigin-RevId: 709453c95d0f4821a616c3abaf069453f5b9a907
This commit is contained in:
Jordi Serra Torrens 2025-05-22 17:58:45 +02:00 committed by MongoDB Bot
parent e13c9f04e6
commit 610a50fa44
1 changed files with 0 additions and 62 deletions

View File

@ -353,67 +353,5 @@ TEST_F(CollectionWriterTest, AutoGetOplogFastPathkLogOpObjectStabilityConcurrent
getServiceContext(), operationContext(), OplogAccessMode::kLogOp);
}
/**
* This test uses a catalog with a large number of collections to make it slow to copy. The idea
* is to trigger the batching behavior when multiple threads want to perform catalog writes
* concurrently. The batching works correctly if the threads all observe the same catalog
* instance when they write. If this test is flaky, try to increase the number of collections in
* the catalog setup.
*/
class CatalogReadCopyUpdateTest : public CatalogTestFixture {
public:
// Number of collection instances in the catalog. We want to have a large number to make the
// CollectionCatalog copy constructor slow enough to trigger the batching behavior. All threads
// need to enter CollectionCatalog::write() to be batched before the first thread finishes its
// write.
static constexpr size_t NumCollections = 50000;
void setUp() override {
CatalogTestFixture::setUp();
Lock::GlobalWrite lk(operationContext());
CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& catalog) {
for (size_t i = 0; i < NumCollections; ++i) {
catalog.registerCollection(
operationContext(),
std::make_shared<CollectionMock>(NamespaceString::createNamespaceString_forTest(
"many", fmt::format("coll{}", i))),
/*ts=*/boost::none);
}
});
}
};
TEST_F(CatalogReadCopyUpdateTest, ConcurrentCatalogWriteBatchingMayThrow) {
// Start threads and perform write that will throw at the same time
constexpr int32_t NumThreads = 4;
unittest::Barrier barrier(NumThreads);
AtomicWord<int32_t> threadIndex{0};
auto job = [&]() {
auto index = threadIndex.fetchAndAdd(1);
barrier.countDownAndWait();
try {
CollectionCatalog::write(getServiceContext(),
[&](CollectionCatalog& writableCatalog) { throw index; });
// Should not reach this assert
ASSERT(false);
} catch (int32_t ex) {
// Verify that we received the correct exception even if our write job executed on a
// different thread
ASSERT_EQ(ex, index);
}
};
std::array<stdx::thread, NumThreads> threads;
for (auto&& thread : threads) {
thread = stdx::thread(job);
}
for (auto&& thread : threads) {
thread.join();
}
}
} // namespace
} // namespace mongo