From 539d73f22a0856d5ab8be248159c1b603b4c2f1a Mon Sep 17 00:00:00 2001 From: qima Date: Thu, 11 Apr 2024 16:24:37 +0800 Subject: [PATCH] fix(node): fetcher completes on_going_fetch entry on record_key only --- sn_networking/src/event.rs | 7 ++++++- sn_networking/src/record_store.rs | 2 +- sn_networking/src/replication_fetcher.rs | 6 +++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/sn_networking/src/event.rs b/sn_networking/src/event.rs index bc13430e8b..a1ec20a448 100644 --- a/sn_networking/src/event.rs +++ b/sn_networking/src/event.rs @@ -1307,7 +1307,12 @@ impl SwarmDriver { // if we have a local value of matching record_type, we don't need to fetch it if let Some((_, local_record_type)) = local { - local_record_type != record_type + let not_same_type = local_record_type != record_type; + if not_same_type { + // Shall only happens for Register + info!("Record {addr:?} has different type: local {local_record_type:?}, incoming {record_type:?}"); + } + not_same_type } else { true } diff --git a/sn_networking/src/record_store.rs b/sn_networking/src/record_store.rs index 88eccb2079..9430081f8b 100644 --- a/sn_networking/src/record_store.rs +++ b/sn_networking/src/record_store.rs @@ -582,7 +582,7 @@ impl RecordStore for NodeRecordStore { // ignored if we don't have the record locally. let key = PrettyPrintRecordKey::from(k); if !self.records.contains_key(k) { - trace!("Record not found locally: {key}"); + trace!("Record not found locally: {key:?}"); return None; } diff --git a/sn_networking/src/replication_fetcher.rs b/sn_networking/src/replication_fetcher.rs index a5cdbdafc5..e21f56c635 100644 --- a/sn_networking/src/replication_fetcher.rs +++ b/sn_networking/src/replication_fetcher.rs @@ -134,6 +134,10 @@ impl ReplicationFetcher { // Notify the replication fetcher about a newly added Record to the node. // The corresponding key can now be removed from the replication fetcher. // Also returns the next set of keys that has to be fetched from the peer/network. + // + // Note: for Register, which different content (i.e. record_type) bearing same record_key + // remove `on_going_fetches` entry bearing same `record_key` only, + // to avoid false FetchFailed alarm against the peer. pub(crate) fn notify_about_new_put( &mut self, new_put: RecordKey, @@ -143,7 +147,7 @@ impl ReplicationFetcher { .retain(|(key, t, _), _| key != &new_put || t != &record_type); // if we're actively fetching for the key, reduce the on_going_fetches - let _ = self.on_going_fetches.remove(&(new_put, record_type)); + self.on_going_fetches.retain(|(key, _t), _| key != &new_put); self.next_keys_to_fetch() }