From d55700267503f68e707e137710d1ee7a0dc4d693 Mon Sep 17 00:00:00 2001 From: Vlad Lazar Date: Thu, 27 Jun 2024 11:56:57 +0100 Subject: [PATCH] strocon: don't overcommit when making node fill plan (#8171) ## Problem The fill requirement was not taken into account when looking through the shards of a given node to fill from. ## Summary of Changes Ensure that we do not fill a node past the recommendation from `Scheduler::compute_fill_requirement`. --- storage_controller/src/service.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/storage_controller/src/service.rs b/storage_controller/src/service.rs index e329f42dd6..a94575b428 100644 --- a/storage_controller/src/service.rs +++ b/storage_controller/src/service.rs @@ -5564,9 +5564,12 @@ impl Service { break; } - let mut can_take = attached - expected_attached; + let can_take = attached - expected_attached; + let needed = fill_requirement - plan.len(); + let mut take = std::cmp::min(can_take, needed); + let mut remove_node = false; - while can_take > 0 { + while take > 0 { match tids_by_node.get_mut(&node_id) { Some(tids) => match tids.pop() { Some(tid) => { @@ -5578,7 +5581,7 @@ impl Service { if *promoted < max_promote_for_tenant { plan.push(tid); *promoted += 1; - can_take -= 1; + take -= 1; } } None => {