Skip to content

Commit 3ab3029

Browse files
committed
fix(pool): add timeout to return_to_pool()
1 parent 8257830 commit 3ab3029

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sqlx-core/src/pool/connection.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ use crate::error::Error;
1212
use super::inner::{is_beyond_max_lifetime, PoolInner};
1313
use crate::pool::connect::{ConnectPermit, ConnectionId};
1414
use crate::pool::options::PoolConnectionMetadata;
15+
use crate::rt;
1516
use std::future::Future;
1617

18+
const RETURN_TO_POOL_TIMEOUT: Duration = Duration::from_secs(5);
1719
const CLOSE_ON_DROP_TIMEOUT: Duration = Duration::from_secs(5);
1820

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

150152
async move {
151153
let returned_to_pool = if let Some(floating) = floating {
152-
floating.return_to_pool().await
154+
rt::timeout(RETURN_TO_POOL_TIMEOUT, floating.return_to_pool())
155+
.await
156+
.unwrap_or(false)
153157
} else {
154158
false
155159
};

0 commit comments

Comments
 (0)