Skip to content

Commit

Permalink
admin: expose time point for last completed scrub
Browse files Browse the repository at this point in the history
When a full scrub of the log finishes, via one or more scrubs, persist
the timestamp at which this happened. This timestamp is then exposed via
the admin API. We will use this in our ducktape tests for end of test
scrubbing.
  • Loading branch information
Vlad Lazar committed Oct 23, 2023
1 parent f6bc4ed commit 13e273f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/v/cloud_storage/partition_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2732,6 +2732,10 @@ void partition_manifest::process_anomalies(
_last_partition_scrub = scrub_timestamp;
_last_scrubbed_offset = last_scrubbed_offset;

if (!_last_scrubbed_offset) {
_detected_anomalies.last_complete_scrub = scrub_timestamp;
}

vlog(
cst_log.debug,
"[{}] Anomalies processed: {{ detected: {}, last_partition_scrub: {}, "
Expand Down
3 changes: 3 additions & 0 deletions src/v/cloud_storage/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ anomalies& anomalies::operator+=(anomalies&& other) {
std::make_move_iterator(other.segment_metadata_anomalies.begin()),
std::make_move_iterator(other.segment_metadata_anomalies.end()));

last_complete_scrub = std::max(
last_complete_scrub, other.last_complete_scrub);

return *this;
}

Expand Down
6 changes: 5 additions & 1 deletion src/v/cloud_storage/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,17 @@ struct anomalies
absl::node_hash_set<segment_meta> missing_segments;
// Segments that have metadata anomalies (e.g. gaps or overlaps)
segment_meta_anomalies segment_metadata_anomalies;
// Optional timestamp indicating the last time point at which
// the scrub of the full log completed.
std::optional<model::timestamp> last_complete_scrub;

auto serde_fields() {
return std::tie(
missing_partition_manifest,
missing_spillover_manifests,
missing_segments,
segment_metadata_anomalies);
segment_metadata_anomalies,
last_complete_scrub);
}

bool has_value() const;
Expand Down
4 changes: 4 additions & 0 deletions src/v/redpanda/admin/api-doc/shadow_indexing.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@
"type": "array",
"items": {"type": "metadata_anomaly"},
"nullable": true
},
"last_complete_scrub_at": {
"type": "long",
"nullable": true
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5296,6 +5296,10 @@ map_anomalies_to_json(
json.partition = ntp.tp.partition();
json.revision_id = initial_rev();

if (detected.last_complete_scrub) {
json.last_complete_scrub_at = detected.last_complete_scrub->value();
}

if (detected.missing_partition_manifest) {
json.missing_partition_manifest = true;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/rptest/tests/cloud_storage_scrubber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def _collect_anomalies(self):
topic=self.topic,
partition=pid)

anomalies.pop("last_complete_scrub_at", None)

ntpr = NTPR(ns=anomalies["ns"],
topic=anomalies["topic"],
partition=anomalies["partition"],
Expand Down

0 comments on commit 13e273f

Please sign in to comment.