diff --git a/src/cmd/src/lib.rs b/src/cmd/src/lib.rs index 674bfb946162..f9f9e699650b 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!(e; "Failed to listen for ctrl-c signal"); // 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 d56bb91d96ff..b1cdd61859dc 100644 --- a/src/datanode/src/heartbeat.rs +++ b/src/datanode/src/heartbeat.rs @@ -109,13 +109,10 @@ impl HeartbeatTask { let mut last_received_lease = Instant::now(); let _handle = common_runtime::spawn_bg(async move { - while let Some(res) = match rx.message().await { - Ok(m) => m, - Err(e) => { - error!(e; "Error while reading heartbeat response"); - None - } - } { + while let Some(res) = rx.message().await.unwrap_or_else(|e| { + error!(e; "Error while reading heartbeat response"); + None + }) { if let Some(msg) = res.mailbox_message.as_ref() { info!("Received mailbox message: {msg:?}, meta_client id: {client_id:?}"); } @@ -276,7 +273,7 @@ impl HeartbeatTask { if let Some(req) = req { debug!("Sending heartbeat request: {:?}", req); if let Err(e) = tx.send(req).await { - error!("Failed to send heartbeat to metasrv, error: {:?}", e); + error!(e; "Failed to send heartbeat to metasrv"); match Self::create_streams( &meta_client, running.clone(), diff --git a/src/frontend/src/heartbeat.rs b/src/frontend/src/heartbeat.rs index d90f15e3bde1..3e744fb7bc11 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/cluster.rs b/src/meta-srv/src/cluster.rs index 0c8def1c0cfe..f7f7fac27722 100644 --- a/src/meta-srv/src/cluster.rs +++ b/src/meta-srv/src/cluster.rs @@ -89,7 +89,7 @@ impl KvBackend for MetaPeerClient { Ok(res) => return Ok(res), Err(e) => { if need_retry(&e) { - warn!("Encountered an error that need to retry, err: {:?}", e); + warn!(e; "Encountered an error that need to retry"); tokio::time::sleep(Duration::from_millis(retry_interval_ms)).await; } else { return Err(e); @@ -138,7 +138,7 @@ impl KvBackend for MetaPeerClient { Ok(res) => return Ok(res), Err(e) => { if need_retry(&e) { - warn!("Encountered an error that need to retry, err: {:?}", e); + warn!(e; "Encountered an error that need to retry"); tokio::time::sleep(Duration::from_millis(retry_interval_ms)).await; } else { return Err(e); diff --git a/src/meta-srv/src/election/etcd.rs b/src/meta-srv/src/election/etcd.rs index 27e9a1b19ae1..49dbfc7c891b 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!(e; "Failed to send leader change message"); } } } else { diff --git a/src/meta-srv/src/handler/failure_handler/runner.rs b/src/meta-srv/src/handler/failure_handler/runner.rs index 01de1ce47738..313a02f25362 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!(e; "FailureDetectRunner is stop receiving heartbeats") } } 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!(e; "FailureDetectRunner is stop receiving controls") } } diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index 70bb78a4ecf7..76fb794f797c 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!(e; "Failed to un_subscribe all"); } } } diff --git a/src/servers/src/grpc/flight/stream.rs b/src/servers/src/grpc/flight/stream.rs index 834583999d03..038c3371b660 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!(e; "stop sending Flight data"); 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!(e; "stop sending Flight data"); 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!(e; "stop sending Flight data"); } return; } diff --git a/src/servers/src/http/authorize.rs b/src/servers/src/http/authorize.rs index 540c94090f13..c60e4356b5ab 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!(e; "extract username and password failed"); 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!(e; "authenticate failed"); crate::metrics::METRIC_AUTH_FAILURE .with_label_values(&[e.status_code().as_ref()]) .inc(); diff --git a/src/servers/src/mysql/handler.rs b/src/servers/src/mysql/handler.rs index d0f4372ef1fb..84a58faeb9f2 100644 --- a/src/servers/src/mysql/handler.rs +++ b/src/servers/src/mysql/handler.rs @@ -191,7 +191,7 @@ impl AsyncMysqlShim for MysqlInstanceShi METRIC_AUTH_FAILURE .with_label_values(&[e.status_code().as_ref()]) .inc(); - warn!("Failed to auth, err: {:?}", e); + warn!(e; "Failed to auth"); return false; } }; diff --git a/src/servers/src/mysql/server.rs b/src/servers/src/mysql/server.rs index 14a95a889ae6..d17d0e58d368 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(e) => warn!(e; "Broken pipe"), // 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!(error; "Unexpected error when handling TcpStream"); }; } }; diff --git a/src/servers/src/postgres/server.rs b/src/servers/src/postgres/server.rs index f66f47ac7224..6b397dbb472c 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!(e; "Failed to get PostgreSQL client addr"); None } }; diff --git a/src/table/src/predicate.rs b/src/table/src/predicate.rs index a9365004cbc8..f338e06d7c8b 100644 --- a/src/table/src/predicate.rs +++ b/src/table/src/predicate.rs @@ -116,11 +116,11 @@ impl Predicate { } } Err(e) => { - warn!("Failed to prune row groups, error: {:?}", e); + warn!(e; "Failed to prune row groups"); } }, Err(e) => { - error!("Failed to create predicate for expr, error: {:?}", e); + error!(e; "Failed to create predicate for expr"); } } }