diff --git a/pageserver/src/tenant/mgr.rs b/pageserver/src/tenant/mgr.rs index 66f1c3dbfa..28a7d71a68 100644 --- a/pageserver/src/tenant/mgr.rs +++ b/pageserver/src/tenant/mgr.rs @@ -1596,7 +1596,7 @@ impl TenantManager { // Since we will do a large number of small filesystem metadata operations, batch them into // spawn_blocking calls rather than doing each one as a tokio::fs round-trip. let jh = tokio::task::spawn_blocking(move || -> anyhow::Result { - for dir in create_dirs { + for dir in &create_dirs { if let Err(e) = std::fs::create_dir_all(&dir) { // Ignore AlreadyExists errors, drop out on all other errors match e.kind() { @@ -1631,6 +1631,18 @@ impl TenantManager { } } + // Durability is not required for correctness, but if we crashed during split and + // then came restarted with empty timeline dirs, it would be very inefficient to + // re-populate from remote storage. + for dir in create_dirs { + if let Err(e) = crashsafe::fsync(&dir) { + // Something removed a newly created timeline dir out from underneath us? Extremely + // unexpected, but not worth panic'ing over as this whole function is just an + // optimization. + tracing::warn!("Failed to fsync directory {dir}: {e}") + } + } + Ok(parent_layers.len()) });