From 0ce9177030d119694ddbeca26a25ceefaaf88bda Mon Sep 17 00:00:00 2001 From: Johnny Graettinger Date: Tue, 30 Jan 2024 03:20:59 +0000 Subject: [PATCH] atf: use saturating_sub when subtracting elapsed duration It can be larger than the desired duration. --- airbyte-to-flow/src/connector_runner.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airbyte-to-flow/src/connector_runner.rs b/airbyte-to-flow/src/connector_runner.rs index 0f8f93a05ea3..1c09e15745fd 100644 --- a/airbyte-to-flow/src/connector_runner.rs +++ b/airbyte-to-flow/src/connector_runner.rs @@ -206,8 +206,9 @@ pub async fn run_airbyte_source_connector( if let Some(interval_minutes) = run_interval_minutes { let elapsed = Instant::now().duration_since(start_time); let total_duration = tokio::time::Duration::from_secs(60 * interval_minutes); - tracing::debug!("atf: sleeping for {:?}", total_duration - elapsed); - tokio::time::sleep(total_duration - elapsed).await; + let remainder = total_duration.saturating_sub(elapsed); + tracing::debug!("atf: sleeping for {remainder:?}"); + tokio::time::sleep(remainder).await; } let r: Result<(), Error> = Ok(());