From 494292136570d568ae76af630f2db1ff43284916 Mon Sep 17 00:00:00 2001 From: jeremyhi Date: Wed, 22 May 2024 16:21:15 +0800 Subject: [PATCH] chore: log error for detail --- src/cmd/src/lib.rs | 2 +- src/datanode/src/heartbeat.rs | 4 ++-- src/frontend/src/heartbeat.rs | 2 +- src/meta-srv/src/election/etcd.rs | 2 +- src/meta-srv/src/handler/collect_stats_handler.rs | 2 +- src/meta-srv/src/handler/failure_handler/runner.rs | 4 ++-- src/meta-srv/src/handler/keep_lease_handler.rs | 2 +- src/meta-srv/src/metasrv.rs | 6 +++--- src/mito2/src/region/opener.rs | 6 +++--- src/script/src/table.rs | 2 +- src/servers/src/error.rs | 2 +- src/servers/src/grpc/flight/stream.rs | 6 +++--- src/servers/src/http/authorize.rs | 4 ++-- src/servers/src/mysql/server.rs | 4 ++-- src/servers/src/postgres/server.rs | 2 +- src/servers/src/server.rs | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/cmd/src/lib.rs b/src/cmd/src/lib.rs index 6444364c10ac..674bfb946162 100644 --- a/src/cmd/src/lib.rs +++ b/src/cmd/src/lib.rs @@ -59,7 +59,7 @@ pub trait App: Send { if self.wait_signal() { if let Err(e) = tokio::signal::ctrl_c().await { - error!("Failed to listen for ctrl-c signal: {}", e); + error!("Failed to listen for ctrl-c signal: {:?}", e); // It's unusual to fail to listen for ctrl-c signal, maybe there's something unexpected in // the underlying system. So we stop the app instead of running nonetheless to let people // investigate the issue. diff --git a/src/datanode/src/heartbeat.rs b/src/datanode/src/heartbeat.rs index eeb0cd1e99fe..d56bb91d96ff 100644 --- a/src/datanode/src/heartbeat.rs +++ b/src/datanode/src/heartbeat.rs @@ -238,7 +238,7 @@ impl HeartbeatTask { Some(req) } Err(e) => { - error!(e;"Failed to encode mailbox messages!"); + error!(e; "Failed to encode mailbox messages!"); None } } @@ -301,7 +301,7 @@ impl HeartbeatTask { Instant::now() + Duration::from_secs(META_KEEP_ALIVE_INTERVAL_SECS), ); - error!(e;"Failed to reconnect to metasrv!"); + error!(e; "Failed to reconnect to metasrv!"); } } } diff --git a/src/frontend/src/heartbeat.rs b/src/frontend/src/heartbeat.rs index d2c343150132..d90f15e3bde1 100644 --- a/src/frontend/src/heartbeat.rs +++ b/src/frontend/src/heartbeat.rs @@ -151,7 +151,7 @@ impl HeartbeatTask { Some(req) } Err(e) => { - error!(e;"Failed to encode mailbox messages!"); + error!(e; "Failed to encode mailbox messages!"); None } } diff --git a/src/meta-srv/src/election/etcd.rs b/src/meta-srv/src/election/etcd.rs index 1cc72ace2e20..27e9a1b19ae1 100644 --- a/src/meta-srv/src/election/etcd.rs +++ b/src/meta-srv/src/election/etcd.rs @@ -251,7 +251,7 @@ impl Election for EtcdElection { .leader_watcher .send(LeaderChangeMessage::Elected(Arc::new(leader.clone()))) { - error!("Failed to send leader change message, error: {e}"); + error!("Failed to send leader change message, error: {e:?}"); } } } else { diff --git a/src/meta-srv/src/handler/collect_stats_handler.rs b/src/meta-srv/src/handler/collect_stats_handler.rs index 4e59a81b2415..d68f1e3b38cf 100644 --- a/src/meta-srv/src/handler/collect_stats_handler.rs +++ b/src/meta-srv/src/handler/collect_stats_handler.rs @@ -45,7 +45,7 @@ impl HeartbeatHandler for CollectStatsHandler { let _ = acc.stat.insert(stat); } Err(err) => { - warn!("Incomplete heartbeat data: {:?}, err: {:?}", req, err); + warn!(err; "Incomplete heartbeat data: {:?}", req); } }; diff --git a/src/meta-srv/src/handler/failure_handler/runner.rs b/src/meta-srv/src/handler/failure_handler/runner.rs index 39eb2665c113..01de1ce47738 100644 --- a/src/meta-srv/src/handler/failure_handler/runner.rs +++ b/src/meta-srv/src/handler/failure_handler/runner.rs @@ -75,13 +75,13 @@ impl FailureDetectRunner { pub(crate) async fn send_heartbeat(&self, heartbeat: DatanodeHeartbeat) { if let Err(e) = self.heartbeat_tx.send(heartbeat).await { - error!("FailureDetectRunner is stop receiving heartbeats: {}", e) + error!("FailureDetectRunner is stop receiving heartbeats: {:?}", e) } } pub(crate) async fn send_control(&self, control: FailureDetectControl) { if let Err(e) = self.control_tx.send(control).await { - error!("FailureDetectRunner is stop receiving controls: {}", e) + error!("FailureDetectRunner is stop receiving controls: {:?}", e) } } diff --git a/src/meta-srv/src/handler/keep_lease_handler.rs b/src/meta-srv/src/handler/keep_lease_handler.rs index 64dfeff698f2..82f2aad20689 100644 --- a/src/meta-srv/src/handler/keep_lease_handler.rs +++ b/src/meta-srv/src/handler/keep_lease_handler.rs @@ -67,7 +67,7 @@ impl HeartbeatHandler for KeepLeaseHandler { let res = ctx.in_memory.put(put_req).await; if let Err(err) = res { - warn!("Failed to update lease KV, peer: {peer:?}, {err}"); + warn!(err; "Failed to update lease KV, peer: {peer:?}"); } Ok(HandleControl::Continue) diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index fb5b302e033a..70bb78a4ecf7 100644 --- a/src/meta-srv/src/metasrv.rs +++ b/src/meta-srv/src/metasrv.rs @@ -296,7 +296,7 @@ impl MetaStateHandler { if let Some(sub_manager) = self.subscribe_manager.clone() { info!("Leader changed, un_subscribe all"); if let Err(e) = sub_manager.unsubscribe_all() { - error!("Failed to un_subscribe all, error: {}", e); + error!("Failed to un_subscribe all, error: {:?}", e); } } } @@ -405,7 +405,7 @@ impl Metasrv { while started.load(Ordering::Relaxed) { let res = election.register_candidate(&node_info).await; if let Err(e) = res { - warn!("Metasrv register candidate error: {}", e); + warn!(e; "Metasrv register candidate error"); } } }); @@ -419,7 +419,7 @@ impl Metasrv { while started.load(Ordering::Relaxed) { let res = election.campaign().await; if let Err(e) = res { - warn!("Metasrv election error: {}", e); + warn!(e; "Metasrv election error"); } info!("Metasrv re-initiate election"); } diff --git a/src/mito2/src/region/opener.rs b/src/mito2/src/region/opener.rs index 2bdeed1c1c5a..64e333c9c476 100644 --- a/src/mito2/src/region/opener.rs +++ b/src/mito2/src/region/opener.rs @@ -155,9 +155,9 @@ impl RegionOpener { ); } Err(e) => { - warn!( - "Failed to open region {} before creating it, region_dir: {}, err: {}", - self.region_id, self.region_dir, e + warn!(e; + "Failed to open region {} before creating it, region_dir: {}", + self.region_id, self.region_dir ); } } diff --git a/src/script/src/table.rs b/src/script/src/table.rs index 8f998d64eb4e..5eacf1ff7ce9 100644 --- a/src/script/src/table.rs +++ b/src/script/src/table.rs @@ -144,7 +144,7 @@ impl ScriptsTable { } Err(err) => { warn!( - r#"Failed to compile script "{}"" in `scripts` table: {}"#, + r#"Failed to compile script "{}"" in `scripts` table: {:?}"#, name, err ); } diff --git a/src/servers/src/error.rs b/src/servers/src/error.rs index 375206d33707..7515b767e235 100644 --- a/src/servers/src/error.rs +++ b/src/servers/src/error.rs @@ -791,7 +791,7 @@ impl IntoResponse for Error { if self.status_code().should_log_error() { error!(self; "Failed to handle HTTP request: "); } else { - debug!("Failed to handle HTTP request: {self}"); + debug!("Failed to handle HTTP request: {self:?}"); } HttpStatusCode::INTERNAL_SERVER_ERROR diff --git a/src/servers/src/grpc/flight/stream.rs b/src/servers/src/grpc/flight/stream.rs index 25813f6b0e45..834583999d03 100644 --- a/src/servers/src/grpc/flight/stream.rs +++ b/src/servers/src/grpc/flight/stream.rs @@ -62,7 +62,7 @@ impl FlightRecordBatchStream { ) { let schema = recordbatches.schema(); if let Err(e) = tx.send(Ok(FlightMessage::Schema(schema))).await { - warn!("stop sending Flight data, err: {e}"); + warn!("stop sending Flight data, err: {e:?}"); return; } @@ -70,14 +70,14 @@ impl FlightRecordBatchStream { match batch_or_err { Ok(recordbatch) => { if let Err(e) = tx.send(Ok(FlightMessage::Recordbatch(recordbatch))).await { - warn!("stop sending Flight data, err: {e}"); + warn!("stop sending Flight data, err: {e:?}"); return; } } Err(e) => { let e = Err(e).context(error::CollectRecordbatchSnafu); if let Err(e) = tx.send(e.map_err(|x| x.into())).await { - warn!("stop sending Flight data, err: {e}"); + warn!("stop sending Flight data, err: {e:?}"); } return; } diff --git a/src/servers/src/http/authorize.rs b/src/servers/src/http/authorize.rs index 971fdce57ef3..540c94090f13 100644 --- a/src/servers/src/http/authorize.rs +++ b/src/servers/src/http/authorize.rs @@ -84,7 +84,7 @@ pub async fn inner_auth( let (username, password) = match extract_username_and_password(&req) { Ok((username, password)) => (username, password), Err(e) => { - warn!("extract username and password failed: {}", e); + warn!("extract username and password failed: {:?}", e); crate::metrics::METRIC_AUTH_FAILURE .with_label_values(&[e.status_code().as_ref()]) .inc(); @@ -108,7 +108,7 @@ pub async fn inner_auth( Ok(req) } Err(e) => { - warn!("authenticate failed: {}", e); + warn!("authenticate failed: {:?}", e); crate::metrics::METRIC_AUTH_FAILURE .with_label_values(&[e.status_code().as_ref()]) .inc(); diff --git a/src/servers/src/mysql/server.rs b/src/servers/src/mysql/server.rs index 1301f88c55b9..14a95a889ae6 100644 --- a/src/servers/src/mysql/server.rs +++ b/src/servers/src/mysql/server.rs @@ -135,7 +135,7 @@ impl MysqlServer { async move { match tcp_stream { - Err(error) => warn!("Broken pipe: {}", error), // IoError doesn't impl ErrorExt. + Err(error) => warn!("Broken pipe: {:?}", error), // IoError doesn't impl ErrorExt. Ok(io_stream) => { if let Err(e) = io_stream.set_nodelay(true) { warn!(e; "Failed to set TCP nodelay"); @@ -143,7 +143,7 @@ impl MysqlServer { if let Err(error) = Self::handle(io_stream, io_runtime, spawn_ref, spawn_config).await { - warn!("Unexpected error when handling TcpStream {}", error); + warn!("Unexpected error when handling TcpStream {:?}", error); }; } }; diff --git a/src/servers/src/postgres/server.rs b/src/servers/src/postgres/server.rs index 41fd89b1b2d3..f66f47ac7224 100644 --- a/src/servers/src/postgres/server.rs +++ b/src/servers/src/postgres/server.rs @@ -86,7 +86,7 @@ impl PostgresServer { Some(addr) } Err(e) => { - warn!("Failed to get PostgreSQL client addr, err: {}", e); + warn!("Failed to get PostgreSQL client addr, err: {:?}", e); None } }; diff --git a/src/servers/src/server.rs b/src/servers/src/server.rs index 129141893ec4..26dfd1ce689d 100644 --- a/src/servers/src/server.rs +++ b/src/servers/src/server.rs @@ -125,7 +125,7 @@ impl AcceptTask { if let Err(error) = join_handle.await { // Couldn't use `error!(e; xxx)` because JoinError doesn't implement ErrorExt. error!( - "Unexpected error during shutdown {} server, error: {}", + "Unexpected error during shutdown {} server, error: {:?}", name, error ); } else {