Skip to content

Commit

Permalink
Fix: metrics has to be updated last
Browse files Browse the repository at this point in the history
Otherwise the application receives updated metrics while the internal raft
state is still stale.
  • Loading branch information
drmingdrmer committed Jul 13, 2022
1 parent 2c3024c commit 8594807
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion openraft/src/core/raft_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ impl<C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> RaftCore<C,
Ok(())
}

// TODO: make it private
#[tracing::instrument(level = "debug", skip(self, msg), fields(state = debug(self.engine.state.server_state), id=display(self.id)))]
pub(crate) async fn handle_api_msg(&mut self, msg: RaftMsg<C, N, S>) -> Result<(), Fatal<C::NodeId>> {
tracing::debug!("recv from rx_api: {}", msg.summary());
Expand Down
4 changes: 2 additions & 2 deletions openraft/src/core/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ impl<'a, C: RaftTypeConfig, N: RaftNetworkFactory<C>, S: RaftStorage<C>> LeaderS
}
};

self.update_replication_metrics(target, matched);

self.core.engine.update_progress(target, Some(matched));
self.run_engine_commands(&[]).await?;

self.update_replication_metrics(target, matched);

Ok(())
}

Expand Down

0 comments on commit 8594807

Please sign in to comment.