mirror of
https://github.com/neondatabase/neon.git
synced 2026-10-26 05:26:42 +00:00
## Problem The location config (which includes the stripe size) is stored on pageserver disk. For unsharded tenants we [do not include the shard identity in the serialized description](https://github.com/neondatabase/neon/blob/ad88ec9257b84d6633be86c5a970709146331ad4/pageserver/src/tenant/config.rs#L64-L66). When the pageserver restarts, it reads that configuration and will use the stripe size from there and rely on storcon input from reattach for generation and mode. The default deserialization is ShardIdentity::unsharded. This has the new default stripe size of 2048. Hence, for unsharded tenants we can be running with a stripe size different from that the one in the storcon observed state. This is not a problem until we shard split without specifying a stripe size (i.e. manual splits via the UI or storcon_cli). When that happens the new shards will use the 2048 stripe size until storcon realises and switches them back. At that point it's too late, since we've ingested data with the wrong stripe sizes. ## Summary of changes Ideally, we would always have the full shard identity on disk. To achieve this over two releases we do: 1. Always persist the shard identity in the location config on the PS. 2. Storage controller includes the stripe size to use in the re attach response. After the first release, we will start persisting correct stripe sizes for any tenant shard that the storage controller explicitly sends a location_conf. After the second release, the re-attach change kicks in and we'll persist the shard identity for all shards.
85 lines
2.4 KiB
Rust
85 lines
2.4 KiB
Rust
//! Types in this file are for pageserver's upward-facing API calls to the storage controller,
|
|
//! required for acquiring and validating tenant generation numbers.
|
|
//!
|
|
//! See docs/rfcs/025-generation-numbers.md
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use utils::generation::Generation;
|
|
use utils::id::{NodeId, TimelineId};
|
|
|
|
use crate::controller_api::NodeRegisterRequest;
|
|
use crate::models::{LocationConfigMode, ShardImportStatus};
|
|
use crate::shard::{ShardStripeSize, TenantShardId};
|
|
|
|
/// Upcall message sent by the pageserver to the configured `control_plane_api` on
|
|
/// startup.
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ReAttachRequest {
|
|
pub node_id: NodeId,
|
|
|
|
/// Optional inline self-registration: this is useful with the storage controller,
|
|
/// if the node already has a node_id set.
|
|
#[serde(skip_serializing_if = "Option::is_none", default)]
|
|
pub register: Option<NodeRegisterRequest>,
|
|
}
|
|
|
|
fn default_mode() -> LocationConfigMode {
|
|
LocationConfigMode::AttachedSingle
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct ReAttachResponseTenant {
|
|
pub id: TenantShardId,
|
|
/// Mandatory if LocationConfigMode is None or set to an Attached* mode
|
|
pub r#gen: Option<u32>,
|
|
|
|
/// Default value only for backward compat: this field should be set
|
|
#[serde(default = "default_mode")]
|
|
pub mode: LocationConfigMode,
|
|
|
|
// Default value only for backward compat: this field should be set
|
|
#[serde(default = "ShardStripeSize::default")]
|
|
pub stripe_size: ShardStripeSize,
|
|
}
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ReAttachResponse {
|
|
pub tenants: Vec<ReAttachResponseTenant>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ValidateRequestTenant {
|
|
pub id: TenantShardId,
|
|
pub r#gen: u32,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ValidateRequest {
|
|
pub tenants: Vec<ValidateRequestTenant>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ValidateResponse {
|
|
pub tenants: Vec<ValidateResponseTenant>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct ValidateResponseTenant {
|
|
pub id: TenantShardId,
|
|
pub valid: bool,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct TimelineImportStatusRequest {
|
|
pub tenant_shard_id: TenantShardId,
|
|
pub timeline_id: TimelineId,
|
|
pub generation: Generation,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct PutTimelineImportStatusRequest {
|
|
pub tenant_shard_id: TenantShardId,
|
|
pub timeline_id: TimelineId,
|
|
pub status: ShardImportStatus,
|
|
pub generation: Generation,
|
|
}
|