summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristina <kristina@10gen.com>2011-03-31 16:55:41 -0400
committerEliot Horowitz <eliot@10gen.com>2011-04-14 14:44:22 -0400
commit0c6ed621b30252235d070ef6e724b391f5ecf7b7 (patch)
tree94b39492599af5c5243c3872c1c0d6cc6a203d1a
parent6b28225ad1ac39bdc6a363cd7d0971c6085a3dce (diff)
downloadmongo-0c6ed621b30252235d070ef6e724b391f5ecf7b7.tar.gz
do not demote primary if a secondary restarts SERVER-2550
-rw-r--r--db/repl/consensus.cpp6
-rw-r--r--jstests/replsets/initial_sync1.js5
2 files changed, 7 insertions, 4 deletions
diff --git a/db/repl/consensus.cpp b/db/repl/consensus.cpp
index f764abe2357..dadb22ee168 100644
--- a/db/repl/consensus.cpp
+++ b/db/repl/consensus.cpp
@@ -154,6 +154,12 @@ namespace mongo {
log() << "couldn't find member with id " << whoid << rsLog;
vote = -10000;
}
+ else if( primary && primary == rs._self && rs.lastOpTimeWritten >= hopeful->hbinfo().opTime ) {
+ // hbinfo is not updated, so we have to check the primary's last optime separately
+ log() << "I am already primary, " << hopeful->fullName()
+ << " can try again once I've stepped down" << 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 " <<
diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js
index ee30b4e8cee..df978c41695 100644
--- a/jstests/replsets/initial_sync1.js
+++ b/jstests/replsets/initial_sync1.js
@@ -114,9 +114,6 @@ wait(function() {
});
-/**
- * TODO: this fails on buildbot
- * see SERVER-2550
print("10. Insert some stuff");
master = replTest.getMaster();
for (var i=0; i<10000; i++) {
@@ -126,4 +123,4 @@ for (var i=0; i<10000; i++) {
print("11. Everyone happy eventually");
replTest.awaitReplication();
-*/
+