summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2021-06-11 07:35:29 +0000
committerGeir Storli <geirst@verizonmedia.com>2021-06-11 07:35:29 +0000
commit9b9379aae11082dcb8950f7740129e3a602b0642 (patch)
tree205efd87ec8ef4079720c0b9e367b887dda1cc04 /storage
parentb4de0d54d61e70f790753bcd948e61aba9d151db (diff)
MinReplica counts the minimum bucket replication factor, so use std::min instead of sum.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/distributor/distributor_host_info_reporter_test.cpp2
-rw-r--r--storage/src/vespa/storage/distributor/min_replica_provider.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp
index 77b42ea9a94..934ecc7456b 100644
--- a/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp
+++ b/storage/src/tests/distributor/distributor_host_info_reporter_test.cpp
@@ -151,7 +151,7 @@ TEST_F(DistributorHostInfoReporterTest, merge_min_replica_stats) {
EXPECT_EQ(3, result.size());
EXPECT_EQ(2, result[3]);
- EXPECT_EQ(10, result[5]);
+ EXPECT_EQ(4, result[5]);
EXPECT_EQ(8, result[7]);
}
diff --git a/storage/src/vespa/storage/distributor/min_replica_provider.cpp b/storage/src/vespa/storage/distributor/min_replica_provider.cpp
index 7fcc977fadf..c9929940560 100644
--- a/storage/src/vespa/storage/distributor/min_replica_provider.cpp
+++ b/storage/src/vespa/storage/distributor/min_replica_provider.cpp
@@ -10,7 +10,9 @@ merge_min_replica_stats(std::unordered_map<uint16_t, uint32_t>& dest,
{
for (const auto& entry : src) {
auto node_index = entry.first;
- dest[node_index] += entry.second;
+ auto itr = dest.find(node_index);
+ auto new_min_replica = (itr != dest.end()) ? std::min(itr->second, entry.second) : entry.second;
+ dest[node_index] = new_min_replica;
}
}