From cd7baebc8b7b8446e4ecdff782c46d637e1c18ee Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Tue, 31 Mar 2026 13:37:27 +0200 Subject: [PATCH] tests: address_map_test: Fix flakiness in debug mode due to task reordering Debug mode shuffles task position in the queue. So the following is possible: 1) shard 1 calls manual_clock::advance(). This expires timers on shard 1 and queues a background smp call to shard 0 which will expire timers there 2) the smp::submit_to(0, ...) from shard 1 called by the test sumbits the call 3) shard 0 creates tasks for both calls, but (2) is run first, and preempts the reactor 4) shard 1 sees the completion, completes m_svc.invoke_on(1, ..) 5) shard 0 inserts the completion from (4) before task from (1) 6) the check on shard 0: m.find(id1) fails because the timer is not expired yet To fix that, wait for timer expiration on shard 0, so that the test doesn't depend on task execution order. Note: I was not able to reproduce the problem locally using test.py --mode debug --repeat 1000. It happens in jenkins very rarely. Which is expected as the scenario which leads to this is quite unlikely. Fixes SCYLLADB-1265 Closes scylladb/scylladb#29290 (cherry picked from commit 2ec47a8a21075c30dfea6b297eaf3b31ddba4472) Closes scylladb/scylladb#29309 --- test/boost/address_map_test.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/boost/address_map_test.cc b/test/boost/address_map_test.cc index a1f98334b1..d0a74b5d3e 100644 --- a/test/boost/address_map_test.cc +++ b/test/boost/address_map_test.cc @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -290,12 +290,17 @@ SEASTAR_THREAD_TEST_CASE(test_address_map_replication) { m.set_expiring(id1); BOOST_CHECK(m.find(id1) && *m.find(id1) == addr1); m.barrier().get(); + promise<> shard0_timer_expired; + timer shard0_timer([&shard0_timer_expired] { + shard0_timer_expired.set_value(); + }); + shard0_timer.arm(manual_clock::now() + expiration_time); m_svc.invoke_on(1, [] (address_map_t& m) { BOOST_CHECK(m.find(id1) && *m.find(id1) == addr1); manual_clock::advance(expiration_time); BOOST_CHECK(!m.find(id1)); - return smp::submit_to(0, []{}); // Ensure shard 0 notices timer is expired. }).get(); + shard0_timer_expired.get_future().get(); BOOST_CHECK(!m.find(id1)); // Expiring entries are replicated