Details
-
Question
-
Resolution: Done
-
Major - P3
-
None
-
3.2.5
-
None
-
Repl 13 (04/22/16)
Description
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?