summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/add_shard_cmd.cpp
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-18 17:02:53 -0300
commit959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch)
treeacc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/s/add_shard_cmd.cpp
parent76588293975fc059cf076779e4283e6ffaf8afff (diff)
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/s/add_shard_cmd.cpp')
-rw-r--r--src/mongo/db/s/add_shard_cmd.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/s/add_shard_cmd.cpp b/src/mongo/db/s/add_shard_cmd.cpp
index 3bfc1cc4a18..af64045ca6a 100644
--- a/src/mongo/db/s/add_shard_cmd.cpp
+++ b/src/mongo/db/s/add_shard_cmd.cpp
@@ -72,6 +72,14 @@ public:
auto addShardCmd = request();
auto shardIdUpsertCmd =
add_shard_util::createShardIdentityUpsertForAddShard(addShardCmd);
+
+ // A request dispatched through a local client is served within the same thread that
+ // submits it (so that the opCtx needs to be used as the vehicle to pass the WC to the
+ // ServiceEntryPoint).
+ const auto originalWC = opCtx->getWriteConcern();
+ ScopeGuard resetWCGuard([&] { opCtx->setWriteConcern(originalWC); });
+ opCtx->setWriteConcern(ShardingCatalogClient::kMajorityWriteConcern);
+
DBDirectClient localClient(opCtx);
BSONObj res;