summaryrefslogtreecommitdiff
path: root/db/repl/consensus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'db/repl/consensus.cpp')
-rw-r--r--db/repl/consensus.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/repl/consensus.cpp b/db/repl/consensus.cpp
index 4eba17d61e0..4044538ec06 100644
--- a/db/repl/consensus.cpp
+++ b/db/repl/consensus.cpp
@@ -83,6 +83,17 @@ namespace mongo {
return vUp * 2 > totalVotes();
}
+ bool Consensus::shouldRelinquish() const {
+ int vUp = rs._self->config().votes;
+ const long long T = rs.config().ho.heartbeatTimeoutMillis * rs.config().ho.heartbeatConnRetries;
+ for( Member *m = rs.head(); m; m=m->next() ) {
+ long long dt = m->hbinfo().timeDown();
+ if( dt < T )
+ vUp += m->config().votes;
+ }
+ return !( vUp * 2 > totalVotes() );
+ }
+
static const int VETO = -10000;
const time_t LeaseTime = 30;
@@ -322,6 +333,7 @@ namespace mongo {
void Consensus::electSelf() {
assert( !rs.lockedByMe() );
assert( !rs.myConfig().arbiterOnly );
+ assert( rs.myConfig().slaveDelay == 0 );
try {
_electSelf();
}