Skip to content

Commit

Permalink
Merge pull request #4940 from neondatabase/sk/release-23-05-25-proxy-…
Browse files Browse the repository at this point in the history
…fixup

Release: proxy retry fixup
  • Loading branch information
kelvich authored Aug 9, 2023
2 parents e78ac22 + d7d066d commit 7943b70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions proxy/src/auth/backend/classic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion proxy/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

1 comment on commit 7943b70

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1264 tests run: 1212 passed, 0 failed, 52 skipped (full report)


Please sign in to comment.