diff options
author | Antonin Kral <a.kral@bobek.cz> | 2010-12-10 13:05:34 +0100 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2010-12-10 13:05:34 +0100 |
commit | ed4a804c027562e1bf6a0f45dae7326198c29f8e (patch) | |
tree | 9d04736132d5421497a80619e30d4c2e03e76728 /db/repl/consensus.cpp | |
parent | e598e7ada36302f35a0da8ae0c63c34b51b6a720 (diff) | |
download | mongodb-ed4a804c027562e1bf6a0f45dae7326198c29f8e.tar.gz |
Imported Upstream version 1.6.5
Diffstat (limited to 'db/repl/consensus.cpp')
-rw-r--r-- | db/repl/consensus.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/db/repl/consensus.cpp b/db/repl/consensus.cpp index 4044538..1519c26 100644 --- a/db/repl/consensus.cpp +++ b/db/repl/consensus.cpp @@ -134,6 +134,9 @@ namespace mongo { OID round = cmd["round"].OID(); int myver = rs.config().version; + const Member* primary = rs.box.getPrimary(); + const Member* hopeful = rs.findById(whoid); + int vote = 0; if( set != rs.name() ) { log() << "replSet error received an elect request for '" << set << "' but our set name is '" << rs.name() << "'" << rsLog; @@ -147,6 +150,16 @@ namespace mongo { log() << "replSet info got stale version # during election" << rsLog; vote = -10000; } + else if( !hopeful ) { + log() << "couldn't find member with id " << whoid << rsLog; + vote = -10000; + } + else if( primary && primary->hbinfo().opTime > hopeful->hbinfo().opTime ) { + // other members might be aware of more up-to-date nodes + log() << hopeful->fullName() << " is trying to elect itself but " << + primary->fullName() << " is already primary and more up-to-date" << rsLog; + vote = -10000; + } else { try { vote = yea(whoid); @@ -165,7 +178,7 @@ namespace mongo { void ReplSetImpl::_getTargets(list<Target>& L, int& configVersion) { configVersion = config().version; for( Member *m = head(); m; m=m->next() ) - if( m->hbinfo().up() ) + if( m->hbinfo().maybeUp() ) L.push_back( Target(m->fullName()) ); } |