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

Do not retry clearing with same height forever #2348

Merged
merged 7 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
@@ -0,0 +1,2 @@
- Do not retry indefinitely on command handling failure in the packet worker
([#2155](https://github.com/informalsystems/ibc-rs/issues/2155))
27 changes: 10 additions & 17 deletions relayer/src/worker/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,20 @@ pub fn spawn_packet_cmd_worker<ChainA: ChainHandle, ChainB: ChainHandle>(
)
};

let mut current_command = None;

spawn_background_task(span, Some(Duration::from_millis(200)), move || {
if current_command.is_none() {
// Only try to receive the next command if the
// previous command was processed successfully.
current_command = cmd_rx.try_recv().ok();
}

if let Some(cmd) = &current_command {
if let Ok(cmd) = cmd_rx.try_recv() {
// Try to clear pending packets. At different levels down in `handle_packet_cmd` there
// are retries mechanisms for MAX_RETRIES (current value hardcoded at 5).
// If clearing fails after all these retries with ignorable error the task continues
// (see `handle_link_error_in_task`) and clearing is retried with the next
// (`NewBlock`) `cmd` that matches the clearing interval.
handle_packet_cmd(
&mut link.lock().unwrap(),
&mut should_clear_on_start,
clear_interval,
&path,
cmd.clone(),
cmd,
)?;

// Only reset current_command if handle_packet_cmd succeeds.
// Otherwise the same command will be retried in the next step.
current_command = None;
}

Ok(Next::Continue)
Expand Down Expand Up @@ -142,12 +135,12 @@ fn handle_packet_cmd<ChainA: ChainHandle, ChainB: ChainHandle>(
};

if do_clear {
handle_clear_packet(link, clear_interval, path, maybe_height)?;

// Reset the `clear_on_start` flag
// Reset the `clear_on_start` flag and attempt packet clearing once now.
// More clearing will be done at clear interval.
if *should_clear_on_start {
*should_clear_on_start = false;
}
handle_clear_packet(link, clear_interval, path, maybe_height)?;
}

// Handle command-specific task
Expand Down