From 1e380ea5af136864f89f359b55c94f55b86c7662 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Fri, 19 Jul 2024 10:09:57 +0000 Subject: [PATCH] refactor: Ancestor::Delete is not needed --- pageserver/src/tenant/timeline/detach_ancestor.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pageserver/src/tenant/timeline/detach_ancestor.rs b/pageserver/src/tenant/timeline/detach_ancestor.rs index 1a4c58b7ce..a127c6ea0c 100644 --- a/pageserver/src/tenant/timeline/detach_ancestor.rs +++ b/pageserver/src/tenant/timeline/detach_ancestor.rs @@ -984,7 +984,6 @@ pub(super) async fn complete( enum Ancestor { NotDetached(Arc, Lsn), Detached(Arc, Lsn), - Deleted(TimelineId, Lsn), } let (recorded_branchpoint, detach_is_ongoing) = { @@ -1018,7 +1017,7 @@ pub(super) async fn complete( if let Some(ancestor) = existing { Ancestor::Detached(ancestor, ancestor_lsn) } else { - Ancestor::Deleted(ancestor_id, ancestor_lsn) + return Ok((reparented_direct_children(detached, tenant)?, true)); } } else { panic!("bug: complete called on a timeline which has not been detached or which has no live ancestor"); @@ -1036,6 +1035,8 @@ pub(super) async fn complete( let (ancestor, ancestor_lsn) = match ancestor { Ancestor::NotDetached(ancestor, ancestor_lsn) => { + // this has to complete before any reparentings because otherwise they would not have + // layers on the new parent. detached .remote_client .schedule_adding_existing_layers_to_index_detach_and_wait( @@ -1048,9 +1049,6 @@ pub(super) async fn complete( (ancestor, ancestor_lsn) } Ancestor::Detached(ancestor, ancestor_lsn) => (ancestor, ancestor_lsn), - Ancestor::Deleted(..) => { - return Ok((reparented_direct_children(detached, tenant)?, true)); - } }; assert!(detach_is_ongoing, "to reparent, gc must still be blocked");