fix: prevent transport de-synchronization because of early fetch cancellation

Came across this while investigating more test_transport_synchronization flakiness,
sometimes missing TransportsModified events or getting a missing configured_addr.
The underlying problem was that stopping IO was triggered immediately during
receiving sync messages, potentially *canceling* the processing of the sync message,
effectively de-syncing the device's view on transports.
This commit is contained in:
holger krekel
2026-07-31 03:03:39 +02:00
parent 67437c946b
commit 2cacdbfd4b
4 changed files with 55 additions and 8 deletions

View File

@@ -235,6 +235,32 @@ async fn test_promote_transport_same_second() -> Result<()> {
promote_transport_and_check_success(alice, alice2, "alice@otherprovider.com").await
}
/// Tests that `sync_transports()` requests an IO restart
/// if and only if it modified anything.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_sync_transports_requests_io_restart() -> Result<()> {
let alice = &TestContext::new_alice().await;
let data = TransportData {
configured: dummy_configured_login_param("alice@otherprovider.com").into(),
entered: EnteredLoginParam {
addr: "alice@otherprovider.com".to_string(),
..Default::default()
},
timestamp: time(),
is_published: true,
};
let data = std::slice::from_ref(&data);
sync_transports(alice, data, &[]).await?;
assert!(alice.restart_io_after_fetch.swap(false, Ordering::Relaxed));
// Applying the same data again modifies nothing.
sync_transports(alice, data, &[]).await?;
assert!(!alice.restart_io_after_fetch.load(Ordering::Relaxed));
Ok(())
}
/// Promotes `addr` to primary on `alice` and checks the change syncs to `alice2`.
async fn promote_transport_and_check_success(
alice: &TestContext,