From 8e3be5b44c1bd671e1e079796d1a92c428d5acf0 Mon Sep 17 00:00:00 2001 From: Dustin Smith Date: Wed, 18 Nov 2026 13:12:49 +0700 Subject: [PATCH] test: fix two start-order and teardown races in native/local tests partition_order_runs_at_most_the_given_number_of_partitions compared the start order of two partitions that start concurrently. Check the started set through assert_executed_once instead, which sorts. cancel_wakes_a_waiting_reader asserted the plan was released as soon as the cancelled reader returned, but an aborted partition task that has not run yet still owns its start closure until a runtime worker drops it. Wait for the count to reach zero under a deadline, as the other teardown checks in the crate do. Closes #7676 Closes #7677 --- native/local/src/handle.rs | 9 ++++++++- native/local/tests/execution.rs | 3 +-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/native/local/src/handle.rs b/native/local/src/handle.rs index 9ca0dd20c23..7ef5ada4dd2 100644 --- a/native/local/src/handle.rs +++ b/native/local/src/handle.rs @@ -211,7 +211,14 @@ mod tests { let result = receiver.recv_timeout(Duration::from_secs(5)).unwrap(); assert!(result.err().unwrap().to_string().contains("cancelled")); assert!(started.elapsed() < Duration::from_secs(5)); - assert_eq!(refs.strong_count(), 0); + let releasing = Instant::now(); + while refs.strong_count() != 0 { + assert!( + releasing.elapsed() < Duration::from_secs(5), + "cancelled graph remained live" + ); + std::thread::yield_now(); + } thread.join().unwrap(); } } diff --git a/native/local/tests/execution.rs b/native/local/tests/execution.rs index 4cf4660b457..a6fbf153af8 100644 --- a/native/local/tests/execution.rs +++ b/native/local/tests/execution.rs @@ -477,7 +477,6 @@ async fn partition_order_cancel_releases_running_partitions() { #[tokio::test(flavor = "multi_thread", worker_threads = 4)] async fn partition_order_runs_at_most_the_given_number_of_partitions() { let (plan, observations) = observe(ordered_input(6, 3)); - let executed = || observations.executions.lock().unwrap().clone(); let mut stream = LocalQuery::new(plan, context(), 2, usize::MAX) .execute() .unwrap(); @@ -490,7 +489,7 @@ async fn partition_order_runs_at_most_the_given_number_of_partitions() { .unwrap() .unwrap(); } - assert_eq!(executed(), vec![0, 1]); + assert_executed_once(&observations, 2); // Finishing the first partition starts the third. timeout(DEADLINE, stream.next()) .await