Skip to content

Commit

Permalink
cs/manifest: allow updating kafka start offset with the same offset
Browse files Browse the repository at this point in the history
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 <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Nov 21, 2023
1 parent 456fbc7 commit b1c1d01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/v/cloud_storage/partition_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,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;
Expand Down
4 changes: 2 additions & 2 deletions src/v/cloud_storage/tests/partition_manifest_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit b1c1d01

Please sign in to comment.