From 8594807c4cd15f5ac3459471fd33e548e94dd660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=82=8E=E6=B3=BC?= Date: Wed, 13 Jul 2022 23:19:46 +0800 Subject: [PATCH] Fix: metrics has to be updated last Otherwise the application receives updated metrics while the internal raft state is still stale. --- openraft/src/core/raft_core.rs | 1 - openraft/src/core/replication.rs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openraft/src/core/raft_core.rs b/openraft/src/core/raft_core.rs index c33a2290f..553006b5e 100644 --- a/openraft/src/core/raft_core.rs +++ b/openraft/src/core/raft_core.rs @@ -971,7 +971,6 @@ impl, S: RaftStorage> RaftCore) -> Result<(), Fatal> { tracing::debug!("recv from rx_api: {}", msg.summary()); diff --git a/openraft/src/core/replication.rs b/openraft/src/core/replication.rs index f361841a8..a7b920c19 100644 --- a/openraft/src/core/replication.rs +++ b/openraft/src/core/replication.rs @@ -122,11 +122,11 @@ impl<'a, C: RaftTypeConfig, N: RaftNetworkFactory, S: RaftStorage> 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(()) }