summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2011-03-17 11:51:26 -0700
committerEliot Horowitz <eliot@10gen.com>2011-03-18 22:04:52 -0400
commit15c6cce90ad277ecb10cc9f4f8a53f4061358259 (patch)
tree15c860810a6fbb68241b92ea99975c98eaf1f327
parentab41f59e8f8d5bd9f40513cd1121f4365d3484c4 (diff)
downloadmongo-15c6cce90ad277ecb10cc9f4f8a53f4061358259.tar.gz
SERVER-2662 don't attempt to yield a query after an earlier yield fails and drops the cursor
-rw-r--r--db/query.cpp20
-rw-r--r--jstests/slowNightly/explain1.js5
2 files changed, 14 insertions, 11 deletions
diff --git a/db/query.cpp b/db/query.cpp
index df09fcec51c..50e2fc385fa 100644
--- a/db/query.cpp
+++ b/db/query.cpp
@@ -435,14 +435,18 @@ namespace mongo {
}
virtual bool prepareToYield() {
- if ( ! _cc ) {
+ if ( _c && !_cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , _ns.c_str() ) );
}
- return _cc->prepareToYield( _yieldData );
+ if ( _cc ) {
+ return _cc->prepareToYield( _yieldData );
+ }
+ // no active cursor - ok to yield
+ return true;
}
virtual void recoverFromYield() {
- if ( !ClientCursor::recoverFromYield( _yieldData ) ) {
+ if ( _cc && !ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
@@ -698,11 +702,15 @@ namespace mongo {
return _findingStartCursor->prepareToYield();
}
else {
- if ( ! _cc ) {
+ if ( _c && !_cc ) {
_cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , _c , _pq.ns() ) );
}
- return _cc->prepareToYield( _yieldData );
+ if ( _cc ) {
+ return _cc->prepareToYield( _yieldData );
+ }
}
+ // no active cursor - ok to yield
+ return true;
}
virtual void recoverFromYield() {
@@ -711,7 +719,7 @@ namespace mongo {
if ( _findingStartCursor.get() ) {
_findingStartCursor->recoverFromYield();
}
- else if ( ! ClientCursor::recoverFromYield( _yieldData ) ) {
+ else if ( _cc && !ClientCursor::recoverFromYield( _yieldData ) ) {
_c.reset();
_cc.reset();
_so.reset();
diff --git a/jstests/slowNightly/explain1.js b/jstests/slowNightly/explain1.js
index c5b3ed28a5d..81baeb6e918 100644
--- a/jstests/slowNightly/explain1.js
+++ b/jstests/slowNightly/explain1.js
@@ -1,8 +1,5 @@
// SERVER-2662 - drop client cursor in a context where query will yield frequently
-// disabled until SERVER-2662 fixed
-if ( false ) {
-
t = db.jstests_slowNightly_explain1;
t.drop();
@@ -18,5 +15,3 @@ s3 = startParallelShell( "t = db.jstests_slowNightly_explain1; for( var i = 0; i
s1();
s2();
s3();
-
-} \ No newline at end of file