From 7bb1fbf4242b29e235b900520949671cab276605 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Thu, 12 Sep 2024 16:39:13 +0100 Subject: [PATCH] global vectored get error class --- pageserver/src/http/routes.rs | 3 +++ pageserver/src/pgdatadir_mapping.rs | 1 + pageserver/src/tenant/timeline.rs | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index d645f3b7b6..c20252a50a 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -183,6 +183,9 @@ impl From for ApiError { PageReconstructError::Cancelled => ApiError::Cancelled, PageReconstructError::AncestorLsnTimeout(e) => ApiError::Timeout(format!("{e}").into()), PageReconstructError::WalRedo(pre) => ApiError::InternalServerError(pre), + PageReconstructError::VectoredGetGlobalError(e) => { + ApiError::InternalServerError(anyhow::anyhow!(e)) + } } } } diff --git a/pageserver/src/pgdatadir_mapping.rs b/pageserver/src/pgdatadir_mapping.rs index 6dd8851b13..4e4a2962e1 100644 --- a/pageserver/src/pgdatadir_mapping.rs +++ b/pageserver/src/pgdatadir_mapping.rs @@ -1814,6 +1814,7 @@ impl<'a> DatadirModification<'a> { n_files = dir.files.len(); aux_files.dir = Some(dir); } + Err(PageReconstructError::VectoredGetGlobalError(_)) => todo!(), Err( e @ (PageReconstructError::Cancelled | PageReconstructError::AncestorLsnTimeout(_)), diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 262dccac7d..84eb4dbd8d 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -526,6 +526,9 @@ pub(crate) enum PageReconstructError { #[error("{0}")] MissingKey(MissingKeyError), + + #[error("vectored get error: {0}")] + VectoredGetGlobalError(VectoredGetGlobalError), } impl From for PageReconstructError { @@ -604,7 +607,11 @@ impl PageReconstructError { use PageReconstructError::*; match self { Cancelled => true, - Other(_) | AncestorLsnTimeout(_) | WalRedo(_) | MissingKey(_) => false, + Other(_) + | AncestorLsnTimeout(_) + | WalRedo(_) + | MissingKey(_) + | VectoredGetGlobalError(_) => false, } } } @@ -818,6 +825,22 @@ impl From for PageReconstructError { } } +#[derive(thiserror::Error, Debug)] +#[error("{0}")] +pub(crate) struct VectoredGetGlobalError(&'static str); +impl<'a> From<&'a GetVectoredError> for VectoredGetGlobalError { + fn from(e: &'a GetVectoredError) -> Self { + match e { + GetVectoredError::Oversized(_) => VectoredGetGlobalError("oversized"), + GetVectoredError::InvalidLsn(_) => VectoredGetGlobalError("invalid LSN"), + GetVectoredError::MissingKey(_) => VectoredGetGlobalError("missing key"), + GetVectoredError::GetReadyAncestorError(_) => VectoredGetGlobalError("ancestor LSN"), + GetVectoredError::Cancelled => VectoredGetGlobalError("cancelled"), + GetVectoredError::Other(_) => VectoredGetGlobalError("other"), + } + } +} + impl From for PageReconstructError { fn from(e: GetReadyAncestorError) -> Self { use GetReadyAncestorError::*;