diff --git a/proxy/src/auth/backend/classic.rs b/proxy/src/auth/backend/classic.rs index d8ee1e8b64d7..46bd215f3b25 100644 --- a/proxy/src/auth/backend/classic.rs +++ b/proxy/src/auth/backend/classic.rs @@ -5,7 +5,7 @@ use crate::{ auth::{self, AuthFlow, ClientCredentials}, compute, console::{self, AuthInfo, CachedNodeInfo, ConsoleReqExtra}, - proxy::handle_try_wake, + proxy::{handle_try_wake, retry_after}, sasl, scram, stream::PqStream, }; @@ -62,10 +62,13 @@ pub(super) async fn authenticate( } Ok(ControlFlow::Continue(e)) => { warn!(error = ?e, num_retries, retriable = true, "couldn't wake compute node"); - num_retries += 1; } Ok(ControlFlow::Break(n)) => break n, } + + let wait_duration = retry_after(num_retries); + num_retries += 1; + tokio::time::sleep(wait_duration).await; }; if let Some(keys) = scram_keys { use tokio_postgres::config::AuthKeys; diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index e6fcf901d974..0267d767eec5 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -545,7 +545,7 @@ impl ShouldRetry for compute::ConnectionError { } } -fn retry_after(num_retries: u32) -> time::Duration { +pub fn retry_after(num_retries: u32) -> time::Duration { // 1.5 seems to be an ok growth factor heuristic BASE_RETRY_WAIT_DURATION.mul_f64(1.5_f64.powi(num_retries as i32)) }