-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression in 0.32: Pool::disconnect does not wait for conns to be dropped anymore #243
Comments
@cloneable, hi. I can't reproduce the issue so it's hard to know whether 8c4b72a fixes it. |
@blackbeam, sorry, the code snippet above was bad and has a race condition. Please see if you can reproduce it with this taken from the README. The fix to master did not help. use std::error::Error as StdError;
use tokio::task::JoinHandle;
#[tokio::main]
async fn main() -> Result<(), Box<dyn StdError + 'static>> {
let pool = mysql_async::Pool::new("mysql://root:[email protected]:3307/mysql");
let task: JoinHandle<mysql_async::Result<()>> = tokio::spawn({
let pool = pool.clone();
let mut conn = pool.get_conn().await?;
async move {
use mysql_async::prelude::*;
#[derive(Debug, PartialEq, Eq, Clone)]
struct Payment {
customer_id: i32,
amount: i32,
account_name: Option<String>,
}
let payments = vec![Payment {
customer_id: 1,
amount: 2,
account_name: None,
}];
r"CREATE TEMPORARY TABLE payment (
customer_id int not null,
amount tinyint(3) not null,
account_name text
)"
.ignore(&mut conn)
.await?;
r"INSERT INTO payment (customer_id, amount, account_name)
VALUES (:customer_id, :amount, :account_name)"
.with(payments.iter().map(|payment| {
params! {
"customer_id" => payment.customer_id,
"amount" => payment.amount,
"account_name" => payment.account_name.as_ref(),
}
}))
.batch(&mut conn)
.await?;
drop(conn);
Ok(())
}
});
task.await??;
pool.disconnect().await?;
Ok(())
}
If it matters, I'm currently testing against MariaDB 10.3.16. Gonna test against a newer one. |
Same with MariaDB 10.11.2. Found this in the logs: |
Thanks for the snippet. |
Yes, this seems to work for me, too. |
Thank you! Can be closed. Could you yank 0.32.0 from crates.io, so no one uses it? |
The following assert fails in a test program with 0.32. Works fine with 0.31.
mysql_async/src/conn/pool/recycler.rs
Lines 228 to 229 in bbf24b0
mysql_async/src/conn/pool/mod.rs
Lines 244 to 248 in bbf24b0
The text was updated successfully, but these errors were encountered: