From abc6a6e1330da6a221442c32aca10e8845136a4e Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 3 Nov 2026 10:03:58 -0600 Subject: [PATCH] test(id): scale the bulk page-transfer session deadline to its work (#4057) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test moves 210 events across four 64-event pages and takes ~39 s unloaded against the production 60 s SESSION_DEADLINE — 1.5x headroom. Under heavy parallel load (load average ~30-43: nix sandbox build plus fleet builds) the session once got no scheduler time at all before the deadline expired, failing with zero events accepted. Give only this test a deadline proportional to its work: 3x production (~4.6x headroom over the unloaded runtime), on both the client and the in-test responder, which previously hardcoded the module DEADLINE. A genuine hang still fails the test in minutes, and every other log_sync test keeps the production deadline. --- pkgs/id/src/log_sync.rs | 45 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/pkgs/id/src/log_sync.rs b/pkgs/id/src/log_sync.rs index 1586ede00d..3b76c4b5c4 100644 --- a/pkgs/id/src/log_sync.rs +++ b/pkgs/id/src/log_sync.rs @@ -684,6 +684,15 @@ mod tests { // substantially more contention than a focused local invocation. const DEADLINE: Duration = SESSION_DEADLINE; + /// The bulk page-transfer test moves 210 events (three chains of 70) across four 64-event + /// pages, so its session does several times the work the production deadline is sized for. + /// Unloaded it takes ~39 s against `SESSION_DEADLINE` — 1.5x headroom — and under heavy + /// parallel load (load average ~30-43) the session once got no scheduler time at all before + /// the deadline expired, failing the test with zero events accepted (#4057). Scale the + /// deadline to this test's work instead of the machine's mood: 3x production leaves ~4.6x + /// headroom over the unloaded runtime, and a genuine hang still fails the test in minutes. + const BULK_DEADLINE: Duration = Duration::from_secs(SESSION_DEADLINE.as_secs() * 3); + fn key(n: u8) -> SigningKey { SigningKey::from_bytes(&[n; 32]) } @@ -798,6 +807,7 @@ mod tests { support: Arc, gate: PullGate, results: mpsc::UnboundedSender>, + deadline: Duration, } impl ProtocolHandler for Capture { @@ -810,7 +820,7 @@ mod tests { conn.remote_id(), send, recv, - DEADLINE, + self.deadline, ) .await; let _ = self.results.send(result); @@ -831,6 +841,32 @@ mod tests { responder_gated(store, testing::open_gate()).await } + /// Serves `store` on loopback with both sides of each session bounded by `deadline`. Only the + /// bulk page-transfer test needs this: it outruns [`DEADLINE`] under suite-wide contention + /// (#4057), so it scales the deadline to its own work size. + async fn responder_with_deadline( + store: &SharedEventStore, + deadline: Duration, + ) -> ( + Endpoint, + Router, + mpsc::UnboundedReceiver>, + ) { + let ep = endpoint().await; + let (results, rx) = mpsc::unbounded_channel(); + let handler = Capture { + store: store.clone(), + support: Arc::new(LogSyncOnly), + gate: testing::open_gate(), + results, + deadline, + }; + let router = Router::builder(ep.clone()) + .accept(SYNC_ALPN, handler) + .spawn(); + (ep, router, rx) + } + /// Serves `store` on loopback under `gate`. async fn responder_gated( store: &SharedEventStore, @@ -847,6 +883,7 @@ mod tests { support: Arc::new(LogSyncOnly), gate, results, + deadline: DEADLINE, }; let router = Router::builder(ep.clone()) .accept(SYNC_ALPN, handler) @@ -870,6 +907,7 @@ mod tests { support, gate: testing::open_gate(), results, + deadline: DEADLINE, }; let router = Router::builder(ep.clone()) .accept(SYNC_ALPN, handler) @@ -983,7 +1021,8 @@ mod tests { let mut attempt = 0; let (outcome, answered) = loop { attempt += 1; - let (server, router, mut results) = responder(&store_a).await; + let (server, router, mut results) = + responder_with_deadline(&store_a, BULK_DEADLINE).await; let client = endpoint().await; match sync_with( &client, @@ -991,7 +1030,7 @@ mod tests { &store_b, topic, &bootstrap(), - DEADLINE, + BULK_DEADLINE, ) .await {