summaryrefslogtreecommitdiff
path: root/src/mongo/db/repair_database.cpp
diff options
context:
space:
mode:
authorDaniel Gottlieb <daniel.gottlieb@mongodb.com>2019-11-26 04:48:50 +0000
committerevergreen <evergreen@mongodb.com>2019-11-26 04:48:50 +0000
commitd471957fc37ef6cafe9ffeda3e231cdc871c3ce3 (patch)
tree3435c9d9420243e350da0f3dfbeecb81afbcd264 /src/mongo/db/repair_database.cpp
parent8b0f534a706005d366e200ee56af5c76217656b2 (diff)
downloadmongo-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/repair_database.cpp')
-rw-r--r--src/mongo/db/repair_database.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mongo/db/repair_database.cpp b/src/mongo/db/repair_database.cpp
index ced21031a10..533e0df0c6d 100644
--- a/src/mongo/db/repair_database.cpp
+++ b/src/mongo/db/repair_database.cpp
@@ -147,7 +147,7 @@ Status repairCollections(OperationContext* opCtx,
log() << "Repairing collection " << nss;
- auto collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(nss);
+ auto collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, nss);
Status status = engine->repairRecordStore(opCtx, collection->getCatalogId(), nss);
if (!status.isOK())
return status;
@@ -155,7 +155,7 @@ Status repairCollections(OperationContext* opCtx,
for (const auto& nss : colls) {
opCtx->checkForInterrupt();
- auto collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(nss);
+ auto collection = CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, nss);
auto swIndexNameObjs = getIndexNameObjs(opCtx, collection->getCatalogId());
if (!swIndexNameObjs.isOK())
return swIndexNameObjs.getStatus();