From b69c1496a903bcdf8a99849e6420e6d6259e1770 Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Mon, 6 Apr 2020 09:10:14 -0400 Subject: SERVER-47157 Require ReplSetMetadata.configTerm --- src/mongo/db/repl/README.md | 4 ++-- src/mongo/rpc/metadata/repl_set_metadata.cpp | 4 +--- src/mongo/rpc/metadata/repl_set_metadata_test.cpp | 21 --------------------- 3 files changed, 3 insertions(+), 26 deletions(-) (limited to 'src') 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::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 -- cgit v1.2.1