Skip to content

Commit

Permalink
Merge pull request #24580 from Lazin/fix/CORE-627
Browse files Browse the repository at this point in the history
[CORE-627] archival: Convert assertion to exception
  • Loading branch information
Lazin authored Dec 23, 2024
2 parents 0536d54 + f1253b2 commit 3fc4ba8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/v/cluster/archival/archival_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,14 @@ ss::future<std::optional<std::error_code>> get_file_range(
upl->max_timestamp = seek.ts;
}
// Recompute content_length based on file offsets
vassert(
upl->file_offset <= upl->final_file_offset,
"Invalid upload candidate {}",
upl);
if (upl->file_offset > upl->final_file_offset) {
// This could potentially happen if the log was truncated after
// file_offset is set. In this case the index could become empty which
// will trigger the condition above. The operation could be retried
// later so throwing makes more sense then the assertion.
throw std::runtime_error(
fmt_with_ctx(fmt::format, "Invalid upload candidate {}", upl));
}
upl->content_length = upl->final_file_offset - upl->file_offset;
if (upl->content_length > segment->reader().file_size()) {
throw std::runtime_error(fmt_with_ctx(
Expand Down

0 comments on commit 3fc4ba8

Please sign in to comment.