Thread ShardIdentity through to Timeline

This commit is contained in:
John Spray
2023-11-05 14:01:55 +00:00
parent feae5f716f
commit e20732fdcb
2 changed files with 15 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ use anyhow::{bail, Context};
use camino::{Utf8Path, Utf8PathBuf};
use futures::FutureExt;
use pageserver_api::models::TimelineState;
use pageserver_api::shard::ShardIdentity;
use remote_storage::DownloadError;
use remote_storage::GenericRemoteStorage;
use storage_broker::BrokerClientChannel;
@@ -169,6 +170,7 @@ pub struct TenantSharedResources {
/// for an attached tenant is a subset of the [`LocationConf`], represented
/// in this struct.
pub(super) struct AttachedTenantConf {
shard: ShardIdentity,
tenant_conf: TenantConfOpt,
location: AttachedLocationConfig,
}
@@ -177,6 +179,7 @@ impl AttachedTenantConf {
fn try_from(location_conf: LocationConf) -> anyhow::Result<Self> {
match &location_conf.mode {
LocationMode::Attached(attach_conf) => Ok(Self {
shard: location_conf.shard,
tenant_conf: location_conf.tenant_conf,
location: attach_conf.clone(),
}),

View File

@@ -12,8 +12,12 @@ use bytes::Bytes;
use camino::{Utf8Path, Utf8PathBuf};
use fail::fail_point;
use itertools::Itertools;
use pageserver_api::models::{
DownloadRemoteLayersTaskInfo, DownloadRemoteLayersTaskSpawnRequest, LayerMapInfo, TimelineState,
use pageserver_api::{
models::{
DownloadRemoteLayersTaskInfo, DownloadRemoteLayersTaskSpawnRequest, LayerMapInfo,
TimelineState,
},
shard::ShardIdentity,
};
use serde_with::serde_as;
use storage_broker::BrokerClientChannel;
@@ -1310,6 +1314,11 @@ impl Timeline {
.unwrap_or(self.conf.default_tenant_conf.gc_feedback)
}
pub(crate) fn get_shard(&self) -> ShardIdentity {
let tenant_conf = &self.tenant_conf.read().unwrap();
tenant_conf.shard.clone()
}
pub(super) fn tenant_conf_updated(&self) {
// NB: Most tenant conf options are read by background loops, so,
// changes will automatically be picked up.
@@ -1538,6 +1547,7 @@ impl Timeline {
.tenant_conf
.max_lsn_wal_lag
.unwrap_or(self.conf.default_tenant_conf.max_lsn_wal_lag);
let shard = tenant_conf_guard.shard.clone();
drop(tenant_conf_guard);
let mut guard = self.walreceiver.lock().unwrap();