summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp')
-rw-r--r--src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
index 9755fcc7dbd..aa6914f88c3 100644
--- a/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
+++ b/src/mongo/db/pipeline/process_interface/shardsvr_process_interface.cpp
@@ -110,7 +110,9 @@ Status ShardServerProcessInterface::insert(
BatchedCommandRequest batchInsertCommand(std::move(insertCommand));
- batchInsertCommand.setWriteConcern(wc.toBSON());
+ const auto originalWC = expCtx->opCtx->getWriteConcern();
+ ScopeGuard resetWCGuard([&] { expCtx->opCtx->setWriteConcern(originalWC); });
+ expCtx->opCtx->setWriteConcern(wc);
cluster::write(expCtx->opCtx, batchInsertCommand, &stats, &response, targetEpoch);
@@ -129,7 +131,10 @@ StatusWith<MongoProcessInterface::UpdateResult> ShardServerProcessInterface::upd
BatchWriteExecStats stats;
BatchedCommandRequest batchUpdateCommand(std::move(updateCommand));
- batchUpdateCommand.setWriteConcern(wc.toBSON());
+
+ const auto originalWC = expCtx->opCtx->getWriteConcern();
+ ScopeGuard resetWCGuard([&] { expCtx->opCtx->setWriteConcern(originalWC); });
+ expCtx->opCtx->setWriteConcern(wc);
cluster::write(expCtx->opCtx, batchUpdateCommand, &stats, &response, targetEpoch);