summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXuerui Fa <xuerui.fa@mongodb.com>2020-03-11 13:33:06 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-03-19 18:35:40 +0000
commiteae3b334d1a69e2421de647db3f197aa2e3dd694 (patch)
treee2b644100ec652ad6e06e89c19b2a2c811214a24
parente398960773331f3b3afe000f2830c84868aaf9e7 (diff)
downloadmongo-eae3b334d1a69e2421de647db3f197aa2e3dd694.tar.gz
SERVER-46090: Remove references to lastCommittedOp
-rw-r--r--src/mongo/db/repl/repl_set_request_votes_args.cpp47
-rw-r--r--src/mongo/db/repl/repl_set_request_votes_args.h6
-rw-r--r--src/mongo/db/repl/topology_coordinator_v1_test.cpp36
-rw-r--r--src/mongo/db/repl/vote_requester.cpp14
4 files changed, 4 insertions, 99 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 d5a3b5b22a3..0dff3a3e22c 100644
--- a/src/mongo/db/repl/repl_set_request_votes_args.cpp
+++ b/src/mongo/db/repl/repl_set_request_votes_args.cpp
@@ -44,8 +44,6 @@ const std::string kCommandName = "replSetRequestVotes";
const std::string kConfigVersionFieldName = "configVersion";
const std::string kConfigTermFieldName = "configTerm";
const std::string kDryRunFieldName = "dryRun";
-// TODO: Remove references to the "lastCommittedOp" field name (SERVER-46090).
-const std::string kLastDurableOpTimeFieldName = "lastCommittedOp";
const std::string kLastAppliedOpTimeFieldName = "lastAppliedOpTime";
const std::string kOkFieldName = "ok";
const std::string kReasonFieldName = "reason";
@@ -54,19 +52,6 @@ const std::string kTermFieldName = "term";
const std::string kVoteGrantedFieldName = "voteGranted";
const std::string kOperationTime = "operationTime";
-// TODO: `kLegalArgsFieldNamesFCV42` should be removed after upgrading to 4.6 (SERVER-46090).
-const std::string kLegalArgsFieldNamesFCV42[] = {
- kCandidateIndexFieldName,
- kCommandName,
- kConfigVersionFieldName,
- kConfigTermFieldName,
- kDryRunFieldName,
- kLastDurableOpTimeFieldName,
- kSetNameFieldName,
- kTermFieldName,
- kOperationTime,
-};
-
const std::string kLegalArgsFieldNames[] = {
kCandidateIndexFieldName,
kCommandName,
@@ -85,24 +70,6 @@ const std::string kLegalArgsFieldNames[] = {
Status ReplSetRequestVotesArgs::initialize(const BSONObj& argsObj) {
Status status =
bsonCheckOnlyHasFieldsForCommand("ReplSetRequestVotes", argsObj, kLegalArgsFieldNames);
- // TODO: Remove this logic once we branch to 4.6 and can always assume
- // _usingLastAppliedOptimeFieldName to be true (SERVER-46090).
- // Since nodes in the replica set may have different values for FCV, we check that the legal
- // field names of either FCV 4.2 or 4.4 are present in the args obj.
- if (!status.isOK()) {
- status = bsonCheckOnlyHasFieldsForCommand(
- "ReplSetRequestVotes", argsObj, kLegalArgsFieldNamesFCV42);
- if (!status.isOK())
- return status;
-
- // If we successfully parsed with the FCV 4.2 field names, use 'lastCommittedOp' as the
- // correct field name.
- _usingLastAppliedOpTimeFieldName = false;
- } else {
- // If we successfully parsed with the FCV 4.4 field names, use 'lastAppliedOpTime' as the
- // correct field name.
- _usingLastAppliedOpTimeFieldName = true;
- }
status = bsonExtractIntegerField(argsObj, kTermFieldName, &_term);
if (!status.isOK())
@@ -131,13 +98,7 @@ Status ReplSetRequestVotesArgs::initialize(const BSONObj& argsObj) {
if (!status.isOK())
return status;
- // If we successfully parsed with the FCV 4.4 field names, use 'lastAppliedOpTime' to extract
- // the data. Else, use 'lastCommittedOp' as the field name.
- if (_usingLastAppliedOpTimeFieldName) {
- status = bsonExtractOpTimeField(argsObj, kLastAppliedOpTimeFieldName, &_lastAppliedOpTime);
- } else {
- status = bsonExtractOpTimeField(argsObj, kLastDurableOpTimeFieldName, &_lastAppliedOpTime);
- }
+ status = bsonExtractOpTimeField(argsObj, kLastAppliedOpTimeFieldName, &_lastAppliedOpTime);
if (!status.isOK()) {
return status;
}
@@ -185,11 +146,7 @@ void ReplSetRequestVotesArgs::addToBSON(BSONObjBuilder* builder) const {
builder->appendIntOrLL(kCandidateIndexFieldName, _candidateIndex);
builder->appendIntOrLL(kConfigVersionFieldName, _cfgVer);
builder->appendIntOrLL(kConfigTermFieldName, _cfgTerm);
- if (_usingLastAppliedOpTimeFieldName) {
- _lastAppliedOpTime.append(builder, kLastAppliedOpTimeFieldName);
- } else {
- _lastAppliedOpTime.append(builder, kLastDurableOpTimeFieldName);
- }
+ _lastAppliedOpTime.append(builder, kLastAppliedOpTimeFieldName);
}
std::string ReplSetRequestVotesArgs::toString() const {
diff --git a/src/mongo/db/repl/repl_set_request_votes_args.h b/src/mongo/db/repl/repl_set_request_votes_args.h
index 3e91de7ad56..3d7c34e9fcf 100644
--- a/src/mongo/db/repl/repl_set_request_votes_args.h
+++ b/src/mongo/db/repl/repl_set_request_votes_args.h
@@ -66,12 +66,6 @@ private:
long long _cfgTerm = OpTime::kUninitializedTerm;
OpTime _lastAppliedOpTime; // The OpTime of the last known applied op of the command issuer.
bool _dryRun = false; // Indicates this is a pre-election check when true.
-
- // TODO: Remove this field once references to 'lastCommittedOp' can be removed in 4.6 and we can
- // assume _usingLastAppliedOpTimeFieldName to always be true (SERVER-46090).
- // When true, indicates that we should use the 'lastAppliedOpTime' field for logging the last
- // applied OpTime. Else, use 'lastCommittedOp'.
- bool _usingLastAppliedOpTimeFieldName = true;
};
class ReplSetRequestVotesResponse {
diff --git a/src/mongo/db/repl/topology_coordinator_v1_test.cpp b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
index 6d7c0813eea..328d2a5229f 100644
--- a/src/mongo/db/repl/topology_coordinator_v1_test.cpp
+++ b/src/mongo/db/repl/topology_coordinator_v1_test.cpp
@@ -3955,42 +3955,6 @@ TEST_F(TopoCoordTest, DoNotGrantDryRunVoteWhenOpTimeIsStale) {
ASSERT_FALSE(response.getVoteGranted());
}
-// TODO: Remove this test in 4.6 when we can remove references to "lastCommittedOp" (SERVER-46090).
-TEST_F(TopoCoordTest, ParseLastAppliedOpTimeWithCorrectFieldName) {
- const OpTime lastOpTimeApplied = OpTime(Timestamp(4, 0), 0);
-
- const auto reqVotesObjWithLastAppliedOpTimeField =
- BSON("replSetRequestVotes" << 1 << "setName"
- << "rs0"
- << "dryRun" << true << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "configTerm" << 1LL
- << "lastAppliedOpTime" << lastOpTimeApplied);
- ReplSetRequestVotesArgs reqVotesArgsWithLastAppliedOpTimeField;
- ASSERT_OK(
- reqVotesArgsWithLastAppliedOpTimeField.initialize(reqVotesObjWithLastAppliedOpTimeField));
-
- // Verify we successfully parse the args with 'lastAppliedOpTime' as the field name.
- ASSERT_EQUALS(lastOpTimeApplied, reqVotesArgsWithLastAppliedOpTimeField.getLastAppliedOpTime());
- // Verify that the request serializes correctly.
- ASSERT_EQUALS(reqVotesObjWithLastAppliedOpTimeField.toString(),
- reqVotesObjWithLastAppliedOpTimeField.toString());
-
- const auto reqVotesObjWithLastCommittedOpField =
- BSON("replSetRequestVotes" << 1 << "setName"
- << "rs1"
- << "dryRun" << true << "term" << 1LL << "candidateIndex" << 1LL
- << "configVersion" << 1LL << "configTerm" << 1LL
- << "lastCommittedOp" << lastOpTimeApplied);
- ReplSetRequestVotesArgs reqVotesArgsWithLastCommittedOpField;
- ASSERT_OK(reqVotesArgsWithLastCommittedOpField.initialize(reqVotesObjWithLastCommittedOpField));
-
- // Verify we successfully parse the args with 'lastCommittedOp' as the field name.
- ASSERT_EQUALS(lastOpTimeApplied, reqVotesArgsWithLastCommittedOpField.getLastAppliedOpTime());
- // Verify that the request serializes correctly.
- ASSERT_EQUALS(reqVotesObjWithLastCommittedOpField.toString(),
- reqVotesArgsWithLastCommittedOpField.toString());
-}
-
TEST_F(TopoCoordTest, NodeTransitionsToRemovedIfCSRSButHaveNoReadCommittedSupport) {
ON_BLOCK_EXIT([]() { serverGlobalParams.clusterRole = ClusterRole::None; });
serverGlobalParams.clusterRole = ClusterRole::ConfigServer;
diff --git a/src/mongo/db/repl/vote_requester.cpp b/src/mongo/db/repl/vote_requester.cpp
index c4ca6584553..33310a03536 100644
--- a/src/mongo/db/repl/vote_requester.cpp
+++ b/src/mongo/db/repl/vote_requester.cpp
@@ -93,18 +93,8 @@ std::vector<RemoteCommandRequest> VoteRequester::Algorithm::getRequests() const
if (_rsConfig.getConfigTerm() != -1) {
requestVotesCmdBuilder.append("configTerm", _rsConfig.getConfigTerm());
}
- // TODO: Remove this check when we upgrade to 4.6 and can remove references to "lastCommittedOp"
- // (SERVER-46090).
- // Only append the config term field to the VoteRequester and use "lastAppliedOpTime" as the
- // field name for _lastAppliedOpTime if we are in FCV 4.4.
- if (serverGlobalParams.featureCompatibility.isVersionInitialized() &&
- serverGlobalParams.featureCompatibility.getVersion() ==
- ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) {
- _lastAppliedOpTime.append(&requestVotesCmdBuilder, "lastAppliedOpTime");
- } else {
- // If we are not in FCV 4.4, use "lastCommittedOp" as the field name instead.
- _lastAppliedOpTime.append(&requestVotesCmdBuilder, "lastCommittedOp");
- }
+
+ _lastAppliedOpTime.append(&requestVotesCmdBuilder, "lastAppliedOpTime");
const BSONObj requestVotesCmd = requestVotesCmdBuilder.obj();