Skip to content

Commit

Permalink
fix(node): fetcher completes on_going_fetch entry on record_key only
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and joshuef committed Apr 12, 2024
1 parent 592ac51 commit 539d73f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sn_networking/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion sn_networking/src/record_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion sn_networking/src/replication_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
}
Expand Down

0 comments on commit 539d73f

Please sign in to comment.