From 46ca6f17c5a27009532f2c8c939893d7004f1588 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Tue, 23 Jul 2024 14:20:02 +0000 Subject: [PATCH] plumbing: notify shared state of existing attempt --- pageserver/src/tenant.rs | 6 ++++++ pageserver/src/tenant/mgr.rs | 6 ++++++ pageserver/src/tenant/timeline/detach_ancestor.rs | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/pageserver/src/tenant.rs b/pageserver/src/tenant.rs index 603d095e44..fdd6434e49 100644 --- a/pageserver/src/tenant.rs +++ b/pageserver/src/tenant.rs @@ -35,6 +35,7 @@ use std::collections::BTreeMap; use std::fmt; use std::time::SystemTime; use storage_broker::BrokerClientChannel; +use timeline::detach_ancestor; use tokio::io::BufReader; use tokio::sync::watch; use tokio::task::JoinSet; @@ -678,6 +679,7 @@ impl Tenant { shard_identity: ShardIdentity, init_order: Option, mode: SpawnMode, + existing_detach_attempt: Option<&detach_ancestor::Attempt>, ctx: &RequestContext, ) -> Arc { let wal_redo_manager = Arc::new(WalRedoManager::from(PostgresRedoManager::new( @@ -707,6 +709,10 @@ impl Tenant { l0_flush_global_state, )); + if let Some(attempt) = existing_detach_attempt { + tenant.ongoing_timeline_detach.notify(attempt); + } + // The attach task will carry a GateGuard, so that shutdown() reliably waits for it to drop out if // we shut down while attaching. let attach_gate_guard = tenant diff --git a/pageserver/src/tenant/mgr.rs b/pageserver/src/tenant/mgr.rs index 7f9b3b7e93..445676c4ae 100644 --- a/pageserver/src/tenant/mgr.rs +++ b/pageserver/src/tenant/mgr.rs @@ -676,6 +676,7 @@ pub async fn init_tenant_mgr( shard_identity, Some(init_order.clone()), SpawnMode::Lazy, + None, &ctx, )), LocationMode::Secondary(secondary_conf) => { @@ -724,6 +725,7 @@ fn tenant_spawn( shard_identity: ShardIdentity, init_order: Option, mode: SpawnMode, + existing_detach_attempt: Option<&detach_ancestor::Attempt>, ctx: &RequestContext, ) -> Arc { // All these conditions should have been satisfied by our caller: the tenant dir exists, is a well formed @@ -744,6 +746,7 @@ fn tenant_spawn( shard_identity, init_order, mode, + existing_detach_attempt, ctx, ) } @@ -1191,6 +1194,7 @@ impl TenantManager { shard_identity, None, spawn_mode, + None, ctx, ); @@ -1312,6 +1316,7 @@ impl TenantManager { shard_identity, None, SpawnMode::Eager, + None, ctx, ); @@ -2052,6 +2057,7 @@ impl TenantManager { shard_identity, None, SpawnMode::Eager, + Some(&attempt), ctx, ); diff --git a/pageserver/src/tenant/timeline/detach_ancestor.rs b/pageserver/src/tenant/timeline/detach_ancestor.rs index e79a1a0549..849596ea8c 100644 --- a/pageserver/src/tenant/timeline/detach_ancestor.rs +++ b/pageserver/src/tenant/timeline/detach_ancestor.rs @@ -134,6 +134,10 @@ impl Default for SharedState { } impl SharedState { + /// Notify an uninitialized shared state that an attempt to detach timeline ancestor continues + /// from previous instance. + pub(crate) fn notify(&self, attempt: &Attempt) {} + /// Only GC must be paused while a detach ancestor is ongoing. Compaction can happen, to aid /// with any ongoing ingestion. Compaction even after restart is ok because layers will not be /// removed until the detach has been persistently completed.