diff --git a/src/common/meta/src/key/schema_metadata_manager.rs b/src/common/meta/src/key/schema_metadata_manager.rs index 8557114348c3..fc6172041d05 100644 --- a/src/common/meta/src/key/schema_metadata_manager.rs +++ b/src/common/meta/src/key/schema_metadata_manager.rs @@ -47,7 +47,7 @@ impl SchemaMetadataManager { } } - /// Gets schema metadata by table id. + /// Gets schema options by table id. pub async fn get_schema_options_by_table_id( &self, table_id: TableId, diff --git a/src/mito2/src/compaction.rs b/src/mito2/src/compaction.rs index e1cf1c6c4ceb..2c2a8f092af8 100644 --- a/src/mito2/src/compaction.rs +++ b/src/mito2/src/compaction.rs @@ -49,8 +49,8 @@ use crate::compaction::picker::{new_picker, CompactionTask}; use crate::compaction::task::CompactionTaskImpl; use crate::config::MitoConfig; use crate::error::{ - CompactRegionSnafu, Error, RegionClosedSnafu, RegionDroppedSnafu, RegionTruncatedSnafu, - RemoteCompactionSnafu, Result, TimeRangePredicateOverflowSnafu, + CompactRegionSnafu, Error, GetSchemaMetadataSnafu, RegionClosedSnafu, RegionDroppedSnafu, + RegionTruncatedSnafu, RemoteCompactionSnafu, Result, TimeRangePredicateOverflowSnafu, }; use crate::metrics::COMPACTION_STAGE_ELAPSED; use crate::read::projection::ProjectionMapper; @@ -434,6 +434,7 @@ impl PendingCompaction { } } +/// Finds TTL of table by first examine table options then database options. async fn find_ttl( table_id: TableId, table_ttl: Option, @@ -446,7 +447,7 @@ async fn find_ttl( let ttl = schema_metadata_manager .get_schema_options_by_table_id(table_id) .await - .expect("Failed to get table ") + .context(GetSchemaMetadataSnafu)? .and_then(|options| options.ttl); Ok(ttl) } diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index 8aa799cbb913..6cb4f8abdd7a 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -870,6 +870,13 @@ pub enum Error { #[snafu(implicit)] location: Location, }, + + #[snafu(display("Failed to get schema metadata"))] + GetSchemaMetadata { + source: common_meta::error::Error, + #[snafu(implicit)] + location: Location, + }, } pub type Result = std::result::Result; @@ -1002,6 +1009,7 @@ impl ErrorExt for Error { | ApplyFulltextIndex { source, .. } => source.status_code(), DecodeStats { .. } | StatsNotPresent { .. } => StatusCode::Internal, RegionBusy { .. } => StatusCode::RegionBusy, + GetSchemaMetadata { source, .. } => source.status_code(), } }