From e58a51f1ef19f3d1a211856d6309c37cb44d8ef5 Mon Sep 17 00:00:00 2001 From: Brandon Allard Date: Sat, 2 May 2026 17:32:55 -0400 Subject: [PATCH] tests/rm_stm: wait for STM replay before LSO check after restart After restart_stm_and_raft() the STM has only applied through the snapshot offset; data batches are still asynchronously replaying, so last_stable_offset() can briefly return invalid_lso. Wrap the check in RPTEST_REQUIRE_EVENTUALLY, mirroring the wait already used at the end of the test. (cherry picked from commit fb111f1ecf4f4d5715cab60d53fa8ccf60e34ba6) --- src/v/cluster/tests/rm_stm_tests.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/v/cluster/tests/rm_stm_tests.cc b/src/v/cluster/tests/rm_stm_tests.cc index 2cb86e234c471..e33cc7a8850a2 100644 --- a/src/v/cluster/tests/rm_stm_tests.cc +++ b/src/v/cluster/tests/rm_stm_tests.cc @@ -1243,9 +1243,14 @@ FIXTURE_TEST( BOOST_REQUIRE(producers().contains(pid1.get_id())); BOOST_REQUIRE(producers().contains(pid2.get_id())); - // Ensure the LSO is held back by the open transactions. - auto lso = stm->last_stable_offset(); - BOOST_REQUIRE_NE(lso, model::invalid_lso); + // Ensure the LSO is held back by the open transactions. After restart + // the STM has applied through the snapshot offset; data batches replay + // asynchronously, so wait for last_stable_offset() to become valid. + model::offset lso; + RPTEST_REQUIRE_EVENTUALLY(10s, [&]() { + lso = stm->last_stable_offset(); + return lso != model::invalid_lso; + }); BOOST_REQUIRE_LE(lso, model::offset(last_data_offset())); // Ensure pid1's transaction can be committed