From 2314baf0d381e8ec05b03cdb40a3fc4881483e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 29 Jan 2021 10:17:37 +0000 Subject: [PATCH] Allowing for a single topology refresh failure (#505) --- clients/client-core/src/client/topology_control.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clients/client-core/src/client/topology_control.rs b/clients/client-core/src/client/topology_control.rs index 016e33f7a6..7e70636d21 100644 --- a/clients/client-core/src/client/topology_control.rs +++ b/clients/client-core/src/client/topology_control.rs @@ -153,6 +153,8 @@ pub struct TopologyRefresher { validator_client: validator_client::Client, topology_accessor: TopologyAccessor, refresh_rate: Duration, + + was_latest_valid: bool, } impl TopologyRefresher { @@ -167,6 +169,7 @@ impl TopologyRefresher { validator_client, topology_accessor, refresh_rate: cfg.refresh_rate, + was_latest_valid: true, } } @@ -187,6 +190,16 @@ impl TopologyRefresher { trace!("Refreshing the topology"); let new_topology = self.get_current_compatible_topology().await; + if new_topology.is_none() && self.was_latest_valid { + // if we failed to grab this topology, but the one before it was alright, let's assume + // validator had a tiny hiccup and use the old data + warn!("we're going to keep on using the old topology for this iteration"); + self.was_latest_valid = false; + return; + } else if new_topology.is_some() { + self.was_latest_valid = true; + } + self.topology_accessor .update_global_topology(new_topology) .await;