diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-07-14 13:19:04 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2017-07-17 14:00:35 -0400 |
commit | 060473c2794e1d86dc4e4988c031b9c7ebda8297 (patch) | |
tree | 10916cc4a849d1c45d5bbdcd633a2b6762fe6ec5 | |
parent | 03f5fa3484cf001c21d48230590a97fafc1a89ec (diff) | |
download | mongo-060473c2794e1d86dc4e4988c031b9c7ebda8297.tar.gz |
SERVER-30060 Do not gather shard disk usage statistics unless 'maxSize' is set
(cherry picked from commit e0136739285c097a7da59ba54d6bcd109bb184b5)
-rw-r--r-- | src/mongo/db/s/balancer/cluster_statistics.h | 4 | ||||
-rw-r--r-- | src/mongo/db/s/balancer/cluster_statistics_impl.cpp | 11 | ||||
-rw-r--r-- | 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<vector<ShardStatistics>> ClusterStatisticsImpl::getStats(OperationCon vector<ShardStatistics> stats; for (const auto& shard : shards) { - auto shardSizeStatus = shardutil::retrieveTotalShardSize(txn, shard.getName()); + const auto shardSizeStatus = [&]() -> StatusWith<long long> { + 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<stdx::mutex> lk(_mutex); _cloneLocs.insert(recordId); |