Skip to content

Commit 40bd96a

Browse files
committed
chore(cubestore): Log query that produces error processing HTTP command
1 parent fbf9ae8 commit 40bd96a

File tree

1 file changed

+21
-6
lines changed
  • rust/cubestore/cubestore/src/http

1 file changed

+21
-6
lines changed

rust/cubestore/cubestore/src/http/mod.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,18 @@ impl HttpServer {
284284
command,
285285
},
286286
Err(e) => {
287+
let command_text = match &command {
288+
HttpCommand::Query { query, .. } => format!("HttpCommand::Query {{ query: {:?} }}", query),
289+
HttpCommand::Error { error } => format!("HttpCommand::Error {{ error: {:?} }}", error),
290+
HttpCommand::CloseConnection { error } => format!("HttpCommand::CloseConnection {{ error: {:?} }}", error),
291+
HttpCommand::ResultSet { .. } => format!("HttpCommand::ResultSet {{}}"),
292+
};
287293
log::error!(
288-
"Error processing HTTP command: {}\n",
289-
e.display_with_backtrace()
290-
);
294+
"Error processing HTTP command (connection_id={}): {}\nThe command: {}",
295+
if let Some(c) = connection_id.as_ref() { c.as_str() } else { "(None)" },
296+
e.display_with_backtrace(),
297+
command_text,
298+
);
291299
let command = if e.is_wrong_connection() {
292300
HttpCommand::CloseConnection {
293301
error: e.to_string(),
@@ -356,6 +364,12 @@ impl HttpServer {
356364
});
357365
} else {
358366
cube_ext::spawn(async move {
367+
let command_text = match &command {
368+
HttpCommand::Query { query, .. } => format!("HttpCommand::Query {{ query: {:?} }}", query),
369+
HttpCommand::Error { error } => format!("HttpCommand::Error {{ error: {:?} }}", error),
370+
HttpCommand::CloseConnection { error } => format!("HttpCommand::CloseConnection {{ error: {:?} }}", error),
371+
HttpCommand::ResultSet { .. } => format!("HttpCommand::ResultSet {{}}"),
372+
};
359373
let res = HttpServer::process_command(
360374
sql_service.clone(),
361375
sql_query_context,
@@ -370,9 +384,10 @@ impl HttpServer {
370384
},
371385
Err(e) => {
372386
log::error!(
373-
"Error processing HTTP command: {}\n",
374-
e.display_with_backtrace()
375-
);
387+
"Error processing HTTP command: {}\nThe command: {}",
388+
e.display_with_backtrace(),
389+
command_text,
390+
);
376391
HttpMessage {
377392
message_id,
378393
connection_id,

0 commit comments

Comments
 (0)