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

Add exponential backoff for error loop in torii engine #1106

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
12 changes: 11 additions & 1 deletion crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,25 @@ where
warn!("start block ignored, stored head exists and will be used instead");
}

let mut backoff_delay = Duration::from_secs(1);
let max_backoff_delay = Duration::from_secs(60);

loop {
if cts.is_cancelled() {
break Ok(());
}

match self.sync_to_head(head).await {
Ok(latest_block_number) => head = latest_block_number,
Ok(latest_block_number) => {
head = latest_block_number;
backoff_delay = Duration::from_secs(1);
}
Err(e) => {
error!("getting block: {}", e);
sleep(backoff_delay).await;
if backoff_delay < max_backoff_delay {
backoff_delay *= 2;
}
continue;
}
};
Expand Down
Loading