diff --git a/src/app/run.rs b/src/app/run.rs index 92428b4..8241028 100644 --- a/src/app/run.rs +++ b/src/app/run.rs @@ -16,7 +16,7 @@ const FOLDER_REFRESH_INTERVAL: Duration = Duration::from_secs(1); const LOCAL_CHANGE_DEBOUNCE: Duration = Duration::from_millis(750); const PEER_POLL_INTERVAL: Duration = Duration::from_secs(30); const SAFETY_SCAN_INTERVAL: Duration = Duration::from_secs(10 * 60); -const MAX_RETRY_DELAY: Duration = Duration::from_secs(60); +const MAX_RETRY_DELAY: Duration = Duration::from_secs(5 * 60); #[derive(Clone, Debug)] struct RetryState { @@ -123,6 +123,7 @@ impl AppaService { let announced_folders = node.take_announced_folders(); for watcher in watchers { if announced_folders.contains(&watcher.folder.id) { + retries.remove(&watcher.folder.id); watcher.schedule_remote_sync(); tracing::info!(folder = %watcher.folder.name, "Peer announced folder changes; checking now"); } @@ -248,7 +249,7 @@ fn schedule_retry(retries: &mut BTreeMap, folder_id: Folde } pub(super) fn retry_delay(failure_count: u32) -> Duration { - let exponent = failure_count.saturating_sub(1).min(5); + let exponent = failure_count.saturating_sub(1).min(8); let seconds = 2_u64 * (1_u64 << exponent); Duration::from_secs(seconds).min(MAX_RETRY_DELAY) } diff --git a/src/app/tests.rs b/src/app/tests.rs index 403f749..74bd169 100644 --- a/src/app/tests.rs +++ b/src/app/tests.rs @@ -31,11 +31,11 @@ fn bounds_exponential_retry_delays() { ); assert_eq!( super::run::retry_delay(6), - std::time::Duration::from_secs(60) + std::time::Duration::from_secs(64) ); assert_eq!( super::run::retry_delay(100), - std::time::Duration::from_secs(60) + std::time::Duration::from_secs(5 * 60) ); }