From 20e224e7731a0670e813de3c2e67c53328ecc5fa Mon Sep 17 00:00:00 2001 From: Eric Milkie Date: Thu, 30 Jul 2015 09:46:03 -0400 Subject: SERVER-18522 permit replicated writes with deleteObjects() (used by sharding) --- src/mongo/db/ops/delete.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/mongo/db/ops/delete.cpp') diff --git a/src/mongo/db/ops/delete.cpp b/src/mongo/db/ops/delete.cpp index 4cc01162bdd..325b0d36bc0 100644 --- a/src/mongo/db/ops/delete.cpp +++ b/src/mongo/db/ops/delete.cpp @@ -35,6 +35,7 @@ #include "mongo/db/ops/delete_request.h" #include "mongo/db/ops/parsed_delete.h" #include "mongo/db/query/get_executor.h" +#include "mongo/db/repl/repl_client_info.h" namespace mongo { @@ -67,14 +68,19 @@ long long deleteObjects(OperationContext* txn, ParsedDelete parsedDelete(txn, &request); uassertStatusOK(parsedDelete.parseRequest()); - // Replicated writes are disallowed with deleteObjects, as we are not properly setting - // lastOp for no-op deletes. - fassert(22001, !txn->writesAreReplicated()); + auto client = txn->getClient(); + auto lastOpAtOperationStart = repl::ReplClientInfo::forClient(client).getLastOp(); std::unique_ptr exec = uassertStatusOK(getExecutorDelete(txn, collection, &parsedDelete)); uassertStatusOK(exec->executePlan()); + + // No-ops need to reset lastOp in the client, for write concern. + if (repl::ReplClientInfo::forClient(client).getLastOp() == lastOpAtOperationStart) { + repl::ReplClientInfo::forClient(client).setLastOpToSystemLastOpTime(txn); + } + return DeleteStage::getNumDeleted(*exec); } -- cgit v1.2.1