diff options
author | Aaron <aaron@10gen.com> | 2010-02-25 20:59:44 -0800 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2010-02-25 20:59:44 -0800 |
commit | de365ac8eb96572003bd158d098916272b68eb75 (patch) | |
tree | 10675fbeee3cd192ebed00dc568ecd7333e6331a | |
parent | a05b907fc4b4641a7d135df735b95cee386d5b27 (diff) | |
download | mongo-de365ac8eb96572003bd158d098916272b68eb75.tar.gz |
CS-6 fix for 'only' mode
-rw-r--r-- | db/matcher.cpp | 1 | ||||
-rw-r--r-- | db/query.cpp | 11 | ||||
-rw-r--r-- | db/repl.cpp | 6 | ||||
-rw-r--r-- | jstests/repl/repl4.js | 8 |
4 files changed, 22 insertions, 4 deletions
diff --git a/db/matcher.cpp b/db/matcher.cpp index a2d376aedef..b6afc699f67 100644 --- a/db/matcher.cpp +++ b/db/matcher.cpp @@ -103,7 +103,6 @@ namespace mongo { if ( ! _needRecord ){ return true; } - return _recordMatcher.matches(recLoc.rec()); } diff --git a/db/query.cpp b/db/query.cpp index e0d303fc37e..a29766f2b4b 100644 --- a/db/query.cpp +++ b/db/query.cpp @@ -481,12 +481,17 @@ namespace mongo { findingStartCursor_ = new ClientCursor(); findingStartCursor_->c = qp().newReverseCursor(); findingStartCursor_->ns = qp().ns(); + BSONElement tsElt = qp().query()[ "ts" ]; + massert( "no ts field in query", !tsElt.eoo() ); + BSONObjBuilder b; + b.append( tsElt ); + BSONObj tsQuery = b.obj(); + matcher_.reset(new KeyValJSMatcher(tsQuery, qp().indexKey())); } else { c_ = qp().newCursor(); + matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey())); } - matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey())); - if ( qp().scanAndOrderRequired() ) { ordering_ = true; so_.reset( new ScanAndOrder( ntoskip_, ntoreturn_, order_ ) ); @@ -498,9 +503,11 @@ namespace mongo { if ( !findingStartCursor_ || !findingStartCursor_->c->ok() ) { findingStart_ = false; c_ = qp().newCursor(); + matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey())); } else if ( !matcher_->matches( findingStartCursor_->c->currKey(), findingStartCursor_->c->currLoc() ) ) { findingStart_ = false; c_ = qp().newCursor( findingStartCursor_->c->currLoc() ); + matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey())); } else { findingStartCursor_->c->advance(); RARELY { diff --git a/db/repl.cpp b/db/repl.cpp index 0ba8e43cc15..331dd12fbcf 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -981,7 +981,11 @@ namespace mongo { void ReplSource::syncToTailOfRemoteLog() { string _ns = ns(); - BSONObj last = conn->findOne( _ns.c_str(), Query().sort( BSON( "$natural" << -1 ) ) ); + BSONObjBuilder b; + if ( !only.empty() ) { + b.appendRegex("ns", string("^") + only); + } + BSONObj last = conn->findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) ); if ( !last.isEmpty() ) { BSONElement ts = last.findElement( "ts" ); massert( "non Date ts found", ts.type() == Date || ts.type() == Timestamp ); diff --git a/jstests/repl/repl4.js b/jstests/repl/repl4.js index 248309c50a1..5475402e544 100644 --- a/jstests/repl/repl4.js +++ b/jstests/repl/repl4.js @@ -28,6 +28,14 @@ doTest = function() { printjson( s.getDBNames() ); assert.eq( -1, s.getDBNames().indexOf( "b" ) ); assert.eq( 0, s.getDB( "b" ).b.find().count() ); + + stopMongod( ports[ 1 ] ); + + cm.save( { x:3 } ); + bm.save( { x:4 } ); + + s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--only", "c", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" ); + soonCount( "c", "c", 2 ); } doTest(); |