From a43d9979c8984dd5cbad0052f4bac09e9503aa08 Mon Sep 17 00:00:00 2001 From: "K. Isom" Date: Thu, 24 Sep 2026 12:22:10 -0700 Subject: [PATCH] gatewayd: serve_restart takes the two caught-up turns in either order The two posts caught up at restart are two top-level posts, so two sessions, and their turns run on their own threads. gatewayd starts them in order, but which one reaches loopd first is up to the scheduler. Under load the test failed about 1 run in 60; task 18's session hit it once. mm_json.rs already checks the order of catch-up (reversing the sort fails there), so this test now compares the two turns as a set. It passed 100 of 100 runs under load. The M4a plan's copy is left as it was handed over. Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/gatewayd/tests/serve_restart.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/gatewayd/tests/serve_restart.rs b/crates/gatewayd/tests/serve_restart.rs index 39442d8..bf366e2 100644 --- a/crates/gatewayd/tests/serve_restart.rs +++ b/crates/gatewayd/tests/serve_restart.rs @@ -41,12 +41,14 @@ fn a_restart_reports_the_cut_off_turn_and_catches_up() { ); let _running = start(config(&home, &mm.url(), "")); let _ws = mm.next_ws(WAIT); - let first = turns.recv_timeout(WAIT).unwrap(); - let second = turns.recv_timeout(WAIT).unwrap(); - assert_eq!( - (first.content.as_str(), second.content.as_str()), - ("first", "second") - ); + // Two top-level posts are two sessions, whose turns run on their own threads: they may reach + // `loopd` in either order. The order of catch-up itself is `mm_json.rs`'s to check. + let mut got = [ + turns.recv_timeout(WAIT).unwrap().content, + turns.recv_timeout(WAIT).unwrap().content, + ]; + got.sort(); + assert_eq!(got, ["first", "second"]); let posts = mm.wait_posts(3, WAIT); assert_eq!(posts[0], (DM.to_string(), cut, INTERRUPTED.to_string())); assert_eq!(posts.len(), 3, "{posts:?}");