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/db/s | |
parent | d10757829f893b01607302b567fa3b1e58bf378a (diff) | |
download | mongo-69fa6204e810606e33d08bad97fff273222b6531.tar.gz |
SERVER-57057 Reduce routing info refreshes on the mergeChunks path
Diffstat (limited to 'src/mongo/db/s')
-rw-r--r-- | src/mongo/db/s/merge_chunks_command.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/mongo/db/s/merge_chunks_command.cpp b/src/mongo/db/s/merge_chunks_command.cpp index 9c5b4d3a9c6..a48107135a5 100644 --- a/src/mongo/db/s/merge_chunks_command.cpp +++ b/src/mongo/db/s/merge_chunks_command.cpp @@ -40,6 +40,7 @@ #include "mongo/db/namespace_string.h" #include "mongo/db/s/collection_sharding_runtime.h" #include "mongo/db/s/dist_lock_manager.h" +#include "mongo/db/s/operation_sharding_state.h" #include "mongo/db/s/shard_filtering_metadata_refresh.h" #include "mongo/db/s/sharding_state.h" #include "mongo/db/vector_clock.h" @@ -196,13 +197,19 @@ void mergeChunks(OperationContext* opCtx, << " to merge chunks in [" << redact(minKey) << ", " << redact(maxKey) << ")"); - // We now have the collection distributed lock, refresh metadata to latest version and sanity - // check - onShardVersionMismatch(opCtx, nss, boost::none); + const bool isVersioned = OperationShardingState::isOperationVersioned(opCtx); + if (!isVersioned) { + onShardVersionMismatch(opCtx, nss, boost::none); + } const auto metadataBeforeMerge = [&] { AutoGetCollection autoColl(opCtx, nss, MODE_IS); - return CollectionShardingRuntime::get(opCtx, nss)->getCurrentMetadataIfKnown(); + auto csr = CollectionShardingRuntime::get(opCtx, nss); + // If there is a version attached to the OperationContext, validate it + if (isVersioned) { + csr->checkShardVersionOrThrow(opCtx); + } + return csr->getCurrentMetadataIfKnown(); }(); uassert(ErrorCodes::StaleEpoch, |