From 60c7c8174cba46bb1895330ef7b33aa906aee56a Mon Sep 17 00:00:00 2001 From: Nicolae Vartolomei Date: Sat, 11 May 2024 17:14:37 +0100 Subject: [PATCH] archival/tests: yield more often to the scheduler Adding a segment takes ~1ms. Adding multiple segments in a single batch can stall the reactor for a while. This, together with a recent seastar change[^1] caused some timeouts to fire very frequently[^2]. Fix the problematic test by splitting the batch passed to add_segments so that we execute more finer grained tasks and yield more often to the scheduler. [^1]: https://github.com/scylladb/seastar/issues/2238 [^2]: https://github.com/redpanda-data/redpanda/issues/13275 --- src/v/archival/tests/ntp_archiver_test.cc | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/v/archival/tests/ntp_archiver_test.cc b/src/v/archival/tests/ntp_archiver_test.cc index 6827ee60566ed..26acf8f793f34 100644 --- a/src/v/archival/tests/ntp_archiver_test.cc +++ b/src/v/archival/tests/ntp_archiver_test.cc @@ -1701,21 +1701,32 @@ static void test_manifest_spillover_impl( }).get(); // Generate new manifest based on data layout on disk - std::vector all_segments; + vlog(test_log.debug, "stm add segments"); + auto add_segments = + [&part](std::vector segments) { + part->archival_meta_stm() + ->add_segments( + std::move(segments), + std::nullopt, + model::producer_id{}, + ss::lowres_clock::now() + 1s, + never_abort, + cluster::segment_validated::yes) + .get(); + }; + + // 10 at a time to avoid reactor stalls. + const int max_batch_size = 10; + std::vector batch; for (const auto& s : manifest) { - all_segments.push_back(s); + if (batch.size() >= max_batch_size) { + add_segments(batch); + batch.clear(); + } + batch.push_back(s); } + add_segments(batch); - vlog(test_log.debug, "stm add segments"); - part->archival_meta_stm() - ->add_segments( - all_segments, - std::nullopt, - model::producer_id{}, - ss::lowres_clock::now() + 1s, - never_abort, - cluster::segment_validated::yes) - .get(); vlog(test_log.debug, "stm add segments completed"); vlog(