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> {
));
continue;
}
if let Some(&follower_number) = aggregation_numbers.get(&follower_id)
&& edge_balance_side(task.aggregation_number, follower_number)
== Some(EdgeSide::Inner)
// A root must aggregate every real edge, even if the other endpoint is evicted.
let follower_number = aggregation_numbers.get(&follower_id).copied();
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!(
"follower edge {upper_id} -> {follower_id} should be an inner edge \
(aggregation numbers {} and {follower_number})",
(aggregation numbers {} and {follower_number:?})",
task.aggregation_number
));
}
......@@ -296,6 +300,10 @@ mod tests {
}
#[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() {
let error = std::panic::catch_unwind(|| {
follower_delta(id(11), id(12), i32::MAX as u32 + 1);
......@@ -340,6 +348,15 @@ mod tests {
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]
fn verify_accepts_valid_edges() {
let mut upper = task(1, 100);
......
......@@ -817,21 +817,22 @@ impl TaskStorage {
}
/// 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"))]
pub fn aggregation_edges_for_verification(
&self,
task_id: TaskId,
) -> 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 followers: Vec<_> = self
.followers()
.into_iter()
.flat_map(|f| f.iter().map(|(&id, &c)| (id, c)))
.collect();
if upper.is_empty() && followers.is_empty() {
return None;
}
Some(crate::backend::operation::TaskAggregationEdges {
task_id,
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