mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-05 12:52:57 +00:00
fix: mysql writer does not print error message in some cases (#2763)
* fix: mysql writer does not print error in some cases * feat: http error msg
This commit is contained in:
@@ -85,7 +85,7 @@ impl GreptimeRequestHandler {
|
||||
logging::error!(e; "Failed to handle request");
|
||||
} else {
|
||||
// Currently, we still print a debug log.
|
||||
logging::debug!("Failed to handle request, err: {}", e);
|
||||
logging::debug!("Failed to handle request, err: {:?}", e);
|
||||
}
|
||||
e
|
||||
})
|
||||
|
||||
@@ -70,7 +70,7 @@ impl RegionServerRequestHandler {
|
||||
error!(e; "Failed to handle request");
|
||||
} else {
|
||||
// Currently, we still print a debug log.
|
||||
debug!("Failed to handle request, err: {}", e);
|
||||
debug!("Failed to handle request, err: {:?}", e);
|
||||
}
|
||||
e
|
||||
})
|
||||
|
||||
@@ -298,10 +298,7 @@ impl JsonResponse {
|
||||
},
|
||||
|
||||
Err(e) => {
|
||||
return Self::with_error(
|
||||
format!("Recordbatch error: {e}"),
|
||||
e.status_code(),
|
||||
);
|
||||
return Self::with_error(e.output_msg(), e.status_code());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ impl<W: AsyncWrite + Send + Sync + Unpin> AsyncMysqlShim<W> for MysqlInstanceShi
|
||||
return w
|
||||
.error(
|
||||
ErrorKind::ER_DBACCESS_DENIED_ERROR,
|
||||
e.to_string().as_bytes(),
|
||||
e.output_msg().as_bytes(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.into());
|
||||
@@ -421,7 +421,7 @@ async fn validate_query(query: &str) -> Result<Statement> {
|
||||
let statement = ParserContext::create_with_dialect(query, &MySqlDialect {});
|
||||
let mut statement = statement.map_err(|e| {
|
||||
InvalidPrepareStatementSnafu {
|
||||
err_msg: e.to_string(),
|
||||
err_msg: e.output_msg(),
|
||||
}
|
||||
.build()
|
||||
})?;
|
||||
|
||||
@@ -17,6 +17,7 @@ use std::ops::Deref;
|
||||
use common_error::ext::ErrorExt;
|
||||
use common_query::Output;
|
||||
use common_recordbatch::{RecordBatch, SendableRecordBatchStream};
|
||||
use common_telemetry::{debug, error};
|
||||
use datatypes::prelude::{ConcreteDataType, Value};
|
||||
use datatypes::schema::SchemaRef;
|
||||
use futures::StreamExt;
|
||||
@@ -147,10 +148,16 @@ impl<'a, W: AsyncWrite + Unpin> MysqlResultWriter<'a, W> {
|
||||
.await?
|
||||
}
|
||||
Err(e) => {
|
||||
let err = e.to_string();
|
||||
if e.status_code().should_log_error() {
|
||||
error!(e; "Failed to handle mysql query");
|
||||
} else {
|
||||
debug!("Failed to handle mysql query, error: {e:?}");
|
||||
}
|
||||
let err = e.output_msg();
|
||||
row_writer
|
||||
.finish_error(ErrorKind::ER_INTERNAL_ERROR, &err.as_bytes())
|
||||
.await?;
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@@ -213,6 +220,12 @@ impl<'a, W: AsyncWrite + Unpin> MysqlResultWriter<'a, W> {
|
||||
.with_label_values(&[METRIC_ERROR_COUNTER_LABEL_MYSQL])
|
||||
.inc();
|
||||
|
||||
if error.status_code().should_log_error() {
|
||||
error!(error; "Failed to handle mysql query");
|
||||
} else {
|
||||
debug!("Failed to handle mysql query, error: {error:?}");
|
||||
}
|
||||
|
||||
let kind = ErrorKind::ER_INTERNAL_ERROR;
|
||||
let error = error.output_msg();
|
||||
w.error(kind, error.as_bytes()).await?;
|
||||
|
||||
Reference in New Issue
Block a user