mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-29 00:32:18 +01:00
SERVER-2809 don't read cursor's nscanned if failed yield invalidated the cursor
This commit is contained in:
parent
75ecdb8d46
commit
c27b540669
@ -85,6 +85,7 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
virtual long long nscanned() {
|
||||
// We don't support yielding, so will always have c_.
|
||||
assert( c_.get() );
|
||||
return c_->nscanned();
|
||||
}
|
||||
|
12
db/query.cpp
12
db/query.cpp
@ -76,8 +76,7 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
virtual long long nscanned() {
|
||||
assert( c_.get() );
|
||||
return c_->nscanned();
|
||||
return c_.get() ? c_->nscanned() : _nscanned;
|
||||
}
|
||||
virtual void next() {
|
||||
if ( !c_->ok() ) {
|
||||
@ -417,6 +416,7 @@ namespace mongo {
|
||||
_ns(ns), _capped(false), _count(), _myCount(),
|
||||
_skip( spec["skip"].numberLong() ),
|
||||
_limit( spec["limit"].numberLong() ),
|
||||
_nscanned(),
|
||||
_bc() {
|
||||
}
|
||||
|
||||
@ -431,8 +431,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
virtual long long nscanned() {
|
||||
assert( _c.get() );
|
||||
return _c->nscanned();
|
||||
return _c.get() ? _c->nscanned() : _nscanned;
|
||||
}
|
||||
|
||||
virtual bool prepareToYield() {
|
||||
@ -466,6 +465,7 @@ namespace mongo {
|
||||
return;
|
||||
}
|
||||
|
||||
_nscanned = _c->nscanned();
|
||||
if ( _bc ) {
|
||||
if ( _firstMatch.isEmpty() ) {
|
||||
_firstMatch = _bc->currKeyNode().key.copy();
|
||||
@ -528,6 +528,7 @@ namespace mongo {
|
||||
long long _myCount;
|
||||
long long _skip;
|
||||
long long _limit;
|
||||
long long _nscanned;
|
||||
shared_ptr<Cursor> _c;
|
||||
BSONObj _query;
|
||||
BtreeCursor * _bc;
|
||||
@ -741,8 +742,7 @@ namespace mongo {
|
||||
if ( _findingStartCursor.get() ) {
|
||||
return 0; // should only be one query plan, so value doesn't really matter.
|
||||
}
|
||||
assert( _c.get() );
|
||||
return _c->nscanned();
|
||||
return _c.get() ? _c->nscanned() : _nscanned;
|
||||
}
|
||||
|
||||
virtual void next() {
|
||||
|
@ -913,8 +913,7 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
virtual long long nscanned() {
|
||||
assert( _c.get() );
|
||||
return _c->nscanned();
|
||||
return _c.get() ? _c->nscanned() : _nscanned;
|
||||
}
|
||||
virtual void next() {
|
||||
if ( ! _c->ok() ) {
|
||||
|
18
jstests/slowNightly/explain2.js
Normal file
18
jstests/slowNightly/explain2.js
Normal file
@ -0,0 +1,18 @@
|
||||
// Test for race condition SERVER-2807. One cursor is dropped and another is not.
|
||||
|
||||
collName = 'jstests_slowNightly_explain2';
|
||||
|
||||
t = db[ collName ];
|
||||
t.drop();
|
||||
|
||||
db.createCollection( collName, {capped:true,size:100000} );
|
||||
t = db[ collName ];
|
||||
t.ensureIndex( {x:1} );
|
||||
|
||||
a = startParallelShell( 'for( i = 0; i < 50000; ++i ) { db.' + collName + '.insert( {x:i,y:1} ); }' );
|
||||
|
||||
for( i = 0; i < 800; ++i ) {
|
||||
t.find( {x:{$gt:-1},y:1} ).sort({x:-1}).explain();
|
||||
}
|
||||
|
||||
a();
|
Loading…
Reference in New Issue
Block a user