From 9a5fd32bfcdbf356a35961e45ed3d6693e85b89e Mon Sep 17 00:00:00 2001 From: Dianna Hohensee Date: Thu, 22 Feb 2018 16:37:38 -0500 Subject: SERVER-33014 Remove unreachable featureCompatibilityVersion document op observers --- .../db/commands/feature_compatibility_version.cpp | 26 ---------------------- .../db/commands/feature_compatibility_version.h | 12 ---------- src/mongo/db/op_observer_impl.cpp | 14 +++++++----- 3 files changed, 9 insertions(+), 43 deletions(-) diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index 60014e63785..1781a956435 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -335,32 +335,6 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons }); } -void FeatureCompatibilityVersion::onDelete(OperationContext* opCtx, const BSONObj& doc) { - auto idElement = doc["_id"]; - if (idElement.type() != BSONType::String || - idElement.String() != FeatureCompatibilityVersion::kParameterName) { - return; - } - - log() << "setting featureCompatibilityVersion to " - << FeatureCompatibilityVersionCommandParser::kVersion34; - opCtx->recoveryUnit()->onCommit([]() { - serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo34); - updateMinWireVersion(); - }); -} - -void FeatureCompatibilityVersion::onDropCollection(OperationContext* opCtx) { - log() << "setting featureCompatibilityVersion to " - << FeatureCompatibilityVersionCommandParser::kVersion36; - opCtx->recoveryUnit()->onCommit([]() { - serverGlobalParams.featureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36); - updateMinWireVersion(); - }); -} - void FeatureCompatibilityVersion::updateMinWireVersion() { WireSpec& spec = WireSpec::instance(); diff --git a/src/mongo/db/commands/feature_compatibility_version.h b/src/mongo/db/commands/feature_compatibility_version.h index aab764f7ea9..1c3916565b0 100644 --- a/src/mongo/db/commands/feature_compatibility_version.h +++ b/src/mongo/db/commands/feature_compatibility_version.h @@ -151,18 +151,6 @@ public: */ static void onInsertOrUpdate(OperationContext* opCtx, const BSONObj& doc); - /** - * Examines the _id of a document removed from admin.system.version. If it is the - * featureCompatibilityVersion document, resets the server parameter to its default value - * on commit. - */ - static void onDelete(OperationContext* opCtx, const BSONObj& doc); - - /** - * Resets the server parameter to its default value on commit. - */ - static void onDropCollection(OperationContext* opCtx); - /** * Sets the server's outgoing and incomingInternalClient minWireVersions according to the * current featureCompatibilityVersion value. diff --git a/src/mongo/db/op_observer_impl.cpp b/src/mongo/db/op_observer_impl.cpp index 8ba3bfd13be..4a1977ebf7d 100644 --- a/src/mongo/db/op_observer_impl.cpp +++ b/src/mongo/db/op_observer_impl.cpp @@ -602,9 +602,11 @@ void OpObserverImpl::onDropDatabase(OperationContext* opCtx, const std::string& kUninitializedStmtId, {}); - if (dbName == FeatureCompatibilityVersion::kDatabase) { - FeatureCompatibilityVersion::onDropCollection(opCtx); - } else if (dbName == NamespaceString::kSessionTransactionsTableNamespace.db()) { + uassert(50714, + "dropping the admin database is not allowed.", + dbName != FeatureCompatibilityVersion::kDatabase); + + if (dbName == NamespaceString::kSessionTransactionsTableNamespace.db()) { SessionCatalog::get(opCtx)->invalidateSessions(opCtx, boost::none); } @@ -636,10 +638,12 @@ repl::OpTime OpObserverImpl::onDropCollection(OperationContext* opCtx, {}); } + uassert(50715, + "dropping the admin.system.version collection is not allowed.", + collectionName.ns() != FeatureCompatibilityVersion::kCollection); + if (collectionName.coll() == DurableViewCatalog::viewsCollectionName()) { DurableViewCatalog::onExternalChange(opCtx, collectionName); - } else if (collectionName.ns() == FeatureCompatibilityVersion::kCollection) { - FeatureCompatibilityVersion::onDropCollection(opCtx); } else if (collectionName == NamespaceString::kSessionTransactionsTableNamespace) { SessionCatalog::get(opCtx)->invalidateSessions(opCtx, boost::none); } -- cgit v1.2.1