From 6165644e1b62afb0d523a34cf6d94bd44cf4f374 Mon Sep 17 00:00:00 2001 From: Willem Kaufmann Date: Wed, 21 Aug 2024 21:40:03 -0400 Subject: [PATCH] Revert `storage`: fix condition in `disk_log_impl::have_segments_to_evict()` Original PR: https://github.com/redpanda-data/redpanda/pull/22686. The associated test with this is deadlocking in every ~1/30-40 runs. Revert the change for now, as well as the expectations for unit test `retention_test_size_with_one_segment`. (cherry picked from commit 6fe0605a473e8b0afd218904b7208ef11efd2f18) --- src/v/storage/disk_log_impl.cc | 2 +- src/v/storage/tests/log_retention_tests.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v/storage/disk_log_impl.cc b/src/v/storage/disk_log_impl.cc index 69c3d35821048..5a3ea1f65e611 100644 --- a/src/v/storage/disk_log_impl.cc +++ b/src/v/storage/disk_log_impl.cc @@ -402,7 +402,7 @@ disk_log_impl::request_eviction_until_offset(model::offset max_offset) { max_offset); // we only notify eviction monitor if there are segments to evict auto have_segments_to_evict - = !_segs.empty() + = (_segs.size() > 1) && _segs.front()->offsets().get_committed_offset() <= max_offset; if (_eviction_monitor && have_segments_to_evict) { diff --git a/src/v/storage/tests/log_retention_tests.cc b/src/v/storage/tests/log_retention_tests.cc index 2c7e290b33eb5..571e09a71245a 100644 --- a/src/v/storage/tests/log_retention_tests.cc +++ b/src/v/storage/tests/log_retention_tests.cc @@ -104,12 +104,12 @@ FIXTURE_TEST(retention_test_size_with_one_segment, gc_fixture) { builder.get_disk_log_impl().get_probe().partition_size())); BOOST_CHECK_EQUAL(builder.get_log()->segment_count(), 1); - BOOST_TEST_MESSAGE("Should collect the segment"); + BOOST_TEST_MESSAGE("Should not collect the segment"); builder | storage::garbage_collect(model::timestamp(1), std::optional(0)) | storage::stop(); - BOOST_CHECK_EQUAL(builder.get_log()->segment_count(), 0); + BOOST_CHECK_EQUAL(builder.get_log()->segment_count(), 1); } /*