Skip to content

Commit

Permalink
fix(pool): add timeout to return_to_pool()
Browse files Browse the repository at this point in the history
  • Loading branch information
abonander committed Nov 8, 2024
1 parent 8257830 commit 3ab3029
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sqlx-core/src/pool/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ use crate::error::Error;
use super::inner::{is_beyond_max_lifetime, PoolInner};
use crate::pool::connect::{ConnectPermit, ConnectionId};
use crate::pool::options::PoolConnectionMetadata;
use crate::rt;
use std::future::Future;

const RETURN_TO_POOL_TIMEOUT: Duration = Duration::from_secs(5);
const CLOSE_ON_DROP_TIMEOUT: Duration = Duration::from_secs(5);

/// A connection managed by a [`Pool`][crate::pool::Pool].
Expand Down Expand Up @@ -149,7 +151,9 @@ impl<DB: Database> PoolConnection<DB> {

async move {
let returned_to_pool = if let Some(floating) = floating {
floating.return_to_pool().await
rt::timeout(RETURN_TO_POOL_TIMEOUT, floating.return_to_pool())
.await
.unwrap_or(false)
} else {
false
};
Expand Down

0 comments on commit 3ab3029

Please sign in to comment.