diff --git a/storage_controller/src/persistence.rs b/storage_controller/src/persistence.rs index 052c0f02eb..557b4c8df4 100644 --- a/storage_controller/src/persistence.rs +++ b/storage_controller/src/persistence.rs @@ -40,6 +40,7 @@ use crate::metrics::{ DatabaseQueryErrorLabelGroup, DatabaseQueryLatencyLabelGroup, METRICS_REGISTRY, }; use crate::node::Node; +use crate::schema::sk_ps_discovery; use crate::timeline_import::{ TimelineImport, TimelineImportUpdateError, TimelineImportUpdateFollowUp, }; diff --git a/storage_controller/src/schema.rs b/storage_controller/src/schema.rs index 20be9bb5ca..2c2b3074fe 100644 --- a/storage_controller/src/schema.rs +++ b/storage_controller/src/schema.rs @@ -66,6 +66,7 @@ diesel::table! { shard_number -> Int4, shard_count -> Int4, shard_stripe_size -> Int4, + // pageserver generation generation -> Nullable, generation_pageserver -> Nullable, placement_policy -> Varchar, @@ -92,6 +93,7 @@ diesel::table! { tenant_id -> Varchar, timeline_id -> Varchar, start_lsn -> PgLsn, + // sk config generation generation -> Int4, sk_set -> Array>, new_sk_set -> Nullable>>, @@ -100,6 +102,25 @@ diesel::table! { } } +// Operational table that contains pending notifications for Safekeepers +// about tenant shard pageserver-side attachments. +// Rows are removed when the notification was acknowledged by the Safekeeper. +diesel::table! { + use diesel::sql_types::*; + sk_ps_discovery(tenant_id, shard_number, shard_count, ps_generation, sk_id) { + tenant_id -> Varchar, + shard_number -> Int4, + shard_count -> Int4, + ps_generation -> Int4, + sk_id -> Int8, + // payload + ps_id -> Int8, + // tracking of reliable delivery + created_at -> Timestamptz, + last_attempt_at -> Nullable, + } +} + diesel::allow_tables_to_appear_in_same_query!( controllers, metadata_health, @@ -109,4 +130,5 @@ diesel::allow_tables_to_appear_in_same_query!( tenant_shards, timeline_imports, timelines, + sk_ps_discovery, ); diff --git a/storage_controller/src/service.rs b/storage_controller/src/service.rs index 7e4bb627af..c0f48c670b 100644 --- a/storage_controller/src/service.rs +++ b/storage_controller/src/service.rs @@ -2,6 +2,7 @@ pub mod chaos_injector; mod context_iterator; pub(crate) mod safekeeper_reconciler; mod safekeeper_service; +mod sk_ps_discovery; use std::borrow::Cow; use std::cmp::Ordering; diff --git a/storage_controller/src/service/sk_ps_discovery.rs b/storage_controller/src/service/sk_ps_discovery.rs new file mode 100644 index 0000000000..c46373d0e8 --- /dev/null +++ b/storage_controller/src/service/sk_ps_discovery.rs @@ -0,0 +1,46 @@ +use utils::{ + generation::Generation, + id::{NodeId, TenantId, TimelineId}, + shard::TenantShardId, +}; + +use crate::persistence::Persistence; + +pub struct ActorClient {} + +enum Message { + PageserverAttachmentNew { + tenant_shard_id: TenantShardId, + ps_generation: Generation, + ps_id: NodeId, + }, + PageserverAttachmentRemoved { + tenant_shard_id: TenantShardId, + ps_generation: Generation, + ps_id: NodeId, + }, + SafekeeperConfigChange { + tenant_id: TenantId, + timeline_id: TimelineId, + safekeeper_ids: Vec, + }, + SafekeeperDelete { + safekeeper_id: NodeId, + }, +} + +struct Actor {} + +pub async fn spawn(persistence: Arc) -> ActorClient { + let actor = Actor { persistence }; + tokio::spawn(actor.run()); + ActorClient {} +} + +impl ActorClient {} + +impl Actor { + async fn run(self) { + loop {} + } +}