summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/find_and_modify.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/commands/find_and_modify.cpp')
-rw-r--r--src/mongo/db/commands/find_and_modify.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/mongo/db/commands/find_and_modify.cpp b/src/mongo/db/commands/find_and_modify.cpp
index d94346896da..abbc0d834fd 100644
--- a/src/mongo/db/commands/find_and_modify.cpp
+++ b/src/mongo/db/commands/find_and_modify.cpp
@@ -41,7 +41,7 @@
#include "mongo/db/client.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/update_metrics.h"
-#include "mongo/db/concurrency/exception_util.h"
+#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop_failpoint_helpers.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/exec/update_stage.h"
@@ -95,17 +95,16 @@ boost::optional<BSONObj> advanceExecutor(OperationContext* opCtx,
PlanExecutor::ExecState state;
try {
state = exec->getNext(&value, nullptr);
- } catch (const WriteConflictException&) {
- // Propagate the WCE to be retried at a higher-level without logging.
- throw;
} catch (DBException& exception) {
auto&& explainer = exec->getPlanExplainer();
auto&& [stats, _] = explainer.getWinningPlanStats(ExplainOptions::Verbosity::kExecStats);
- LOGV2_WARNING(23802,
- "Plan executor error during findAndModify",
- "error"_attr = exception.toStatus(),
- "stats"_attr = redact(stats),
- "cmd"_attr = request.toBSON(BSONObj() /* commandPassthroughFields */));
+ LOGV2_WARNING(
+ 23802,
+ "Plan executor error during findAndModify: {error}, stats: {stats}, cmd: {cmd}",
+ "Plan executor error during findAndModify",
+ "error"_attr = exception.toStatus(),
+ "stats"_attr = redact(stats),
+ "cmd"_attr = request.toBSON(BSONObj() /* commandPassthroughFields */));
exception.addContext("Plan executor error during findAndModify");
throw;
@@ -170,8 +169,9 @@ void makeUpdateRequest(OperationContext* opCtx,
requestOut->setMulti(false);
requestOut->setExplain(explain);
- requestOut->setYieldPolicy(PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
- requestOut->setBypassEmptyTsReplacement(request.getBypassEmptyTsReplacement());
+ requestOut->setYieldPolicy(opCtx->inMultiDocumentTransaction()
+ ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY
+ : PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
}
void makeDeleteRequest(OperationContext* opCtx,
@@ -190,7 +190,9 @@ void makeDeleteRequest(OperationContext* opCtx,
requestOut->setReturnDeleted(true); // Always return the old value.
requestOut->setIsExplain(explain);
- requestOut->setYieldPolicy(PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
+ requestOut->setYieldPolicy(opCtx->inMultiDocumentTransaction()
+ ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY
+ : PlanYieldPolicy::YieldPolicy::YIELD_AUTO);
}
write_ops::FindAndModifyCommandReply buildResponse(const PlanExecutor* exec,
@@ -761,9 +763,6 @@ void CmdFindAndModify::Invocation::appendMirrorableRequest(BSONObjBuilder* bob)
if (const auto& shardVersion = rawCmd.getField("shardVersion"); !shardVersion.eoo()) {
bob->append(shardVersion);
}
- if (const auto& databaseVersion = rawCmd.getField("databaseVersion"); !databaseVersion.eoo()) {
- bob->append(databaseVersion);
- }
// Prevent the find from returning multiple documents since we can
bob->append("batchSize", 1);