summaryrefslogtreecommitdiff
path: root/src/mongo/db/catalog
diff options
context:
space:
mode:
authorTommaso Tocci <tommaso.tocci@mongodb.com>2020-07-22 10:13:21 +0200
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-22 08:36:04 +0000
commitf853fe2eb7fd1918ff1f391f982499c49c006524 (patch)
treef48d323b9457589ac5eecfe90e2bf971a0c29c7f /src/mongo/db/catalog
parent1a8092b741ebd9d24122559648f14f5d3f37ba8a (diff)
downloadmongo-f853fe2eb7fd1918ff1f391f982499c49c006524.tar.gz
Revert "SERVER-49765 fail with MovePrimaryInProgress for dropIndexes, create view, modify view commands"
This reverts commit c0cc8994d2f8343a08928be10873f4ae3220fb45.
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r--src/mongo/db/catalog/coll_mod.cpp4
-rw-r--r--src/mongo/db/catalog/database_impl.cpp19
-rw-r--r--src/mongo/db/catalog/drop_indexes.cpp30
3 files changed, 1 insertions, 52 deletions
diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp
index ad98c2d9531..25d9db7db51 100644
--- a/src/mongo/db/catalog/coll_mod.cpp
+++ b/src/mongo/db/catalog/coll_mod.cpp
@@ -367,10 +367,6 @@ Status _collModInternal(OperationContext* opCtx,
}
}
- if (view) {
- Lock::CollectionLock collLock(opCtx, view->viewOn(), MODE_IS);
- assertMovePrimaryInProgress(opCtx, view->viewOn());
- }
// This can kill all cursors so don't allow running it while a background operation is in
// progress.
if (coll) {
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index bfaf0151fd1..7a0e74071ba 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -62,7 +62,6 @@
#include "mongo/db/repl/drop_pending_collection_reaper.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/repl/replication_coordinator.h"
-#include "mongo/db/s/collection_sharding_state.h"
#include "mongo/db/s/database_sharding_state.h"
#include "mongo/db/s/operation_sharding_state.h"
#include "mongo/db/server_options.h"
@@ -580,6 +579,7 @@ void DatabaseImpl::_checkCanCreateCollection(OperationContext* opCtx,
str::stream() << "Cannot create collection " << nss
<< " - database is in the process of being dropped.",
!_dropPending.load());
+ assertMovePrimaryInProgress(opCtx, nss);
}
Status DatabaseImpl::createView(OperationContext* opCtx,
@@ -593,22 +593,6 @@ Status DatabaseImpl::createView(OperationContext* opCtx,
NamespaceString viewOnNss(viewName.db(), options.viewOn);
_checkCanCreateCollection(opCtx, viewName, options);
-
- try {
- Lock::CollectionLock collLock(opCtx, viewOnNss, MODE_IS);
- const auto collDesc =
- CollectionShardingState::get(opCtx, viewOnNss)->getCollectionDescription(opCtx);
- if (!collDesc.isSharded()) {
- assertMovePrimaryInProgress(opCtx, viewOnNss);
- }
- } catch (const DBException& ex) {
- if (ex.toStatus() == ErrorCodes::MovePrimaryInProgress) {
- throw;
- } else {
- LOGV2(4909101, "Error when getting colleciton description", "what"_attr = ex.what());
- }
- }
-
audit::logCreateCollection(&cc(), viewName.toString());
if (viewName.isOplog())
@@ -675,7 +659,6 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx,
}
_checkCanCreateCollection(opCtx, nss, optionsWithUUID);
- assertMovePrimaryInProgress(opCtx, nss);
audit::logCreateCollection(&cc(), nss.ns());
LOGV2(20320,
diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp
index 498c9421d1e..f64d6b3b821 100644
--- a/src/mongo/db/catalog/drop_indexes.cpp
+++ b/src/mongo/db/catalog/drop_indexes.cpp
@@ -43,8 +43,6 @@
#include "mongo/db/op_observer.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/repl_set_member_in_standalone_mode.h"
-#include "mongo/db/s/collection_sharding_state.h"
-#include "mongo/db/s/database_sharding_state.h"
#include "mongo/db/service_context.h"
#include "mongo/db/views/view_catalog.h"
#include "mongo/logv2/log.h"
@@ -285,33 +283,6 @@ Status dropReadyIndexes(OperationContext* opCtx,
return Status::OK();
}
-void assertMovePrimaryInProgress(OperationContext* opCtx, const NamespaceString& ns) {
- auto dss = DatabaseShardingState::get(opCtx, ns.db());
- auto dssLock = DatabaseShardingState::DSSLock::lockShared(opCtx, dss);
-
- try {
- const auto collDesc =
- CollectionShardingState::get(opCtx, ns)->getCollectionDescription(opCtx);
- if (!collDesc.isSharded()) {
- auto mpsm = dss->getMovePrimarySourceManager(dssLock);
-
- if (mpsm) {
- LOGV2(
- 4976500, "assertMovePrimaryInProgress", "movePrimaryNss"_attr = ns.toString());
-
- uasserted(ErrorCodes::MovePrimaryInProgress,
- "movePrimary is in progress for namespace " + ns.toString());
- }
- }
- } catch (const DBException& ex) {
- if (ex.toStatus() != ErrorCodes::MovePrimaryInProgress) {
- LOGV2(4976501, "Error when getting colleciton description", "what"_attr = ex.what());
- return;
- }
- throw;
- }
-}
-
} // namespace
Status dropIndexes(OperationContext* opCtx,
@@ -429,7 +400,6 @@ Status dropIndexes(OperationContext* opCtx,
}
if (!abortAgain) {
- assertMovePrimaryInProgress(opCtx, nss);
break;
}
}