summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2021-09-21 14:37:24 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-21 15:36:09 +0000
commitbf407b88c0641ba62d7dd29b2bfd973bfbe67667 (patch)
treea298bd6162f2bca9143316f4b702f3136d604abf
parent5f5f4ede9151d2da43a92145e3b3b6f735a09d43 (diff)
downloadmongo-bf407b88c0641ba62d7dd29b2bfd973bfbe67667.tar.gz
SERVER-60057 Remove ConcurrentCatalogWriteBatches test
-rw-r--r--src/mongo/db/catalog/collection_writer_test.cpp62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/mongo/db/catalog/collection_writer_test.cpp b/src/mongo/db/catalog/collection_writer_test.cpp
index dcacde6cdf6..f1d74c2e354 100644
--- a/src/mongo/db/catalog/collection_writer_test.cpp
+++ b/src/mongo/db/catalog/collection_writer_test.cpp
@@ -277,68 +277,6 @@ public:
}
};
-TEST_F(CatalogReadCopyUpdateTest, ConcurrentCatalogWriteBatches) {
- // Start threads and perform write at the same time, record catalog instance observed
- constexpr int32_t NumThreads = 4;
-
- unittest::Barrier barrier(NumThreads);
- std::array<const CollectionCatalog*, NumThreads> catalogInstancesObserved;
- std::array<NamespaceString, NumThreads> namespacesInserted;
- AtomicWord<int32_t> threadIndex{0};
- auto job = [&]() {
- // Determine a unique index for this worker, we use this to be able to write our results
- // without any synchronization.
- auto index = threadIndex.fetchAndAdd(1);
-
- // Prepare a Collection instance that the writer will insert.
- NamespaceString nssToInsert("test", fmt::format("coll{}", index));
- auto collectionToInsert = std::make_shared<CollectionMock>(nssToInsert);
- namespacesInserted[index] = std::move(nssToInsert);
-
- // Wait for all worker threads to reach this point before proceeding.
- barrier.countDownAndWait();
-
- // The first thread that enters write() will begin copying the catalog instance, other
- // threads that enter while this copy is being made will be enqueued. When the thread
- // copying the catalog instance finishes the copy it will execute all writes using the same
- // writable catalog instance.
- //
- // To minimize the risk of this test being flaky we need to make the catalog copy slow
- // enough so the other threads properly enter the queue state. We achieve this by having a
- // large numbers of collections in the catalog.
- CollectionCatalog::write(getServiceContext(), [&](CollectionCatalog& writableCatalog) {
- catalogInstancesObserved[index] = &writableCatalog;
-
- // Perform a write, we will later verify that all writes are observable even when
- // workers are batched together.
- writableCatalog.registerCollection(
- operationContext(), CollectionUUID::gen(), std::move(collectionToInsert));
- });
- };
-
- std::array<stdx::thread, NumThreads> threads;
- for (auto&& thread : threads) {
- thread = stdx::thread(job);
- }
- for (auto&& thread : threads) {
- thread.join();
- }
-
- // Verify that some batching was achieved where at least two threads observed the same catalog
- // instance. We do this by sorting the array, removing all duplicates and last verify that we
- // have less elements remaining than number of threads.
- std::sort(catalogInstancesObserved.begin(), catalogInstancesObserved.end());
- auto it = std::unique(catalogInstancesObserved.begin(), catalogInstancesObserved.end());
- ASSERT_LT(std::distance(catalogInstancesObserved.begin(), it), NumThreads);
-
- // Check that all Collections we inserted are in the final Catalog instance, no overwrites
- // occured.
- auto catalog = CollectionCatalog::get(getServiceContext());
- for (auto&& nss : namespacesInserted) {
- ASSERT(catalog->lookupCollectionByNamespace(operationContext(), nss));
- }
-}
-
TEST_F(CatalogReadCopyUpdateTest, ConcurrentCatalogWriteBatchingMayThrow) {
// Start threads and perform write that will throw at the same time
constexpr int32_t NumThreads = 4;