This commit is contained in:
Christian Schwarz
2025-05-27 13:44:25 +02:00
parent cdb6479c8a
commit 322e742e4c
4 changed files with 70 additions and 0 deletions

View File

@@ -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,
};

View File

@@ -66,6 +66,7 @@ diesel::table! {
shard_number -> Int4,
shard_count -> Int4,
shard_stripe_size -> Int4,
// pageserver generation
generation -> Nullable<Int4>,
generation_pageserver -> Nullable<Int8>,
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<Nullable<Int8>>,
new_sk_set -> Nullable<Array<Nullable<Int8>>>,
@@ -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<Timestamptz>,
}
}
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,
);

View File

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

View File

@@ -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<NodeId>,
},
SafekeeperDelete {
safekeeper_id: NodeId,
},
}
struct Actor {}
pub async fn spawn(persistence: Arc<Persistence>) -> ActorClient {
let actor = Actor { persistence };
tokio::spawn(actor.run());
ActorClient {}
}
impl ActorClient {}
impl Actor {
async fn run(self) {
loop {}
}
}