diff options
author | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-02-22 00:39:28 -0500 |
---|---|---|
committer | Xiangyu Yao <xiangyu.yao@mongodb.com> | 2018-02-27 22:31:05 -0500 |
commit | cc4cb29486a87598d7b490c53712d06085e5cf91 (patch) | |
tree | 1b81a7306381ad3bcad898a4c91ad12215bbc492 /src | |
parent | ce91d96dc6fe04db3327653c145a54b3768a88ac (diff) | |
download | mongo-cc4cb29486a87598d7b490c53712d06085e5cf91.tar.gz |
SERVER-33260 Log more helpful messages for FCV-related IncompatibleServerVersion errors
Diffstat (limited to 'src')
10 files changed, 147 insertions, 92 deletions
diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index afa789dd60e..c0edc6a028e 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -33,6 +33,7 @@ #include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/base/status.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/operation_context.h" #include "mongo/db/repl/optime.h" @@ -73,39 +74,40 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili } else if (fieldName == FeatureCompatibilityVersion::kVersionField || fieldName == FeatureCompatibilityVersion::kTargetVersionField) { if (elem.type() != BSONType::String) { - return Status(ErrorCodes::TypeMismatch, - str::stream() << fieldName - << " must be of type String, but was of type " - << typeName(elem.type()) - << ". Contents of " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); + return Status( + ErrorCodes::TypeMismatch, + str::stream() << fieldName << " must be of type String, but was of type " + << typeName(elem.type()) + << ". Contents of " + << FeatureCompatibilityVersion::kParameterName + << " document in " + << FeatureCompatibilityVersion::kCollection + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } if (elem.String() != FeatureCompatibilityVersionCommandParser::kVersion40 && elem.String() != FeatureCompatibilityVersionCommandParser::kVersion36) { - return Status(ErrorCodes::BadValue, - str::stream() << "Invalid value for " << fieldName << ", found " - << elem.String() - << ", expected '" - << FeatureCompatibilityVersionCommandParser::kVersion40 - << "' or '" - << FeatureCompatibilityVersionCommandParser::kVersion36 - << "'. Contents of " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); + return Status( + ErrorCodes::BadValue, + str::stream() << "Invalid value for " << fieldName << ", found " + << elem.String() + << ", expected '" + << FeatureCompatibilityVersionCommandParser::kVersion40 + << "' or '" + << FeatureCompatibilityVersionCommandParser::kVersion36 + << "'. Contents of " + << FeatureCompatibilityVersion::kParameterName + << " document in " + << FeatureCompatibilityVersion::kCollection + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } if (fieldName == FeatureCompatibilityVersion::kVersionField) { @@ -114,16 +116,17 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili targetVersionString = elem.String(); } } else { - return Status(ErrorCodes::BadValue, - str::stream() << "Unrecognized field '" << fieldName << "'. Contents of " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); + return Status( + ErrorCodes::BadValue, + str::stream() << "Unrecognized field '" << fieldName << "'. Contents of " + << FeatureCompatibilityVersion::kParameterName + << " document in " + << FeatureCompatibilityVersion::kCollection + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } } @@ -138,32 +141,33 @@ StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibili } else if (versionString == FeatureCompatibilityVersionCommandParser::kVersion40) { if (targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion40 || targetVersionString == FeatureCompatibilityVersionCommandParser::kVersion36) { - return Status(ErrorCodes::BadValue, - str::stream() << "Invalid state for " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); + return Status( + ErrorCodes::BadValue, + str::stream() << "Invalid state for " << FeatureCompatibilityVersion::kParameterName + << " document in " + << FeatureCompatibilityVersion::kCollection + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } else { version = ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo40; } } else { return Status(ErrorCodes::BadValue, - str::stream() << "Missing required field '" - << FeatureCompatibilityVersion::kVersionField - << "''. Contents of " - << FeatureCompatibilityVersion::kParameterName - << " document in " - << FeatureCompatibilityVersion::kCollection - << ": " - << featureCompatibilityVersionDoc - << ". See " - << feature_compatibility_version::kDochubLink - << "."); + str::stream() + << "Missing required field '" + << FeatureCompatibilityVersion::kVersionField + << "''. Contents of " + << FeatureCompatibilityVersion::kParameterName + << " document in " + << FeatureCompatibilityVersion::kCollection + << ": " + << featureCompatibilityVersionDoc + << ". See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } return version; @@ -308,7 +312,7 @@ void FeatureCompatibilityVersion::_validateVersion(StringData version) { << "' or '" << FeatureCompatibilityVersionCommandParser::kVersion36 << "'. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << ".", version == FeatureCompatibilityVersionCommandParser::kVersion40 || version == FeatureCompatibilityVersionCommandParser::kVersion36); @@ -394,18 +398,20 @@ public: virtual Status set(const BSONElement& newValueElement) { return Status(ErrorCodes::IllegalOperation, - str::stream() << FeatureCompatibilityVersion::kParameterName - << " cannot be set via setParameter. See " - << feature_compatibility_version::kDochubLink - << "."); + str::stream() + << FeatureCompatibilityVersion::kParameterName + << " cannot be set via setParameter. See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } virtual Status setFromString(const std::string& str) { return Status(ErrorCodes::IllegalOperation, - str::stream() << FeatureCompatibilityVersion::kParameterName - << " cannot be set via setParameter. See " - << feature_compatibility_version::kDochubLink - << "."); + str::stream() + << FeatureCompatibilityVersion::kParameterName + << " cannot be set via setParameter. See " + << feature_compatibility_version_documentation::kCompatibilityLink + << "."); } } featureCompatibilityVersionParameter; diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp index 49ce4128b8d..43d5824f07d 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.cpp @@ -33,6 +33,7 @@ #include "mongo/base/status_with.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/commands.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/query/query_request.h" #include "mongo/util/version.h" @@ -62,7 +63,7 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion << " in: " << cmdObj << ". See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << "."}; } @@ -78,7 +79,7 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion << " in " << cmdObj << ". See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << "."); } @@ -96,7 +97,7 @@ StatusWith<std::string> FeatureCompatibilityVersionCommandParser::extractVersion << " in: " << cmdObj << ". See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << "."}; } diff --git a/src/mongo/db/commands/feature_compatibility_version_command_parser.h b/src/mongo/db/commands/feature_compatibility_version_command_parser.h index 284471de123..8ae35af84ca 100644 --- a/src/mongo/db/commands/feature_compatibility_version_command_parser.h +++ b/src/mongo/db/commands/feature_compatibility_version_command_parser.h @@ -38,10 +38,6 @@ class BSONObj; template <typename T> class StatusWith; -namespace feature_compatibility_version { -constexpr StringData kDochubLink = "http://dochub.mongodb.org/core/4.0-feature-compatibility"_sd; -} // namespace feature_compatibility_version - class FeatureCompatibilityVersionCommandParser { public: /** diff --git a/src/mongo/db/commands/feature_compatibility_version_documentation.h b/src/mongo/db/commands/feature_compatibility_version_documentation.h new file mode 100644 index 00000000000..f1bc4e04ad2 --- /dev/null +++ b/src/mongo/db/commands/feature_compatibility_version_documentation.h @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2018 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects + * for all of the code used other than as permitted herein. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. If you + * delete this exception statement from all source files in the program, + * then also delete it in the license file. + */ + +#pragma once + +namespace mongo { +namespace feature_compatibility_version_documentation { +constexpr StringData kCompatibilityLink = + "http://dochub.mongodb.org/core/4.0-feature-compatibility"_sd; +constexpr StringData kUpgradeLink = "http://dochub.mongodb.org/core/4.0-upgrade-fcv"_sd; +} +} diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp index bccb159e9ef..5eb5867d5b8 100644 --- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp +++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp @@ -35,6 +35,7 @@ #include "mongo/db/commands.h" #include "mongo/db/commands/feature_compatibility_version.h" #include "mongo/db/commands/feature_compatibility_version_command_parser.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/db_raii.h" #include "mongo/db/repl/repl_client_info.h" @@ -89,7 +90,7 @@ public: << FeatureCompatibilityVersionCommandParser::kVersion40 << "\", then 4.0 features are enabled, and all nodes in the cluster must be binary " "version 4.0. See " - << feature_compatibility_version::kDochubLink << "."; + << feature_compatibility_version_documentation::kCompatibilityLink << "."; return h.str(); } diff --git a/src/mongo/db/logical_session_id_helpers.cpp b/src/mongo/db/logical_session_id_helpers.cpp index 32f743d0e42..41e9f01eb6f 100644 --- a/src/mongo/db/logical_session_id_helpers.cpp +++ b/src/mongo/db/logical_session_id_helpers.cpp @@ -34,6 +34,7 @@ #include "mongo/db/auth/user.h" #include "mongo/db/auth/user_name.h" #include "mongo/db/commands/feature_compatibility_version_command_parser.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/logical_session_cache.h" #include "mongo/db/operation_context.h" @@ -193,7 +194,7 @@ Status SessionsCommandFCV34Status(StringData command) { StringBuilder sb; sb << command; sb << " is not available in featureCompatibilityVersion 3.4. See "; - sb << feature_compatibility_version::kDochubLink << " ."; + sb << feature_compatibility_version_documentation::kCompatibilityLink << " ."; return {ErrorCodes::InvalidOptions, sb.str()}; } diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp index a8d002e0c35..8bc7abe7000 100644 --- a/src/mongo/db/pipeline/expression.cpp +++ b/src/mongo/db/pipeline/expression.cpp @@ -36,7 +36,7 @@ #include <cstdio> #include <vector> -#include "mongo/db/commands/feature_compatibility_version_command_parser.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/jsobj.h" #include "mongo/db/pipeline/document.h" #include "mongo/db/pipeline/expression_context.h" @@ -151,7 +151,7 @@ intrusive_ptr<Expression> Expression::parseExpression( // introduce a dependency cycle. str::stream() << opName << " is not allowed in the current feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", !expCtx->maxFeatureCompatibilityVersion || !entry.requiredMinVersion || (*entry.requiredMinVersion <= *expCtx->maxFeatureCompatibilityVersion)); @@ -1335,21 +1335,21 @@ intrusive_ptr<Expression> ExpressionDateFromString::parse( ErrorCodes::QueryFeatureNotAllowed, str::stream() << "\"format\" option to $dateFromString is not allowed with the current " "feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", !formatElem); uassert( ErrorCodes::QueryFeatureNotAllowed, str::stream() << "\"onNull\" option to $dateFromString is not allowed with the current " "feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", !onNullElem); uassert(ErrorCodes::QueryFeatureNotAllowed, str::stream() << "\"onError\" option to $dateFromString is not allowed with the current " "feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", !onErrorElem); } @@ -1684,14 +1684,14 @@ intrusive_ptr<Expression> ExpressionDateToString::parse( ErrorCodes::QueryFeatureNotAllowed, str::stream() << "\"onNull\" option to $dateToString is not allowed with the current " "feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", !onNullElem); uassert(ErrorCodes::QueryFeatureNotAllowed, str::stream() << "\"format\" option to $dateToString is required with the current " "feature compatibility version. See " - << feature_compatibility_version::kDochubLink + << feature_compatibility_version_documentation::kCompatibilityLink << " for more information.", formatElem); } diff --git a/src/mongo/db/repair_database_and_check_version.cpp b/src/mongo/db/repair_database_and_check_version.cpp index 61799885d98..43d3017cf5b 100644 --- a/src/mongo/db/repair_database_and_check_version.cpp +++ b/src/mongo/db/repair_database_and_check_version.cpp @@ -36,6 +36,7 @@ #include "mongo/db/catalog/database_holder.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/commands/feature_compatibility_version.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/dbhelpers.h" @@ -61,9 +62,10 @@ using std::endl; namespace { -constexpr StringData upgradeLink = "http://dochub.mongodb.org/core/4.0-upgrade-fcv"_sd; -constexpr StringData mustDowngradeErrorMsg = - "UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.6 before attempting an upgrade to 4.0; see http://dochub.mongodb.org/core/4.0-upgrade-fcv for more details."_sd; +const std::string mustDowngradeErrorMsg = str::stream() + << "UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.6 before attempting " + "an upgrade to 4.0; see " + << feature_compatibility_version_documentation::kUpgradeLink << " for more details."; Status restoreMissingFeatureCompatibilityVersionDocument(OperationContext* opCtx, const std::vector<std::string>& dbNames) { @@ -426,7 +428,7 @@ StatusWith<bool> repairDatabasesAndCheckVersion(OperationContext* opCtx) { "featureCompatibilityVersion document. The data files need " "to be fully upgraded to version 3.4 before attempting an " "upgrade to 3.6. If you are upgrading to 3.6, see " - << upgradeLink + << feature_compatibility_version_documentation::kUpgradeLink << "."}; } fcvDocumentExists = true; diff --git a/src/mongo/rpc/protocol.cpp b/src/mongo/rpc/protocol.cpp index 8d4823da8e8..fa7c9940d1a 100644 --- a/src/mongo/rpc/protocol.cpp +++ b/src/mongo/rpc/protocol.cpp @@ -216,9 +216,18 @@ Status validateWireVersion(const WireVersionInfo client, const WireVersionInfo s << server.maxWireVersion << ") is incompatible with client min wire version (" << client.minWireVersion << "," << client.maxWireVersion << ")."; if (client.maxWireVersion < server.minWireVersion) { - return Status(ErrorCodes::IncompatibleWithUpgradedServer, errmsg); + return Status(ErrorCodes::IncompatibleWithUpgradedServer, + str::stream() + << errmsg + << "You (client) are attempting to connect to a node (server) that " + "no longer accepts connections with your(client’s) binary " + "version.Please upgrade the client’s binary version."); } - return Status(ErrorCodes::IncompatibleServerVersion, errmsg); + return Status(ErrorCodes::IncompatibleServerVersion, + str::stream() << errmsg << "You (client) are attempting to connect to a node " + "(server) with a binary version with which " + "you(client) no longer accept connections.Please " + "upgrade the server’s binary version."); } return Status::OK(); diff --git a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp index 21f2a9b259e..0e991f4a4f2 100644 --- a/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_feature_compatibility_version_cmd.cpp @@ -31,6 +31,7 @@ #include "mongo/db/auth/authorization_session.h" #include "mongo/db/commands.h" #include "mongo/db/commands/feature_compatibility_version_command_parser.h" +#include "mongo/db/commands/feature_compatibility_version_documentation.h" #include "mongo/s/client/shard.h" #include "mongo/s/client/shard_registry.h" #include "mongo/s/grid.h" @@ -73,7 +74,8 @@ public: << "\", then 4.0 features are disabled. If \"" << FeatureCompatibilityVersionCommandParser::kVersion40 << "\", then 4.0 features are enabled, and all nodes in the cluster must be version " - << "4.0. See " << feature_compatibility_version::kDochubLink << "."; + << "4.0. See " << feature_compatibility_version_documentation::kCompatibilityLink + << "."; } Status checkAuthForCommand(Client* client, |