Skip to content

Commit de365ac

Browse files
committed
CS-6 fix for 'only' mode
1 parent a05b907 commit de365ac

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

db/matcher.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ namespace mongo {
103103
if ( ! _needRecord ){
104104
return true;
105105
}
106-
107106
return _recordMatcher.matches(recLoc.rec());
108107
}
109108

db/query.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,17 @@ namespace mongo {
481481
findingStartCursor_ = new ClientCursor();
482482
findingStartCursor_->c = qp().newReverseCursor();
483483
findingStartCursor_->ns = qp().ns();
484+
BSONElement tsElt = qp().query()[ "ts" ];
485+
massert( "no ts field in query", !tsElt.eoo() );
486+
BSONObjBuilder b;
487+
b.append( tsElt );
488+
BSONObj tsQuery = b.obj();
489+
matcher_.reset(new KeyValJSMatcher(tsQuery, qp().indexKey()));
484490
} else {
485491
c_ = qp().newCursor();
492+
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
486493
}
487494

488-
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
489-
490495
if ( qp().scanAndOrderRequired() ) {
491496
ordering_ = true;
492497
so_.reset( new ScanAndOrder( ntoskip_, ntoreturn_, order_ ) );
@@ -498,9 +503,11 @@ namespace mongo {
498503
if ( !findingStartCursor_ || !findingStartCursor_->c->ok() ) {
499504
findingStart_ = false;
500505
c_ = qp().newCursor();
506+
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
501507
} else if ( !matcher_->matches( findingStartCursor_->c->currKey(), findingStartCursor_->c->currLoc() ) ) {
502508
findingStart_ = false;
503509
c_ = qp().newCursor( findingStartCursor_->c->currLoc() );
510+
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
504511
} else {
505512
findingStartCursor_->c->advance();
506513
RARELY {

db/repl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,11 @@ namespace mongo {
981981

982982
void ReplSource::syncToTailOfRemoteLog() {
983983
string _ns = ns();
984-
BSONObj last = conn->findOne( _ns.c_str(), Query().sort( BSON( "$natural" << -1 ) ) );
984+
BSONObjBuilder b;
985+
if ( !only.empty() ) {
986+
b.appendRegex("ns", string("^") + only);
987+
}
988+
BSONObj last = conn->findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) );
985989
if ( !last.isEmpty() ) {
986990
BSONElement ts = last.findElement( "ts" );
987991
massert( "non Date ts found", ts.type() == Date || ts.type() == Timestamp );

jstests/repl/repl4.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ doTest = function() {
2828
printjson( s.getDBNames() );
2929
assert.eq( -1, s.getDBNames().indexOf( "b" ) );
3030
assert.eq( 0, s.getDB( "b" ).b.find().count() );
31+
32+
stopMongod( ports[ 1 ] );
33+
34+
cm.save( { x:3 } );
35+
bm.save( { x:4 } );
36+
37+
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" );
38+
soonCount( "c", "c", 2 );
3139
}
3240

3341
doTest();

0 commit comments

Comments
 (0)