summaryrefslogtreecommitdiff
path: root/db/repl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'db/repl.cpp')
-rw-r--r--db/repl.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/db/repl.cpp b/db/repl.cpp
index 8cdd545..37197ba 100644
--- a/db/repl.cpp
+++ b/db/repl.cpp
@@ -858,11 +858,13 @@ namespace mongo {
see logOp() comments.
*/
void ReplSource::sync_pullOpLog_applyOperation(BSONObj& op, OpTime *localLogTail) {
- log( 6 ) << "processing op: " << op << endl;
+ if( logLevel >= 6 ) // op.tostring is expensive so doing this check explicitly
+ log(6) << "processing op: " << op << endl;
+
// skip no-op
- if ( op.getStringField( "op" )[ 0 ] == 'n' )
+ if( op.getStringField("op")[0] == 'n' )
return;
-
+
char clientName[MaxDatabaseLen];
const char *ns = op.getStringField("ns");
nsToDatabase(ns, clientName);
@@ -1303,12 +1305,15 @@ namespace mongo {
1) find most recent op in local log
2) more()?
*/
- if ( !oplogReader.more() ) {
+
+ bool moreInitialSyncsPending = !addDbNextPass.empty() && n; // we need "&& n" to assure we actually process at least one op to get a sync point recorded in the first place.
+
+ if ( moreInitialSyncsPending || !oplogReader.more() ) {
dblock lk;
OpTime nextLastSaved = nextLastSavedLocalTs();
{
dbtemprelease t;
- if ( oplogReader.more() ) {
+ if ( !moreInitialSyncsPending && oplogReader.more() ) {
if ( getInitialSyncCompleted() ) { // if initial sync hasn't completed, break out of loop so we can set to completed or clone more dbs
continue;
}
@@ -1325,6 +1330,8 @@ namespace mongo {
log() << "repl: end sync_pullOpLog syncedTo: " << syncedTo.toStringLong() << endl;
break;
}
+ else {
+ }
OCCASIONALLY if( n > 0 && ( n > 100000 || time(0) - saveLast > 60 ) ) {
// periodically note our progress, in case we are doing a lot of work and crash