summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2014-10-17 12:07:55 -0400
committerAndy Schwerin <schwerin@mongodb.com>2014-10-17 16:29:45 -0400
commit35fb6b94298f97171337f521ecd19de2385386d0 (patch)
tree02be17476b897f11267eca8672a84522404cc3a1 /src/mongo/db
parentd6bce9d4935b967546cd2cf028f5cc9e7801f967 (diff)
downloadmongo-35fb6b94298f97171337f521ecd19de2385386d0.tar.gz
SERVER-15535 Do not consider a remote node electable if it explicitly reports that it is not.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/repl/member_heartbeat_data.h6
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/topology_coordinator_impl.h3
3 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/db/repl/member_heartbeat_data.h b/src/mongo/db/repl/member_heartbeat_data.h
index 65dd9819ad5..f5015669a0b 100644
--- a/src/mongo/db/repl/member_heartbeat_data.h
+++ b/src/mongo/db/repl/member_heartbeat_data.h
@@ -59,6 +59,12 @@ namespace repl {
OpTime getElectionTime() const { return _lastResponse.getElectionTime(); }
+ // Returns true if the last heartbeat data explicilty stated that the node
+ // is not electable.
+ bool isUnelectable() const {
+ return _lastResponse.hasIsElectable() && !_lastResponse.isElectable();
+ }
+
// Was this member up for the last heartbeat?
bool up() const { return _health > 0; }
// Was this member up for the last hearbeeat
diff --git a/src/mongo/db/repl/topology_coordinator_impl.cpp b/src/mongo/db/repl/topology_coordinator_impl.cpp
index 0a345a35616..fd546f71e00 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.cpp
+++ b/src/mongo/db/repl/topology_coordinator_impl.cpp
@@ -1589,6 +1589,9 @@ namespace {
else if (!_isOpTimeCloseEnoughToLatestToElect(hbData.getOpTime(), lastOpApplied)) {
return NotCloseEnoughToLatestOptime;
}
+ else if (hbData.up() && hbData.isUnelectable()) {
+ return RefusesToStand;
+ }
else {
invariant(memberConfig.isElectable());
return None;
@@ -1653,6 +1656,8 @@ namespace {
return "member is more than 10 seconds behind the most up-to-date member";
case NotInitialized:
return "node is not a member of a valid replica set configuration";
+ case RefusesToStand:
+ return "most recent heartbeat indicates node will not stand for election";
}
invariant(false); // unreachable
}
diff --git a/src/mongo/db/repl/topology_coordinator_impl.h b/src/mongo/db/repl/topology_coordinator_impl.h
index 24591142ebd..188eab50551 100644
--- a/src/mongo/db/repl/topology_coordinator_impl.h
+++ b/src/mongo/db/repl/topology_coordinator_impl.h
@@ -224,7 +224,8 @@ namespace repl {
StepDownPeriodActive,
NoData,
NotInitialized,
- VotedTooRecently
+ VotedTooRecently,
+ RefusesToStand
};
// Returns the number of heartbeat pings which have occurred.