diff options
author | Eric Milkie <milkie@10gen.com> | 2020-02-27 08:34:36 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-27 14:14:58 +0000 |
commit | ff3d386a7172117b6326aec60475e55eae22c753 (patch) | |
tree | a1187ae6e87dd2942bb7650defcdf87c72a6aefd /src/mongo | |
parent | 3a59e217a4b34234acbd6a404f98276a87435ee0 (diff) | |
download | mongo-ff3d386a7172117b6326aec60475e55eae22c753.tar.gz |
Revert "SERVER-44367 Allow hinting the delete command"
This reverts commit 78020f2c19cb3318cac3d603be99cfd9a3fe12b1.
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/db/commands/find_and_modify.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/commands/write_commands/write_commands.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/ops/delete_request.h | 7 | ||||
-rw-r--r-- | src/mongo/db/ops/parsed_delete.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops.idl | 4 | ||||
-rw-r--r-- | src/mongo/db/ops/write_ops_exec.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/find_and_modify_request.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 67 |
8 files changed, 36 insertions, 53 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp index 35f9bb54a4d..5d995f1c70e 100644 --- a/src/mongo/db/commands/find_and_modify.cpp +++ b/src/mongo/db/commands/find_and_modify.cpp @@ -146,7 +146,6 @@ void makeDeleteRequest(OperationContext* opCtx, requestOut->setRuntimeConstants( args.getRuntimeConstants().value_or(Variables::generateRuntimeConstants(opCtx))); requestOut->setSort(args.getSort()); - requestOut->setHint(args.getHint()); requestOut->setCollation(args.getCollation()); requestOut->setMulti(false); requestOut->setReturnDeleted(true); // Always return the old value. diff --git a/src/mongo/db/commands/write_commands/write_commands.cpp b/src/mongo/db/commands/write_commands/write_commands.cpp index 7930e04e482..0b1184238ae 100644 --- a/src/mongo/db/commands/write_commands/write_commands.cpp +++ b/src/mongo/db/commands/write_commands/write_commands.cpp @@ -445,7 +445,6 @@ private: deleteRequest.setCollation(write_ops::collationOf(_batch.getDeletes()[0])); deleteRequest.setMulti(_batch.getDeletes()[0].getMulti()); deleteRequest.setYieldPolicy(PlanExecutor::YIELD_AUTO); - deleteRequest.setHint(_batch.getDeletes()[0].getHint()); deleteRequest.setExplain(); ParsedDelete parsedDelete(opCtx, &deleteRequest); diff --git a/src/mongo/db/ops/delete_request.h b/src/mongo/db/ops/delete_request.h index 4758b3486bc..a49e6eb37b9 100644 --- a/src/mongo/db/ops/delete_request.h +++ b/src/mongo/db/ops/delete_request.h @@ -116,12 +116,6 @@ public: bool isExplain() const { return _isExplain; } - void setHint(const BSONObj& hint) { - _hint = hint; - } - BSONObj getHint() const { - return _hint; - } bool shouldReturnDeleted() const { return _returnDeleted; } @@ -139,7 +133,6 @@ public: private: const NamespaceString& _nsString; - BSONObj _hint; BSONObj _query; BSONObj _proj; BSONObj _sort; diff --git a/src/mongo/db/ops/parsed_delete.cpp b/src/mongo/db/ops/parsed_delete.cpp index c15e3e0d9b6..cc7039a10b9 100644 --- a/src/mongo/db/ops/parsed_delete.cpp +++ b/src/mongo/db/ops/parsed_delete.cpp @@ -78,7 +78,6 @@ Status ParsedDelete::parseQueryToCQ() { qr->setSort(_request->getSort()); qr->setCollation(_request->getCollation()); qr->setExplain(_request->isExplain()); - qr->setHint(_request->getHint()); // Limit should only used for the findAndModify command when a sort is specified. If a sort // is requested, we want to use a top-k sort for efficiency reasons, so should pass the diff --git a/src/mongo/db/ops/write_ops.idl b/src/mongo/db/ops/write_ops.idl index 464b25ae9d4..42f86b1f481 100644 --- a/src/mongo/db/ops/write_ops.idl +++ b/src/mongo/db/ops/write_ops.idl @@ -150,10 +150,6 @@ structs: matching documents and 1 deletes a single document." type: multi_delete_bool cpp_name: multi - hint: - description: "Specifies the hint to use for the operation." - type: indexHint - default: mongo::BSONObj() collation: description: "Specifies the collation to use for the operation." type: object diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp index 4c14cafac75..f30b1bd979d 100644 --- a/src/mongo/db/ops/write_ops_exec.cpp +++ b/src/mongo/db/ops/write_ops_exec.cpp @@ -27,6 +27,7 @@ * it in the license file. */ +#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kWrite #define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kWrite #include "mongo/platform/basic.h" @@ -880,7 +881,6 @@ static SingleWriteResult performSingleDeleteOp(OperationContext* opCtx, request.setYieldPolicy(opCtx->inMultiDocumentTransaction() ? PlanExecutor::INTERRUPT_ONLY : PlanExecutor::YIELD_AUTO); request.setStmtId(stmtId); - request.setHint(op.getHint()); ParsedDelete parsedDelete(opCtx, &request); uassertStatusOK(parsedDelete.parseRequest()); diff --git a/src/mongo/db/query/find_and_modify_request.cpp b/src/mongo/db/query/find_and_modify_request.cpp index 703a3621a43..c86edcbde5c 100644 --- a/src/mongo/db/query/find_and_modify_request.cpp +++ b/src/mongo/db/query/find_and_modify_request.cpp @@ -168,6 +168,7 @@ StatusWith<FindAndModifyRequest> FindAndModifyRequest::parseFromBSON(NamespaceSt bool isRemove = false; bool bypassDocumentValidation = false; bool arrayFiltersSet = false; + bool hintSet = false; std::vector<BSONObj> arrayFilters; boost::optional<RuntimeConstants> runtimeConstants; bool writeConcernOptionsSet = false; @@ -194,6 +195,7 @@ StatusWith<FindAndModifyRequest> FindAndModifyRequest::parseFromBSON(NamespaceSt sort = sortElement.embeddedObject(); } else if (field == kHintField) { hint = parseHint(cmdObj[kHintField]); + hintSet = true; } else if (field == kRemoveField) { isRemove = cmdObj[kRemoveField].trueValue(); } else if (field == kUpdateField) { @@ -285,6 +287,10 @@ StatusWith<FindAndModifyRequest> FindAndModifyRequest::parseFromBSON(NamespaceSt " 'remove' always returns the deleted document"}; } + if (hintSet) { + return {ErrorCodes::FailedToParse, "Cannot specify a hint with remove=true"}; + } + if (arrayFiltersSet) { return {ErrorCodes::FailedToParse, "Cannot specify arrayFilters and remove=true"}; } diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 829613fe814..cc85be2533f 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -767,46 +767,37 @@ StatusWith<unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutorDelete( } if (!parsedDelete->hasParsedQuery()) { - - // Only consider using the idhack if no hint was provided. - if (request->getHint().isEmpty()) { - // This is the idhack fast-path for getting a PlanExecutor without doing the work to - // create a CanonicalQuery. - const BSONObj& unparsedQuery = request->getQuery(); - - const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(opCtx); - - // Construct delete request collator. - std::unique_ptr<CollatorInterface> collator; - if (!request->getCollation().isEmpty()) { - auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext()) - ->makeFromBSON(request->getCollation()); - if (!statusWithCollator.isOK()) { - return statusWithCollator.getStatus(); - } - collator = std::move(statusWithCollator.getValue()); + // This is the idhack fast-path for getting a PlanExecutor without doing the work to create + // a CanonicalQuery. + const BSONObj& unparsedQuery = request->getQuery(); + + const IndexDescriptor* descriptor = collection->getIndexCatalog()->findIdIndex(opCtx); + + // Construct delete request collator. + std::unique_ptr<CollatorInterface> collator; + if (!request->getCollation().isEmpty()) { + auto statusWithCollator = CollatorFactoryInterface::get(opCtx->getServiceContext()) + ->makeFromBSON(request->getCollation()); + if (!statusWithCollator.isOK()) { + return statusWithCollator.getStatus(); } - const bool hasCollectionDefaultCollation = request->getCollation().isEmpty() || - CollatorInterface::collatorsMatch(collator.get(), collection->getDefaultCollator()); - - if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && - request->getProj().isEmpty() && hasCollectionDefaultCollation) { - LOGV2_DEBUG(20928, - 2, - "Using idhack: {unparsedQuery}", - "unparsedQuery"_attr = redact(unparsedQuery)); + collator = std::move(statusWithCollator.getValue()); + } + const bool hasCollectionDefaultCollation = request->getCollation().isEmpty() || + CollatorInterface::collatorsMatch(collator.get(), collection->getDefaultCollator()); - auto idHackStage = std::make_unique<IDHackStage>( - opCtx, unparsedQuery["_id"].wrap(), ws.get(), descriptor); - unique_ptr<DeleteStage> root = - std::make_unique<DeleteStage>(opCtx, - std::move(deleteStageParams), - ws.get(), - collection, - idHackStage.release()); - return PlanExecutor::make( - opCtx, std::move(ws), std::move(root), collection, policy); - } + if (descriptor && CanonicalQuery::isSimpleIdQuery(unparsedQuery) && + request->getProj().isEmpty() && hasCollectionDefaultCollation) { + LOGV2_DEBUG(20928, + 2, + "Using idhack: {unparsedQuery}", + "unparsedQuery"_attr = redact(unparsedQuery)); + + auto idHackStage = std::make_unique<IDHackStage>( + opCtx, unparsedQuery["_id"].wrap(), ws.get(), descriptor); + unique_ptr<DeleteStage> root = std::make_unique<DeleteStage>( + opCtx, std::move(deleteStageParams), ws.get(), collection, idHackStage.release()); + return PlanExecutor::make(opCtx, std::move(ws), std::move(root), collection, policy); } // If we're here then we don't have a parsed query, but we're also not eligible for |