summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorA. Jesse Jiryu Davis <jesse@mongodb.com>2020-04-06 09:10:14 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-04-09 20:12:38 +0000
commitb69c1496a903bcdf8a99849e6420e6d6259e1770 (patch)
tree96e075c02011dffb62e845c91d6e4d9392d9c5c8 /src
parente9379fcee79456d3795b598ccad91a0694007d0e (diff)
downloadmongo-b69c1496a903bcdf8a99849e6420e6d6259e1770.tar.gz
SERVER-47157 Require ReplSetMetadata.configTerm
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/README.md4
-rw-r--r--src/mongo/rpc/metadata/repl_set_metadata.cpp4
-rw-r--r--src/mongo/rpc/metadata/repl_set_metadata_test.cpp21
3 files changed, 3 insertions, 26 deletions
diff --git a/src/mongo/db/repl/README.md b/src/mongo/db/repl/README.md
index a3ffc9afad9..60a10c9746b 100644
--- a/src/mongo/db/repl/README.md
+++ b/src/mongo/db/repl/README.md
@@ -248,8 +248,8 @@ It includes:
1. The upstream node's last committed OpTime
2. The current term.
-3. The `ReplicaSetConfig` version (this is used to determine if a reconfig has occurred on the
- upstream node that hasn't been registered by the downstream node yet).
+3. The `ReplicaSetConfig` version and term (this is used to determine if a reconfig has occurred on
+ the upstream node that hasn't been registered by the downstream node yet).
4. The replica set ID.
If the metadata has a different config version than the downstream node's config version, then the
diff --git a/src/mongo/rpc/metadata/repl_set_metadata.cpp b/src/mongo/rpc/metadata/repl_set_metadata.cpp
index 2d01a732960..6eb0942bc2b 100644
--- a/src/mongo/rpc/metadata/repl_set_metadata.cpp
+++ b/src/mongo/rpc/metadata/repl_set_metadata.cpp
@@ -93,10 +93,8 @@ StatusWith<ReplSetMetadata> ReplSetMetadata::readFromMetadata(const BSONObj& met
if (!status.isOK())
return status;
- // TODO(SERVER-47157): require configTerm.
long long configTerm;
- status = bsonExtractIntegerFieldWithDefault(
- replMetadataObj, kConfigTermFieldName, OpTime::kUninitializedTerm, &configTerm);
+ status = bsonExtractIntegerField(replMetadataObj, kConfigTermFieldName, &configTerm);
if (!status.isOK())
return status;
diff --git a/src/mongo/rpc/metadata/repl_set_metadata_test.cpp b/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
index 7aa199fa046..9a121fd20d5 100644
--- a/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
+++ b/src/mongo/rpc/metadata/repl_set_metadata_test.cpp
@@ -106,27 +106,6 @@ TEST(ReplResponseMetadataTest, MetadataCanBeConstructedWhenMissingOplogQueryMeta
ASSERT_EQ(metadata.getReplicaSetId(), metadata.getReplicaSetId());
ASSERT_EQ(metadata.getTerm(), 3);
}
-
-TEST(ReplResponseMetadataTest, MetadataCanBeConstructedFrom42) {
- // TODO(SERVER-47125): delete this test in 4.6 when we can rely on the isPrimary and configTerm
- // fields.
- BSONObj obj(
- BSON(kReplSetMetadataFieldName
- << BSON("term" << 3 << "lastOpCommitted"
- << BSON("ts" << opTime.getTimestamp() << "t" << opTime.getTerm())
- << "lastCommittedWall" << committedWallTime << "lastOpVisible"
- << BSON("ts" << opTime2.getTimestamp() << "t" << opTime2.getTerm())
- << "configVersion" << 6 << "replicaSetId" << metadata.getReplicaSetId()
- << "primaryIndex" << 12 << "syncSourceIndex" << -1)));
-
- auto status = ReplSetMetadata::readFromMetadata(obj);
- ASSERT_OK(status.getStatus());
-
- const auto& metadata = status.getValue();
- ASSERT_FALSE(metadata.getIsPrimary().is_initialized());
- ASSERT_EQUALS(metadata.getConfigTerm(), -1);
-}
-
} // unnamed namespace
} // namespace rpc
} // namespace mongo