Skip to content

Commit 193aba8

Browse files
committed
SERVER-13715 fix use of auto_ptr after release in subplan runner
1 parent 4d03aae commit 193aba8

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

jstests/core/orq.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// A few rooted $or cases.
2+
3+
var t = db.jstests_orq;
4+
t.drop();
5+
6+
t.ensureIndex({a: 1, c: 1});
7+
t.ensureIndex({b: 1, c: 1});
8+
9+
t.save({a: 1, c: 9});
10+
t.save({a: 1, c: 10});
11+
t.save({b: 2, c: 8});
12+
t.save({b: 2, c: 7});
13+
14+
// This can be answered using a merge sort. See SERVER-13715.
15+
var cursor = t.find({$or: [{a: 1}, {b: 2}]}).sort({c: 1});
16+
for (var i = 7; i < 11; i++) {
17+
assert.eq(i, cursor.next()["c"]);
18+
}
19+
assert(!cursor.hasNext());
20+
21+
// SERVER-13715
22+
assert.eq(4, t.find({$or: [{a: 1}, {b: 2}]}).sort({a: 1}).itcount());

src/mongo/db/query/subplan_runner.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,13 @@ namespace mongo {
277277
// We want a well-formed *indexed* solution.
278278
if (NULL == autoSoln->cacheData.get()) {
279279
// For example, we don't cache things for 2d indices.
280-
QLOG() << "Subplanner: No cache data for subchild " << orChildCQ->toString();
280+
QLOG() << "Subplanner: No cache data for subchild " << orChild->toString();
281281
return false;
282282
}
283283

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

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

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

@@ -326,23 +326,23 @@ namespace mongo {
326326
BSONObj errorObj;
327327
if (!mpr->pickBestPlan(&bestPlan, &errorObj)) {
328328
QLOG() << "Subplanner: Failed to pick best plan for subchild "
329-
<< orChildCQ->toString()
329+
<< orChild->toString()
330330
<< " error obj is " << errorObj.toString();
331331
return false;
332332
}
333333

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

341341
QuerySolution* bestSoln = solutions[bestPlan];
342342

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

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

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

0 commit comments

Comments
 (0)