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

[CORE-627] archival: Convert assertion to exception #24580

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q1: (this comment is based on the code comment alone) Is it possible for the log to get truncated and have new batches appended where the above condition still passes but the actual content?

Q2: We should be uploading only below LSO, how we end up trying to create upload candidate with an offset which gets truncated? What type of truncation we are talking about?

if (upl->content_length > segment->reader().file_size()) {
throw std::runtime_error(fmt_with_ctx(
Expand Down
Loading