Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-23706

replication electable condition

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.2.5
    • Component/s: Replication
    • Labels:
      None
    • Repl 13 (04/22/16)

      In official document: https://docs.mongodb.org/manual/core/replica-set-elections/

       A member will veto an election:
      
      If the member seeking an election is not a member of the voter’s set.
      If the current primary has more recent operations (i.e. a higher optime) than the member seeking election, from the perspective of another voting member.
      If the current primary has the same or more recent operations (i.e. a higher or equal optime) than the member seeking election.
      
      

      but in the source code: src/mongo/db/repl/topology_coordinator_impl.cpp, which means the node with older oplog(10 seconds within newest) maybe elected as a primary.

      bool TopologyCoordinatorImpl::_isOpTimeCloseEnoughToLatestToElect(
          const OpTime& otherOpTime, const OpTime& ourLastOpApplied) const {
          const OpTime latestKnownOpTime = _latestKnownOpTime(ourLastOpApplied);
          // Use addition instead of subtraction to avoid overflow.
          return otherOpTime.getSecs() + 10 >= (latestKnownOpTime.getSecs());
      }
      

      I want to know if it's a bug or the document is wrong?

            Assignee:
            milkie@mongodb.com Eric Milkie
            Reporter:
            zyd_com@126.com Zhang Youdong
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: