diff options
Diffstat (limited to 'src/mongo/db/s/add_shard_cmd.cpp')
| -rw-r--r-- | src/mongo/db/s/add_shard_cmd.cpp | 8 |
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; |
