diff options
author | Simon Gratzer <simon.gratzer@mongodb.com> | 2021-05-18 20:59:17 +0200 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-26 11:08:11 +0000 |
commit | 69fa6204e810606e33d08bad97fff273222b6531 (patch) | |
tree | 1106073c6e18de14448c1591cb79c8ea8675712b /src/mongo/s | |
parent | d10757829f893b01607302b567fa3b1e58bf378a (diff) | |
download | mongo-69fa6204e810606e33d08bad97fff273222b6531.tar.gz |
SERVER-57057 Reduce routing info refreshes on the mergeChunks path
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/commands/cluster_merge_chunks_cmd.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp index 531aa1ab41e..5d826c9c0cf 100644 --- a/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp +++ b/src/mongo/s/commands/cluster_merge_chunks_cmd.cpp @@ -103,10 +103,6 @@ public: BSONObjBuilder& result) override { const NamespaceString nss(parseNs(dbname, cmdObj)); - const auto cm = uassertStatusOK( - Grid::get(opCtx)->catalogCache()->getShardedCollectionRoutingInfoWithRefresh(opCtx, - nss)); - vector<BSONObj> bounds; if (!FieldParser::extract(cmdObj, boundsField, &bounds, &errmsg)) { return false; @@ -135,6 +131,9 @@ public: return false; } + auto const cm = + Grid::get(opCtx)->catalogCache()->getShardedCollectionRoutingInfo(opCtx, nss); + if (!cm.getShardKeyPattern().isShardKey(minKey) || !cm.getShardKeyPattern().isShardKey(maxKey)) { errmsg = str::stream() @@ -148,6 +147,7 @@ public: maxKey = cm.getShardKeyPattern().normalizeShardKey(maxKey); const auto firstChunk = cm.findIntersectingChunkWithSimpleCollation(minKey); + ChunkVersion shardVersion = cm.getVersion(firstChunk.getShardId()); BSONObjBuilder remoteCmdObjB; remoteCmdObjB.append(cmdObj[ClusterMergeChunksCommand::nsField()]); @@ -157,7 +157,8 @@ public: Grid::get(opCtx)->shardRegistry()->getConfigServerConnectionString().toString()); remoteCmdObjB.append(ClusterMergeChunksCommand::shardNameField(), firstChunk.getShardId().toString()); - remoteCmdObjB.append("epoch", cm.getVersion().epoch()); + remoteCmdObjB.append("epoch", shardVersion.epoch()); + shardVersion.appendToCommand(&remoteCmdObjB); BSONObj remoteResult; |