From e113c6fa8d5d478bbf7e78297a4f63b20474719b Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 20 Apr 2022 16:23:16 +0300 Subject: [PATCH] Print a warning if unlinking an ephemeral file fails. Unlink failure isn't serious on its own, we were about to remove the file anyway, but it shouldn't happen and could be a symptom of something more serious. We just saw "No such file or directory" errors happening from ephemeral file writeback in staging, and I suspect if we had this warning in place, we would have seen these warnings too, if the problem was that the ephemeral file was removed before dropping the EphemeralFile struct. Next time it happens, we'll have more information. --- pageserver/src/layered_repository/ephemeral_file.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pageserver/src/layered_repository/ephemeral_file.rs b/pageserver/src/layered_repository/ephemeral_file.rs index d509186e6f..060d44f810 100644 --- a/pageserver/src/layered_repository/ephemeral_file.rs +++ b/pageserver/src/layered_repository/ephemeral_file.rs @@ -16,6 +16,7 @@ use std::io::{Error, ErrorKind}; use std::ops::DerefMut; use std::path::PathBuf; use std::sync::{Arc, RwLock}; +use tracing::*; use zenith_utils::zid::ZTenantId; use zenith_utils::zid::ZTimelineId; @@ -244,9 +245,15 @@ impl Drop for EphemeralFile { // remove entry from the hash map EPHEMERAL_FILES.write().unwrap().files.remove(&self.file_id); - // unlink file - // FIXME: print error - let _ = std::fs::remove_file(&self.file.path); + // unlink the file + let res = std::fs::remove_file(&self.file.path); + if let Err(e) = res { + warn!( + "could not remove ephemeral file '{}': {}", + self.file.path.display(), + e + ); + } } }