Skip to content

Commit c86030b

Browse files
committed
When first request fails, try alternative peers in staggered parallel.
1 parent 9a4c985 commit c86030b

File tree

3 files changed

+399
-61
lines changed

3 files changed

+399
-61
lines changed

linera-core/src/client/requests_scheduler/in_flight_tracker.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ impl<N: Clone> InFlightTracker<N> {
173173
let peers = entry.alternative_peers.read().await;
174174
Some(peers.clone())
175175
}
176+
177+
/// Removes a specific peer from the alternative peers list.
178+
///
179+
/// # Arguments
180+
/// - `key`: The request key to look up
181+
/// - `peer`: The peer to remove from alternatives
182+
pub(super) async fn remove_alternative_peer(&self, key: &RequestKey, peer: &N)
183+
where
184+
N: PartialEq + Eq,
185+
{
186+
if let Some(entry) = self.entries.read().await.get(key) {
187+
let mut alt_peers = entry.alternative_peers.write().await;
188+
alt_peers.retain(|p| p != peer);
189+
}
190+
}
176191
}
177192

178193
/// Type of in-flight request match found.

linera-core/src/client/requests_scheduler/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub const CACHE_TTL_MS: u64 = 2000;
2121
pub const CACHE_MAX_SIZE: usize = 1000;
2222
pub const MAX_REQUEST_TTL_MS: u64 = 200;
2323
pub const ALPHA_SMOOTHING_FACTOR: f64 = 0.1;
24+
pub const STAGGERED_DELAY_MS: u64 = 75;
2425

2526
/// Configuration for the `RequestsScheduler`.
2627
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)