Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mongodb/mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jul 30, 2010
2 parents b6524e0 + 6a5c95a commit a003db6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/dbclient.cpp
Expand Up @@ -1045,7 +1045,7 @@ namespace mongo {
string e; string e;
_conns[i]->auth( dbname , username , pwd , e , digestPassword ); _conns[i]->auth( dbname , username , pwd , e , digestPassword );
} }
catch ( AssertionException& e ){ catch ( AssertionException& ){
} }
} }


Expand Down
2 changes: 1 addition & 1 deletion db/repl/consensus.cpp
Expand Up @@ -307,7 +307,7 @@ namespace mongo {
} }
else { else {
/* succeeded. */ /* succeeded. */
log() << "replSet election succeeded, assuming primary role" << rsLog; log(1) << "replSet election succeeded, assuming primary role" << rsLog;
success = true; success = true;
rs.assumePrimary(); rs.assumePrimary();
} }
Expand Down
2 changes: 1 addition & 1 deletion db/repl/heartbeat.cpp
Expand Up @@ -130,7 +130,7 @@ namespace mongo {
string name() { return "ReplSetHealthPollTask"; } string name() { return "ReplSetHealthPollTask"; }
void doWork() { void doWork() {
if ( !theReplSet ) { if ( !theReplSet ) {
log() << "theReplSet not initialized yet, skipping health poll this round" << rsLog; log(2) << "theReplSet not initialized yet, skipping health poll this round" << rsLog;
return; return;
} }


Expand Down
8 changes: 3 additions & 5 deletions db/repl/rs.cpp
Expand Up @@ -34,7 +34,7 @@ namespace mongo {
assert( iAmPotentiallyHot() ); assert( iAmPotentiallyHot() );
writelock lk("admin."); // so we are synchronized with _logOp() writelock lk("admin."); // so we are synchronized with _logOp()
box.setSelfPrimary(_self); box.setSelfPrimary(_self);
log(2) << "replSet self (" << _self->id() << ") is now primary" << rsLog; log() << "replSet PRIMARY" << rsLog; // self (" << _self->id() << ") is now primary" << rsLog;
} }


void ReplSetImpl::changeState(MemberState s) { box.change(s, _self); } void ReplSetImpl::changeState(MemberState s) { box.change(s, _self); }
Expand Down Expand Up @@ -164,7 +164,7 @@ namespace mongo {
seedSet.insert(m); seedSet.insert(m);
//uassert(13101, "can't use localhost in replset host list", !m.isLocalHost()); //uassert(13101, "can't use localhost in replset host list", !m.isLocalHost());
if( m.isSelf() ) { if( m.isSelf() ) {
log() << "replSet ignoring seed " << m.toString() << " (=self)" << rsLog; log(1) << "replSet ignoring seed " << m.toString() << " (=self)" << rsLog;
} else } else
seeds.push_back(m); seeds.push_back(m);
if( *comma == 0 ) if( *comma == 0 )
Expand Down Expand Up @@ -372,13 +372,11 @@ namespace mongo {
log() << "replSet have you ran replSetInitiate yet?" << rsLog; log() << "replSet have you ran replSetInitiate yet?" << rsLog;
if( _seeds->size() == 0 ) if( _seeds->size() == 0 )
log() << "replSet no seed hosts were specified on the --replSet command line - that might be the issue" << rsLog; log() << "replSet no seed hosts were specified on the --replSet command line - that might be the issue" << rsLog;
log() << "replSet sleeping 20sec and will try again." << rsLog;
} }
else { else {
startupStatus = EMPTYUNREACHABLE; startupStatus = EMPTYUNREACHABLE;
startupStatusMsg = "can't currently get " + rsConfigNs + " config from self or any seed (EMPTYUNREACHABLE)"; startupStatusMsg = "can't currently get " + rsConfigNs + " config from self or any seed (EMPTYUNREACHABLE)";
log() << "replSet can't get " << rsConfigNs << " config from self or any seed." << rsLog; log() << "replSet can't get " << rsConfigNs << " config from self or any seed (yet)" << rsLog;
log() << "replSet sleeping 20sec and will try again." << rsLog;
} }


sleepsecs(10); sleepsecs(10);
Expand Down
34 changes: 31 additions & 3 deletions db/repl/rs_sync.cpp
Expand Up @@ -22,6 +22,8 @@


namespace mongo { namespace mongo {


using namespace bson;

void startSyncThread() { void startSyncThread() {
Client::initThread("rs_sync"); Client::initThread("rs_sync");
theReplSet->syncThread(); theReplSet->syncThread();
Expand Down Expand Up @@ -82,14 +84,39 @@ namespace mongo {


{ {
if( !r.more() ) { if( !r.more() ) {
/* maybe we are ahead and need to roll back? */
try {
bo theirLastOp = r.getLastOp(rsoplog);
if( theirLastOp.isEmpty() ) {
log() << "replSet error empty query result from " << hn << " oplog" << rsLog;
sleepsecs(2);
return;
}
OpTime theirTS = theirLastOp["ts"]._opTime();
if( theirTS < lastOpTimeWritten ) {
log() << "replSet we are ahead of the primary, will try to roll back" << rsLog;
syncRollback(r);
return;
}
/* we're not ahead? maybe our new query got fresher data. best to come back and try again */
log() << "replSet syncTail condition 1" << rsLog;
sleepsecs(1);
}
catch(DBException& e) {
log() << "replSet error querying " << hn << ' ' << e.toString() << rsLog;
sleepsecs(2);
}
return;
/*
log() << "replSet syncTail error querying oplog >= " << lastOpTimeWritten.toString() << " from " << hn << rsLog; log() << "replSet syncTail error querying oplog >= " << lastOpTimeWritten.toString() << " from " << hn << rsLog;
try { try {
log() << "replSet " << hn << " last op: " << r.getLastOp(rsoplog).toString() << rsLog; log() << "replSet " << hn << " last op: " << r.getLastOp(rsoplog).toString() << rsLog;
} }
catch(...) { } catch(...) { }
sleepsecs(1); sleepsecs(1);
return; return;*/
} }

BSONObj o = r.nextSafe(); BSONObj o = r.nextSafe();
OpTime ts = o["ts"]._opTime(); OpTime ts = o["ts"]._opTime();
long long h = o["h"].numberLong(); long long h = o["h"].numberLong();
Expand Down Expand Up @@ -127,10 +154,11 @@ namespace mongo {
} }
if( golive ) { if( golive ) {
sethbmsg(""); sethbmsg("");
log() << "replSet SECONDARY" << rsLog;
changeState(MemberState::RS_SECONDARY); changeState(MemberState::RS_SECONDARY);
} }
else { else {
sethbmsg("recovering; not yet to minValid optime"); sethbmsg("still syncing, not yet to minValid optime");
} }


/* todo: too stale capability */ /* todo: too stale capability */
Expand Down Expand Up @@ -201,7 +229,7 @@ namespace mongo {
_syncThread(); _syncThread();
} }
catch(DBException& e) { catch(DBException& e) {
log() << "replSet syncThread: " << e.toString() << rsLog; sethbmsg("syncThread: " + e.toString());
sleepsecs(10); sleepsecs(10);
} }
catch(...) { catch(...) {
Expand Down

0 comments on commit a003db6

Please sign in to comment.