Skip to content

Commit

Permalink
fix: the raft protocol is used to synchronize node information fix is…
Browse files Browse the repository at this point in the history
…sue #1348
  • Loading branch information
lutengda committed Jul 13, 2023
1 parent 8d511fe commit b338b22
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions meta/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ async fn detect_node_heartbeat(heartbeat_config: HeartBeatConfig, app: Data<Meta
interval.tick().await;

if let Ok(_leader) = app.raft.is_leader().await {
let sm = app.store.state_machine.write().await;
let opt_list = app.store.state_machine.write().await.children_data::<NodeMetrics>(&metrics_path);

if let Ok(list) = sm.children_data::<NodeMetrics>(&metrics_path) {
if let Ok(list) = opt_list {
let node_metrics_list: Vec<NodeMetrics> = list.into_values().collect();

let time = now_timestamp_secs();
Expand All @@ -151,7 +151,9 @@ async fn detect_node_heartbeat(heartbeat_config: HeartBeatConfig, app: Data<Meta
now_node_metrics,
);

sm.process_write_command(&req);
if app.raft.client_write(req).await.is_err() {
tracing::error!("failed to change node status to unreachable");
}
}
}
}
Expand Down

0 comments on commit b338b22

Please sign in to comment.