From 6744f5470b2b96aef596a522261d01366c032b9e Mon Sep 17 00:00:00 2001 From: "Lei, HUANG" <6406592+v0y4g3r@users.noreply.github.com> Date: Tue, 15 Jul 2025 22:32:45 +0800 Subject: [PATCH] fix(grpc): check grpc client unavailable (#6488) * fix/check-grpc-client-unavailable: Improve async handling in `greptime_handler.rs` - Updated the `DoPut` response handling to use `await` with `result_sender.send` for better asynchronous operation. Signed-off-by: Lei, HUANG * fix/check-grpc-client-unavailable: ### Improve Error Handling in `greptime_handler.rs` - Enhanced error handling for the `DoPut` operation by switching from `send` to `try_send` for the `result_sender`. - Added specific logging for unreachable clients, including `request_id` in the warning message. Signed-off-by: Lei, HUANG --------- Signed-off-by: Lei, HUANG --- src/servers/src/grpc/greptime_handler.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/servers/src/grpc/greptime_handler.rs b/src/servers/src/grpc/greptime_handler.rs index 91457e5452..477af876b0 100644 --- a/src/servers/src/grpc/greptime_handler.rs +++ b/src/servers/src/grpc/greptime_handler.rs @@ -42,6 +42,7 @@ use session::hints::READ_PREFERENCE_HINT; use snafu::{OptionExt, ResultExt}; use table::TableRef; use tokio::sync::mpsc; +use tokio::sync::mpsc::error::TrySendError; use crate::error::Error::UnsupportedAuthScheme; use crate::error::{ @@ -176,8 +177,9 @@ impl GreptimeRequestHandler { let result = result .map(|x| DoPutResponse::new(request_id, x)) .map_err(Into::into); - if result_sender.try_send(result).is_err() { - warn!(r#""DoPut" client maybe unreachable, abort handling its message"#); + if let Err(e)= result_sender.try_send(result) + && let TrySendError::Closed(_) = e { + warn!(r#""DoPut" client with request_id {} maybe unreachable, abort handling its message"#, request_id); break; } }