Skip to content

Regression in 0.32: Pool::disconnect does not wait for conns to be dropped anymore #243

Closed
@cloneable

Description

@cloneable

The following assert fails in a test program with 0.32. Works fine with 0.31.

// we're about to exit, so there better be no outstanding connections
assert_eq!(exchange.exist, 0);

#[tokio::main]
async fn main() -> mysql_async::Result<()> {
    let pool = mysql_async::Pool::new("mysql://root:password@127.0.0.1:3307/mysql");

    tokio::spawn({
        let pool = pool.clone();
        async move {
            let mut _conn = pool.get_conn().await.unwrap();
            tokio::time::sleep(std::time::Duration::from_secs(5)).await;
        }
    });

    pool.disconnect().await?;

    Ok(())
}

/// Async function that disconnects this pool from the server and resolves to `()`.
///
/// **Note:** This Future won't resolve until all active connections, taken from it,
/// are dropped or disonnected. Also all pending and new `GetConn`'s will resolve to error.
pub fn disconnect(self) -> DisconnectPool {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions