From 56633521d3ca82dbb635aad85c9d5b0ae1dc670d Mon Sep 17 00:00:00 2001 From: Alex Chi Date: Tue, 23 May 2023 11:44:58 -0400 Subject: [PATCH] fix fmt Signed-off-by: Alex Chi --- pageserver/src/tenant/mgr.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pageserver/src/tenant/mgr.rs b/pageserver/src/tenant/mgr.rs index dd153f880c..c15ecaf259 100644 --- a/pageserver/src/tenant/mgr.rs +++ b/pageserver/src/tenant/mgr.rs @@ -279,11 +279,16 @@ pub async fn create_tenant( remote_storage: Option, ctx: &RequestContext, ) -> Result, TenantMapInsertError> { - tenant_map_insert(tenant_id, |vacant_entry| { + let func = |vacant_entry: hash_map::VacantEntry<_, _>| { // We're holding the tenants lock in write mode while doing local IO. // If this section ever becomes contentious, introduce a new `TenantState::Creating` // and do the work in that state. - let tenant_directory = super::create_tenant_files(conf, tenant_conf, tenant_id, CreateTenantFilesMode::Create)?; + let tenant_directory = super::create_tenant_files( + conf, + tenant_conf, + tenant_id, + CreateTenantFilesMode::Create, + )?; let guard_fs = scopeguard::guard((), |_| { if let Err(e) = std::fs::remove_dir_all(&tenant_directory) { @@ -293,13 +298,12 @@ pub async fn create_tenant( }); let created_tenant = - schedule_local_tenant_processing(conf, &tenant_directory, remote_storage, ctx)?; + schedule_local_tenant_processing(conf, &tenant_directory, remote_storage, ctx)?; let created_tenant = scopeguard::guard(created_tenant, |tenant| { // As we might have removed the directory, the tenant should directly go into the broken state. tenant.set_broken("failed to create".into()); }); - fail::fail_point!("tenant-create-fail", |_| { anyhow::bail!("failpoint: tenant-create-fail"); }); @@ -312,10 +316,11 @@ pub async fn create_tenant( vacant_entry.insert(Arc::clone(&created_tenant)); + // Ok, we're good. Disarm the cleanup scopeguards and return the tenant. ScopeGuard::into_inner(guard_fs); - Ok(ScopeGuard::into_inner(created_tenant)) - }).await + }; + tenant_map_insert(tenant_id, func).await } pub async fn set_new_tenant_config(