Skip to content

Commit

Permalink
cloud_storage: simplify the out_of_range logging code
Browse files Browse the repository at this point in the history
No functional changes.
  • Loading branch information
nvartolomei committed May 17, 2024
1 parent 680a67e commit 3a9058a
Showing 1 changed file with 49 additions and 51 deletions.
100 changes: 49 additions & 51 deletions src/v/cloud_storage/remote_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -576,57 +576,55 @@ class partition_record_batch_reader_impl final
// exception and let the caller deal with it. If the caller doesn't
// handle it it leads to a closed kafka connection which the
// end clients retry.
if (
cur.error() == error_outcome::out_of_range
&& ss::visit(
query,
[&](model::offset) {
vassert(
false,
"Unreachable code. Remote partition doesn't know how to "
"handle model::offset queries.");
return false;
},
[&](kafka::offset query_offset) {
// Bug or retention racing with the query.
const auto log_start_offset
= _partition->_manifest_view->stm_manifest()
.full_log_start_kafka_offset();

if (log_start_offset && query_offset < *log_start_offset) {
vlog(
_ctxlog.warn,
"Manifest query below the log's start Kafka offset: "
"{} < {}",
query_offset(),
log_start_offset.value()());
}
return false;
},
[&](model::timestamp query_ts) {
// Special case, it can happen when a timequery falls below
// the clean offset. Caused when the query races with
// retention/gc.
auto const& spillovers = _partition->_manifest_view
->stm_manifest()
.get_spillover_map();

bool timestamp_inside_spillover
= query_ts() <= spillovers.get_max_timestamp_column()
.last_value()
.value_or(model::timestamp::min()());

if (timestamp_inside_spillover) {
vlog(
_ctxlog.debug,
"Manifest query raced with retention and the result "
"is below the clean/start offset for {}",
query_ts);
}
return false;
})) {
// error was handled
co_return;
if (cur.error() == error_outcome::out_of_range) {
ss::visit(
query,
[&](model::offset) {
vassert(
false,
"Unreachable code. Remote partition doesn't know how "
"to "
"handle model::offset queries.");
},
[&](kafka::offset query_offset) {
// Bug or retention racing with the query.
const auto log_start_offset
= _partition->_manifest_view->stm_manifest()
.full_log_start_kafka_offset();

if (
log_start_offset && query_offset < *log_start_offset) {
vlog(
_ctxlog.warn,
"Manifest query below the log's start Kafka "
"offset: "
"{} < {}",
query_offset(),
log_start_offset.value()());
}
},
[&](model::timestamp query_ts) {
// Special case, it can happen when a timequery falls
// below the clean offset. Caused when the query races
// with retention/gc.
auto const& spillovers = _partition->_manifest_view
->stm_manifest()
.get_spillover_map();

bool timestamp_inside_spillover
= query_ts() <= spillovers.get_max_timestamp_column()
.last_value()
.value_or(model::timestamp::min()());

if (timestamp_inside_spillover) {
vlog(
_ctxlog.debug,
"Manifest query raced with retention and the "
"result "
"is below the clean/start offset for {}",
query_ts);
}
});
}

throw std::runtime_error(fmt::format(
Expand Down

0 comments on commit 3a9058a

Please sign in to comment.