Unverified Commit c4af18be authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Strengthen aggregation debt race and verifier coverage

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent ba0939fc
...@@ -178,13 +178,17 @@ pub fn verify_aggregation_edges(tasks: &[TaskAggregationEdges]) -> Vec<String> { ...@@ -178,13 +178,17 @@ pub fn verify_aggregation_edges(tasks: &[TaskAggregationEdges]) -> Vec<String> {
)); ));
continue; continue;
} }
if let Some(&follower_number) = aggregation_numbers.get(&follower_id) // A root must aggregate every real edge, even if the other endpoint is evicted.
&& edge_balance_side(task.aggregation_number, follower_number) let follower_number = aggregation_numbers.get(&follower_id).copied();
== Some(EdgeSide::Inner) if count > 0
&& (is_root_node(task.aggregation_number)
|| follower_number.is_some_and(|number| {
edge_balance_side(task.aggregation_number, number) == Some(EdgeSide::Inner)
}))
{ {
violations.push(format!( violations.push(format!(
"follower edge {upper_id} -> {follower_id} should be an inner edge \ "follower edge {upper_id} -> {follower_id} should be an inner edge \
(aggregation numbers {} and {follower_number})", (aggregation numbers {} and {follower_number:?})",
task.aggregation_number task.aggregation_number
)); ));
} }
...@@ -296,6 +300,10 @@ mod tests { ...@@ -296,6 +300,10 @@ mod tests {
} }
#[test] #[test]
#[cfg_attr(
target_family = "wasm",
ignore = "no unwinding on wasm: std is built panic=abort, so catch_unwind cannot catch"
)]
fn follower_delta_conversion_overflow_names_edge() { fn follower_delta_conversion_overflow_names_edge() {
let error = std::panic::catch_unwind(|| { let error = std::panic::catch_unwind(|| {
follower_delta(id(11), id(12), i32::MAX as u32 + 1); follower_delta(id(11), id(12), i32::MAX as u32 + 1);
...@@ -340,6 +348,15 @@ mod tests { ...@@ -340,6 +348,15 @@ mod tests {
TaskId::new(id).unwrap() TaskId::new(id).unwrap()
} }
#[test]
fn verify_rejects_root_follower_even_with_unknown_endpoint() {
let mut root = task(1, ROOT);
root.followers.push((id(2), 1));
let violations = verify_aggregation_edges(&[root]);
assert_eq!(violations.len(), 1);
assert!(violations[0].contains("should be an inner edge"));
}
#[test] #[test]
fn verify_accepts_valid_edges() { fn verify_accepts_valid_edges() {
let mut upper = task(1, 100); let mut upper = task(1, 100);
......
...@@ -817,21 +817,22 @@ impl TaskStorage { ...@@ -817,21 +817,22 @@ impl TaskStorage {
} }
/// Captures the aggregation edges of this task for verification of the aggregation graph. /// Captures the aggregation edges of this task for verification of the aggregation graph.
/// Returns `None` when the task has no aggregation edges. /// Returns `None` when metadata is not restored. Edgeless resident tasks must be included:
/// another task can reference them, and placement verification needs both aggregation numbers.
#[cfg(any(test, feature = "verify_aggregation_graph"))] #[cfg(any(test, feature = "verify_aggregation_graph"))]
pub fn aggregation_edges_for_verification( pub fn aggregation_edges_for_verification(
&self, &self,
task_id: TaskId, task_id: TaskId,
) -> Option<crate::backend::operation::TaskAggregationEdges> { ) -> Option<crate::backend::operation::TaskAggregationEdges> {
if !self.flags.is_restored(TaskDataCategory::Meta) {
return None;
}
let upper: Vec<_> = self.upper().iter().map(|(&id, &c)| (id, c)).collect(); let upper: Vec<_> = self.upper().iter().map(|(&id, &c)| (id, c)).collect();
let followers: Vec<_> = self let followers: Vec<_> = self
.followers() .followers()
.into_iter() .into_iter()
.flat_map(|f| f.iter().map(|(&id, &c)| (id, c))) .flat_map(|f| f.iter().map(|(&id, &c)| (id, c)))
.collect(); .collect();
if upper.is_empty() && followers.is_empty() {
return None;
}
Some(crate::backend::operation::TaskAggregationEdges { Some(crate::backend::operation::TaskAggregationEdges {
task_id, task_id,
aggregation_number: self.get_aggregation_number().map_or(0, |a| a.effective), aggregation_number: self.get_aggregation_number().map_or(0, |a| a.effective),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment