Skip to content

Commit

Permalink
c/pb_planner: clamp calculated free space down to prevent overshoot
Browse files Browse the repository at this point in the history
In the initial phase `health_report`` reported space may be incorrect as
not all partition storage information are included. Introduced clamping
down to actual disk free space + reclaimable size. This way we will never
go beyond the actual free space but when all reported values are up to date
the calculated free space should always be smaller then or equal to
free space plus reclaimable space.

Signed-off-by: Michal Maslanka <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Oct 20, 2023
1 parent ff7cb50 commit 0240196
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/v/cluster/partition_balancer_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ std::pair<uint64_t, uint64_t> partition_balancer_planner::get_node_bytes_info(
}
}

/**
* In the initial phase reported space may be incorrect as not all
* partition storage information are reported. Clamp down to actual
* disk free space + reclaimable size. This way we will never go beyond
* the actual free space but when all reported values are up to date
* the calculated free space should always be smaller then or equal to
* free space to reclaimable space.
*/
total_free = std::min(
reclaimable_size + node_state.data_disk.free, total_free);
// Clamp to total available target size.
total_free = std::min(target_size, total_free);
return std::make_pair(target_size, total_free);
Expand Down

0 comments on commit 0240196

Please sign in to comment.