Permalink
Browse files

Merge branch 'master' of github.com:mongodb/mongo

  • Loading branch information...
2 parents b6524e0 + 6a5c95a commit a003db68839fa7d161ace0fed91aa2c8b81448da @erh erh committed Jul 30, 2010
Showing with 37 additions and 11 deletions.
  1. +1 −1 client/dbclient.cpp
  2. +1 −1 db/repl/consensus.cpp
  3. +1 −1 db/repl/heartbeat.cpp
  4. +3 −5 db/repl/rs.cpp
  5. +31 −3 db/repl/rs_sync.cpp
View
2 client/dbclient.cpp
@@ -1045,7 +1045,7 @@ namespace mongo {
string e;
_conns[i]->auth( dbname , username , pwd , e , digestPassword );
}
- catch ( AssertionException& e ){
+ catch ( AssertionException& ){
}
}
View
2 db/repl/consensus.cpp
@@ -307,7 +307,7 @@ namespace mongo {
}
else {
/* succeeded. */
- log() << "replSet election succeeded, assuming primary role" << rsLog;
+ log(1) << "replSet election succeeded, assuming primary role" << rsLog;
success = true;
rs.assumePrimary();
}
View
2 db/repl/heartbeat.cpp
@@ -130,7 +130,7 @@ namespace mongo {
string name() { return "ReplSetHealthPollTask"; }
void doWork() {
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;
}
View
8 db/repl/rs.cpp
@@ -34,7 +34,7 @@ namespace mongo {
assert( iAmPotentiallyHot() );
writelock lk("admin."); // so we are synchronized with _logOp()
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); }
@@ -164,7 +164,7 @@ namespace mongo {
seedSet.insert(m);
//uassert(13101, "can't use localhost in replset host list", !m.isLocalHost());
if( m.isSelf() ) {
- log() << "replSet ignoring seed " << m.toString() << " (=self)" << rsLog;
+ log(1) << "replSet ignoring seed " << m.toString() << " (=self)" << rsLog;
} else
seeds.push_back(m);
if( *comma == 0 )
@@ -372,13 +372,11 @@ namespace mongo {
log() << "replSet have you ran replSetInitiate yet?" << rsLog;
if( _seeds->size() == 0 )
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 {
startupStatus = 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 sleeping 20sec and will try again." << rsLog;
+ log() << "replSet can't get " << rsConfigNs << " config from self or any seed (yet)" << rsLog;
}
sleepsecs(10);
View
34 db/repl/rs_sync.cpp
@@ -22,6 +22,8 @@
namespace mongo {
+ using namespace bson;
+
void startSyncThread() {
Client::initThread("rs_sync");
theReplSet->syncThread();
@@ -82,14 +84,39 @@ namespace mongo {
{
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;
try {
log() << "replSet " << hn << " last op: " << r.getLastOp(rsoplog).toString() << rsLog;
}
catch(...) { }
sleepsecs(1);
- return;
+ return;*/
}
+
BSONObj o = r.nextSafe();
OpTime ts = o["ts"]._opTime();
long long h = o["h"].numberLong();
@@ -127,10 +154,11 @@ namespace mongo {
}
if( golive ) {
sethbmsg("");
+ log() << "replSet SECONDARY" << rsLog;
changeState(MemberState::RS_SECONDARY);
}
else {
- sethbmsg("recovering; not yet to minValid optime");
+ sethbmsg("still syncing, not yet to minValid optime");
}
/* todo: too stale capability */
@@ -201,7 +229,7 @@ namespace mongo {
_syncThread();
}
catch(DBException& e) {
- log() << "replSet syncThread: " << e.toString() << rsLog;
+ sethbmsg("syncThread: " + e.toString());
sleepsecs(10);
}
catch(...) {

0 comments on commit a003db6

Please sign in to comment.