diff options
author | Andrew Shuvalov <andrew.shuvalov@mongodb.com> | 2021-10-15 19:21:43 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-15 20:02:55 +0000 |
commit | b996dfbc5135e94b38fb86014c656930cdc2f533 (patch) | |
tree | 510fc780d0b875e996aba67bfa6e3852da86b3cf /src/mongo/client/sdam/topology_description.h | |
parent | b69563e8b35f91441bc6b666cba1c09414b27a08 (diff) | |
download | mongo-b996dfbc5135e94b38fb86014c656930cdc2f533.tar.gz |
SERVER-59409 backport BACKPORT-10657: Fix race between reconfig replication and stepup part 4
Diffstat (limited to 'src/mongo/client/sdam/topology_description.h')
-rw-r--r-- | src/mongo/client/sdam/topology_description.h | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/mongo/client/sdam/topology_description.h b/src/mongo/client/sdam/topology_description.h index b7de69401a0..d8799356513 100644 --- a/src/mongo/client/sdam/topology_description.h +++ b/src/mongo/client/sdam/topology_description.h @@ -67,11 +67,7 @@ public: const UUID& getId() const; TopologyType getType() const; const boost::optional<std::string>& getSetName() const; - - // TODO(SERVER-59409): remove next 2 methods and keep only pair getter. - const boost::optional<int>& getMaxSetVersion() const; - const boost::optional<OID>& getMaxElectionId() const; - const ElectionIdSetVersionPair getMaxElectionIdSetVersionPair() const; + ElectionIdSetVersionPair getMaxElectionIdSetVersionPair() const; const std::vector<ServerDescriptionPtr>& getServers() const; @@ -105,15 +101,13 @@ private: friend bool operator==(const TopologyDescription& lhs, const TopologyDescription& rhs) { return std::tie(lhs._setName, lhs._type, - lhs._maxSetVersion, - lhs._maxElectionId, + lhs._maxElectionIdSetVersionPair, lhs._servers, lhs._compatible, lhs._logicalSessionTimeoutMinutes) == std::tie(rhs._setName, rhs._type, - rhs._maxSetVersion, - rhs._maxElectionId, + rhs._maxElectionIdSetVersionPair, rhs._servers, rhs._compatible, rhs._logicalSessionTimeoutMinutes); @@ -147,6 +141,8 @@ private: */ void calculateLogicalSessionTimeout(); + void updateMaxElectionIdSetVersionPair(const ElectionIdSetVersionPair& pair); + // unique id for this topology UUID _id = UUID::gen(); @@ -156,13 +152,12 @@ private: // setName: the replica set name. Default null. boost::optional<std::string> _setName; - // maxSetVersion: an integer or null. The largest setVersion ever reported by a primary. - // Default null. - boost::optional<int> _maxSetVersion; - - // maxElectionId: an ObjectId or null. The largest electionId ever reported by a primary. - // Default null. - boost::optional<OID> _maxElectionId; + // The tuple consisting of: + // maxSetVersion: an integer or none. The largest setVersion ever reported by a primary. + // Note: maxSetVersion can go backwards. + // maxElectionId: an ObjectId or none. The largest electionId ever reported by a primary. + // Default {none, none}. + ElectionIdSetVersionPair _maxElectionIdSetVersionPair; // servers: a set of ServerDescription instances. Default contains one server: // "localhost:27017", ServerType Unknown. |