-
-
Notifications
You must be signed in to change notification settings - Fork 443
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
RefCell<T> already borrowed #34
Comments
My gut feeling is that it's the same root cause as #31: rust-lang/rust#13246. |
Your gut feeling is correct. My code is equivalent to the following extern crate postgres;
fn main() {
let pool = postgres::pool::PostgresConnectionPool::new("postgres://localhost/postgres", postgres::NoSsl, 1).unwrap();
let _ : Vec<i32> = {
let conn = pool.clone().get_connection();
let stmt = conn.prepare("SELECT 1 UNION SELECT 2").unwrap();
let rows = stmt.query([]).unwrap();
rows.map(|r| {
r[1]
}).collect()
};
} which currently will drop the |
You can work around it by splitting the last statement to let v = rows.map(|r| r[1]).collect();
v I might redo the internals a bit to store an |
This is a workaround for rust-lang/rust#13246 to prevent total badness until it gets fixed. cc #34, #31
I believe this should be fixed by rust-lang/rust#21972. |
I'm seeing
pool.get_connection()
return connections where theRefCell
isWRITING
(as opposed toUNUSED
like it should be), so that the first use of the connection fails withRefCell<T> already borrowed
. If Isleep(1)
after getting the connection, then it becomesUNUSED
, so it seems like a race condition.This only happens when the client is
cond.wait()
ing inget_connection()
, so that it gets a connection that was just previously used.The text was updated successfully, but these errors were encountered: