Skip to content

Commit

Permalink
archival: Convert assertion to exception
Browse files Browse the repository at this point in the history
The situation in which the assertion is triggered can only be caused
by a race and is retrieable. There is no need to crash the whole process
in that case.

Signed-off-by: Evgeny Lazin <[email protected]>
  • Loading branch information
Lazin committed Dec 16, 2024
1 parent 60ad2f4 commit 83ba039
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 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,12 @@ 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 happen if the compaction was running concurrently with
// the upload. The operation will be retried later.
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 83ba039

Please sign in to comment.