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

fix: mysql writer does not print error message in some cases #2763

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/servers/src/grpc/greptime_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
2 changes: 1 addition & 1 deletion src/servers/src/grpc/region_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
5 changes: 1 addition & 4 deletions src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/servers/src/mysql/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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()
})?;
Expand Down
15 changes: 14 additions & 1 deletion src/servers/src/mysql/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(());
}
}
Expand Down Expand Up @@ -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?;
Expand Down
Loading