allow deleting timeline unblock gc

This commit is contained in:
Joonas Koivunen
2024-07-19 16:08:03 +00:00
parent 89426570d3
commit 55aeeb5765
2 changed files with 38 additions and 0 deletions

View File

@@ -221,6 +221,8 @@ impl DeleteTimelineFlow {
// Now that the Timeline is in Stopping state, request all the related tasks to shut down.
timeline.shutdown(super::ShutdownMode::Hard).await;
tenant.ongoing_timeline_detach.on_delete(&timeline);
fail::fail_point!("timeline-delete-before-index-deleted-at", |_| {
Err(anyhow::anyhow!(
"failpoint: timeline-delete-before-index-deleted-at"

View File

@@ -446,6 +446,42 @@ impl SharedStateInner {
assert!(!self.known_ongoing.is_empty());
self.latest = Some((ExistingAttempt::ReadFromIndexPart, witnessed));
}
fn on_delete(&mut self, timeline_id: &TimelineId) {
let witnessed = match self.latest.as_ref() {
Some((ExistingAttempt::Actual(x, barrier), witnessed)) if x == timeline_id => {
assert!(
barrier.is_ready(),
"the attempt is still ongoing; is this call happening before closing the gate?"
);
*witnessed
}
Some((ExistingAttempt::ContinuedOverRestart(x), witnessed)) if x == timeline_id => {
*witnessed
}
Some((ExistingAttempt::ReadFromIndexPart, witnessed))
if self.known_ongoing.contains(timeline_id) =>
{
*witnessed
}
_ => return,
};
assert!(self.known_ongoing.remove(timeline_id));
if self.known_ongoing.is_empty() {
self.latest = None;
tracing::info!("gc is now unblocked following timeline deletion");
} else {
self.latest = Some((ExistingAttempt::ReadFromIndexPart, witnessed));
tracing::info!(
n = self.known_ongoing.len(),
"gc is still blocked for remaining ongoing detaches"
);
}
todo!("there should be a test for this.")
}
}
#[derive(Debug)]