summaryrefslogtreecommitdiff
path: root/src/mongo/db/query
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2018-12-03 15:03:14 -0500
committerRandolph Tan <randolph@10gen.com>2019-01-11 14:32:51 -0500
commita83b8477796991c522199cdd5b53800ae08c1e55 (patch)
tree1f2b4768db4b3303351889fd94599cf4cb8a82c0 /src/mongo/db/query
parent891ca0c23f979268fa0b9403500a8a582646613b (diff)
downloadmongo-a83b8477796991c522199cdd5b53800ae08c1e55.tar.gz
SERVER-38179 range deleter must be prepared for document to be deleted from under it
Diffstat (limited to 'src/mongo/db/query')
-rw-r--r--src/mongo/db/query/get_executor.cpp23
-rw-r--r--src/mongo/db/query/internal_plans.cpp10
-rw-r--r--src/mongo/db/query/internal_plans.h6
3 files changed, 21 insertions, 18 deletions
diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp
index 2bb817d1699..c3bdcae3786 100644
--- a/src/mongo/db/query/get_executor.cpp
+++ b/src/mongo/db/query/get_executor.cpp
@@ -830,14 +830,14 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDelete(
str::stream() << "Not primary while removing from " << nss.ns());
}
- DeleteStageParams deleteStageParams;
- deleteStageParams.isMulti = request->isMulti();
- deleteStageParams.fromMigrate = request->isFromMigrate();
- deleteStageParams.isExplain = request->isExplain();
- deleteStageParams.returnDeleted = request->shouldReturnDeleted();
- deleteStageParams.sort = request->getSort();
- deleteStageParams.opDebug = opDebug;
- deleteStageParams.stmtId = request->getStmtId();
+ auto deleteStageParams = std::make_unique<DeleteStageParams>();
+ deleteStageParams->isMulti = request->isMulti();
+ deleteStageParams->fromMigrate = request->isFromMigrate();
+ deleteStageParams->isExplain = request->isExplain();
+ deleteStageParams->returnDeleted = request->shouldReturnDeleted();
+ deleteStageParams->sort = request->getSort();
+ deleteStageParams->opDebug = opDebug;
+ deleteStageParams->stmtId = request->getStmtId();
unique_ptr<WorkingSet> ws = make_unique<WorkingSet>();
const PlanExecutor::YieldPolicy policy = parsedDelete->yieldPolicy();
@@ -878,7 +878,7 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDelete(
auto idHackStage = std::make_unique<IDHackStage>(
opCtx, unparsedQuery["_id"].wrap(), ws.get(), descriptor);
unique_ptr<DeleteStage> root = make_unique<DeleteStage>(
- opCtx, deleteStageParams, ws.get(), collection, idHackStage.release());
+ opCtx, std::move(deleteStageParams), ws.get(), collection, idHackStage.release());
return PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, policy);
}
@@ -903,10 +903,11 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDelete(
unique_ptr<QuerySolution> querySolution = std::move(executionResult.getValue().querySolution);
unique_ptr<PlanStage> root = std::move(executionResult.getValue().root);
- deleteStageParams.canonicalQuery = cq.get();
+ deleteStageParams->canonicalQuery = cq.get();
invariant(root);
- root = make_unique<DeleteStage>(opCtx, deleteStageParams, ws.get(), collection, root.release());
+ root = make_unique<DeleteStage>(
+ opCtx, std::move(deleteStageParams), ws.get(), collection, root.release());
if (!request->getProj().isEmpty()) {
invariant(request->shouldReturnDeleted());
diff --git a/src/mongo/db/query/internal_plans.cpp b/src/mongo/db/query/internal_plans.cpp
index cc29c363412..e2e767d567b 100644
--- a/src/mongo/db/query/internal_plans.cpp
+++ b/src/mongo/db/query/internal_plans.cpp
@@ -78,7 +78,7 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::collection
std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::deleteWithCollectionScan(
OperationContext* opCtx,
Collection* collection,
- const DeleteStageParams& params,
+ std::unique_ptr<DeleteStageParams> params,
PlanExecutor::YieldPolicy yieldPolicy,
Direction direction,
const RecordId& startLoc) {
@@ -87,7 +87,8 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::deleteWith
auto root = _collectionScan(opCtx, ws.get(), collection, direction, startLoc);
- root = stdx::make_unique<DeleteStage>(opCtx, params, ws.get(), collection, root.release());
+ root = stdx::make_unique<DeleteStage>(
+ opCtx, std::move(params), ws.get(), collection, root.release());
auto executor =
PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, yieldPolicy);
@@ -127,7 +128,7 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::indexScan(
std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::deleteWithIndexScan(
OperationContext* opCtx,
Collection* collection,
- const DeleteStageParams& params,
+ std::unique_ptr<DeleteStageParams> params,
const IndexDescriptor* descriptor,
const BSONObj& startKey,
const BSONObj& endKey,
@@ -147,7 +148,8 @@ std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> InternalPlanner::deleteWith
direction,
InternalPlanner::IXSCAN_FETCH);
- root = stdx::make_unique<DeleteStage>(opCtx, params, ws.get(), collection, root.release());
+ root = stdx::make_unique<DeleteStage>(
+ opCtx, std::move(params), ws.get(), collection, root.release());
auto executor =
PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, yieldPolicy);
diff --git a/src/mongo/db/query/internal_plans.h b/src/mongo/db/query/internal_plans.h
index c12fd3e3f5c..a33beb1a963 100644
--- a/src/mongo/db/query/internal_plans.h
+++ b/src/mongo/db/query/internal_plans.h
@@ -31,6 +31,7 @@
#pragma once
#include "mongo/base/string_data.h"
+#include "mongo/db/exec/delete.h"
#include "mongo/db/query/plan_executor.h"
#include "mongo/db/record_id.h"
@@ -42,7 +43,6 @@ class IndexDescriptor;
class OperationContext;
class PlanStage;
class WorkingSet;
-struct DeleteStageParams;
struct UpdateStageParams;
/**
@@ -83,7 +83,7 @@ public:
static std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> deleteWithCollectionScan(
OperationContext* opCtx,
Collection* collection,
- const DeleteStageParams& params,
+ std::unique_ptr<DeleteStageParams> params,
PlanExecutor::YieldPolicy yieldPolicy,
Direction direction = FORWARD,
const RecordId& startLoc = RecordId());
@@ -108,7 +108,7 @@ public:
static std::unique_ptr<PlanExecutor, PlanExecutor::Deleter> deleteWithIndexScan(
OperationContext* opCtx,
Collection* collection,
- const DeleteStageParams& params,
+ std::unique_ptr<DeleteStageParams> params,
const IndexDescriptor* descriptor,
const BSONObj& startKey,
const BSONObj& endKey,