Skip to content

Commit

Permalink
SERVER-13715 fix use of auto_ptr after release in subplan runner
Browse files Browse the repository at this point in the history
  • Loading branch information
dstorch committed May 9, 2014
1 parent 4d03aae commit 193aba8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
22 changes: 22 additions & 0 deletions jstests/core/orq.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// A few rooted $or cases.

var t = db.jstests_orq;
t.drop();

t.ensureIndex({a: 1, c: 1});
t.ensureIndex({b: 1, c: 1});

t.save({a: 1, c: 9});
t.save({a: 1, c: 10});
t.save({b: 2, c: 8});
t.save({b: 2, c: 7});

// This can be answered using a merge sort. See SERVER-13715.
var cursor = t.find({$or: [{a: 1}, {b: 2}]}).sort({c: 1});
for (var i = 7; i < 11; i++) {
assert.eq(i, cursor.next()["c"]);
}
assert(!cursor.hasNext());

// SERVER-13715
assert.eq(4, t.find({$or: [{a: 1}, {b: 2}]}).sort({a: 1}).itcount());
18 changes: 9 additions & 9 deletions src/mongo/db/query/subplan_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ namespace mongo {
// We want a well-formed *indexed* solution.
if (NULL == autoSoln->cacheData.get()) {
// For example, we don't cache things for 2d indices.
QLOG() << "Subplanner: No cache data for subchild " << orChildCQ->toString();
QLOG() << "Subplanner: No cache data for subchild " << orChild->toString();
return false;
}

if (SolutionCacheData::USE_INDEX_TAGS_SOLN != autoSoln->cacheData->solnType) {
QLOG() << "Subplanner: No indexed cache data for subchild "
<< orChildCQ->toString();
<< orChild->toString();
return false;
}

Expand All @@ -292,8 +292,8 @@ namespace mongo {
orChild, autoSoln->cacheData->tree.get(), _indexMap);

if (!tagStatus.isOK()) {
QLOG() << "Subplanner: Failed to extract indices from subchild"
<< orChildCQ->toString();
QLOG() << "Subplanner: Failed to extract indices from subchild "
<< orChild->toString();
return false;
}

Expand Down Expand Up @@ -326,23 +326,23 @@ namespace mongo {
BSONObj errorObj;
if (!mpr->pickBestPlan(&bestPlan, &errorObj)) {
QLOG() << "Subplanner: Failed to pick best plan for subchild "
<< orChildCQ->toString()
<< orChild->toString()
<< " error obj is " << errorObj.toString();
return false;
}

// pickBestPlan can yield. Make sure we're not dead any which way.
if (_killed) {
QLOG() << "Subplanner: Killed while picking best plan for subchild "
<< orChildCQ->toString();
<< orChild->toString();
return false;
}

QuerySolution* bestSoln = solutions[bestPlan];

if (SolutionCacheData::USE_INDEX_TAGS_SOLN != bestSoln->cacheData->solnType) {
QLOG() << "Subplanner: No indexed cache data for subchild "
<< orChildCQ->toString();
<< orChild->toString();
return false;
}

Expand All @@ -351,8 +351,8 @@ namespace mongo {
orChild, bestSoln->cacheData->tree.get(), _indexMap);

if (!tagStatus.isOK()) {
QLOG() << "Subplanner: Failed to extract indices from subchild"
<< orChildCQ->toString();
QLOG() << "Subplanner: Failed to extract indices from subchild "
<< orChild->toString();
return false;
}

Expand Down

0 comments on commit 193aba8

Please sign in to comment.