diff options
author | Mihai Andrei <mihai.andrei@mongodb.com> | 2023-02-07 00:58:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-07 02:32:02 +0000 |
commit | b185d04364c298e701943a1e800c4036ce8df6e7 (patch) | |
tree | 6a91575c0096863e38b1b0fd12d1bfd90d55ac7f /src/mongo/db/s/collection_sharding_runtime.cpp | |
parent | 967a6745ba487edaff558e36fdc572c6ca066fea (diff) | |
download | mongo-b185d04364c298e701943a1e800c4036ce8df6e7.tar.gz |
SERVER-71798 Expand the set of queries eligible for SBE in the 6.3 release
Diffstat (limited to 'src/mongo/db/s/collection_sharding_runtime.cpp')
-rw-r--r-- | src/mongo/db/s/collection_sharding_runtime.cpp | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/src/mongo/db/s/collection_sharding_runtime.cpp b/src/mongo/db/s/collection_sharding_runtime.cpp index bc13cdd914c..be3c4ff4b4a 100644 --- a/src/mongo/db/s/collection_sharding_runtime.cpp +++ b/src/mongo/db/s/collection_sharding_runtime.cpp @@ -662,52 +662,48 @@ void CollectionShardingRuntime::_cleanupBeforeInstallingNewCollectionMetadata( return; } - if (feature_flags::gFeatureFlagSbeFull.isEnabledAndIgnoreFCV()) { - const auto oldUUID = _metadataManager->getCollectionUuid(); - const auto oldShardVersion = _metadataManager->getActiveShardVersion(); - ExecutorFuture<void>{Grid::get(opCtx)->getExecutorPool()->getFixedExecutor()} - .then([svcCtx{opCtx->getServiceContext()}, oldUUID, oldShardVersion] { - ThreadClient tc{"CleanUpShardedMetadata", svcCtx}; - { - stdx::lock_guard<Client> lk{*tc.get()}; - tc->setSystemOperationKillableByStepdown(lk); - } - auto uniqueOpCtx{tc->makeOperationContext()}; - auto opCtx{uniqueOpCtx.get()}; - - try { - auto& planCache = sbe::getPlanCache(opCtx); - planCache.removeIf([&](const sbe::PlanCacheKey& key, - const sbe::PlanCacheEntry& entry) -> bool { - const auto matchingCollState = - [&](const sbe::PlanCacheKeyCollectionState& entryCollState) { - return entryCollState.uuid == oldUUID && - entryCollState.shardVersion && - entryCollState.shardVersion->epoch == oldShardVersion.epoch() && - entryCollState.shardVersion->ts == - oldShardVersion.getTimestamp(); - }; - - // Check whether the main collection of this plan is the one being removed - if (matchingCollState(key.getMainCollectionState())) + const auto oldUUID = _metadataManager->getCollectionUuid(); + const auto oldShardVersion = _metadataManager->getActiveShardVersion(); + ExecutorFuture<void>{Grid::get(opCtx)->getExecutorPool()->getFixedExecutor()} + .then([svcCtx{opCtx->getServiceContext()}, oldUUID, oldShardVersion] { + ThreadClient tc{"CleanUpShardedMetadata", svcCtx}; + { + stdx::lock_guard<Client> lk{*tc.get()}; + tc->setSystemOperationKillableByStepdown(lk); + } + auto uniqueOpCtx{tc->makeOperationContext()}; + auto opCtx{uniqueOpCtx.get()}; + + try { + auto& planCache = sbe::getPlanCache(opCtx); + planCache.removeIf([&](const sbe::PlanCacheKey& key, + const sbe::PlanCacheEntry& entry) -> bool { + const auto matchingCollState = + [&](const sbe::PlanCacheKeyCollectionState& entryCollState) { + return entryCollState.uuid == oldUUID && entryCollState.shardVersion && + entryCollState.shardVersion->epoch == oldShardVersion.epoch() && + entryCollState.shardVersion->ts == oldShardVersion.getTimestamp(); + }; + + // Check whether the main collection of this plan is the one being removed + if (matchingCollState(key.getMainCollectionState())) + return true; + + // Check whether a secondary collection is the one being removed + for (const auto& secCollState : key.getSecondaryCollectionStates()) { + if (matchingCollState(secCollState)) return true; - - // Check whether a secondary collection is the one being removed - for (const auto& secCollState : key.getSecondaryCollectionStates()) { - if (matchingCollState(secCollState)) - return true; - } - - return false; - }); - } catch (const DBException& ex) { - LOGV2(6549200, - "Interrupted deferred clean up of sharded metadata", - "error"_attr = redact(ex)); - } - }) - .getAsync([](auto) {}); - } + } + + return false; + }); + } catch (const DBException& ex) { + LOGV2(6549200, + "Interrupted deferred clean up of sharded metadata", + "error"_attr = redact(ex)); + } + }) + .getAsync([](auto) {}); } void CollectionShardingRuntime::_checkCritSecForIndexMetadata(OperationContext* opCtx) const { |