From cc2c1a8bf4273c68827f30ee3b1b311a5bcfb22c Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 2 Oct 2023 14:27:46 +0100 Subject: [PATCH] pageserver: add hook for terminating on I/O errors --- pageserver/src/virtual_file.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pageserver/src/virtual_file.rs b/pageserver/src/virtual_file.rs index dfb8d397b4..385920c5b2 100644 --- a/pageserver/src/virtual_file.rs +++ b/pageserver/src/virtual_file.rs @@ -208,6 +208,15 @@ impl CrashsafeOverwriteError { } } +/// Call this when the local filesystem gives us an error with an external +/// cause: this includes EIO, EROFS, and EACCESS: all these indicate either +/// bad storage or bad configuration, and we can't fix that from inside +/// a running process. +pub(crate) fn on_fatal_io_error(e: &std::io::Error) { + tracing::error!("Fatal I/O error: {}", &e); + std::process::abort(); +} + impl VirtualFile { /// Open a file in read-only mode. Like File::open. pub async fn open(path: &Path) -> Result {