diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2019-11-26 04:48:50 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-26 04:48:50 +0000 |
commit | d471957fc37ef6cafe9ffeda3e231cdc871c3ce3 (patch) | |
tree | 3435c9d9420243e350da0f3dfbeecb81afbcd264 /src/mongo/db/storage/kv | |
parent | 8b0f534a706005d366e200ee56af5c76217656b2 (diff) | |
download | mongo-d471957fc37ef6cafe9ffeda3e231cdc871c3ce3.tar.gz |
SERVER-43859: Take MODE_IX locks for collection creation.
Two concurrent storage transactions can now create collections with the same
collection name. These transactions will conflict at commit time; the first
committer will win and register their collection into the global catalog. The
losing transactions will bubble a WriteConflictException.
Top-level callers that should fail if the collection already existed must now
check and fail with a NamespaceExists error code. Previously, those callers
could rely on lower level code returning the NamespaceExists error.
Callers that were implicitly creating a collection may retry the operation,
using the now-registered collection.
These transaction-local collections (UncommittedCollections) are returned when
doing any CollectionCatalog::lookup* call.
Diffstat (limited to 'src/mongo/db/storage/kv')
-rw-r--r-- | src/mongo/db/storage/kv/durable_catalog_feature_tracker_test.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/durable_catalog_test.cpp | 6 |
2 files changed, 3 insertions, 9 deletions
diff --git a/src/mongo/db/storage/kv/durable_catalog_feature_tracker_test.cpp b/src/mongo/db/storage/kv/durable_catalog_feature_tracker_test.cpp index 82d69cf454d..d5a2594b37c 100644 --- a/src/mongo/db/storage/kv/durable_catalog_feature_tracker_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_feature_tracker_test.cpp @@ -107,12 +107,6 @@ private: std::unique_ptr<DurableCatalogImpl::FeatureTracker> _featureTracker; }; -TEST_F(DurableCatalogFeatureTrackerTest, FeatureDocumentIsNotEagerlyCreated) { - auto opCtx = newOperationContext(); - auto cursor = getRecordStore()->getCursor(opCtx.get()); - ASSERT_FALSE(static_cast<bool>(cursor->next())); -} - TEST_F(DurableCatalogFeatureTrackerTest, CanMarkNonRepairableFeatureAsInUse) { { auto opCtx = newOperationContext(); diff --git a/src/mongo/db/storage/kv/durable_catalog_test.cpp b/src/mongo/db/storage/kv/durable_catalog_test.cpp index 5a2da09c0ea..c5b5b469f09 100644 --- a/src/mongo/db/storage/kv/durable_catalog_test.cpp +++ b/src/mongo/db/storage/kv/durable_catalog_test.cpp @@ -88,9 +88,9 @@ public: ASSERT_OK(swColl.getStatus()); std::pair<RecordId, std::unique_ptr<RecordStore>> coll = std::move(swColl.getValue()); _catalogId = coll.first; - auto collection = std::make_unique<CollectionMock>(_nss); - CollectionCatalog::get(opCtx.get()) - .registerCollection(options.uuid.get(), std::move(collection)); + std::unique_ptr<Collection> collection = + std::make_unique<CollectionMock>(_nss, _catalogId); + CollectionCatalog::get(opCtx.get()).registerCollection(options.uuid.get(), &collection); wuow.commit(); } } |