From fd4a9285216ead9bb615027aa85d17583a329550 Mon Sep 17 00:00:00 2001 From: zyy17 Date: Tue, 2 Jul 2024 20:33:57 +0800 Subject: [PATCH] refactor: add `RemoteCompaction` error (#4251) * refactor: make location field public * refactor: add RemoteCompaction error --- src/mito2/src/error.rs | 16 ++++++++++++++++ src/mito2/src/schedule/remote_job_scheduler.rs | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 57f4e957f4..1306edf09d 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -33,6 +33,7 @@ use store_api::storage::RegionId; use crate::cache::file_cache::FileType; use crate::region::RegionState; +use crate::schedule::remote_job_scheduler::JobId; use crate::sst::file::FileId; use crate::worker::WorkerId; @@ -768,6 +769,20 @@ pub enum Error { #[snafu(implicit)] location: Location, }, + + #[snafu(display( + "Failed to remotely compact region {} by job {} due to {}", + region_id, + job_id, + reason + ))] + RemoteCompaction { + region_id: RegionId, + job_id: JobId, + reason: String, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; @@ -888,6 +903,7 @@ impl ErrorExt for Error { TimeRangePredicateOverflow { .. } => StatusCode::InvalidArguments, BuildTimeRangeFilter { .. } => StatusCode::Unexpected, UnsupportedOperation { .. } => StatusCode::Unsupported, + RemoteCompaction { .. } => StatusCode::Unexpected, } } diff --git a/src/mito2/src/schedule/remote_job_scheduler.rs b/src/mito2/src/schedule/remote_job_scheduler.rs index ff87439e6a..8f51a774d5 100644 --- a/src/mito2/src/schedule/remote_job_scheduler.rs +++ b/src/mito2/src/schedule/remote_job_scheduler.rs @@ -66,7 +66,7 @@ pub trait RemoteJobScheduler: Send + Sync + 'static { #[snafu(display("Internal error occurred in remote job scheduler: {}", reason))] pub struct RemoteJobSchedulerError { #[snafu(implicit)] - location: Location, + pub location: Location, pub reason: String, // Keep the waiters in the error so that we can notify them when fallback to the local compaction. pub waiters: Vec,