From 3d338fb5241b2b7d9f0382749378dc06eb84aa81 Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Mon, 20 Nov 2023 17:08:06 +0100 Subject: [PATCH] cs/manifest: allow updating kafka start offset with the same offset Previously validation was failing when `_kafka_start_offset` was overridden with the same offset. Since re-setting the offset to the same number doesn't change anything we may relax the validation here. Signed-off-by: Michal Maslanka (cherry picked from commit b1c1d014a1b6b263a465f5796e9586a9ba9150cf) --- src/v/cloud_storage/partition_manifest.cc | 2 +- src/v/cloud_storage/tests/partition_manifest_test.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/v/cloud_storage/partition_manifest.cc b/src/v/cloud_storage/partition_manifest.cc index 85b89df4e6ec..cffc7aea0bb3 100644 --- a/src/v/cloud_storage/partition_manifest.cc +++ b/src/v/cloud_storage/partition_manifest.cc @@ -730,7 +730,7 @@ void partition_manifest::set_archive_clean_offset( bool partition_manifest::advance_start_kafka_offset( kafka::offset new_start_offset) { - if (_start_kafka_offset_override >= new_start_offset) { + if (_start_kafka_offset_override > new_start_offset) { return false; } _start_kafka_offset_override = new_start_offset; diff --git a/src/v/cloud_storage/tests/partition_manifest_test.cc b/src/v/cloud_storage/tests/partition_manifest_test.cc index cab061378d37..d27db9dc00d6 100644 --- a/src/v/cloud_storage/tests/partition_manifest_test.cc +++ b/src/v/cloud_storage/tests/partition_manifest_test.cc @@ -1431,9 +1431,9 @@ SEASTAR_THREAD_TEST_CASE(test_partition_manifest_start_kafka_offset_advance) { m.get_start_kafka_offset_override(), kafka::offset(370)); BOOST_REQUIRE_EQUAL(m.get_start_offset(), model::offset(100)); BOOST_REQUIRE_EQUAL(m.get_start_kafka_offset(), kafka::offset(90)); - + // Allow update with the same value + BOOST_REQUIRE(m.advance_start_kafka_offset(kafka::offset(370))); // If trying to move back, it should no-op. - BOOST_REQUIRE(!m.advance_start_kafka_offset(kafka::offset(370))); BOOST_REQUIRE(!m.advance_start_kafka_offset(kafka::offset(369))); BOOST_REQUIRE_EQUAL( m.get_start_kafka_offset_override(), kafka::offset(370));