Skip to content

Commit

Permalink
chore: log remote addr when meta-service raft API recevies a message (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer authored Sep 11, 2024
1 parent dcf1eab commit 30101f3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/meta/service/src/configs/outer_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ pub struct RaftConfig {
#[clap(long, default_value_t = get_default_raft_advertise_host())]
pub raft_advertise_host: String,

/// The listening port for metadata communication.
/// The listening port for raft communication.
#[clap(long, default_value = "28004")]
pub raft_api_port: u16,

Expand Down
36 changes: 30 additions & 6 deletions src/meta/service/src/meta_service/raft_service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ impl RaftService for RaftServiceImpl {
request: Request<RaftRequest>,
) -> Result<Response<RaftReply>, Status> {
let root = databend_common_tracing::start_trace_for_remote_request(full_name!(), &request);
let remote_addr = remote_addr(&request);

async {
self.incr_meta_metrics_recv_bytes_from_peer(&request);
Expand All @@ -332,14 +333,20 @@ impl RaftService for RaftServiceImpl {
let req_summary = ae_req.summary();
let raft = &self.meta_node.raft;

info!("RaftServiceImpl::append_entries: {}", req_summary);
info!(
"RaftServiceImpl::append_entries: from:{remote_addr} {}",
req_summary
);

let resp = raft
.append_entries(ae_req)
.await
.map_err(GrpcHelper::internal_err)?;

info!("RaftServiceImpl::append_entries: done: {}", req_summary);
info!(
"RaftServiceImpl::append_entries: from:{remote_addr} done: {}",
req_summary
);

GrpcHelper::ok_response(&resp)
}
Expand All @@ -365,6 +372,7 @@ impl RaftService for RaftServiceImpl {

async fn vote(&self, request: Request<RaftRequest>) -> Result<Response<RaftReply>, Status> {
let root = databend_common_tracing::start_trace_for_remote_request(full_name!(), &request);
let remote_addr = remote_addr(&request);

async {
self.incr_meta_metrics_recv_bytes_from_peer(&request);
Expand All @@ -373,13 +381,19 @@ impl RaftService for RaftServiceImpl {

let v_req_summary = v_req.summary();

info!("RaftServiceImpl::vote: start: {}", v_req_summary);
info!(
"RaftServiceImpl::vote: from:{remote_addr} start: {}",
v_req_summary
);

let raft = &self.meta_node.raft;

let resp = raft.vote(v_req).await.map_err(GrpcHelper::internal_err)?;

info!("RaftServiceImpl::vote: done: {}", v_req_summary);
info!(
"RaftServiceImpl::vote: from:{remote_addr} done: {}",
v_req_summary
);

GrpcHelper::ok_response(&resp)
}
Expand All @@ -392,21 +406,31 @@ impl RaftService for RaftServiceImpl {
request: Request<pb::TransferLeaderRequest>,
) -> Result<Response<Empty>, Status> {
let root = databend_common_tracing::start_trace_for_remote_request(full_name!(), &request);
let remote_addr = remote_addr(&request);

let fu = async {
let req = request.into_inner();
let req: TransferLeaderRequest = req.try_into()?;

let req_str = req.to_string();

info!("RaftServiceImpl::{}: start: {}", func_name!(), req_str);
info!(
"RaftServiceImpl::{}: from:{remote_addr} start: {}",
func_name!(),
req_str
);

let raft = &self.meta_node.raft;

raft.handle_transfer_leader(req)
.await
.map_err(GrpcHelper::internal_err)?;

info!("RaftServiceImpl::{}: done: {}", func_name!(), req_str);
info!(
"RaftServiceImpl::{}: from:{remote_addr} done: {}",
func_name!(),
req_str
);

Ok(Response::new(pb::Empty {}))
};
Expand Down

0 comments on commit 30101f3

Please sign in to comment.