Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix next_retry busy waiting on first retry #4192

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl RequestManager {
/// Returns an instant at which the next request to be retried will be ready.
pub fn next_retry_time(&mut self) -> Option<Instant> {
let mut next = None;
for (_id, request) in &self.requests {
for (_id, request) in self.requests.iter().filter(|(_id, request)| !request.in_flight) {
if let Some(next_retry_time) = request.next_retry_time {
if next.map_or(true, |next| next_retry_time < next) {
next = Some(next_retry_time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,31 @@ fn should_delay_before_retrying_dropped_requests() {
// Sleep for the given amount of time. This should reset the delay for the first candidate.
futures_timer::Delay::new(REQUEST_RETRY_DELAY).await;

// We re-try the first request.
// We re-try the first request the second time drop it again.
assert_matches!(
overseer.recv().await,
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendRequests(mut requests, IfDisconnected::ImmediateError)) => {
assert_eq!(requests.len(), 1);
assert_matches!(
requests.pop().unwrap(),
Requests::AttestedCandidateV2(outgoing) => {
assert_eq!(outgoing.peer, Recipient::Peer(peer_c));
assert_eq!(outgoing.payload.candidate_hash, candidate_hash_1);
assert_eq!(outgoing.payload.mask, mask);
}
);
}
);

assert_matches!(
overseer_recv_with_timeout(&mut overseer, Duration::from_millis(100)).await,
None
);

// Sleep for the given amount of time. This should reset the delay for the first candidate.
futures_timer::Delay::new(REQUEST_RETRY_DELAY).await;

// We re-try the first request, for the third time, so let's answer to it.
{
let statements = vec![
state
Expand Down
Loading