Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloud_storage: fix empty segment check in reader #10782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/v/cloud_storage/remote_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,11 @@ remote_partition::borrow_result_t remote_partition::borrow_next_reader(
if (mit->delta_offset_end == model::offset_delta{}) {
break;
}

// If a segment contains kafka data batches, its next offset will
// be greater than its base offset.
auto b = mit->base_kafka_offset();
auto end = mit->next_kafka_offset() - kafka::offset(1);
auto end = mit->next_kafka_offset();
if (b != end) {
break;
}
Expand Down
8 changes: 7 additions & 1 deletion src/v/cloud_storage/tests/remote_partition_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,13 @@ FIXTURE_TEST(test_overlapping_segments, cloud_storage_fixture) {
cloud_storage::partition_manifest manifest(manifest_ntp, manifest_revision);

auto expectations = make_imposter_expectations(
manifest, segments, false, model::offset_delta(0));
manifest,
segments,
false,
model::offset_delta(0),
// Use v1 format because it only includes the base offset, not the
// committed offset. We will modify the committed offset.
segment_name_format::v1);

std::stringstream sstr;
manifest.serialize(sstr);
Expand Down
6 changes: 3 additions & 3 deletions src/v/cloud_storage/tests/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@ std::vector<cloud_storage_fixture::expectation> make_imposter_expectations(
cloud_storage::partition_manifest& m,
const std::vector<in_memory_segment>& segments,
bool truncate_segments = false,
model::offset_delta delta = model::offset_delta(0)) {
model::offset_delta delta = model::offset_delta(0),
segment_name_format sname_format = segment_name_format::v2) {
std::vector<cloud_storage_fixture::expectation> results;

for (const auto& s : segments) {
Expand Down Expand Up @@ -524,8 +525,7 @@ std::vector<cloud_storage_fixture::expectation> make_imposter_expectations(
.delta_offset = segment_delta,
.ntp_revision = m.get_revision_id(),
.delta_offset_end = model::offset_delta(delta)
+ model::offset_delta(s.num_config_records),
};
+ model::offset_delta(s.num_config_records)};

m.add(s.sname, meta);
delta = delta
Expand Down