Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add comment and test for query optimizer failed yield of a cached pla…

…n with retry
  • Loading branch information...
commit 716dc72fc03be867c1166640f24f335e71607157 1 parent dd62235
@astaple astaple authored
Showing with 29 additions and 1 deletion.
  1. +2 −1  db/queryoptimizer.cpp
  2. +27 −0 jstests/queryoptimizer5.js
View
3  db/queryoptimizer.cpp
@@ -553,6 +553,7 @@ namespace mongo {
if ( _bestGuessOnly || res->complete() || _plans.size() > 1 )
return res;
// A cached plan was used, so clear the plan for this query pattern and retry the query without a cached plan.
+ // Carefull here, as the namespace may have been dropped.
QueryUtilIndexed::clearIndexesForPatterns( *_frsp, _order );
init();
}
@@ -667,7 +668,7 @@ namespace mongo {
int micros = ClientCursor::suggestYieldMicros();
if ( micros <= 0 )
return;
-
+
if ( !prepareToYield() )
return;
View
27 jstests/queryoptimizer5.js
@@ -0,0 +1,27 @@
+// Don't crash attempting to retry additional query plans if a recorded plan failed because a cursor was dropped.
+
+t = db.jstests_queryoptimizer5;
+t.drop();
+
+function reset() {
+ t.drop();
+ for( var i = 0; i < 5000; ++i ) {
+ t.save({a:i,b:i});
+ }
+ t.ensureIndex({a:1});
+ t.ensureIndex({b:1});
+}
+
+s = startParallelShell( "for( i = 0; i < 30; ++i ) { sleep( 200 ); db.jstests_queryoptimizer5.drop(); }" );
+
+for( var i = 0; i < 10; ++i ) {
+ try {
+ reset();
+ t.find( {$or:[{a:{$gte:0},b:{$gte:0}}]} ).batchSize( 10000 ).itcount();
+ t.find( {$or:[{a:{$gte:0},b:{$gte:0}}]} ).batchSize( 10000 ).itcount();
+ } catch (e) {
+// printjson(e);
+ }
+}
+
+s();
Please sign in to comment.
Something went wrong with that request. Please try again.