fix crash in layout computation when changing all nodes of a zone to gateway mode #937

Merged
lx merged 1 commit from baptiste/garage:fix_layout_crash into main 2025-02-19 17:09:11 +00:00

View file

@ -650,10 +650,13 @@ impl LayoutVersion {
let mut cost = CostFunction::new();
for (p, assoc_p) in prev_assign.iter().enumerate() {
for n in assoc_p.iter() {
Review

Maybe add a // FIXME comment to indicate that we are not sure that this is the correct solution.

Even if this is the "wrong" solution, I don't think it will have a big impact. At worse, too much data will be migrated between nodes, but I don't think it can crash Garage or put it in an invalid state.

Maybe add a `// FIXME` comment to indicate that we are not sure that this is the correct solution. Even if this is the "wrong" solution, I don't think it will have a big impact. At worse, too much data will be migrated between nodes, but I don't think it can crash Garage or put it in an invalid state.
let node_zone = zone_to_id[self.expect_get_node_zone(&self.node_id_vec[*n])];
if let Some(&node_zone) =
zone_to_id.get(self.expect_get_node_zone(&self.node_id_vec[*n]))
{
cost.insert((Vertex::PZ(p, node_zone), Vertex::N(*n)), -1);
}
}
}
// We compute the maximal length of a simple path in gflow. It is used in the
// Bellman-Ford algorithm in optimize_flow_with_cost to set the number
@ -751,8 +754,11 @@ impl LayoutVersion {
if let Some(prev_assign) = prev_assign_opt {
let mut old_zones_of_p = Vec::<usize>::new();
for n in prev_assign[p].iter() {
old_zones_of_p
.push(zone_to_id[self.expect_get_node_zone(&self.node_id_vec[*n])]);
if let Some(&zone_id) =
zone_to_id.get(self.expect_get_node_zone(&self.node_id_vec[*n]))
Review

This one does not impact correctness of the layout computation, at worse wrong statistics will be shown but I think that's ok to leave for a future issue if it happens.

This one does not impact correctness of the layout computation, at worse wrong statistics will be shown but I think that's ok to leave for a future issue if it happens.
{
old_zones_of_p.push(zone_id);
}
}
if !old_zones_of_p.contains(&z) {
new_partitions_zone[z] += 1;