startup: transition tenant into Broken state if config load fails (instead of skipping over it and not adding it to the tenants map)

This commit is contained in:
Christian Schwarz
2022-11-25 14:01:03 -05:00
parent fdfa86b5b0
commit c9a2b1fd10
2 changed files with 14 additions and 9 deletions

View File

@@ -535,7 +535,7 @@ impl Tenant {
conf: &'static PageServerConf,
tenant_id: TenantId,
remote_storage: &GenericRemoteStorage,
) -> anyhow::Result<Arc<Tenant>> {
) -> Arc<Tenant> {
// XXX: Attach should provide the config, especially during tenant migration.
// See https://github.com/neondatabase/neon/issues/1555
let tenant_conf = TenantConfOpt::default();
@@ -571,7 +571,7 @@ impl Tenant {
Ok(())
},
);
Ok(tenant)
tenant
}
///
@@ -741,9 +741,14 @@ impl Tenant {
conf: &'static PageServerConf,
tenant_id: TenantId,
remote_storage: Option<GenericRemoteStorage>,
) -> anyhow::Result<Arc<Tenant>> {
// FIXME: also go into Broken state if this fails
let tenant_conf = Self::load_tenant_config(conf, tenant_id)?;
) -> Arc<Tenant> {
let tenant_conf = match Self::load_tenant_config(conf, tenant_id) {
Ok(conf) => conf,
Err(e) => {
error!("load tenant config failed: {}", e);
return Tenant::create_broken_tenant(conf, tenant_id);
}
};
let wal_redo_manager = Arc::new(PostgresRedoManager::new(conf, tenant_id));
let tenant = Tenant::new(
@@ -781,7 +786,7 @@ impl Tenant {
info!("spawned load into background");
Ok(tenant)
tenant
}
///

View File

@@ -147,7 +147,7 @@ fn load_local_tenant(
let tenant = if conf.tenant_attaching_mark_file_path(&tenant_id).exists() {
info!("tenant {tenant_id} has attaching mark file, resuming its attach operation");
if let Some(remote_storage) = remote_storage {
Tenant::spawn_attach(conf, tenant_id, &remote_storage)?
Tenant::spawn_attach(conf, tenant_id, &remote_storage)
} else {
warn!("tenant {tenant_id} has attaching mark file, but pageserver has no remote storage configured");
Tenant::create_broken_tenant(conf, tenant_id)
@@ -155,7 +155,7 @@ fn load_local_tenant(
} else {
info!("tenant {tenant_id} is assumed to be loadable, starting load operation");
// Start loading the tenant into memory. It will initially be in Loading state.
Tenant::spawn_load(conf, tenant_id, remote_storage)?
Tenant::spawn_load(conf, tenant_id, remote_storage)
};
Ok(Some(tenant))
}
@@ -364,7 +364,7 @@ pub async fn attach_tenant(
}
}
hash_map::Entry::Vacant(v) => {
let tenant = Tenant::spawn_attach(conf, tenant_id, remote_storage)?;
let tenant = Tenant::spawn_attach(conf, tenant_id, remote_storage);
v.insert(tenant);
Ok(())
}