Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stack trace style debug print for error #2489

Merged
merged 10 commits into from
Sep 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
replace snafu backtrace with location
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
  • Loading branch information
waynexia committed Sep 26, 2023
commit 308a8c81fbae9471d48b33ce31969c703141a7b5
65 changes: 32 additions & 33 deletions src/frontend/src/error.rs
Original file line number Diff line number Diff line change
@@ -46,31 +46,31 @@ pub enum Error {

#[snafu(display(""))]
External {
#[snafu(backtrace)]
location: Location,
source: BoxedError,
},

#[snafu(display("Failed to query"))]
RequestQuery {
#[snafu(backtrace)]
location: Location,
source: common_meta::error::Error,
},

#[snafu(display("Runtime resource error"))]
RuntimeResource {
#[snafu(backtrace)]
location: Location,
source: common_runtime::error::Error,
},

#[snafu(display("Failed to start server"))]
StartServer {
#[snafu(backtrace)]
location: Location,
source: servers::error::Error,
},

#[snafu(display("Failed to shutdown server"))]
ShutdownServer {
#[snafu(backtrace)]
location: Location,
source: servers::error::Error,
},

@@ -83,7 +83,7 @@ pub enum Error {

#[snafu(display("Failed to parse SQL"))]
ParseSql {
#[snafu(backtrace)]
location: Location,
source: sql::error::Error,
},

@@ -116,13 +116,13 @@ pub enum Error {

#[snafu(display("General catalog error"))]
Catalog {
#[snafu(backtrace)]
location: Location,
source: catalog::error::Error,
},

#[snafu(display("Failed to start Meta client"))]
StartMetaClient {
#[snafu(backtrace)]
location: Location,
source: meta_client::error::Error,
},

@@ -135,7 +135,7 @@ pub enum Error {
#[snafu(display("Failed to find table route for table id {}", table_id))]
FindTableRoute {
table_id: u32,
#[snafu(backtrace)]
location: Location,
source: partition::error::Error,
},

@@ -144,7 +144,7 @@ pub enum Error {

#[snafu(display("Table occurs error"))]
Table {
#[snafu(backtrace)]
location: Location,
source: table::error::Error,
},

@@ -153,26 +153,26 @@ pub enum Error {

#[snafu(display("Failed to plan statement"))]
PlanStatement {
#[snafu(backtrace)]
location: Location,
source: query::error::Error,
},

#[snafu(display("Failed to read table: {table_name}"))]
ReadTable {
table_name: String,
#[snafu(backtrace)]
location: Location,
source: query::error::Error,
},

#[snafu(display("Failed to execute logical plan"))]
ExecLogicalPlan {
#[snafu(backtrace)]
location: Location,
source: query::error::Error,
},

#[snafu(display(""))]
InvokeRegionServer {
#[snafu(backtrace)]
location: Location,
source: servers::error::Error,
},

@@ -193,27 +193,27 @@ pub enum Error {

#[snafu(display("SQL execution intercepted"))]
SqlExecIntercepted {
#[snafu(backtrace)]
location: Location,
source: BoxedError,
},

// TODO(ruihang): merge all query execution error kinds
#[snafu(display("Failed to execute PromQL query {}", query))]
ExecutePromql {
query: String,
#[snafu(backtrace)]
location: Location,
source: servers::error::Error,
},

#[snafu(display("Failed to create logical plan for prometheus query"))]
PromStoreRemoteQueryPlan {
#[snafu(backtrace)]
location: Location,
source: servers::error::Error,
},

#[snafu(display("Failed to describe schema for given statement"))]
DescribeStatement {
#[snafu(backtrace)]
location: Location,
source: query::error::Error,
},

@@ -222,21 +222,21 @@ pub enum Error {

#[snafu(display("Failed to start script manager"))]
StartScriptManager {
#[snafu(backtrace)]
location: Location,
source: script::error::Error,
},

#[snafu(display("Failed to copy table: {}", table_name))]
CopyTable {
table_name: String,
#[snafu(backtrace)]
location: Location,
source: table::error::Error,
},

#[snafu(display("Failed to insert value into table: {}", table_name))]
Insert {
table_name: String,
#[snafu(backtrace)]
location: Location,
source: table::error::Error,
},

@@ -296,7 +296,7 @@ impl ErrorExt for Error {

Error::Permission { source, .. } => source.status_code(),

Error::DescribeStatement { source } => source.status_code(),
Error::DescribeStatement { source, .. } => source.status_code(),

Error::HandleHeartbeatResponse { source, .. }
| Error::TableMetadataManager { source, .. } => source.status_code(),
@@ -309,17 +309,17 @@ impl ErrorExt for Error {
Error::StartServer { source, .. } => source.status_code(),
Error::ShutdownServer { source, .. } => source.status_code(),

Error::ParseSql { source } => source.status_code(),
Error::ParseSql { source, .. } => source.status_code(),

Error::InvalidateTableCache { source, .. } => source.status_code(),

Error::Table { source }
Error::Table { source, .. }
| Error::CopyTable { source, .. }
| Error::Insert { source, .. } => source.status_code(),

Error::OpenRaftEngineBackend { .. } => StatusCode::StorageUnavailable,

Error::RequestQuery { source } => source.status_code(),
Error::RequestQuery { source, .. } => source.status_code(),

Error::FindDatanode { .. }
| Error::VectorToGrpcColumn { .. }
@@ -333,22 +333,21 @@ impl ErrorExt for Error {

Error::Catalog { source, .. } => source.status_code(),

Error::StartMetaClient { source } | Error::CreateMetaHeartbeatStream { source, .. } => {
source.status_code()
}
Error::StartMetaClient { source, .. }
| Error::CreateMetaHeartbeatStream { source, .. } => source.status_code(),

Error::PlanStatement { source }
Error::PlanStatement { source, .. }
| Error::ReadTable { source, .. }
| Error::ExecLogicalPlan { source } => source.status_code(),
| Error::ExecLogicalPlan { source, .. } => source.status_code(),

Error::LeaderNotFound { .. } => StatusCode::StorageUnavailable,
Error::TableAlreadyExist { .. } => StatusCode::TableAlreadyExists,
Error::InvokeRegionServer { source } => source.status_code(),
Error::InvokeRegionServer { source, .. } => source.status_code(),

Error::External { source } => source.status_code(),
Error::External { source, .. } => source.status_code(),
Error::FindTableRoute { source, .. } => source.status_code(),

Error::StartScriptManager { source } => source.status_code(),
Error::StartScriptManager { source, .. } => source.status_code(),

Error::TableOperation { source, .. } => source.status_code(),
}
10 changes: 4 additions & 6 deletions src/frontend/src/server.rs
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ use common_base::Plugins;
use common_runtime::Builder as RuntimeBuilder;
use common_telemetry::info;
use servers::configurator::ConfiguratorRef;
use servers::error::Error::InternalIo;
use servers::error::InternalIoSnafu;
use servers::grpc::GrpcServer;
use servers::http::HttpServerBuilder;
use servers::metrics_handler::MetricsHandler;
@@ -33,8 +33,7 @@ use servers::query_handler::sql::ServerSqlQueryHandlerAdaptor;
use servers::server::Server;
use snafu::ResultExt;

use crate::error::Error::StartServer;
use crate::error::{self, Result};
use crate::error::{self, Result, StartServerSnafu};
use crate::frontend::FrontendOptions;
use crate::instance::FrontendInstance;

@@ -144,9 +143,8 @@ impl Services {
opts.tls.should_force_tls(),
opts.tls
.setup()
.map_err(|e| StartServer {
source: InternalIo { error: e },
})?
.context(InternalIoSnafu)
.context(StartServerSnafu)?
.map(Arc::new),
opts.reject_no_database.unwrap_or(false),
)),
Loading