summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/merge_sort.cpp
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2015-08-24 23:51:27 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2015-08-24 23:51:27 -0400
commit764e0c45471d5ca63c708f362be0e6d01ee72eb0 (patch)
tree77c6693c1c1003d802a40a30eda8a79a4e0d7704 /src/mongo/db/exec/merge_sort.cpp
parent564f8089c0d4541215d1aa31dae331115e68b95f (diff)
downloadmongo-764e0c45471d5ca63c708f362be0e6d01ee72eb0.tar.gz
SERVER-16444 Copy data in the query subsystem as needed.
A WorkingSetMember in the LOC_AND_OBJ state must be made owned when: 1. Its WorkingSetID is cached across multiple calls to work(). 2. Multiple calls to next(), seekExact(), saveState(), etc. are performed on the same WiredTiger cursor in a single work() call. No longer necessary to always copy data out of WiredTiger buffers.
Diffstat (limited to 'src/mongo/db/exec/merge_sort.cpp')
-rw-r--r--src/mongo/db/exec/merge_sort.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/mongo/db/exec/merge_sort.cpp b/src/mongo/db/exec/merge_sort.cpp
index 8faf6cfdeb3..be218d266b5 100644
--- a/src/mongo/db/exec/merge_sort.cpp
+++ b/src/mongo/db/exec/merge_sort.cpp
@@ -87,10 +87,10 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
StageState code = child->work(&id);
if (PlanStage::ADVANCED == code) {
+ WorkingSetMember* member = _ws->get(id);
+
// If we're deduping...
if (_dedup) {
- WorkingSetMember* member = _ws->get(id);
-
if (!member->hasLoc()) {
// Can't dedup data unless there's a RecordId. We go ahead and use its
// result.
@@ -122,6 +122,8 @@ PlanStage::StageState MergeSortStage::work(WorkingSetID* out) {
StageWithValue value;
value.id = id;
value.stage = child;
+ // Ensure that the BSONObj underlying the WorkingSetMember is owned in case we yield.
+ member->makeObjOwned();
_mergingData.push_front(value);
// Insert the result (indirectly) into our priority queue.