diff options
author | Kristina <kristina@10gen.com> | 2013-01-15 15:59:43 -0500 |
---|---|---|
committer | Kristina <kristina@10gen.com> | 2013-01-15 15:59:57 -0500 |
commit | f380d40a3da93c22e9eb95d5308855f377a4123f (patch) | |
tree | 536e4429c517037d08952daf8d2b8d92ba2666eb /src/mongo/db/repl/bgsync.cpp | |
parent | db62658b202c3570a5f7e091cb5bb1ee0437adc8 (diff) | |
download | mongo-f380d40a3da93c22e9eb95d5308855f377a4123f.tar.gz |
SERVER-8070 Make sure buffer is drained before choosing sync target
Diffstat (limited to 'src/mongo/db/repl/bgsync.cpp')
-rw-r--r-- | src/mongo/db/repl/bgsync.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp index a5bbc541438..90c0c6942ed 100644 --- a/src/mongo/db/repl/bgsync.cpp +++ b/src/mongo/db/repl/bgsync.cpp @@ -21,9 +21,12 @@ #include "mongo/db/commands/server_status.h" #include "mongo/db/repl/bgsync.h" #include "mongo/db/repl/rs_sync.h" +#include "mongo/util/fail_point_service.h" namespace mongo { namespace replset { + MONGO_FP_DECLARE(rsBgSyncProduce); + BackgroundSync* BackgroundSync::s_instance = 0; boost::mutex BackgroundSync::s_mutex; @@ -294,6 +297,10 @@ namespace replset { return; } + while (MONGO_FAIL_POINT(rsBgSyncProduce)) { + sleepmillis(0); + } + uassert(1000, "replSet source for syncing doesn't seem to be await capable -- is it an older version of mongodb?", r.awaitCapable() ); if (isRollbackRequired(r)) { @@ -434,13 +441,18 @@ namespace replset { const Member *target = NULL, *stale = NULL; BSONObj oldest; - // then we're initial syncing and we're still waiting for this to be set { boost::unique_lock<boost::mutex> lock(_mutex); if (_lastOpTimeFetched.isNull()) { + // then we're initial syncing and we're still waiting for this to be set _currentSyncTarget = NULL; return; } + + // Wait until we've applied the ops we have before we choose a sync target + while (!_appliedBuffer) { + _condvar.wait(lock); + } } verify(r.conn() == NULL); @@ -496,7 +508,8 @@ namespace replset { } OpTime theirTS = theirLastOp["ts"]._opTime(); if (theirTS < _lastOpTimeFetched) { - log() << "replSet we are ahead of the primary, will try to roll back" << rsLog; + log() << "replSet we are ahead of the sync source, will try to roll back" + << rsLog; theReplSet->syncRollback(r); return true; } |