Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Jul 23, 2010
1 parent 03d4cf0 commit e7cb7d2
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions db/repl/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ namespace mongo {

if( p2 ) {
/* someone else thinks they are primary. */
if( p == p2 ) { // already match
if( p == p2 ) {
// we thought the same; all set.
return;
}
if( p == 0 ) {
Expand All @@ -93,37 +94,45 @@ namespace mongo {
}
// todo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
if( p != rs->_self ) {
// switch primary from oldremotep->newremotep2
noteARemoteIsPrimary(p2);
return;
}
/* we thought we were primary, yet now someone else thinks they are. */
if( !rs->elect.aMajoritySeemsToBeUp() ) {
/* we can't see a majority. so the other node is probably the right choice. */
noteARemoteIsPrimary(p2);
return;
}
/* ignore for now, keep thinking we are master */
/* ignore for now, keep thinking we are master.
this could just be timing (we poll every couple seconds) or could indicate
a problem? if it happens consistently for a duration of time we should
alert the sysadmin.
*/
return;
}

if( !rs->iAmPotentiallyHot() ) // if not we never try to be primary
return;

/* TODO : CHECK PRIORITY HERE. can't be elected if priority zero. */
/* didn't find anyone who wants to be primary */

if( p ) {
/* we are already primary, and nothing significant out there has changed. */
/* todo: if !aMajoritySeemsToBeUp, relinquish */
/* TODO: if !aMajoritySeemsToBeUp, relinquish */
assert( p == rs->_self );
return;
}

if( !rs->iAmPotentiallyHot() ) // if not we never try to be primary
return;

/* TODO : CHECK PRIORITY HERE. can't be elected if priority zero. */

/* no one seems to be primary. shall we try to elect ourself? */
if( !rs->elect.aMajoritySeemsToBeUp() ) {
rs->_self->lhb() = "can't see a majority, won't consider electing self";
rs->sethbmsg("can't see a majority, won't consider electing self",2);
return;
}

rs->_self->lhb() = "";
rs->sethbmsg("",9);
busyWithElectSelf = true; // don't try to do further elections & such while we are already working on one.
}
try {
Expand Down

0 comments on commit e7cb7d2

Please sign in to comment.