plumbing: notify shared state of existing attempt

This commit is contained in:
Joonas Koivunen
2024-07-23 14:20:02 +00:00
parent 14869abb77
commit 46ca6f17c5
3 changed files with 16 additions and 0 deletions

View File

@@ -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<InitializationOrder>,
mode: SpawnMode,
existing_detach_attempt: Option<&detach_ancestor::Attempt>,
ctx: &RequestContext,
) -> Arc<Tenant> {
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

View File

@@ -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<InitializationOrder>,
mode: SpawnMode,
existing_detach_attempt: Option<&detach_ancestor::Attempt>,
ctx: &RequestContext,
) -> Arc<Tenant> {
// 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,
);

View File

@@ -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.