Skip to content

Commit 1b41bc0

Browse files
committed
Merge remote branch 'main_readonly/master'
2 parents 76c64d0 + 206a2db commit 1b41bc0

File tree

12 files changed

+280
-209
lines changed

12 files changed

+280
-209
lines changed

jstests/bench_test3.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
t = db.bench_test3
2+
t.drop();
3+
4+
5+
benchArgs = { ops : [ { ns : t.getFullName() ,
6+
op : "update" ,
7+
upsert : true ,
8+
query : { _id : { "#RAND_INT" : [ 0 , 5 , 4 ] } } ,
9+
update : { $inc : { x : 1 } } } ] ,
10+
parallel : 2 ,
11+
seconds : 1 ,
12+
totals : true ,
13+
host : db.getMongo().host }
14+
15+
if (jsTest.options().auth) {
16+
benchArgs['db'] = 'admin';
17+
benchArgs['username'] = jsTest.options().adminUser;
18+
benchArgs['password'] = jsTest.options().adminPassword;
19+
}
20+
21+
res = benchRun( benchArgs )
22+
printjson( res );
23+
24+
var keys = []
25+
var totals = {}
26+
db.bench_test3.find().sort( { _id : 1 } ).forEach( function(z){ keys.push( z._id ); totals[z._id] = z.x } );
27+
assert.eq( [ 0 , 4 , 8 , 12 , 16 ] , keys )

jstests/find9.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test that the MaxBytesToReturnToClientAtOnce limit is enforced.
2+
3+
t = db.jstests_find9;
4+
t.drop();
5+
6+
big = new Array( 500000 ).toString();
7+
for( i = 0; i < 20; ++i ) {
8+
t.save( { a:i, b:big } );
9+
}
10+
11+
// Check size limit with a simple query.
12+
assert.eq( 20, t.find( {}, { a:1 } ).objsLeftInBatch() ); // Projection resizes the result set.
13+
assert.gt( 20, t.find().objsLeftInBatch() );
14+
15+
// Check size limit on a query with an explicit batch size.
16+
assert.eq( 20, t.find( {}, { a:1 } ).batchSize( 30 ).objsLeftInBatch() );
17+
assert.gt( 20, t.find().batchSize( 30 ).objsLeftInBatch() );
18+
19+
for( i = 0; i < 20; ++i ) {
20+
t.save( { a:i, b:big } );
21+
}
22+
23+
// Check size limit with get more.
24+
c = t.find().batchSize( 30 );
25+
while( c.hasNext() ) {
26+
assert.gt( 20, c.objsLeftInBatch() );
27+
c.next();
28+
}

src/mongo/db/oplog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ namespace mongo {
545545
return shared_ptr<Cursor>( new BasicCursor( DiskLoc() ) );
546546
}
547547
FieldRangeSetPair frsp( ns, query );
548-
QueryPlan oplogPlan( d, -1, frsp, 0, query, shared_ptr<Projection>(), order, false );
548+
QueryPlan oplogPlan( d, -1, frsp, 0, query, shared_ptr<Projection>(), order );
549549
FindingStartCursor finder( oplogPlan );
550550
ElapsedTracker yieldCondition( 256, 20 );
551551
while( !finder.done() ) {

src/mongo/db/ops/query.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace mongo {
145145
}
146146

147147
// in some cases (clone collection) there won't be a matcher
148-
if ( c->matcher() && !c->matcher()->matchesCurrent( c ) ) {
148+
if ( !c->currentMatches() ) {
149149
}
150150
else if ( manager && ! manager->belongsToMe( cc ) ){
151151
LOG(2) << "cursor skipping document in un-owned chunk: " << c->current() << endl;
@@ -642,6 +642,12 @@ namespace mongo {
642642
queryResponseBuilder.noteYield();
643643
// !!! TODO The queryResponseBuilder still holds cursor. Currently it will not do
644644
// anything unsafe with the cursor in handoff(), but this is very fragile.
645+
//
646+
// We don't fail the query since we're fine with returning partial data if the
647+
// collection was dropped.
648+
// NOTE see SERVER-2454.
649+
// TODO This is wrong. The cursor could be gone if the closeAllDatabases command
650+
// just ran.
645651
break;
646652
}
647653

0 commit comments

Comments
 (0)