From 5f25b6d0e7e63731c024ec7d7f00679f398e6c6d Mon Sep 17 00:00:00 2001 From: jiachun Date: Tue, 19 Sep 2023 15:57:54 +0800 Subject: [PATCH 1/2] feat: err on faild to open region --- src/mito2/src/error.rs | 16 +++++++++++++++- src/mito2/src/region/opener.rs | 14 +++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 7986db4c8a81..31164252e517 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -26,6 +26,7 @@ use snafu::{Location, Snafu}; use store_api::manifest::ManifestVersion; use store_api::storage::RegionId; +use crate::manifest::manager::RegionManifestOptions; use crate::sst::file::FileId; use crate::worker::WorkerId; @@ -453,6 +454,18 @@ pub enum Error { region_id: RegionId, location: Location, }, + + #[snafu(display( + "Failed to open region {} with options: {:?}, location: {}", + region_id, + options, + location + ))] + OpenRegion { + region_id: RegionId, + options: RegionManifestOptions, + location: Location, + }, } pub type Result = std::result::Result; @@ -495,7 +508,8 @@ impl ErrorExt for Error { | WorkerStopped { .. } | Recv { .. } | EncodeWal { .. } - | DecodeWal { .. } => StatusCode::Internal, + | DecodeWal { .. } + | OpenRegion { .. } => StatusCode::Internal, WriteBuffer { source, .. } => source.status_code(), WriteGroup { source, .. } => source.status_code(), FieldTypeMismatch { source, .. } => source.status_code(), diff --git a/src/mito2/src/region/opener.rs b/src/mito2/src/region/opener.rs index 157eff1a4a5d..cd5d327e0c1d 100644 --- a/src/mito2/src/region/opener.rs +++ b/src/mito2/src/region/opener.rs @@ -29,7 +29,7 @@ use store_api::storage::RegionId; use crate::access_layer::AccessLayer; use crate::config::MitoConfig; -use crate::error::{RegionCorruptedSnafu, RegionNotFoundSnafu, Result}; +use crate::error::{OpenRegionSnafu, RegionCorruptedSnafu, Result}; use crate::manifest::manager::{RegionManifestManager, RegionManifestOptions}; use crate::memtable::MemtableBuilderRef; use crate::region::version::{VersionBuilder, VersionControl, VersionControlRef}; @@ -130,12 +130,12 @@ impl RegionOpener { compress_type: config.manifest_compress_type, checkpoint_distance: config.manifest_checkpoint_distance, }; - let manifest_manager = - RegionManifestManager::open(options) - .await? - .context(RegionNotFoundSnafu { - region_id: self.region_id, - })?; + let manifest_manager = RegionManifestManager::open(options.clone()) + .await? + .context(OpenRegionSnafu { + region_id: self.region_id, + options, + })?; let manifest = manifest_manager.manifest().await; let metadata = manifest.metadata.clone(); From 0e4a3d5e69868e18b3b7c89839fc02508afdbbb7 Mon Sep 17 00:00:00 2001 From: jiachun Date: Tue, 19 Sep 2023 17:04:48 +0800 Subject: [PATCH 2/2] fix: unit test --- src/mito2/src/engine/open_test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mito2/src/engine/open_test.rs b/src/mito2/src/engine/open_test.rs index edacb0e067ef..9cc77424d648 100644 --- a/src/mito2/src/engine/open_test.rs +++ b/src/mito2/src/engine/open_test.rs @@ -43,7 +43,7 @@ async fn test_engine_open_empty() { ) .await .unwrap_err(); - assert_eq!(StatusCode::RegionNotFound, err.status_code()); + assert_eq!(StatusCode::Internal, err.status_code()); let err = engine.set_writable(region_id, true).unwrap_err(); assert_eq!(StatusCode::RegionNotFound, err.status_code()); }