diff options
Diffstat (limited to 'src/mongo/db/repl/repl_set_request_votes_args.cpp')
-rw-r--r-- | src/mongo/db/repl/repl_set_request_votes_args.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mongo/db/repl/repl_set_request_votes_args.cpp b/src/mongo/db/repl/repl_set_request_votes_args.cpp index 57256d71554..ee132d999d1 100644 --- a/src/mongo/db/repl/repl_set_request_votes_args.cpp +++ b/src/mongo/db/repl/repl_set_request_votes_args.cpp @@ -33,6 +33,7 @@ #include "mongo/bson/util/bson_extract.h" #include "mongo/db/jsobj.h" #include "mongo/db/repl/bson_extract_optime.h" +#include "mongo/db/server_options.h" namespace mongo { namespace repl { @@ -41,6 +42,7 @@ namespace { const std::string kCandidateIndexFieldName = "candidateIndex"; const std::string kCommandName = "replSetRequestVotes"; const std::string kConfigVersionFieldName = "configVersion"; +const std::string kConfigTermFieldName = "configTerm"; const std::string kDryRunFieldName = "dryRun"; // The underlying field name is inaccurate, but changing it requires a fair amount of cross // compatibility work for no real benefit. @@ -56,6 +58,7 @@ const std::string kLegalArgsFieldNames[] = { kCandidateIndexFieldName, kCommandName, kConfigVersionFieldName, + kConfigTermFieldName, kDryRunFieldName, kLastDurableOpTimeFieldName, kSetNameFieldName, @@ -84,6 +87,13 @@ Status ReplSetRequestVotesArgs::initialize(const BSONObj& argsObj) { if (!status.isOK()) return status; + // In order to be compatible with FCV 4.2, default the config term to -1 if we are unable + // parse a configTerm field from the args. + status = bsonExtractIntegerFieldWithDefault( + argsObj, kConfigTermFieldName, OpTime::kUninitializedTerm, &_cfgterm); + if (!status.isOK()) + return status; + status = bsonExtractStringField(argsObj, kSetNameFieldName, &_setName); if (!status.isOK()) return status; @@ -115,6 +125,10 @@ long long ReplSetRequestVotesArgs::getConfigVersion() const { return _cfgver; } +long long ReplSetRequestVotesArgs::getConfigTerm() const { + return _cfgterm; +} + OpTime ReplSetRequestVotesArgs::getLastDurableOpTime() const { return _lastDurableOpTime; } @@ -130,6 +144,7 @@ void ReplSetRequestVotesArgs::addToBSON(BSONObjBuilder* builder) const { builder->append(kTermFieldName, _term); builder->appendIntOrLL(kCandidateIndexFieldName, _candidateIndex); builder->appendIntOrLL(kConfigVersionFieldName, _cfgver); + builder->appendIntOrLL(kConfigTermFieldName, _cfgterm); _lastDurableOpTime.append(builder, kLastDurableOpTimeFieldName); } |