From 060473c2794e1d86dc4e4988c031b9c7ebda8297 Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Fri, 14 Jul 2017 13:19:04 -0400 Subject: SERVER-30060 Do not gather shard disk usage statistics unless 'maxSize' is set (cherry picked from commit e0136739285c097a7da59ba54d6bcd109bb184b5) --- src/mongo/db/s/balancer/cluster_statistics.h | 4 ++-- src/mongo/db/s/balancer/cluster_statistics_impl.cpp | 11 +++++++++-- src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp | 5 +++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mongo/db/s/balancer/cluster_statistics.h b/src/mongo/db/s/balancer/cluster_statistics.h index a8e433062e8..9feb8a4a8f4 100644 --- a/src/mongo/db/s/balancer/cluster_statistics.h +++ b/src/mongo/db/s/balancer/cluster_statistics.h @@ -78,10 +78,10 @@ public: // The id of the shard for which this statistic applies ShardId shardId; - // The maximum size allowed for the shard + // The maximum storage size allowed for the shard. Zero means no maximum specified. uint64_t maxSizeMB{0}; - // The current size of the shard + // The current storage size of the shard. uint64_t currSizeMB{0}; // Whether the shard is in draining mode diff --git a/src/mongo/db/s/balancer/cluster_statistics_impl.cpp b/src/mongo/db/s/balancer/cluster_statistics_impl.cpp index 6ae4d9c223f..3bde0866770 100644 --- a/src/mongo/db/s/balancer/cluster_statistics_impl.cpp +++ b/src/mongo/db/s/balancer/cluster_statistics_impl.cpp @@ -117,9 +117,16 @@ StatusWith> ClusterStatisticsImpl::getStats(OperationCon vector stats; for (const auto& shard : shards) { - auto shardSizeStatus = shardutil::retrieveTotalShardSize(txn, shard.getName()); + const auto shardSizeStatus = [&]() -> StatusWith { + if (!shard.getMaxSizeMB()) { + return 0; + } + + return shardutil::retrieveTotalShardSize(txn, shard.getName()); + }(); + if (!shardSizeStatus.isOK()) { - const Status& status = shardSizeStatus.getStatus(); + const auto& status = shardSizeStatus.getStatus(); return {status.code(), str::stream() << "Unable to obtain shard utilization information for " diff --git a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp index d503e3aeaa0..a11d74ef587 100644 --- a/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp +++ b/src/mongo/db/s/migration_chunk_cloner_source_legacy.cpp @@ -592,6 +592,11 @@ Status MigrationChunkClonerSourceLegacy::_storeCurrentLocs(OperationContext* txn RecordId recordId; PlanExecutor::ExecState state; while (PlanExecutor::ADVANCED == (state = exec->getNext(&obj, &recordId))) { + Status interruptStatus = txn->checkForInterruptNoAssert(); + if (!interruptStatus.isOK()) { + return interruptStatus; + } + if (!isLargeChunk) { stdx::lock_guard lk(_mutex); _cloneLocs.insert(recordId); -- cgit v1.2.1