summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Wlodarek <gregory.wlodarek@mongodb.com>2020-02-26 10:46:49 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-02-26 19:27:47 +0000
commite423a7ce2f5e514054dbbdb4af838e64c8edd11a (patch)
tree96454f6b6a74282aff121e4cd79bb7f59d4226ec /src
parentb64086a93dfc996719c1edcb21741f593e35db82 (diff)
downloadmongo-e423a7ce2f5e514054dbbdb4af838e64c8edd11a.tar.gz
SERVER-46123 Check whether the database is drop pending for aggregation operations
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/catalog/rename_collection.cpp9
-rw-r--r--src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp13
-rw-r--r--src/mongo/db/pipeline/process_interface/standalone_process_interface.cpp13
3 files changed, 24 insertions, 11 deletions
diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp
index a38eb0ae38a..26c7aa08494 100644
--- a/src/mongo/db/catalog/rename_collection.cpp
+++ b/src/mongo/db/catalog/rename_collection.cpp
@@ -111,8 +111,10 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx,
"Cannot rename collections between a replicated and an unreplicated database"};
auto db = DatabaseHolder::get(opCtx)->getDb(opCtx, source.db());
- if (!db)
- return Status(ErrorCodes::NamespaceNotFound, "source namespace does not exist");
+ if (!db || db->isDropPending(opCtx))
+ return Status(ErrorCodes::NamespaceNotFound,
+ str::stream()
+ << "Database " << source.db() << " does not exist or is drop pending");
Collection* const sourceColl =
CollectionCatalog::get(opCtx).lookupCollectionByNamespace(opCtx, source);
@@ -120,7 +122,8 @@ Status checkSourceAndTargetNamespaces(OperationContext* opCtx,
if (ViewCatalog::get(db)->lookup(opCtx, source.ns()))
return Status(ErrorCodes::CommandNotSupportedOnView,
str::stream() << "cannot rename view: " << source);
- return Status(ErrorCodes::NamespaceNotFound, "source namespace does not exist");
+ return Status(ErrorCodes::NamespaceNotFound,
+ str::stream() << "Source collection " << source.ns() << " does not exist");
}
BackgroundOperation::assertNoBgOpInProgForNs(source.ns());
diff --git a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
index 17a2c69a207..44b87b8a534 100644
--- a/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/replica_set_node_process_interface.cpp
@@ -123,11 +123,16 @@ void ReplicaSetNodeProcessInterface::createIndexesOnEmptyCollection(
AutoGetCollection autoColl(opCtx, ns, MODE_X);
writeConflictRetry(
opCtx, "CommonMongodProcessInterface::createIndexesOnEmptyCollection", ns.ns(), [&] {
+ uassert(ErrorCodes::DatabaseDropPending,
+ str::stream() << "The database is in the process of being dropped " << ns.db(),
+ autoColl.getDb() && !autoColl.getDb()->isDropPending(opCtx));
+
auto collection = autoColl.getCollection();
- invariant(collection,
- str::stream() << "Failed to create indexes for aggregation because "
- "collection does not exist: "
- << ns << ": " << BSON("indexes" << indexSpecs));
+ uassert(ErrorCodes::NamespaceNotFound,
+ str::stream() << "Failed to create indexes for aggregation because collection "
+ "does not exist: "
+ << ns << ": " << BSON("indexes" << indexSpecs),
+ collection);
invariant(0U == collection->numRecords(opCtx),
str::stream() << "Expected empty collection for index creation: " << ns
diff --git a/src/mongo/db/pipeline/process_interface/standalone_process_interface.cpp b/src/mongo/db/pipeline/process_interface/standalone_process_interface.cpp
index fd93bff6e1f..9cddcba6a02 100644
--- a/src/mongo/db/pipeline/process_interface/standalone_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/standalone_process_interface.cpp
@@ -53,11 +53,16 @@ void StandaloneProcessInterface::createIndexesOnEmptyCollection(
AutoGetCollection autoColl(opCtx, ns, MODE_X);
writeConflictRetry(
opCtx, "CommonMongodProcessInterface::createIndexesOnEmptyCollection", ns.ns(), [&] {
+ uassert(ErrorCodes::DatabaseDropPending,
+ str::stream() << "The database is in the process of being dropped " << ns.db(),
+ autoColl.getDb() && !autoColl.getDb()->isDropPending(opCtx));
+
auto collection = autoColl.getCollection();
- invariant(collection,
- str::stream() << "Failed to create indexes for aggregation because "
- "collection does not exist: "
- << ns << ": " << BSON("indexes" << indexSpecs));
+ uassert(ErrorCodes::NamespaceNotFound,
+ str::stream() << "Failed to create indexes for aggregation because collection "
+ "does not exist: "
+ << ns << ": " << BSON("indexes" << indexSpecs),
+ collection);
invariant(0U == collection->numRecords(opCtx),
str::stream() << "Expected empty collection for index creation: " << ns