mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-07 13:52:59 +00:00
chore: clean up unused errors (#2901)
This commit is contained in:
@@ -17,8 +17,6 @@ use std::any::Any;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_procedure::ProcedureId;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use servers::define_into_tonic_status;
|
||||
use snafu::{Location, Snafu};
|
||||
use store_api::storage::RegionId;
|
||||
@@ -41,24 +39,6 @@ pub enum Error {
|
||||
source: common_meta::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute sql"))]
|
||||
ExecuteSql {
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to plan statement"))]
|
||||
PlanStatement {
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute statement"))]
|
||||
ExecuteStatement {
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to execute logical plan"))]
|
||||
ExecuteLogicalPlan {
|
||||
location: Location,
|
||||
@@ -80,46 +60,6 @@ pub enum Error {
|
||||
#[snafu(display("Schema not found: {}", name))]
|
||||
SchemaNotFound { name: String, location: Location },
|
||||
|
||||
#[snafu(display("Failed to create table: {}", table_name))]
|
||||
CreateTable {
|
||||
table_name: String,
|
||||
location: Location,
|
||||
source: TableError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to drop table {}", table_name))]
|
||||
DropTable {
|
||||
table_name: String,
|
||||
location: Location,
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
#[snafu(display("Table engine not found: {}", engine_name))]
|
||||
TableEngineNotFound {
|
||||
engine_name: String,
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Table engine procedure not found: {}", engine_name))]
|
||||
EngineProcedureNotFound {
|
||||
engine_name: String,
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Table not found: {}", table_name))]
|
||||
TableNotFound {
|
||||
table_name: String,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Column {} not found in table {}", column_name, table_name))]
|
||||
ColumnNotFound {
|
||||
column_name: String,
|
||||
table_name: String,
|
||||
},
|
||||
|
||||
#[snafu(display("Missing timestamp column in request"))]
|
||||
MissingTimestampColumn { location: Location },
|
||||
|
||||
@@ -130,19 +70,6 @@ pub enum Error {
|
||||
))]
|
||||
ColumnValuesNumberMismatch { columns: usize, values: usize },
|
||||
|
||||
#[snafu(display("Missing insert body"))]
|
||||
MissingInsertBody {
|
||||
source: sql::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to insert value to table: {}", table_name))]
|
||||
Insert {
|
||||
table_name: String,
|
||||
location: Location,
|
||||
source: TableError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete value from table: {}", table_name))]
|
||||
Delete {
|
||||
table_name: String,
|
||||
@@ -150,25 +77,12 @@ pub enum Error {
|
||||
source: TableError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to flush table: {}", table_name))]
|
||||
FlushTable {
|
||||
table_name: String,
|
||||
location: Location,
|
||||
source: TableError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to start server"))]
|
||||
StartServer {
|
||||
location: Location,
|
||||
source: servers::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to wait for GRPC serving"))]
|
||||
WaitForGrpcServing {
|
||||
source: servers::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse address {}", addr))]
|
||||
ParseAddr {
|
||||
addr: String,
|
||||
@@ -224,42 +138,9 @@ pub enum Error {
|
||||
#[snafu(display("Illegal primary keys definition: {}", msg))]
|
||||
IllegalPrimaryKeysDef { msg: String, location: Location },
|
||||
|
||||
#[snafu(display(
|
||||
"Constraint in CREATE TABLE statement is not supported yet: {}",
|
||||
constraint
|
||||
))]
|
||||
ConstraintNotSupported {
|
||||
constraint: String,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to register a new schema"))]
|
||||
RegisterSchema {
|
||||
location: Location,
|
||||
source: catalog::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Schema {} already exists", name))]
|
||||
SchemaExists { name: String, location: Location },
|
||||
|
||||
#[snafu(display("Failed to convert delete expr to request"))]
|
||||
DeleteExprToRequest {
|
||||
location: Location,
|
||||
source: common_grpc_expr::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse SQL"))]
|
||||
ParseSql {
|
||||
location: Location,
|
||||
source: sql::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to prepare immutable table"))]
|
||||
PrepareImmutableTable {
|
||||
location: Location,
|
||||
source: query::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to access catalog"))]
|
||||
Catalog {
|
||||
location: Location,
|
||||
@@ -272,23 +153,11 @@ pub enum Error {
|
||||
source: meta_client::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to insert data"))]
|
||||
InsertData {
|
||||
location: Location,
|
||||
source: common_grpc_expr::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
"Table id provider not found, cannot execute SQL directly on datanode in distributed mode"
|
||||
))]
|
||||
TableIdProviderNotFound { location: Location },
|
||||
|
||||
#[snafu(display("Failed to bump table id"))]
|
||||
BumpTableId {
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Missing node id in Datanode config"))]
|
||||
MissingNodeId { location: Location },
|
||||
|
||||
@@ -298,39 +167,12 @@ pub enum Error {
|
||||
#[snafu(display("Cannot find requested database: {}-{}", catalog, schema))]
|
||||
DatabaseNotFound { catalog: String, schema: String },
|
||||
|
||||
#[snafu(display("Failed to build default value, column: {}", column))]
|
||||
ColumnDefaultValue {
|
||||
column: String,
|
||||
location: Location,
|
||||
source: datatypes::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display(
|
||||
"No valid default value can be built automatically, column: {}",
|
||||
column,
|
||||
))]
|
||||
ColumnNoneDefaultValue { column: String, location: Location },
|
||||
|
||||
#[snafu(display("Unrecognized table option"))]
|
||||
UnrecognizedTableOption {
|
||||
location: Location,
|
||||
source: table::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to submit procedure {}", procedure_id))]
|
||||
SubmitProcedure {
|
||||
procedure_id: ProcedureId,
|
||||
location: Location,
|
||||
source: common_procedure::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to wait procedure {} done", procedure_id))]
|
||||
WaitProcedure {
|
||||
procedure_id: ProcedureId,
|
||||
location: Location,
|
||||
source: common_procedure::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to shutdown server"))]
|
||||
ShutdownServer {
|
||||
location: Location,
|
||||
@@ -343,32 +185,12 @@ pub enum Error {
|
||||
source: BoxedError,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to encode object into json"))]
|
||||
EncodeJson {
|
||||
location: Location,
|
||||
#[snafu(source)]
|
||||
error: JsonError,
|
||||
},
|
||||
|
||||
#[snafu(display("Payload not exist"))]
|
||||
PayloadNotExist { location: Location },
|
||||
|
||||
#[snafu(display("Missing WAL dir config"))]
|
||||
MissingWalDirConfig { location: Location },
|
||||
|
||||
#[snafu(display("Failed to join task"))]
|
||||
JoinTask {
|
||||
#[snafu(source)]
|
||||
error: common_runtime::JoinError,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Column datatype error"))]
|
||||
ColumnDataType {
|
||||
location: Location,
|
||||
source: api::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Unexpected, violated: {}", violated))]
|
||||
Unexpected {
|
||||
violated: String,
|
||||
@@ -432,10 +254,7 @@ impl ErrorExt for Error {
|
||||
fn status_code(&self) -> StatusCode {
|
||||
use Error::*;
|
||||
match self {
|
||||
ExecuteSql { source, .. }
|
||||
| PlanStatement { source, .. }
|
||||
| ExecuteStatement { source, .. }
|
||||
| ExecuteLogicalPlan { source, .. } => source.status_code(),
|
||||
ExecuteLogicalPlan { source, .. } => source.status_code(),
|
||||
|
||||
BuildRegionRequests { source, .. } => source.status_code(),
|
||||
HandleHeartbeatResponse { source, .. } | GetMetadata { source, .. } => {
|
||||
@@ -443,21 +262,8 @@ impl ErrorExt for Error {
|
||||
}
|
||||
|
||||
DecodeLogicalPlan { source, .. } => source.status_code(),
|
||||
RegisterSchema { source, .. } => source.status_code(),
|
||||
CreateTable { source, .. } => source.status_code(),
|
||||
DropTable { source, .. } => source.status_code(),
|
||||
FlushTable { source, .. } => source.status_code(),
|
||||
|
||||
Insert { source, .. } => source.status_code(),
|
||||
Delete { source, .. } => source.status_code(),
|
||||
TableEngineNotFound { source, .. } | EngineProcedureNotFound { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
TableNotFound { .. } => StatusCode::TableNotFound,
|
||||
ColumnNotFound { .. } => StatusCode::TableColumnNotFound,
|
||||
|
||||
ParseSql { source, .. } => source.status_code(),
|
||||
DeleteExprToRequest { source, .. } | InsertData { source, .. } => source.status_code(),
|
||||
|
||||
ColumnValuesNumberMismatch { .. }
|
||||
| InvalidSql { .. }
|
||||
@@ -467,19 +273,14 @@ impl ErrorExt for Error {
|
||||
| MissingTimestampColumn { .. }
|
||||
| CatalogNotFound { .. }
|
||||
| SchemaNotFound { .. }
|
||||
| ConstraintNotSupported { .. }
|
||||
| SchemaExists { .. }
|
||||
| DatabaseNotFound { .. }
|
||||
| MissingNodeId { .. }
|
||||
| ColumnNoneDefaultValue { .. }
|
||||
| MissingWalDirConfig { .. }
|
||||
| PrepareImmutableTable { .. }
|
||||
| ColumnDataType { .. }
|
||||
| MissingKvBackend { .. } => StatusCode::InvalidArguments,
|
||||
|
||||
EncodeJson { .. } | PayloadNotExist { .. } | Unexpected { .. } => {
|
||||
StatusCode::Unexpected
|
||||
}
|
||||
PayloadNotExist { .. } | Unexpected { .. } => StatusCode::Unexpected,
|
||||
|
||||
// TODO(yingwen): Further categorize http error.
|
||||
ParseAddr { .. }
|
||||
@@ -488,18 +289,14 @@ impl ErrorExt for Error {
|
||||
| Catalog { .. }
|
||||
| MissingRequiredField { .. }
|
||||
| IncorrectInternalState { .. }
|
||||
| MissingInsertBody { .. }
|
||||
| ShutdownInstance { .. }
|
||||
| JoinTask { .. }
|
||||
| RegionEngineNotFound { .. }
|
||||
| UnsupportedOutput { .. }
|
||||
| GetRegionMetadata { .. } => StatusCode::Internal,
|
||||
|
||||
RegionNotFound { .. } => StatusCode::RegionNotFound,
|
||||
|
||||
StartServer { source, .. }
|
||||
| ShutdownServer { source, .. }
|
||||
| WaitForGrpcServing { source, .. } => source.status_code(),
|
||||
StartServer { source, .. } | ShutdownServer { source, .. } => source.status_code(),
|
||||
|
||||
InitBackend { .. } => StatusCode::StorageUnavailable,
|
||||
|
||||
@@ -509,11 +306,6 @@ impl ErrorExt for Error {
|
||||
TableIdProviderNotFound { .. } | UnsupportedGrpcRequest { .. } => {
|
||||
StatusCode::Unsupported
|
||||
}
|
||||
BumpTableId { source, .. } => source.status_code(),
|
||||
ColumnDefaultValue { source, .. } => source.status_code(),
|
||||
UnrecognizedTableOption { .. } => StatusCode::InvalidArguments,
|
||||
SubmitProcedure { source, .. } => source.status_code(),
|
||||
WaitProcedure { source, .. } => source.status_code(),
|
||||
HandleRegionRequest { source, .. } => source.status_code(),
|
||||
StopRegionEngine { source, .. } => source.status_code(),
|
||||
}
|
||||
|
||||
@@ -26,12 +26,6 @@ use store_api::storage::RegionNumber;
|
||||
#[snafu(visibility(pub))]
|
||||
#[stack_trace_debug]
|
||||
pub enum Error {
|
||||
#[snafu(display("Failed to init ddl manager"))]
|
||||
InitDdlManager {
|
||||
location: Location,
|
||||
source: common_meta::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to invalidate table cache"))]
|
||||
InvalidateTableCache {
|
||||
location: Location,
|
||||
@@ -243,12 +237,6 @@ pub enum Error {
|
||||
#[snafu(display("Unsupported format: {:?}", format))]
|
||||
UnsupportedFormat { location: Location, format: Format },
|
||||
|
||||
#[snafu(display("Table metadata manager error"))]
|
||||
TableMetadataManager {
|
||||
source: common_meta::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to pass permission check"))]
|
||||
Permission {
|
||||
source: auth::error::Error,
|
||||
@@ -308,8 +296,7 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::DescribeStatement { source, .. } => source.status_code(),
|
||||
|
||||
Error::HandleHeartbeatResponse { source, .. }
|
||||
| Error::TableMetadataManager { source, .. } => source.status_code(),
|
||||
Error::HandleHeartbeatResponse { source, .. } => source.status_code(),
|
||||
|
||||
Error::RuntimeResource { source, .. } => source.status_code(),
|
||||
Error::PromStoreRemoteQueryPlan { source, .. }
|
||||
@@ -321,9 +308,7 @@ impl ErrorExt for Error {
|
||||
|
||||
Error::ParseSql { source, .. } => source.status_code(),
|
||||
|
||||
Error::InvalidateTableCache { source, .. } | Error::InitDdlManager { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
Error::InvalidateTableCache { source, .. } => source.status_code(),
|
||||
|
||||
Error::Table { source, .. }
|
||||
| Error::CopyTable { source, .. }
|
||||
|
||||
@@ -302,12 +302,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to build scan predicate"))]
|
||||
BuildPredicate {
|
||||
source: table::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to delete SST file, file id: {}", file_id))]
|
||||
DeleteSst {
|
||||
file_id: FileId,
|
||||
@@ -471,7 +465,6 @@ impl ErrorExt for Error {
|
||||
InvalidSender { .. } => StatusCode::InvalidArguments,
|
||||
InvalidSchedulerState { .. } => StatusCode::InvalidArguments,
|
||||
StopScheduler { .. } => StatusCode::Internal,
|
||||
BuildPredicate { source, .. } => source.status_code(),
|
||||
DeleteSst { .. } => StatusCode::StorageUnavailable,
|
||||
FlushRegion { source, .. } => source.status_code(),
|
||||
RegionDropped { .. } => StatusCode::Cancelled,
|
||||
|
||||
@@ -36,12 +36,6 @@ pub enum Error {
|
||||
#[snafu(display("Failed to get meta info from cache, error: {}", err_msg))]
|
||||
GetCache { err_msg: String, location: Location },
|
||||
|
||||
#[snafu(display("Failed to request Meta"))]
|
||||
RequestMeta {
|
||||
location: Location,
|
||||
source: meta_client::error::Error,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to find Datanode, table id: {}, region: {}", table_id, region))]
|
||||
FindDatanode {
|
||||
table_id: TableId,
|
||||
@@ -133,7 +127,6 @@ impl ErrorExt for Error {
|
||||
Error::GetCache { .. } | Error::FindLeader { .. } => StatusCode::StorageUnavailable,
|
||||
Error::FindRegionRoutes { .. } => StatusCode::InvalidArguments,
|
||||
Error::FindTableRoutes { .. } => StatusCode::InvalidArguments,
|
||||
Error::RequestMeta { source, .. } => source.status_code(),
|
||||
Error::FindRegion { .. }
|
||||
| Error::FindRegions { .. }
|
||||
| Error::RegionKeysSize { .. }
|
||||
|
||||
@@ -18,7 +18,6 @@ use std::time::Duration;
|
||||
use common_error::ext::{BoxedError, ErrorExt};
|
||||
use common_error::status_code::StatusCode;
|
||||
use common_macro::stack_trace_debug;
|
||||
use common_meta::table_name::TableName;
|
||||
use datafusion::error::DataFusionError;
|
||||
use datatypes::prelude::ConcreteDataType;
|
||||
use datatypes::value::Value;
|
||||
@@ -167,32 +166,6 @@ pub enum Error {
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to route partition of table {}", table))]
|
||||
RoutePartition {
|
||||
table: TableName,
|
||||
source: partition::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to parse SQL"))]
|
||||
ParseSql {
|
||||
source: sql::error::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Failed to request remote peer"))]
|
||||
RemoteRequest {
|
||||
source: client::Error,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Unexpected query output. Expected: {}, Got: {}", expected, got))]
|
||||
UnexpectedOutputKind {
|
||||
expected: String,
|
||||
got: String,
|
||||
location: Location,
|
||||
},
|
||||
|
||||
#[snafu(display("Missing required field: {}", name))]
|
||||
MissingRequiredField { name: String, location: Location },
|
||||
|
||||
@@ -313,7 +286,6 @@ impl ErrorExt for Error {
|
||||
VectorComputation { source, .. } | ConvertDatafusionSchema { source, .. } => {
|
||||
source.status_code()
|
||||
}
|
||||
ParseSql { source, .. } => source.status_code(),
|
||||
CreateRecordBatch { source, .. } => source.status_code(),
|
||||
QueryExecution { source, .. } | QueryPlan { source, .. } => source.status_code(),
|
||||
DataFusion { error, .. } => match error {
|
||||
@@ -322,12 +294,10 @@ impl ErrorExt for Error {
|
||||
DataFusionError::Plan(_) => StatusCode::PlanQuery,
|
||||
_ => StatusCode::EngineExecuteQuery,
|
||||
},
|
||||
MissingTimestampColumn { .. } | RoutePartition { .. } => StatusCode::EngineExecuteQuery,
|
||||
MissingTimestampColumn { .. } => StatusCode::EngineExecuteQuery,
|
||||
Sql { source, .. } => source.status_code(),
|
||||
PlanSql { .. } => StatusCode::PlanQuery,
|
||||
ConvertSqlType { source, .. } | ConvertSqlValue { source, .. } => source.status_code(),
|
||||
RemoteRequest { source, .. } => source.status_code(),
|
||||
UnexpectedOutputKind { .. } => StatusCode::Unexpected,
|
||||
CreateSchema { source, .. } => source.status_code(),
|
||||
|
||||
RegionQuery { source, .. } => source.status_code(),
|
||||
|
||||
Reference in New Issue
Block a user