[SERVER-45084] Audit all uses of ReplSetConfig::getConfigVersion() Created: 12/Dec/19  Updated: 29/Oct/23  Resolved: 29/Jan/20

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.3.4

Type: Task Priority: Major - P3
Reporter: Siyuan Zhou Assignee: William Schultz (Inactive)
Resolution: Fixed Votes: 0
Labels: safe-reconfig-consensus
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Repl 2020-01-27, Repl 2020-02-10
Participants:

 Description   

Since in safe reconfig, we always compare config term and version, we need to audit all places where config version is used and see if they should be updated.



 Comments   
Comment by Githook User [ 29/Jan/20 ]

Author:

{'name': 'William Schultz', 'username': 'will62794', 'email': 'william.schultz@mongodb.com'}

Message: SERVER-45084 Audit all usages of ReplSetConfig::getConfigVersion()
Branch: master
https://github.com/mongodb/mongo/commit/4a62f87856ee58e2a2f8dbf98ee671c03447c8da

Comment by William Schultz (Inactive) [ 15/Jan/20 ]

A quick IDE search for non-test usages of ReplSetConfig::getConfigVersion turns up the following:

Function
    getConfigVersion() const : long long int
Found usages  (47 usages found)
    Production  (47 usages found)
        Member access  (47 usages found)
            mongo  (47 usages found)
                src/mongo/db/repl  (47 usages found)
                    check_quorum_for_config_change.cpp  (8 usages found)
                        _onQuorumCheckComplete  (1 usage found)
                            133 if (_rsConfig->getConfigVersion() == 1 && !_badResponses.empty()) {
                        _tabulateHeartbeatResponse  (2 usages found)
                            216 if (hbResp.getConfigVersion() >= _rsConfig->getConfigVersion()) {
                            218 << "Our config version of " << _rsConfig->getConfigVersion()
                        checkQuorumForInitiate  (1 usage found)
                            299 invariant(rsConfig.getConfigVersion() == 1);
                        checkQuorumForReconfig  (1 usage found)
                            307 invariant(rsConfig.getConfigVersion() > 1);
                        getRequests  (2 usages found)
                            78 const bool isInitialConfig = _rsConfig->getConfigVersion() == 1;
                            90 hbArgs.setConfigVersion(_rsConfig->getConfigVersion());
                        hasReceivedSufficientResponses  (1 usage found)
                            262 if (_rsConfig->getConfigVersion() == 1) {
                    repl_set_config_checks.cpp  (8 usages found)
                        checkElectable  (1 usage found)
                            99 << newConfig.getConfigVersion() << " for replica set "
                        findSelfInConfig  (2 usages found)
                            67 << newConfig.getConfigVersion() << " for replica set "
                            78 << newConfig.getConfigVersion() << " for replica set "
                        validateConfigForInitiate  (2 usages found)
                            320 if (newConfig.getConfigVersion() != 1) {
                            324 << newConfig.getConfigVersion());
                        validateOldAndNewConfigsCompatible  (3 usages found)
                            203 if (oldConfig.getConfigVersion() >= newConfig.getConfigVersion()) {
                            207 << newConfig.getConfigVersion() << " is not greater than "
                            208 << oldConfig.getConfigVersion() << " for replica set "
                    replication_coordinator_impl.cpp  (2 usages found)
                        _finishReplSetReconfig  (1 usage found)
                            2812 << newConfig.getConfigVersion();
                        _processReplSetMetadata_inlock  (1 usage found)
                            2603 if (replMetadata.getConfigVersion() != _rsConfig.getConfigVersion()) {
                    replication_coordinator_impl_heartbeat.cpp  (8 usages found)
                        _heartbeatReconfigFinish  (2 usages found)
                            600 << newConfig.getConfigVersion();
                            652 _rsConfig.getConfigVersion() < newConfig.getConfigVersion());
                        _heartbeatReconfigStore  (2 usages found)
                            518 LOG_FOR_HEARTBEATS(2) << "Config with version " << newConfig.getConfigVersion()
                            555 LOG_FOR_HEARTBEATS(2) << "New configuration with version " << newConfig.getConfigVersion()
                        _scheduleHeartbeatReconfig_inlock  (4 usages found)
                            447 << newConfig.getConfigVersion();
                            453 << newConfig.getConfigVersion()
                            465 _rsConfig.getConfigVersion() < newConfig.getConfigVersion());
                            468 << newConfig.getConfigVersion()
                    replication_coordinator_mock.cpp  (1 usage found)
                        awaitIsMasterResponse  (1 usage found)
                            560 response->setReplSetVersion(_getConfigReturnValue.getConfigVersion());
                    replication_coordinator_test_fixture.cpp  (3 usages found)
                        consumeHeartbeatV1  (1 usage found)
                            437 hbResp.setConfigVersion(rsConfig.getConfigVersion());
                        simulateEnoughHeartbeatsForAllNodesUp  (1 usage found)
                            238 hbResp.setConfigVersion(rsConfig.getConfigVersion());
                        simulateSuccessfulV1ElectionWithoutExitingDrainMode  (1 usage found)
                            346 hbResp.setConfigVersion(rsConfig.getConfigVersion());
                    topology_coordinator.cpp  (16 usages found)
                        fillIsMasterForReplSet  (1 usage found)
                            1755 response->setReplSetVersion(_rsConfig.getConfigVersion());
                        prepareHeartbeatRequestV1  (1 usage found)
                            678 hbArgs.setConfigVersion(_rsConfig.getConfigVersion());
                        prepareHeartbeatResponseV1  (1 usage found)
                            628 const long long v = _rsConfig.getConfigVersion();
                        prepareReplSetMetadata  (1 usage found)
                            2702 _rsConfig.getConfigVersion(),
                        prepareReplSetUpdatePositionCommand  (1 usage found)
                            1689 entry.append(UpdatePositionArgs::kConfigVersionFieldName, _rsConfig.getConfigVersion());
                        prepareStatusResponse  (1 usage found)
                            1518 bb.appendIntOrLL("configVersion", _rsConfig.getConfigVersion());
                        processHeartbeatResponse  (3 usages found)
                            749 _rsConfig.isInitialized() ? _rsConfig.getConfigVersion() : -2;
                            751 if (newConfig.getConfigVersion() > currentConfigVersion) {
                            758 if (newConfig.getConfigVersion() < currentConfigVersion) {
                        processReplSetRequestVotes  (2 usages found)
                            2747 } else if (args.getConfigVersion() != _rsConfig.getConfigVersion()) {
                            2751 << ") differs from mine (" << _rsConfig.getConfigVersion() << ")");
                        setLastOptime  (3 usages found)
                            1074 if (args.cfgver != _rsConfig.getConfigVersion()) {
                            1078 << _rsConfig.getConfigVersion();
                            1080 *configVersion = _rsConfig.getConfigVersion();
                        shouldChangeSyncSource  (2 usages found)
                            2600 if (replMetadata.getConfigVersion() != _rsConfig.getConfigVersion()) {
                            2603 << _rsConfig.getConfigVersion();
                    vote_requester.cpp  (1 usage found)
                        getRequests  (1 usage found)
                            89 requestVotesCmdBuilder.append("configVersion", _rsConfig.getConfigVersion());

Due to the file grep pattern used, the search above also includes usages in replication_coordinator_test_fixture.cpp and replication_coordinator_mock.cpp which shouldn't be as interesting. We can filter those test usages out and also filter out usages that are only for printing log messages. We may want to eventually update these log messages to include both a configVersion and configTerm, but we can look at where config version affects system behavior first. These are the non-test and non-logging usages:

check_quorum_for_config_change.cpp  (7 usages found)
    _onQuorumCheckComplete  (1 usage found)
        133 if (_rsConfig->getConfigVersion() == 1 && !_badResponses.empty()) {
    _tabulateHeartbeatResponse  (1 usages found)
        216 if (hbResp.getConfigVersion() >= _rsConfig->getConfigVersion()) {
    checkQuorumForInitiate  (1 usage found)
        299 invariant(rsConfig.getConfigVersion() == 1);
    checkQuorumForReconfig  (1 usage found)
        307 invariant(rsConfig.getConfigVersion() > 1);
    getRequests  (2 usages found)
        78 const bool isInitialConfig = _rsConfig->getConfigVersion() == 1;
        90 hbArgs.setConfigVersion(_rsConfig->getConfigVersion());
    hasReceivedSufficientResponses  (1 usage found)
        262 if (_rsConfig->getConfigVersion() == 1) {
 
repl_set_config_checks.cpp  (2 usages found)
    validateConfigForInitiate  (1 usages found)
        320 if (newConfig.getConfigVersion() != 1) {
    validateOldAndNewConfigsCompatible  (1 usages found)
        203 if (oldConfig.getConfigVersion() >= newConfig.getConfigVersion()) {
 
replication_coordinator_impl.cpp  (1 usages found)
    _processReplSetMetadata_inlock  (1 usage found)
        2603 if (replMetadata.getConfigVersion() != _rsConfig.getConfigVersion()) {
 
replication_coordinator_impl_heartbeat.cpp  (2 usages found)
    _heartbeatReconfigFinish  (1 usages found)
        652 _rsConfig.getConfigVersion() < newConfig.getConfigVersion());
    _scheduleHeartbeatReconfig_inlock  (1 usages found)
        465 _rsConfig.getConfigVersion() < newConfig.getConfigVersion());
 
topology_coordinator.cpp  (14 usages found)
    fillIsMasterForReplSet  (1 usage found)
        1755 response->setReplSetVersion(_rsConfig.getConfigVersion());
    prepareHeartbeatRequestV1  (1 usage found)
        678 hbArgs.setConfigVersion(_rsConfig.getConfigVersion());
    prepareHeartbeatResponseV1  (1 usage found)
        628 const long long v = _rsConfig.getConfigVersion();
    prepareReplSetMetadata  (1 usage found)
        2702 _rsConfig.getConfigVersion(),
    prepareReplSetUpdatePositionCommand  (1 usage found)
        1689 entry.append(UpdatePositionArgs::kConfigVersionFieldName, _rsConfig.getConfigVersion());
    prepareStatusResponse  (1 usage found)
        1518 bb.appendIntOrLL("configVersion", _rsConfig.getConfigVersion());
    processHeartbeatResponse  (3 usages found)
        749 _rsConfig.isInitialized() ? _rsConfig.getConfigVersion() : -2;
        751 if (newConfig.getConfigVersion() > currentConfigVersion) {
        758 if (newConfig.getConfigVersion() < currentConfigVersion) {
    processReplSetRequestVotes  (1 usages found)
        2747 } else if (args.getConfigVersion() != _rsConfig.getConfigVersion()) {
    setLastOptime  (3 usages found)
        1074 if (args.cfgver != _rsConfig.getConfigVersion()) {
        1078 << _rsConfig.getConfigVersion();
        1080 *configVersion = _rsConfig.getConfigVersion();
    shouldChangeSyncSource  (1 usages found)
        2600 if (replMetadata.getConfigVersion() != _rsConfig.getConfigVersion()) {
 
vote_requester.cpp  (1 usage found)
    getRequests  (1 usage found)
        89 requestVotesCmdBuilder.append("configVersion", _rsConfig.getConfigVersion());

Generated at Thu Feb 08 05:07:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.