Closed
Description
Hi,
I found what seems to be a bug. When multiple connections return true
on has_broken()
, all future requests to get()
fail with a TimedOut
error. This code can be used to reproduce the problem:
use std::{convert::Infallible, time::Duration};
struct ConnectionManager;
struct Connection;
#[async_trait::async_trait]
impl bb8::ManageConnection for ConnectionManager {
type Connection = Connection;
type Error = Infallible;
async fn connect(&self) -> Result<Self::Connection, Self::Error> {
Ok(Connection)
}
async fn is_valid(&self, _: &mut Self::Connection) -> Result<(), Self::Error> {
Ok(())
}
fn has_broken(&self, _: &mut Self::Connection) -> bool {
true
}
}
#[tokio::test]
async fn pool() {
let pool = bb8::Pool::builder()
.max_size(5)
.connection_timeout(Duration::from_secs(10))
.build(ConnectionManager)
.await
.unwrap();
let mut futures = Vec::new();
for _ in 0..10 {
let pool = pool.clone();
futures.push(tokio::spawn(async move {
let conn = pool.get().await.unwrap();
drop(conn);
}));
}
for future in futures {
future.await.unwrap();
}
}
Metadata
Metadata
Assignees
Labels
No labels