From 64cad4e891c9634e1b6ca92408d1e82c36147fd6 Mon Sep 17 00:00:00 2001 From: dennis zhuang Date: Mon, 15 Jul 2024 00:50:16 -0700 Subject: [PATCH] feat: tweak error and status codes (#4359) * feat: tweak status codes * fix: typo * fix: by cr comments --- src/auth/src/error.rs | 12 ++-------- src/cache/src/error.rs | 2 +- src/client/src/error.rs | 8 ------- src/common/decimal/src/error.rs | 4 ++-- src/common/error/src/status_code.rs | 27 ++++++++++++++++++++--- src/common/meta/src/error.rs | 18 ++++++++------- src/common/procedure/src/error.rs | 14 +++++++----- src/common/recordbatch/src/error.rs | 8 ++++--- src/common/substrait/src/error.rs | 6 ++--- src/datanode/src/error.rs | 31 +++++++++----------------- src/datatypes/src/error.rs | 32 +++++++++++++++++++++++++-- src/frontend/src/error.rs | 9 ++++---- src/meta-srv/src/error.rs | 7 ++++-- src/mito2/src/error.rs | 22 ++++++++++--------- src/partition/src/error.rs | 22 ++++++++++++------- src/query/src/error.rs | 3 ++- src/servers/src/error.rs | 9 +++++--- src/servers/src/http/error_result.rs | 3 +++ src/table/src/error.rs | 33 ++-------------------------- 19 files changed, 143 insertions(+), 127 deletions(-) diff --git a/src/auth/src/error.rs b/src/auth/src/error.rs index ab5a3227e0..23c5f0d66c 100644 --- a/src/auth/src/error.rs +++ b/src/auth/src/error.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use common_error::ext::{BoxedError, ErrorExt}; +use common_error::ext::ErrorExt; use common_error::status_code::StatusCode; use common_macro::stack_trace_debug; use snafu::{Location, Snafu}; @@ -38,13 +38,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Auth failed"))] - AuthBackend { - #[snafu(implicit)] - location: Location, - source: BoxedError, - }, - #[snafu(display("User not found, username: {}", username))] UserNotFound { username: String }, @@ -87,8 +80,7 @@ impl ErrorExt for Error { Error::IllegalParam { .. } => StatusCode::InvalidArguments, Error::FileWatch { .. } => StatusCode::InvalidArguments, Error::InternalState { .. } => StatusCode::Unexpected, - Error::Io { .. } => StatusCode::Internal, - Error::AuthBackend { .. } => StatusCode::Internal, + Error::Io { .. } => StatusCode::StorageUnavailable, Error::UserNotFound { .. } => StatusCode::UserNotFound, Error::UnsupportedPasswordType { .. } => StatusCode::UnsupportedPasswordType, diff --git a/src/cache/src/error.rs b/src/cache/src/error.rs index 646a82bc98..636cdcdfb5 100644 --- a/src/cache/src/error.rs +++ b/src/cache/src/error.rs @@ -34,7 +34,7 @@ pub type Result = std::result::Result; impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::CacheRequired { .. } => StatusCode::Internal, + Error::CacheRequired { .. } => StatusCode::Unexpected, } } diff --git a/src/client/src/error.rs b/src/client/src/error.rs index 7750295bde..f200b1c93d 100644 --- a/src/client/src/error.rs +++ b/src/client/src/error.rs @@ -53,13 +53,6 @@ pub enum Error { source: common_grpc::Error, }, - #[snafu(display("Column datatype error"))] - ColumnDataType { - #[snafu(implicit)] - location: Location, - source: api::error::Error, - }, - #[snafu(display("Illegal GRPC client state: {}", err_msg))] IllegalGrpcClientState { err_msg: String, @@ -137,7 +130,6 @@ impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { Error::IllegalFlightMessages { .. } - | Error::ColumnDataType { .. } | Error::MissingField { .. } | Error::IllegalDatabaseResponse { .. } | Error::ClientStreaming { .. } => StatusCode::Internal, diff --git a/src/common/decimal/src/error.rs b/src/common/decimal/src/error.rs index c1b8dd6705..65c77911be 100644 --- a/src/common/decimal/src/error.rs +++ b/src/common/decimal/src/error.rs @@ -54,8 +54,8 @@ pub enum Error { impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { - Error::BigDecimalOutOfRange { .. } => StatusCode::Internal, - Error::ParseRustDecimalStr { .. } + Error::BigDecimalOutOfRange { .. } + | Error::ParseRustDecimalStr { .. } | Error::InvalidPrecisionOrScale { .. } | Error::ParseBigDecimalStr { .. } => StatusCode::InvalidArguments, } diff --git a/src/common/error/src/status_code.rs b/src/common/error/src/status_code.rs index f54cb728ed..6b8a574c50 100644 --- a/src/common/error/src/status_code.rs +++ b/src/common/error/src/status_code.rs @@ -36,6 +36,8 @@ pub enum StatusCode { InvalidArguments = 1004, /// The task is cancelled. Cancelled = 1005, + /// Illegal state, can be exposed to users + IllegalState = 1006, // ====== End of common status code ================ // ====== Begin of SQL related status code ========= @@ -53,18 +55,27 @@ pub enum StatusCode { // ====== Begin of catalog related status code ===== /// Table already exists. TableAlreadyExists = 4000, + /// Table not found TableNotFound = 4001, + /// Table column not found TableColumnNotFound = 4002, + /// Table column already exists TableColumnExists = 4003, + /// Database not found DatabaseNotFound = 4004, + /// Region not found RegionNotFound = 4005, + /// Region already exists RegionAlreadyExists = 4006, RegionReadonly = 4007, /// Region is not in a proper state to handle specific request. RegionNotReady = 4008, - // If mutually exclusive operations are reached at the same time, - // only one can be executed, another one will get region busy. + /// Region is temporarily in busy state RegionBusy = 4009, + /// Table is temporarily unable to handle the request + TableUnavailable = 4010, + /// Database not found + DatabaseAlreadyExists = 4011, // ====== End of catalog related status code ======= // ====== Begin of storage related status code ===== @@ -118,15 +129,18 @@ impl StatusCode { | StatusCode::RuntimeResourcesExhausted | StatusCode::Internal | StatusCode::RegionNotReady + | StatusCode::TableUnavailable | StatusCode::RegionBusy => true, StatusCode::Success | StatusCode::Unknown | StatusCode::Unsupported + | StatusCode::IllegalState | StatusCode::Unexpected | StatusCode::InvalidArguments | StatusCode::Cancelled | StatusCode::InvalidSyntax + | StatusCode::DatabaseAlreadyExists | StatusCode::PlanQuery | StatusCode::EngineExecuteQuery | StatusCode::TableAlreadyExists @@ -159,6 +173,7 @@ impl StatusCode { | StatusCode::Unexpected | StatusCode::Internal | StatusCode::Cancelled + | StatusCode::IllegalState | StatusCode::EngineExecuteQuery | StatusCode::StorageUnavailable | StatusCode::RuntimeResourcesExhausted => true, @@ -181,6 +196,8 @@ impl StatusCode { | StatusCode::DatabaseNotFound | StatusCode::RateLimited | StatusCode::UserNotFound + | StatusCode::TableUnavailable + | StatusCode::DatabaseAlreadyExists | StatusCode::UnsupportedPasswordType | StatusCode::UserPasswordMismatch | StatusCode::AuthHeaderNotFound @@ -241,6 +258,7 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code { StatusCode::Unknown => Code::Unknown, StatusCode::Unsupported => Code::Unimplemented, StatusCode::Unexpected + | StatusCode::IllegalState | StatusCode::Internal | StatusCode::PlanQuery | StatusCode::EngineExecuteQuery => Code::Internal, @@ -251,6 +269,7 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code { StatusCode::TableAlreadyExists | StatusCode::TableColumnExists | StatusCode::RegionAlreadyExists + | StatusCode::DatabaseAlreadyExists | StatusCode::FlowAlreadyExists => Code::AlreadyExists, StatusCode::TableNotFound | StatusCode::RegionNotFound @@ -258,7 +277,9 @@ pub fn status_to_tonic_code(status_code: StatusCode) -> Code { | StatusCode::DatabaseNotFound | StatusCode::UserNotFound | StatusCode::FlowNotFound => Code::NotFound, - StatusCode::StorageUnavailable | StatusCode::RegionNotReady => Code::Unavailable, + StatusCode::TableUnavailable + | StatusCode::StorageUnavailable + | StatusCode::RegionNotReady => Code::Unavailable, StatusCode::RuntimeResourcesExhausted | StatusCode::RateLimited | StatusCode::RegionBusy => Code::ResourceExhausted, diff --git a/src/common/meta/src/error.rs b/src/common/meta/src/error.rs index c8867fd623..ccd887345c 100644 --- a/src/common/meta/src/error.rs +++ b/src/common/meta/src/error.rs @@ -658,9 +658,12 @@ impl ErrorExt for Error { | EtcdTxnFailed { .. } | ConnectEtcd { .. } | MoveValues { .. } - | ValueNotExist { .. } | GetCache { .. } => StatusCode::Internal, + ValueNotExist { .. } => StatusCode::Unexpected, + + Unsupported { .. } => StatusCode::Unsupported, + SerdeJson { .. } | ParseOption { .. } | RouteInfoCorrupted { .. } @@ -696,17 +699,16 @@ impl ErrorExt for Error { | FromUtf8 { .. } | MetadataCorruption { .. } => StatusCode::Unexpected, - SendMessage { .. } - | GetKvCache { .. } - | CacheNotGet { .. } - | CatalogAlreadyExists { .. } - | SchemaAlreadyExists { .. } - | RenameTable { .. } - | Unsupported { .. } => StatusCode::Internal, + SendMessage { .. } | GetKvCache { .. } | CacheNotGet { .. } | RenameTable { .. } => { + StatusCode::Internal + } + + SchemaAlreadyExists { .. } => StatusCode::DatabaseAlreadyExists, ProcedureNotFound { .. } | InvalidViewInfo { .. } | PrimaryKeyNotFound { .. } + | CatalogAlreadyExists { .. } | EmptyKey { .. } | InvalidEngineType { .. } | AlterLogicalTablesInvalidArguments { .. } diff --git a/src/common/procedure/src/error.rs b/src/common/procedure/src/error.rs index 48084b2635..fbad7f3ef2 100644 --- a/src/common/procedure/src/error.rs +++ b/src/common/procedure/src/error.rs @@ -205,13 +205,15 @@ impl ErrorExt for Error { Error::ToJson { .. } | Error::DeleteState { .. } | Error::FromJson { .. } - | Error::RetryTimesExceeded { .. } - | Error::RollbackTimesExceeded { .. } - | Error::RetryLater { .. } | Error::WaitWatcher { .. } - | Error::ManagerNotStart { .. } - | Error::RollbackProcedureRecovered { .. } - | Error::RollbackNotSupported { .. } => StatusCode::Internal, + | Error::RetryLater { .. } + | Error::RollbackProcedureRecovered { .. } => StatusCode::Internal, + + Error::RetryTimesExceeded { .. } + | Error::RollbackTimesExceeded { .. } + | Error::ManagerNotStart { .. } => StatusCode::IllegalState, + + Error::RollbackNotSupported { .. } => StatusCode::Unsupported, Error::LoaderConflict { .. } | Error::DuplicateProcedure { .. } => { StatusCode::InvalidArguments } diff --git a/src/common/recordbatch/src/error.rs b/src/common/recordbatch/src/error.rs index 4f9136333c..f5424d410a 100644 --- a/src/common/recordbatch/src/error.rs +++ b/src/common/recordbatch/src/error.rs @@ -167,9 +167,11 @@ impl ErrorExt for Error { | Error::PollStream { .. } | Error::Format { .. } | Error::ToArrowScalar { .. } - | Error::ColumnNotExists { .. } - | Error::ProjectArrowRecordBatch { .. } - | Error::ArrowCompute { .. } => StatusCode::Internal, + | Error::ProjectArrowRecordBatch { .. } => StatusCode::Internal, + + Error::ArrowCompute { .. } => StatusCode::IllegalState, + + Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound, Error::External { source, .. } => source.status_code(), diff --git a/src/common/substrait/src/error.rs b/src/common/substrait/src/error.rs index 5a39a1a6d1..00552c9ad2 100644 --- a/src/common/substrait/src/error.rs +++ b/src/common/substrait/src/error.rs @@ -87,10 +87,8 @@ impl ErrorExt for Error { Error::UnknownPlan { .. } | Error::EncodeRel { .. } | Error::DecodeRel { .. } => { StatusCode::InvalidArguments } - Error::DFInternal { .. } - | Error::Internal { .. } - | Error::EncodeDfPlan { .. } - | Error::DecodeDfPlan { .. } => StatusCode::Internal, + Error::DFInternal { .. } | Error::Internal { .. } => StatusCode::Internal, + Error::EncodeDfPlan { .. } | Error::DecodeDfPlan { .. } => StatusCode::Unexpected, } } diff --git a/src/datanode/src/error.rs b/src/datanode/src/error.rs index d564b417d3..cd1265569e 100644 --- a/src/datanode/src/error.rs +++ b/src/datanode/src/error.rs @@ -78,13 +78,6 @@ pub enum Error { source: common_query::error::Error, }, - #[snafu(display("Incorrect internal state: {}", state))] - IncorrectInternalState { - state: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Catalog not found: {}", name))] CatalogNotFound { name: String, @@ -436,6 +429,10 @@ impl ErrorExt for Error { | MissingNodeId { .. } | ColumnNoneDefaultValue { .. } | MissingWalDirConfig { .. } + | Catalog { .. } + | MissingRequiredField { .. } + | RegionEngineNotFound { .. } + | ParseAddr { .. } | MissingKvBackend { .. } | TomlFormat { .. } => StatusCode::InvalidArguments, @@ -445,17 +442,9 @@ impl ErrorExt for Error { AsyncTaskExecute { source, .. } => source.status_code(), - // TODO(yingwen): Further categorize http error. - ParseAddr { .. } - | CreateDir { .. } - | RemoveDir { .. } - | Catalog { .. } - | MissingRequiredField { .. } - | IncorrectInternalState { .. } - | ShutdownInstance { .. } - | RegionEngineNotFound { .. } - | UnsupportedOutput { .. } - | DataFusion { .. } => StatusCode::Internal, + CreateDir { .. } | RemoveDir { .. } | ShutdownInstance { .. } | DataFusion { .. } => { + StatusCode::Internal + } RegionNotFound { .. } => StatusCode::RegionNotFound, RegionNotReady { .. } => StatusCode::RegionNotReady, @@ -468,9 +457,9 @@ impl ErrorExt for Error { OpenLogStore { source, .. } => source.status_code(), RuntimeResource { .. } => StatusCode::RuntimeResourcesExhausted, MetaClientInit { source, .. } => source.status_code(), - TableIdProviderNotFound { .. } | UnsupportedGrpcRequest { .. } => { - StatusCode::Unsupported - } + UnsupportedOutput { .. } + | TableIdProviderNotFound { .. } + | UnsupportedGrpcRequest { .. } => StatusCode::Unsupported, HandleRegionRequest { source, .. } | GetRegionMetadata { source, .. } | HandleBatchOpenRequest { source, .. } => source.status_code(), diff --git a/src/datatypes/src/error.rs b/src/datatypes/src/error.rs index f161d13a98..5a255dc0a6 100644 --- a/src/datatypes/src/error.rs +++ b/src/datatypes/src/error.rs @@ -209,8 +209,36 @@ pub enum Error { impl ErrorExt for Error { fn status_code(&self) -> StatusCode { - // Inner encoding and decoding error should not be exposed to users. - StatusCode::Internal + use Error::*; + match self { + UnsupportedOperation { .. } + | UnsupportedArrowType { .. } + | UnsupportedDefaultExpr { .. } => StatusCode::Unsupported, + + DuplicateColumn { .. } + | BadArrayAccess { .. } + | NullDefault { .. } + | InvalidTimestampIndex { .. } + | DefaultValueType { .. } + | DuplicateMeta { .. } + | InvalidTimestampPrecision { .. } + | InvalidPrecisionOrScale { .. } => StatusCode::InvalidArguments, + + ValueExceedsPrecision { .. } + | CastType { .. } + | CastTimeType { .. } + | Conversion { .. } => StatusCode::IllegalState, + + Serialize { .. } + | Deserialize { .. } + | UnknownVector { .. } + | ParseSchemaVersion { .. } + | ArrowCompute { .. } + | ProjectArrowSchema { .. } + | ToScalarValue { .. } + | TryFromValue { .. } + | ConvertArrowArrayToScalars { .. } => StatusCode::Internal, + } } fn as_any(&self) -> &dyn Any { diff --git a/src/frontend/src/error.rs b/src/frontend/src/error.rs index e7b7a19885..1b6aa0655d 100644 --- a/src/frontend/src/error.rs +++ b/src/frontend/src/error.rs @@ -413,10 +413,11 @@ impl ErrorExt for Error { Error::RequestQuery { source, .. } => source.status_code(), - Error::FindDatanode { .. } - | Error::VectorToGrpcColumn { .. } - | Error::InvalidRegionRequest { .. } - | Error::CacheRequired { .. } => StatusCode::Internal, + Error::FindDatanode { .. } => StatusCode::RegionNotReady, + + Error::VectorToGrpcColumn { .. } | Error::CacheRequired { .. } => StatusCode::Internal, + + Error::InvalidRegionRequest { .. } => StatusCode::IllegalState, Error::ContextValueNotFound { .. } => StatusCode::Unexpected, diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index 15b4b24fc0..6e9efc4857 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -888,7 +888,6 @@ impl ErrorExt for Error { | Error::LockNotConfig { .. } | Error::ExceededRetryLimit { .. } | Error::SendShutdownSignal { .. } - | Error::SchemaAlreadyExists { .. } | Error::PusherNotFound { .. } | Error::PushMessage { .. } | Error::MailboxClosed { .. } @@ -903,8 +902,12 @@ impl ErrorExt for Error { | Error::Join { .. } | Error::WeightArray { .. } | Error::NotSetWeightArray { .. } - | Error::Unsupported { .. } | Error::PeerUnavailable { .. } => StatusCode::Internal, + + Error::Unsupported { .. } => StatusCode::Unsupported, + + Error::SchemaAlreadyExists { .. } => StatusCode::DatabaseAlreadyExists, + Error::TableAlreadyExists { .. } => StatusCode::TableAlreadyExists, Error::EmptyKey { .. } | Error::MissingRequiredParameter { .. } diff --git a/src/mito2/src/error.rs b/src/mito2/src/error.rs index d6fe9f226a..cce25fab3e 100644 --- a/src/mito2/src/error.rs +++ b/src/mito2/src/error.rs @@ -882,26 +882,32 @@ impl ErrorExt for Error { | WorkerStopped { .. } | Recv { .. } | EncodeWal { .. } + | ConvertMetaData { .. } | DecodeWal { .. } + | ComputeArrow { .. } + | BiError { .. } + | StopScheduler { .. } + | ComputeVector { .. } + | SerializeField { .. } + | EncodeMemtable { .. } + | ReadDataPart { .. } + | CorruptedEntry { .. } | BuildEntry { .. } => StatusCode::Internal, + OpenRegion { source, .. } => source.status_code(), - WriteParquet { .. } => StatusCode::Internal, + WriteParquet { .. } => StatusCode::StorageUnavailable, WriteGroup { source, .. } => source.status_code(), FieldTypeMismatch { source, .. } => source.status_code(), - SerializeField { .. } => StatusCode::Internal, NotSupportedField { .. } => StatusCode::Unsupported, DeserializeField { .. } => StatusCode::Unexpected, InvalidBatch { .. } => StatusCode::InvalidArguments, InvalidRecordBatch { .. } => StatusCode::InvalidArguments, ConvertVector { source, .. } => source.status_code(), - ConvertMetaData { .. } => StatusCode::Internal, - ComputeArrow { .. } => StatusCode::Internal, - ComputeVector { .. } => StatusCode::Internal, + PrimaryKeyLengthMismatch { .. } => StatusCode::InvalidArguments, InvalidSender { .. } => StatusCode::InvalidArguments, InvalidSchedulerState { .. } => StatusCode::InvalidArguments, - StopScheduler { .. } => StatusCode::Internal, DeleteSst { .. } | DeleteIndex { .. } => StatusCode::StorageUnavailable, FlushRegion { source, .. } => source.status_code(), RegionDropped { .. } => StatusCode::Cancelled, @@ -932,10 +938,6 @@ impl ErrorExt for Error { FilterRecordBatch { source, .. } => source.status_code(), Upload { .. } => StatusCode::StorageUnavailable, - BiError { .. } => StatusCode::Internal, - EncodeMemtable { .. } | ReadDataPart { .. } | CorruptedEntry { .. } => { - StatusCode::Internal - } ChecksumMismatch { .. } => StatusCode::Unexpected, RegionStopped { .. } => StatusCode::RegionNotReady, TimeRangePredicateOverflow { .. } => StatusCode::InvalidArguments, diff --git a/src/partition/src/error.rs b/src/partition/src/error.rs index ff0d668b23..b7ece9e7f9 100644 --- a/src/partition/src/error.rs +++ b/src/partition/src/error.rs @@ -205,25 +205,31 @@ impl ErrorExt for Error { fn status_code(&self) -> StatusCode { match self { Error::GetCache { .. } | Error::FindLeader { .. } => StatusCode::StorageUnavailable, - Error::FindRegionRoutes { .. } - | Error::ConjunctExprWithNonExpr { .. } + Error::FindRegionRoutes { .. } => StatusCode::RegionNotReady, + + Error::ConjunctExprWithNonExpr { .. } | Error::UnclosedValue { .. } | Error::InvalidExpr { .. } - | Error::FindTableRoutes { .. } | Error::UndefinedColumn { .. } => StatusCode::InvalidArguments, + Error::FindRegion { .. } | Error::FindRegions { .. } | Error::RegionKeysSize { .. } | Error::InvalidInsertRequest { .. } | Error::InvalidDeleteRequest { .. } => StatusCode::InvalidArguments, - Error::SerializeJson { .. } | Error::DeserializeJson { .. } => StatusCode::Internal, + + Error::ConvertScalarValue { .. } + | Error::SerializeJson { .. } + | Error::DeserializeJson { .. } => StatusCode::Internal, + Error::Unexpected { .. } => StatusCode::Unexpected, - Error::InvalidTableRouteData { .. } => StatusCode::Internal, - Error::ConvertScalarValue { .. } => StatusCode::Internal, - Error::FindDatanode { .. } => StatusCode::InvalidArguments, + Error::InvalidTableRouteData { .. } => StatusCode::TableUnavailable, + Error::FindTableRoutes { .. } | Error::FindDatanode { .. } => { + StatusCode::TableUnavailable + } Error::TableRouteNotFound { .. } => StatusCode::TableNotFound, Error::TableRouteManager { source, .. } => source.status_code(), - Error::MissingDefaultValue { .. } => StatusCode::Internal, + Error::MissingDefaultValue { .. } => StatusCode::IllegalState, Error::UnexpectedLogicalRouteTable { source, .. } => source.status_code(), } } diff --git a/src/query/src/error.rs b/src/query/src/error.rs index f882486035..f05bfe855e 100644 --- a/src/query/src/error.rs +++ b/src/query/src/error.rs @@ -358,6 +358,7 @@ impl ErrorExt for Error { DataFusion { error, .. } => match error { DataFusionError::Internal(_) => StatusCode::Internal, DataFusionError::NotImplemented(_) => StatusCode::Unsupported, + DataFusionError::ResourcesExhausted(_) => StatusCode::RuntimeResourcesExhausted, DataFusionError::Plan(_) => StatusCode::PlanQuery, _ => StatusCode::EngineExecuteQuery, }, @@ -369,7 +370,7 @@ impl ErrorExt for Error { RegionQuery { source, .. } => source.status_code(), TableMutation { source, .. } => source.status_code(), MissingTableMutationHandler { .. } => StatusCode::Unexpected, - GetRegionMetadata { .. } => StatusCode::Internal, + GetRegionMetadata { .. } => StatusCode::RegionNotReady, TableReadOnly { .. } => StatusCode::Unsupported, GetFulltextOptions { source, .. } => source.status_code(), } diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index b9a859cc8c..69e4615396 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -617,17 +617,20 @@ impl ErrorExt for Error { | TokioIo { .. } | StartHttp { .. } | StartGrpc { .. } - | AlreadyStarted { .. } - | InvalidPromRemoteReadQueryResult { .. } | TcpBind { .. } | SendPromRemoteRequest { .. } | TcpIncoming { .. } - | CatalogError { .. } | GrpcReflectionService { .. } | BuildHttpResponse { .. } | Arrow { .. } | FileWatch { .. } => StatusCode::Internal, + AlreadyStarted { .. } | InvalidPromRemoteReadQueryResult { .. } => { + StatusCode::IllegalState + } + + CatalogError { source, .. } => source.status_code(), + UnsupportedDataType { .. } => StatusCode::Unsupported, #[cfg(not(windows))] diff --git a/src/servers/src/http/error_result.rs b/src/servers/src/http/error_result.rs index 4eb2f476d2..7823dacbc8 100644 --- a/src/servers/src/http/error_result.rs +++ b/src/servers/src/http/error_result.rs @@ -97,6 +97,7 @@ impl IntoResponse for ErrorResponse { | StatusCode::TableNotFound | StatusCode::TableColumnNotFound | StatusCode::PlanQuery + | StatusCode::DatabaseAlreadyExists | StatusCode::FlowNotFound | StatusCode::FlowAlreadyExists => HttpStatusCode::BAD_REQUEST, @@ -112,11 +113,13 @@ impl IntoResponse for ErrorResponse { StatusCode::RateLimited => HttpStatusCode::TOO_MANY_REQUESTS, StatusCode::RegionNotReady + | StatusCode::TableUnavailable | StatusCode::RegionBusy | StatusCode::StorageUnavailable => HttpStatusCode::SERVICE_UNAVAILABLE, StatusCode::Internal | StatusCode::Unexpected + | StatusCode::IllegalState | StatusCode::Unknown | StatusCode::RuntimeResourcesExhausted | StatusCode::EngineExecuteQuery => HttpStatusCode::INTERNAL_SERVER_ERROR, diff --git a/src/table/src/error.rs b/src/table/src/error.rs index ee91e83046..66d692c82a 100644 --- a/src/table/src/error.rs +++ b/src/table/src/error.rs @@ -21,8 +21,6 @@ use datafusion::error::DataFusionError; use datatypes::arrow::error::ArrowError; use snafu::{Location, Snafu}; -use crate::metadata::TableId; - pub type Result = std::result::Result; /// Default error implementation of table. @@ -84,13 +82,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Duplicated call to plan execute method. table: {}", table))] - DuplicatedExecuteCall { - #[snafu(implicit)] - location: Location, - table: String, - }, - #[snafu(display( "Not allowed to remove index column {} from table {}", column_name, @@ -117,13 +108,6 @@ pub enum Error { location: Location, }, - #[snafu(display("Regions schemas mismatch in table: {}", table))] - RegionSchemaMismatch { - table: String, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Failed to operate table"))] TableOperation { source: BoxedError }, @@ -146,13 +130,6 @@ pub enum Error { err: String, }, - #[snafu(display("Invalid table state: {}", table_id))] - InvalidTable { - table_id: TableId, - #[snafu(implicit)] - location: Location, - }, - #[snafu(display("Missing time index column in table: {}", table_name))] MissingTimeIndexColumn { table_name: String, @@ -170,20 +147,14 @@ impl ErrorExt for Error { Error::RemoveColumnInIndex { .. } | Error::BuildColumnDescriptor { .. } | Error::InvalidAlterRequest { .. } => StatusCode::InvalidArguments, - Error::TablesRecordBatch { .. } | Error::DuplicatedExecuteCall { .. } => { - StatusCode::Unexpected - } + Error::TablesRecordBatch { .. } => StatusCode::Unexpected, Error::ColumnExists { .. } => StatusCode::TableColumnExists, Error::SchemaBuild { source, .. } => source.status_code(), Error::TableOperation { source } => source.status_code(), Error::ColumnNotExists { .. } => StatusCode::TableColumnNotFound, - Error::RegionSchemaMismatch { .. } => StatusCode::StorageUnavailable, Error::Unsupported { .. } => StatusCode::Unsupported, Error::ParseTableOption { .. } => StatusCode::InvalidArguments, - - Error::InvalidTable { .. } | Error::MissingTimeIndexColumn { .. } => { - StatusCode::Internal - } + Error::MissingTimeIndexColumn { .. } => StatusCode::IllegalState, } }