Skip to content

Commit

Permalink
rs better fatal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight authored and erh committed Sep 15, 2010
1 parent 20b546a commit 5ecb7b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
5 changes: 3 additions & 2 deletions db/repl/rs.cpp
Expand Up @@ -494,6 +494,7 @@ namespace mongo {
startupStatusMsg = "replSet error loading set config (BADCONFIG)";
log() << "replSet error loading configurations " << e.toString() << rsLog;
log() << "replSet error replication will not start" << rsLog;
sethbmsg("error loading set config");
_fatal();
throw;
}
Expand All @@ -507,8 +508,8 @@ namespace mongo {
{
//lock l(this);
box.set(MemberState::RS_FATAL, 0);
sethbmsg("fatal error");
log() << "replSet error fatal error, stopping replication" << rsLog;
//sethbmsg("fatal error");
log() << "replSet error fatal, stopping replication" << rsLog;
}

void ReplSet::haveNewConfig(ReplSetConfig& newConfig, bool addComment) {
Expand Down
2 changes: 1 addition & 1 deletion db/repl/rs.h
Expand Up @@ -206,7 +206,7 @@ namespace mongo {
}
void noteRemoteIsPrimary(const Member *remote) {
scoped_lock lk(m);
if( !sp.state.secondary() )
if( !sp.state.secondary() && !sp.state.fatal() )
sp.state = MemberState::RS_RECOVERING;
sp.primary = remote;
}
Expand Down
6 changes: 6 additions & 0 deletions db/repl/rs_rollback.cpp
Expand Up @@ -431,6 +431,7 @@ namespace mongo {
log() << "replSet error rolling back : " << err << ". A full resync will be necessary." << rsLog;
/* todo: reset minvalid so that we are permanently in fatal state */
/* todo: don't be fatal, but rather, get all the data first. */
sethbmsg("rollback error");
throw rsfatal();
}
}
Expand Down Expand Up @@ -649,6 +650,11 @@ namespace mongo {
try {
syncFixUp(how, r);
}
catch( rsfatal& ) {
sethbmsg("rollback fixup error");
_fatal();
return 2;
}
catch(...) {
incRBID(); throw;
}
Expand Down
6 changes: 5 additions & 1 deletion jstests/replsets/rollback3.js
Expand Up @@ -30,7 +30,11 @@ function wait(f) {
if (n % 4 == 0)
print("rollback3.js waiting " + w);
if (++n == 4) {
print("" + f);
print("" + f);
}
if (n == 200) {
print("rollback3.js failing waited too long");
throw "wait error";
}
sleep(1000);
}
Expand Down

0 comments on commit 5ecb7b9

Please sign in to comment.