0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

cleaning cursor test and added assert

This commit is contained in:
Eliot Horowitz 2010-10-27 10:27:37 -04:00
parent 690970bae1
commit 7a83a6fb21
2 changed files with 14 additions and 11 deletions

View File

@ -162,6 +162,7 @@ namespace mongo {
bool justOne = justOneOrig;
bool canYield = !god && !creal->matcher()->docMatcher().atomic();
do {
if ( canYield && ! cc->yieldSometimes() ){
cc.release(); // has already been deleted elsewhere
@ -655,17 +656,17 @@ namespace mongo {
}
virtual void recoverFromYield() {
++_nYields;
_nYields++;
if ( _findingStartCursor.get() ) {
_findingStartCursor->recoverFromYield();
} else {
if ( !ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
_so.reset();
massert( 13338, "cursor dropped during query", false );
// TODO maybe we want to prevent recording the winning plan as well?
}
}
else if ( ! ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
_so.reset();
massert( 13338, "cursor dropped during query", false );
// TODO maybe we want to prevent recording the winning plan as well?
}
}

View File

@ -14,13 +14,15 @@ function run( n , atomic ){
join = startParallelShell( "sleep(50); db.cursora.remove( {" + ( atomic ? "$atomic:true" : "" ) + "} ); db.getLastError();" );
start = new Date()
num = t.find( function(){ num = 2; for ( var x=0; x<1000; x++ ) num += 2; return num > 0; } ).sort( { _id : -1 } ).limit(n).itcount()
ex = t.find( function(){ num = 2; for ( var x=0; x<1000; x++ ) num += 2; return num > 0; } ).sort( { _id : -1 } ).explain()
num = ex.n
end = new Date()
join()
print( "num: " + num + " time:" + ( end.getTime() - start.getTime() ) )
assert.eq( 0 , t.count() , "after remove" )
assert.lt( 0 , ex.nYields , "not enough yields" )
if ( n == num )
print( "warning: shouldn't have counted all n: " + n + " num: " + num );
}